diff --git a/.github/workflows/async-stripe.yml b/.github/workflows/async-stripe.yml index 01e6e1f0e..a295bcaf0 100644 --- a/.github/workflows/async-stripe.yml +++ b/.github/workflows/async-stripe.yml @@ -97,7 +97,7 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Run clippy - run: cargo clippy --features "runtime-${{ matrix.runtime }} full" + run: cargo clippy --features "runtime-${{ matrix.runtime }} full serde" test: runs-on: ubuntu-latest @@ -131,7 +131,7 @@ jobs: - 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 }} + run: cargo llvm-cov --lcov --output-path lcov.info --features "runtime-${{ matrix.runtime }} serde" - name: Upload to codecov.io uses: codecov/codecov-action@v2.1.0 with: @@ -155,7 +155,7 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Build Documentation - run: cargo doc --lib --no-deps --features "runtime-tokio-hyper full" + run: cargo doc --lib --no-deps --features "runtime-tokio-hyper full serde" # Examples tested separately so that we can use crates which don't match our MSRV examples: diff --git a/Cargo.toml b/Cargo.toml index afa6c7ef0..a22017f5f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,7 @@ edition = "2021" [workspace.dependencies] serde = { version = ">=1.0.79", features = ["derive"] } # we use `serde(other)` which was introduced in 1.0.79 +serde_json = "1" 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 +miniserde = "0.1.34" diff --git a/async-stripe/Cargo.toml b/async-stripe/Cargo.toml index a3b75428a..b2bddad9c 100644 --- a/async-stripe/Cargo.toml +++ b/async-stripe/Cargo.toml @@ -78,24 +78,24 @@ 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 } hyper-tls = { version = "0.5", optional = true } hyper-rustls = { version = "0.24", default-features = false, features = ["http1", "http2", "tls12", "logging"], optional = true } -serde_json.workspace = true 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 +serde_json.workspace = true http-types.workspace = true smol_str.workspace = true +miniserde.workspace = true # stream for lists futures-util = { version = "0.3.21", optional = true } diff --git a/async-stripe/src/client/base/async_std.rs b/async-stripe/src/client/base/async_std.rs index b13c56da8..ac90def2c 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 miniserde::json::from_str; 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( + pub fn execute( &self, request: Request, strategy: &RequestStrategy, @@ -38,8 +38,11 @@ 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()))?; + from_str(str).map_err(|_| { + StripeError::JSONDeserialize("error deserializing request data".into()) + }) }) } } @@ -100,10 +103,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 = from_str(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..0c54aa003 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 miniserde::json::from_str; use tokio::time::sleep; use crate::client::request_strategy::{Outcome, RequestStrategy}; @@ -77,7 +77,7 @@ impl TokioClient { } } - pub fn execute( + pub fn execute( &self, request: Request, strategy: &RequestStrategy, @@ -89,8 +89,11 @@ 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()))?; + from_str(str).map_err(|_| { + StripeError::JSONDeserialize("error deserializing request data".into()) + }) }) } } @@ -153,12 +156,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 = from_str(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 +311,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 +342,7 @@ 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::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..339ba21f3 100644 --- a/async-stripe/src/client/base/tokio_blocking.rs +++ b/async-stripe/src/client/base/tokio_blocking.rs @@ -2,7 +2,6 @@ use std::{sync::Arc, time::Duration}; use http_types::Request; -use serde::de::DeserializeOwned; use crate::client::base::tokio::TokioClient; use crate::client::request_strategy::RequestStrategy; @@ -39,7 +38,7 @@ impl TokioBlockingClient { TokioBlockingClient { inner, runtime: Arc::new(runtime) } } - pub fn execute( + pub fn execute( &self, request: Request, strategy: &RequestStrategy, diff --git a/async-stripe/src/client/stripe.rs b/async-stripe/src/client/stripe.rs index e058db0e3..9bb6418fa 100644 --- a/async-stripe/src/client/stripe.rs +++ b/async-stripe/src/client/stripe.rs @@ -1,7 +1,7 @@ // 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 miniserde::Deserialize; use serde::Serialize; use stripe_shared::version::VERSION; @@ -81,12 +81,12 @@ impl Client { } /// Make a `GET` http request with just a path - pub fn get(&self, path: &str) -> Response { + pub fn get(&self, path: &str) -> Response { self.send(path, Method::Get) } /// Make a `GET` http request with url query parameters - pub fn get_query( + pub fn get_query( &self, path: &str, params: P, @@ -98,27 +98,23 @@ impl Client { self.client.execute::(self.create_request(Method::Get, url), &self.strategy) } - pub fn send( - &self, - path: &str, - method: Method, - ) -> Response { + pub fn send(&self, path: &str, method: Method) -> Response { let url = self.url(path); self.client.execute::(self.create_request(method, url), &self.strategy) } /// Make a `DELETE` http request with just a path - pub fn delete(&self, path: &str) -> Response { + pub fn delete(&self, path: &str) -> Response { self.send(path, Method::Delete) } /// Make a `POST` http request with just a path - pub fn post(&self, path: &str) -> Response { + pub fn post(&self, path: &str) -> Response { self.send(path, Method::Post) } /// Make a `POST` http request with urlencoded body - pub fn post_form( + pub fn post_form( &self, path: &str, form: F, @@ -127,7 +123,7 @@ impl Client { } /// Make a `DELETE` http request with urlencoded body - pub fn delete_form( + pub fn delete_form( &self, path: &str, form: F, @@ -136,7 +132,7 @@ impl Client { } /// Make an http request with urlencoded body - pub fn send_form( + pub fn send_form( &self, path: &str, form: F, @@ -145,15 +141,8 @@ impl Client { let url = self.url(path); let mut req = self.create_request(method, url); - let mut params_buffer = Vec::new(); - let qs_ser = &mut serde_qs::Serializer::new(&mut params_buffer); - if let Err(qs_ser_err) = serde_path_to_error::serialize(&form, qs_ser) { - return err(StripeError::QueryStringSerialize(qs_ser_err)); - } - - let body = - String::from_utf8(params_buffer).expect("Unable to extract string from params_buffer"); - + // We control the types here, so this should never fail + let body = serde_qs::to_string(&form).expect("serialization should work"); req.set_body(Body::from_string(body)); req.insert_header("content-type", "application/x-www-form-urlencoded"); @@ -169,14 +158,9 @@ impl Client { fn url_with_params(&self, path: &str, params: P) -> Result { let mut url = self.url(path); - let mut params_buffer = Vec::new(); - let qs_ser = &mut serde_qs::Serializer::new(&mut params_buffer); - serde_path_to_error::serialize(¶ms, qs_ser).map_err(StripeError::from)?; - - let params = - String::from_utf8(params_buffer).expect("Unable to extract string from params_buffer"); - - url.set_query(Some(¶ms)); + // We control the types here, so this should never fail + let query = serde_qs::to_string(¶ms).expect("serialization should work"); + url.set_query(Some(&query)); Ok(url) } diff --git a/async-stripe/src/error.rs b/async-stripe/src/error.rs index 51b440e28..457ebddaa 100644 --- a/async-stripe/src/error.rs +++ b/async-stripe/src/error.rs @@ -6,10 +6,8 @@ use thiserror::Error; pub enum StripeError { #[error("error reported by stripe: {0:#?}, status code: {1}")] Stripe(ApiErrors, u16), - #[error("error serializing or deserializing a querystring: {0}")] - QueryStringSerialize(#[from] serde_path_to_error::Error), - #[error("error serializing or deserializing a request")] - JSONSerialize(#[from] serde_path_to_error::Error), + #[error("error deserializing a request: {0}")] + JSONDeserialize(String), #[error("attempted to access an unsupported version of the api")] UnsupportedVersion, #[error("error communicating with stripe: {0}")] 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: -//! -//! 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: -//! -//! 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: - -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..e3a54dfc5 100644 --- a/examples/endpoints/Cargo.toml +++ b/examples/endpoints/Cargo.toml @@ -8,14 +8,14 @@ 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 = [] @@ -23,4 +23,4 @@ async = [] 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/generated/stripe_billing/Cargo.toml b/generated/stripe_billing/Cargo.toml index 7d6c2572c..2d11b01a6 100644 --- a/generated/stripe_billing/Cargo.toml +++ b/generated/stripe_billing/Cargo.toml @@ -16,8 +16,9 @@ path = "src/mod.rs" [dependencies] serde.workspace = true -smol_str.workspace = true serde_json.workspace = true +smol_str.workspace = true +miniserde.workspace = true stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +serde = ["stripe_types/serde","stripe_shared/serde"] 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..58a7119db 100644 --- a/generated/stripe_billing/src/billing_portal_configuration/requests.rs +++ b/generated/stripe_billing/src/billing_portal_configuration/requests.rs @@ -221,6 +221,16 @@ impl serde::Serialize for CreateBillingPortalConfigurationFeaturesCustomerUpdate serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateBillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdates +{ + fn deserialize>(deserializer: D) -> 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 CreateBillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdates")) + } +} /// Information about showing the billing history in the portal. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateBillingPortalConfigurationFeaturesInvoiceHistory { @@ -356,6 +366,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions +{ + fn deserialize>(deserializer: D) -> 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 CreateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions")) + } +} /// Whether to cancel subscriptions immediately or at the end of the billing period. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateBillingPortalConfigurationFeaturesSubscriptionCancelMode { @@ -402,6 +422,20 @@ impl serde::Serialize for CreateBillingPortalConfigurationFeaturesSubscriptionCa serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateBillingPortalConfigurationFeaturesSubscriptionCancelMode +{ + fn deserialize>(deserializer: D) -> 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 CreateBillingPortalConfigurationFeaturesSubscriptionCancelMode", + ) + }) + } +} /// Whether to create prorations when canceling subscriptions. /// 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. @@ -461,6 +495,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior +{ + fn deserialize>(deserializer: D) -> 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 CreateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior")) + } +} /// Information about updating subscriptions in the portal. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateBillingPortalConfigurationFeaturesSubscriptionUpdate<'a> { @@ -543,6 +587,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates +{ + fn deserialize>(deserializer: D) -> 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 CreateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates")) + } +} /// Determines how to handle prorations resulting from subscription updates. /// Valid values are `none`, `create_prorations`, and `always_invoice`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -601,6 +655,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior +{ + fn deserialize>(deserializer: D) -> 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 CreateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior")) + } +} /// The hosted login page for this configuration. /// Learn more about the portal login page in our [integration docs](https://stripe.com/docs/billing/subscriptions/integrating-customer-portal#share). #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -775,6 +839,16 @@ impl serde::Serialize for UpdateBillingPortalConfigurationFeaturesCustomerUpdate serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateBillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdates +{ + fn deserialize>(deserializer: D) -> 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 UpdateBillingPortalConfigurationFeaturesCustomerUpdateAllowedUpdates")) + } +} /// Information about showing the billing history in the portal. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdateBillingPortalConfigurationFeaturesInvoiceHistory { @@ -910,6 +984,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions +{ + fn deserialize>(deserializer: D) -> 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 UpdateBillingPortalConfigurationFeaturesSubscriptionCancelCancellationReasonOptions")) + } +} /// Whether to cancel subscriptions immediately or at the end of the billing period. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateBillingPortalConfigurationFeaturesSubscriptionCancelMode { @@ -956,6 +1040,20 @@ impl serde::Serialize for UpdateBillingPortalConfigurationFeaturesSubscriptionCa serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelMode +{ + fn deserialize>(deserializer: D) -> 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 UpdateBillingPortalConfigurationFeaturesSubscriptionCancelMode", + ) + }) + } +} /// Whether to create prorations when canceling subscriptions. /// 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. @@ -1015,6 +1113,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior +{ + fn deserialize>(deserializer: D) -> 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 UpdateBillingPortalConfigurationFeaturesSubscriptionCancelProrationBehavior")) + } +} /// Information about updating subscriptions in the portal. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateBillingPortalConfigurationFeaturesSubscriptionUpdate<'a> { @@ -1097,6 +1205,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates +{ + fn deserialize>(deserializer: D) -> 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 UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates")) + } +} /// Determines how to handle prorations resulting from subscription updates. /// Valid values are `none`, `create_prorations`, and `always_invoice`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -1155,6 +1273,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior +{ + fn deserialize>(deserializer: D) -> 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 UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateProrationBehavior")) + } +} /// The hosted login page for this configuration. /// Learn more about the portal login page in our [integration docs](https://stripe.com/docs/billing/subscriptions/integrating-customer-portal#share). #[derive(Copy, Clone, Debug, 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..834b2614a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct BillingPortalConfiguration { /// Whether the configuration is active and can be used to create portal sessions. pub active: bool, @@ -23,9 +25,233 @@ pub struct BillingPortalConfiguration { /// 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>, + /// String representing the object's type. Objects of the same type share the same value. + pub object: BillingPortalConfigurationObject, /// Time at which the object was last updated. Measured in seconds since the Unix epoch. pub updated: stripe_types::Timestamp, } +#[doc(hidden)] +pub struct BillingPortalConfigurationBuilder { + active: Option, + application: Option>>, + business_profile: Option, + created: Option, + default_return_url: Option>, + features: Option, + id: Option, + is_default: Option, + livemode: Option, + login_page: Option, + metadata: Option>>, + object: Option, + updated: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BillingPortalConfigurationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "updated" => Deserialize::begin(&mut self.updated), + + _ => ::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(), + object: Deserialize::default(), + updated: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + active: self.active?, + application: self.application.take()?, + business_profile: self.business_profile.take()?, + created: self.created?, + default_return_url: self.default_return_url.take()?, + features: self.features.take()?, + id: self.id.take()?, + is_default: self.is_default?, + livemode: self.livemode?, + login_page: self.login_page.take()?, + metadata: self.metadata.take()?, + object: self.object?, + updated: self.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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "updated" => b.updated = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum BillingPortalConfigurationObject { + BillingPortalConfiguration, +} +impl BillingPortalConfigurationObject { + pub fn as_str(self) -> &'static str { + use BillingPortalConfigurationObject::*; + match self { + BillingPortalConfiguration => "billing_portal.configuration", + } + } +} + +impl std::str::FromStr for BillingPortalConfigurationObject { + type Err = (); + fn from_str(s: &str) -> Result { + use BillingPortalConfigurationObject::*; + match s { + "billing_portal.configuration" => Ok(BillingPortalConfiguration), + _ => Err(()), + } + } +} +impl std::fmt::Display for BillingPortalConfigurationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for BillingPortalConfigurationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for BillingPortalConfigurationObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for BillingPortalConfigurationObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(BillingPortalConfigurationObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(BillingPortalConfigurationObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for BillingPortalConfigurationObject { + fn deserialize>(deserializer: D) -> 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 BillingPortalConfigurationObject") + }) + } +} 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..46e37d0e2 100644 --- a/generated/stripe_billing/src/billing_portal_session/requests.rs +++ b/generated/stripe_billing/src/billing_portal_session/requests.rs @@ -163,6 +163,18 @@ impl serde::Serialize for CreateBillingPortalSessionFlowDataAfterCompletionType serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateBillingPortalSessionFlowDataAfterCompletionType { + fn deserialize>(deserializer: D) -> 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 CreateBillingPortalSessionFlowDataAfterCompletionType", + ) + }) + } +} /// Configuration when `flow_data.type=subscription_cancel`. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateBillingPortalSessionFlowDataSubscriptionCancel<'a> { @@ -248,6 +260,16 @@ impl serde::Serialize for CreateBillingPortalSessionFlowDataSubscriptionCancelRe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateBillingPortalSessionFlowDataSubscriptionCancelRetentionType +{ + fn deserialize>(deserializer: D) -> 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 CreateBillingPortalSessionFlowDataSubscriptionCancelRetentionType")) + } +} /// Configuration when `flow_data.type=subscription_update`. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateBillingPortalSessionFlowDataSubscriptionUpdate<'a> { @@ -368,6 +390,16 @@ impl serde::Serialize for CreateBillingPortalSessionFlowDataType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateBillingPortalSessionFlowDataType { + fn deserialize>(deserializer: D) -> 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 CreateBillingPortalSessionFlowDataType") + }) + } +} impl<'a> CreateBillingPortalSession<'a> { /// Creates a session of the customer portal. pub fn send( diff --git a/generated/stripe_billing/src/billing_portal_session/types.rs b/generated/stripe_billing/src/billing_portal_session/types.rs index 04d6bd964..b7df17c73 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct BillingPortalSession { /// The configuration used by this session, describing the features available. pub configuration: stripe_types::Expandable, @@ -30,6 +32,8 @@ pub struct BillingPortalSession { /// The IETF language tag of the locale Customer Portal is displayed in. /// If blank or auto, the customer’s `preferred_locales` or browser’s locale is used. pub locale: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: BillingPortalSessionObject, /// The account for which the session was created on behalf of. /// When specified, only subscriptions and invoices with this `on_behalf_of` account appear in the portal. /// For more information, see the [docs](https://stripe.com/docs/connect/separate-charges-and-transfers#on-behalf-of). @@ -40,6 +44,214 @@ pub struct BillingPortalSession { /// The short-lived URL of the session that gives customers access to the customer portal. pub url: String, } +#[doc(hidden)] +pub struct BillingPortalSessionBuilder { + configuration: Option>, + created: Option, + customer: Option, + flow: Option>, + id: Option, + livemode: Option, + locale: Option>, + object: Option, + on_behalf_of: Option>, + return_url: Option>, + url: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BillingPortalSessionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of), + "return_url" => Deserialize::begin(&mut self.return_url), + "url" => Deserialize::begin(&mut self.url), + + _ => ::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(), + object: Deserialize::default(), + on_behalf_of: Deserialize::default(), + return_url: Deserialize::default(), + url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + configuration: self.configuration.take()?, + created: self.created?, + customer: self.customer.take()?, + flow: self.flow.take()?, + id: self.id.take()?, + livemode: self.livemode?, + locale: self.locale?, + object: self.object?, + on_behalf_of: self.on_behalf_of.take()?, + return_url: self.return_url.take()?, + url: self.url.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum BillingPortalSessionObject { + BillingPortalSession, +} +impl BillingPortalSessionObject { + pub fn as_str(self) -> &'static str { + use BillingPortalSessionObject::*; + match self { + BillingPortalSession => "billing_portal.session", + } + } +} + +impl std::str::FromStr for BillingPortalSessionObject { + type Err = (); + fn from_str(s: &str) -> Result { + use BillingPortalSessionObject::*; + match s { + "billing_portal.session" => Ok(BillingPortalSession), + _ => Err(()), + } + } +} +impl std::fmt::Display for BillingPortalSessionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for BillingPortalSessionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for BillingPortalSessionObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for BillingPortalSessionObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(BillingPortalSessionObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(BillingPortalSessionObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for BillingPortalSessionObject { + fn deserialize>(deserializer: D) -> 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 BillingPortalSessionObject")) + } +} impl stripe_types::Object for BillingPortalSession { type Id = stripe_billing::BillingPortalSessionId; fn id(&self) -> &Self::Id { @@ -231,10 +443,28 @@ impl serde::Serialize for BillingPortalSessionLocale { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for BillingPortalSessionLocale { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + BillingPortalSessionLocale::from_str(s).unwrap_or(BillingPortalSessionLocale::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(BillingPortalSessionLocale); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for BillingPortalSessionLocale { fn deserialize>(deserializer: D) -> Result { 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)) } } diff --git a/generated/stripe_billing/src/credit_note/requests.rs b/generated/stripe_billing/src/credit_note/requests.rs index 7fa35022d..4cbd38019 100644 --- a/generated/stripe_billing/src/credit_note/requests.rs +++ b/generated/stripe_billing/src/credit_note/requests.rs @@ -224,6 +224,15 @@ impl serde::Serialize for PreviewCreditNoteLinesType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for PreviewCreditNoteLinesType { + fn deserialize>(deserializer: D) -> 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 PreviewCreditNoteLinesType")) + } +} impl<'a> PreviewCreditNote<'a> { /// Get a preview of a credit note without creating it. pub fn send(&self, client: &stripe::Client) -> stripe::Response { @@ -409,6 +418,16 @@ impl serde::Serialize for PreviewLinesCreditNoteLinesType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for PreviewLinesCreditNoteLinesType { + fn deserialize>(deserializer: D) -> 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 PreviewLinesCreditNoteLinesType") + }) + } +} 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. @@ -586,6 +605,15 @@ impl serde::Serialize for CreateCreditNoteLinesType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCreditNoteLinesType { + fn deserialize>(deserializer: D) -> 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 CreateCreditNoteLinesType")) + } +} 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. diff --git a/generated/stripe_billing/src/invoice/requests.rs b/generated/stripe_billing/src/invoice/requests.rs index ae4506f97..a66439b17 100644 --- a/generated/stripe_billing/src/invoice/requests.rs +++ b/generated/stripe_billing/src/invoice/requests.rs @@ -324,6 +324,16 @@ impl serde::Serialize for UpcomingInvoiceAutomaticTaxLiabilityType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingInvoiceAutomaticTaxLiabilityType { + fn deserialize>(deserializer: D) -> 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 UpcomingInvoiceAutomaticTaxLiabilityType") + }) + } +} /// 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)] @@ -398,6 +408,16 @@ impl serde::Serialize for UpcomingInvoiceCustomerDetailsTaxExempt { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingInvoiceCustomerDetailsTaxExempt { + fn deserialize>(deserializer: D) -> 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 UpcomingInvoiceCustomerDetailsTaxExempt") + }) + } +} /// The customer's tax IDs. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpcomingInvoiceCustomerDetailsTaxIds<'a> { @@ -654,6 +674,14 @@ impl serde::Serialize for UpcomingInvoiceCustomerDetailsTaxIdsType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingInvoiceCustomerDetailsTaxIdsType { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// List of invoice items to add or update in the upcoming invoice preview. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpcomingInvoiceInvoiceItems<'a> { @@ -807,6 +835,18 @@ impl serde::Serialize for UpcomingInvoiceInvoiceItemsPriceDataTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingInvoiceInvoiceItemsPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 UpcomingInvoiceInvoiceItemsPriceDataTaxBehavior", + ) + }) + } +} /// 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`. @@ -859,6 +899,16 @@ impl serde::Serialize for UpcomingInvoiceInvoiceItemsTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingInvoiceInvoiceItemsTaxBehavior { + fn deserialize>(deserializer: D) -> 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 UpcomingInvoiceInvoiceItemsTaxBehavior") + }) + } +} /// 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)] @@ -921,6 +971,15 @@ impl serde::Serialize for UpcomingInvoiceIssuerType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingInvoiceIssuerType { + fn deserialize>(deserializer: D) -> 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 UpcomingInvoiceIssuerType")) + } +} /// 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`. @@ -1086,6 +1145,18 @@ impl serde::Serialize for UpcomingInvoiceSubscriptionItemsPriceDataRecurringInte serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingInvoiceSubscriptionItemsPriceDataRecurringInterval { + fn deserialize>(deserializer: D) -> 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 UpcomingInvoiceSubscriptionItemsPriceDataRecurringInterval", + ) + }) + } +} /// 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`. @@ -1138,6 +1209,18 @@ impl serde::Serialize for UpcomingInvoiceSubscriptionItemsPriceDataTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingInvoiceSubscriptionItemsPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 UpcomingInvoiceSubscriptionItemsPriceDataTaxBehavior", + ) + }) + } +} /// 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)] @@ -1188,6 +1271,18 @@ impl serde::Serialize for UpcomingInvoiceSubscriptionProrationBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingInvoiceSubscriptionProrationBehavior { + fn deserialize>(deserializer: D) -> 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 UpcomingInvoiceSubscriptionProrationBehavior", + ) + }) + } +} /// 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 UpcomingInvoiceSubscriptionResumeAt { @@ -1231,6 +1326,16 @@ impl serde::Serialize for UpcomingInvoiceSubscriptionResumeAt { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingInvoiceSubscriptionResumeAt { + fn deserialize>(deserializer: D) -> 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 UpcomingInvoiceSubscriptionResumeAt") + }) + } +} /// 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)] @@ -1460,6 +1565,18 @@ impl serde::Serialize for UpcomingLinesInvoiceAutomaticTaxLiabilityType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingLinesInvoiceAutomaticTaxLiabilityType { + fn deserialize>(deserializer: D) -> 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 UpcomingLinesInvoiceAutomaticTaxLiabilityType", + ) + }) + } +} /// 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)] @@ -1534,6 +1651,18 @@ impl serde::Serialize for UpcomingLinesInvoiceCustomerDetailsTaxExempt { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingLinesInvoiceCustomerDetailsTaxExempt { + fn deserialize>(deserializer: D) -> 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 UpcomingLinesInvoiceCustomerDetailsTaxExempt", + ) + }) + } +} /// The customer's tax IDs. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpcomingLinesInvoiceCustomerDetailsTaxIds<'a> { @@ -1790,6 +1919,14 @@ impl serde::Serialize for UpcomingLinesInvoiceCustomerDetailsTaxIdsType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingLinesInvoiceCustomerDetailsTaxIdsType { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// List of invoice items to add or update in the upcoming invoice preview. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpcomingLinesInvoiceInvoiceItems<'a> { @@ -1943,6 +2080,18 @@ impl serde::Serialize for UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 UpcomingLinesInvoiceInvoiceItemsPriceDataTaxBehavior", + ) + }) + } +} /// 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`. @@ -1995,6 +2144,18 @@ impl serde::Serialize for UpcomingLinesInvoiceInvoiceItemsTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingLinesInvoiceInvoiceItemsTaxBehavior { + fn deserialize>(deserializer: D) -> 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 UpcomingLinesInvoiceInvoiceItemsTaxBehavior", + ) + }) + } +} /// 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)] @@ -2057,6 +2218,16 @@ impl serde::Serialize for UpcomingLinesInvoiceIssuerType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingLinesInvoiceIssuerType { + fn deserialize>(deserializer: D) -> 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 UpcomingLinesInvoiceIssuerType") + }) + } +} /// 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`. @@ -2222,6 +2393,20 @@ impl serde::Serialize for UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurrin serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval +{ + fn deserialize>(deserializer: D) -> 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 UpcomingLinesInvoiceSubscriptionItemsPriceDataRecurringInterval", + ) + }) + } +} /// 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`. @@ -2274,6 +2459,18 @@ impl serde::Serialize for UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehav serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 UpcomingLinesInvoiceSubscriptionItemsPriceDataTaxBehavior", + ) + }) + } +} /// 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)] @@ -2324,6 +2521,18 @@ impl serde::Serialize for UpcomingLinesInvoiceSubscriptionProrationBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingLinesInvoiceSubscriptionProrationBehavior { + fn deserialize>(deserializer: D) -> 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 UpcomingLinesInvoiceSubscriptionProrationBehavior", + ) + }) + } +} /// 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 { @@ -2367,6 +2576,16 @@ impl serde::Serialize for UpcomingLinesInvoiceSubscriptionResumeAt { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpcomingLinesInvoiceSubscriptionResumeAt { + fn deserialize>(deserializer: D) -> 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 UpcomingLinesInvoiceSubscriptionResumeAt") + }) + } +} /// 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)] @@ -2390,7 +2609,7 @@ impl<'a> UpcomingLinesInvoice<'a> { stripe::ListPaginator::from_list_params("/invoices/upcoming/lines", self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(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")] @@ -2608,6 +2827,16 @@ impl serde::Serialize for CreateInvoiceAutomaticTaxLiabilityType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateInvoiceAutomaticTaxLiabilityType { + fn deserialize>(deserializer: D) -> 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 CreateInvoiceAutomaticTaxLiabilityType") + }) + } +} /// 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. @@ -2685,6 +2914,16 @@ impl serde::Serialize for CreateInvoiceFromInvoiceAction { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateInvoiceFromInvoiceAction { + fn deserialize>(deserializer: D) -> 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 CreateInvoiceFromInvoiceAction") + }) + } +} /// 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)] @@ -2747,8 +2986,17 @@ impl serde::Serialize for CreateInvoiceIssuerType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateInvoiceIssuerType { + fn deserialize>(deserializer: D) -> 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 CreateInvoiceIssuerType")) + } +} /// Configuration settings for the PaymentIntent that is generated when the invoice is finalized. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(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. @@ -2769,7 +3017,7 @@ impl<'a> CreateInvoicePaymentSettings<'a> { } } /// Payment-method-specific configuration to provide to the invoice’s PaymentIntent. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(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")] @@ -2785,7 +3033,8 @@ pub struct CreateInvoicePaymentSettingsPaymentMethodOptions<'a> { pub customer_balance: Option>, /// 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 konbini: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub konbini: Option, /// 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>, @@ -2880,6 +3129,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType +{ + fn deserialize>(deserializer: D) -> 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 CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType")) + } +} /// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { @@ -2937,6 +3196,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 CreateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod")) + } +} /// 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 { @@ -3010,6 +3279,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage +{ + fn deserialize>(deserializer: D) -> 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 CreateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage")) + } +} /// 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 { @@ -3121,6 +3400,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval +{ + fn deserialize>(deserializer: D) -> 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 CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval")) + } +} /// Type of installment plan, one of `fixed_count`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { @@ -3168,6 +3457,16 @@ impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodOptionsCardIn serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType +{ + fn deserialize>(deserializer: D) -> 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 CreateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType")) + } +} /// 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. @@ -3219,6 +3518,16 @@ impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodOptionsCardRe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure +{ + fn deserialize>(deserializer: D) -> 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 CreateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure")) + } +} /// 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 CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccount<'a> { @@ -3318,6 +3627,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions +{ + fn deserialize>(deserializer: D) -> 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 CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions")) + } +} /// List of data features that you would like to retrieve upon account creation. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { @@ -3372,6 +3691,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch +{ + fn deserialize>(deserializer: D) -> 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 CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch")) + } +} /// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { @@ -3429,6 +3758,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 CreateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod")) + } +} /// 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). @@ -3553,6 +3892,14 @@ impl serde::Serialize for CreateInvoicePaymentSettingsPaymentMethodTypes { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateInvoicePaymentSettingsPaymentMethodTypes { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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. @@ -3606,6 +3953,16 @@ impl serde::Serialize for CreateInvoicePendingInvoiceItemsBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateInvoicePendingInvoiceItemsBehavior { + fn deserialize>(deserializer: D) -> 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 CreateInvoicePendingInvoiceItemsBehavior") + }) + } +} /// 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 { @@ -3673,6 +4030,16 @@ impl serde::Serialize for CreateInvoiceRenderingAmountTaxDisplay { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateInvoiceRenderingAmountTaxDisplay { + fn deserialize>(deserializer: D) -> 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 CreateInvoiceRenderingAmountTaxDisplay") + }) + } +} /// Invoice pdf rendering options #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateInvoiceRenderingPdf { @@ -3738,6 +4105,16 @@ impl serde::Serialize for CreateInvoiceRenderingPdfPageSize { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateInvoiceRenderingPdfPageSize { + fn deserialize>(deserializer: D) -> 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 CreateInvoiceRenderingPdfPageSize") + }) + } +} /// This is a legacy field that will be removed soon. /// For details about `rendering_options`, refer to `rendering` instead. /// Options for invoice PDF rendering. @@ -3804,6 +4181,18 @@ impl serde::Serialize for CreateInvoiceRenderingOptionsAmountTaxDisplay { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateInvoiceRenderingOptionsAmountTaxDisplay { + fn deserialize>(deserializer: D) -> 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 CreateInvoiceRenderingOptionsAmountTaxDisplay", + ) + }) + } +} /// Settings for the cost of shipping for this invoice. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateInvoiceShippingCost<'a> { @@ -3951,6 +4340,16 @@ impl serde::Serialize for CreateInvoiceShippingCostShippingRateDataDeliveryEstim serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit +{ + fn deserialize>(deserializer: D) -> 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 CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit")) + } +} /// The lower bound of the estimated range. If empty, represents no lower bound. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimum { @@ -4022,6 +4421,16 @@ impl serde::Serialize for CreateInvoiceShippingCostShippingRateDataDeliveryEstim serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit +{ + fn deserialize>(deserializer: D) -> 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 CreateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit")) + } +} /// 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> { @@ -4120,6 +4529,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior +{ + fn deserialize>(deserializer: D) -> 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 CreateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior")) + } +} /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. /// One of `inclusive`, `exclusive`, or `unspecified`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -4170,6 +4589,18 @@ impl serde::Serialize for CreateInvoiceShippingCostShippingRateDataTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateInvoiceShippingCostShippingRateDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 CreateInvoiceShippingCostShippingRateDataTaxBehavior", + ) + }) + } +} /// The type of calculation to use on the shipping rate. Can only be `fixed_amount` for now. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateInvoiceShippingCostShippingRateDataType { @@ -4213,6 +4644,18 @@ impl serde::Serialize for CreateInvoiceShippingCostShippingRateDataType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateInvoiceShippingCostShippingRateDataType { + fn deserialize>(deserializer: D) -> 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 CreateInvoiceShippingCostShippingRateDataType", + ) + }) + } +} 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. @@ -4220,7 +4663,7 @@ impl<'a> CreateInvoice<'a> { client.send_form("/invoices", self, http_types::Method::Post) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(Clone, Debug, Default, serde::Serialize)] 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")] @@ -4417,6 +4860,16 @@ impl serde::Serialize for UpdateInvoiceAutomaticTaxLiabilityType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateInvoiceAutomaticTaxLiabilityType { + fn deserialize>(deserializer: D) -> 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 UpdateInvoiceAutomaticTaxLiabilityType") + }) + } +} /// The discounts that will apply to the invoice. /// Pass an empty string to remove previously-defined discounts. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -4495,8 +4948,17 @@ impl serde::Serialize for UpdateInvoiceIssuerType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateInvoiceIssuerType { + fn deserialize>(deserializer: D) -> 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 UpdateInvoiceIssuerType")) + } +} /// Configuration settings for the PaymentIntent that is generated when the invoice is finalized. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(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. @@ -4517,7 +4979,7 @@ impl<'a> UpdateInvoicePaymentSettings<'a> { } } /// Payment-method-specific configuration to provide to the invoice’s PaymentIntent. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(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")] @@ -4533,7 +4995,8 @@ pub struct UpdateInvoicePaymentSettingsPaymentMethodOptions<'a> { pub customer_balance: Option>, /// 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 konbini: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub konbini: Option, /// 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>, @@ -4628,6 +5091,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType +{ + fn deserialize>(deserializer: D) -> 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 UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType")) + } +} /// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { @@ -4685,6 +5158,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 UpdateInvoicePaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod")) + } +} /// 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 { @@ -4758,6 +5241,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage +{ + fn deserialize>(deserializer: D) -> 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 UpdateInvoicePaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage")) + } +} /// 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 { @@ -4869,6 +5362,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval +{ + fn deserialize>(deserializer: D) -> 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 UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanInterval")) + } +} /// Type of installment plan, one of `fixed_count`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType { @@ -4916,6 +5419,16 @@ impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardIn serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType +{ + fn deserialize>(deserializer: D) -> 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 UpdateInvoicePaymentSettingsPaymentMethodOptionsCardInstallmentsPlanType")) + } +} /// 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. @@ -4967,6 +5480,16 @@ impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure +{ + fn deserialize>(deserializer: D) -> 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 UpdateInvoicePaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure")) + } +} /// 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> { @@ -5066,6 +5589,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions +{ + fn deserialize>(deserializer: D) -> 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 UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions")) + } +} /// List of data features that you would like to retrieve upon account creation. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { @@ -5120,6 +5653,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch +{ + fn deserialize>(deserializer: D) -> 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 UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch")) + } +} /// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { @@ -5177,6 +5720,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 UpdateInvoicePaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod")) + } +} /// 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). @@ -5301,6 +5854,14 @@ impl serde::Serialize for UpdateInvoicePaymentSettingsPaymentMethodTypes { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateInvoicePaymentSettingsPaymentMethodTypes { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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 { @@ -5368,6 +5929,16 @@ impl serde::Serialize for UpdateInvoiceRenderingAmountTaxDisplay { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateInvoiceRenderingAmountTaxDisplay { + fn deserialize>(deserializer: D) -> 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 UpdateInvoiceRenderingAmountTaxDisplay") + }) + } +} /// Invoice pdf rendering options #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateInvoiceRenderingPdf { @@ -5433,6 +6004,16 @@ impl serde::Serialize for UpdateInvoiceRenderingPdfPageSize { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateInvoiceRenderingPdfPageSize { + fn deserialize>(deserializer: D) -> 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 UpdateInvoiceRenderingPdfPageSize") + }) + } +} /// This is a legacy field that will be removed soon. /// For details about `rendering_options`, refer to `rendering` instead. /// Options for invoice PDF rendering. @@ -5499,6 +6080,18 @@ impl serde::Serialize for UpdateInvoiceRenderingOptionsAmountTaxDisplay { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateInvoiceRenderingOptionsAmountTaxDisplay { + fn deserialize>(deserializer: D) -> 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 UpdateInvoiceRenderingOptionsAmountTaxDisplay", + ) + }) + } +} /// Settings for the cost of shipping for this invoice. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateInvoiceShippingCost<'a> { @@ -5646,6 +6239,16 @@ impl serde::Serialize for UpdateInvoiceShippingCostShippingRateDataDeliveryEstim serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit +{ + fn deserialize>(deserializer: D) -> 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 UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMaximumUnit")) + } +} /// The lower bound of the estimated range. If empty, represents no lower bound. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimum { @@ -5717,6 +6320,16 @@ impl serde::Serialize for UpdateInvoiceShippingCostShippingRateDataDeliveryEstim serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit +{ + fn deserialize>(deserializer: D) -> 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 UpdateInvoiceShippingCostShippingRateDataDeliveryEstimateMinimumUnit")) + } +} /// 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> { @@ -5815,6 +6428,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior +{ + fn deserialize>(deserializer: D) -> 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 UpdateInvoiceShippingCostShippingRateDataFixedAmountCurrencyOptionsTaxBehavior")) + } +} /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. /// One of `inclusive`, `exclusive`, or `unspecified`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -5865,6 +6488,18 @@ impl serde::Serialize for UpdateInvoiceShippingCostShippingRateDataTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateInvoiceShippingCostShippingRateDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 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 { @@ -5908,6 +6543,18 @@ impl serde::Serialize for UpdateInvoiceShippingCostShippingRateDataType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateInvoiceShippingCostShippingRateDataType { + fn deserialize>(deserializer: D) -> 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 UpdateInvoiceShippingCostShippingRateDataType", + ) + }) + } +} impl<'a> UpdateInvoice<'a> { /// Draft invoices are fully editable. /// Once an invoice is [finalized](https://stripe.com/docs/billing/invoices/workflow#finalized),. diff --git a/generated/stripe_billing/src/invoice_item/requests.rs b/generated/stripe_billing/src/invoice_item/requests.rs index be135e7f6..405537e20 100644 --- a/generated/stripe_billing/src/invoice_item/requests.rs +++ b/generated/stripe_billing/src/invoice_item/requests.rs @@ -277,6 +277,16 @@ impl serde::Serialize for CreateInvoiceItemPriceDataTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateInvoiceItemPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 CreateInvoiceItemPriceDataTaxBehavior") + }) + } +} /// 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`. @@ -329,6 +339,15 @@ impl serde::Serialize for CreateInvoiceItemTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateInvoiceItemTaxBehavior { + fn deserialize>(deserializer: D) -> 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 CreateInvoiceItemTaxBehavior")) + } +} impl<'a> CreateInvoiceItem<'a> { /// Creates an item to be added to a draft invoice (up to 250 items per invoice). /// If no invoice is specified, the item will be on the next invoice created for the customer specified. @@ -488,6 +507,16 @@ impl serde::Serialize for UpdateInvoiceItemPriceDataTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateInvoiceItemPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 UpdateInvoiceItemPriceDataTaxBehavior") + }) + } +} /// 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`. @@ -540,6 +569,15 @@ impl serde::Serialize for UpdateInvoiceItemTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateInvoiceItemTaxBehavior { + fn deserialize>(deserializer: D) -> 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 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. diff --git a/generated/stripe_billing/src/invoice_line_item/requests.rs b/generated/stripe_billing/src/invoice_line_item/requests.rs index 0ea7ef846..62478297e 100644 --- a/generated/stripe_billing/src/invoice_line_item/requests.rs +++ b/generated/stripe_billing/src/invoice_line_item/requests.rs @@ -253,6 +253,16 @@ impl serde::Serialize for UpdateInvoiceLineItemPriceDataTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateInvoiceLineItemPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 UpdateInvoiceLineItemPriceDataTaxBehavior") + }) + } +} /// A list of up to 10 tax amounts for this line item. /// This can be useful if you calculate taxes on your own or use a third-party to calculate them. /// You cannot set tax amounts if any line item has [tax_rates](https://stripe.com/docs/api/invoices/line_item#invoice_line_item_object-tax_rates) or if the invoice has [default_tax_rates](https://stripe.com/docs/api/invoices/object#invoice_object-default_tax_rates) or uses [automatic tax](https://stripe.com/docs/tax/invoicing). @@ -412,6 +422,14 @@ impl serde::Serialize for UpdateInvoiceLineItemTaxAmountsTaxRateDataTaxType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateInvoiceLineItemTaxAmountsTaxRateDataTaxType { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} impl<'a> UpdateInvoiceLineItem<'a> { /// Updates an invoice’s line item. /// Some fields, such as `tax_amounts`, only live on the invoice line item,. diff --git a/generated/stripe_billing/src/mod.rs b/generated/stripe_billing/src/mod.rs index 354f802ff..2369d08a8 100644 --- a/generated/stripe_billing/src/mod.rs +++ b/generated/stripe_billing/src/mod.rs @@ -7,6 +7,8 @@ //! for requests mentioned in the `Billing` section of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_billing; + +miniserde::make_place!(Place); pub use billing_portal_configuration::types::*; pub use stripe_shared::automatic_tax::*; pub mod billing_portal_configuration; diff --git a/generated/stripe_billing/src/plan/requests.rs b/generated/stripe_billing/src/plan/requests.rs index c2394c9db..2457908e8 100644 --- a/generated/stripe_billing/src/plan/requests.rs +++ b/generated/stripe_billing/src/plan/requests.rs @@ -341,6 +341,16 @@ impl serde::Serialize for CreatePlanTransformUsageRound { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePlanTransformUsageRound { + fn deserialize>(deserializer: D) -> 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 CreatePlanTransformUsageRound") + }) + } +} impl<'a> CreatePlan<'a> { /// You can now model subscriptions more flexibly using the [Prices API](https://stripe.com/docs/api#prices). /// It replaces the Plans API and is backwards compatible to simplify your migration. diff --git a/generated/stripe_billing/src/portal_business_profile.rs b/generated/stripe_billing/src/portal_business_profile.rs index 3252be5c4..7e7e22010 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PortalBusinessProfile { /// The messaging shown to customers in the portal. pub headline: Option, @@ -7,3 +9,107 @@ pub struct PortalBusinessProfile { /// A link to the business’s publicly available terms of service. pub terms_of_service_url: Option, } +#[doc(hidden)] +pub struct PortalBusinessProfileBuilder { + headline: Option>, + privacy_policy_url: Option>, + terms_of_service_url: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalBusinessProfileBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + headline: self.headline.take()?, + privacy_policy_url: self.privacy_policy_url.take()?, + terms_of_service_url: self.terms_of_service_url.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..78f860a98 100644 --- a/generated/stripe_billing/src/portal_customer_update.rs +++ b/generated/stripe_billing/src/portal_customer_update.rs @@ -1,10 +1,104 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PortalCustomerUpdate { /// The types of customer updates that are supported. When empty, customers are not updateable. pub allowed_updates: Vec, /// Whether the feature is enabled. pub enabled: bool, } +#[doc(hidden)] +pub struct PortalCustomerUpdateBuilder { + allowed_updates: Option>, + enabled: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalCustomerUpdateBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { allowed_updates: Deserialize::default(), enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + allowed_updates: self.allowed_updates.take()?, + enabled: self.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 { + 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 { @@ -55,6 +149,7 @@ impl std::fmt::Debug for PortalCustomerUpdateAllowedUpdates { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PortalCustomerUpdateAllowedUpdates { fn serialize(&self, serializer: S) -> Result where @@ -63,6 +158,23 @@ impl serde::Serialize for PortalCustomerUpdateAllowedUpdates { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PortalCustomerUpdateAllowedUpdates { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(PortalCustomerUpdateAllowedUpdates::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PortalCustomerUpdateAllowedUpdates); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PortalCustomerUpdateAllowedUpdates { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_billing/src/portal_features.rs b/generated/stripe_billing/src/portal_features.rs index e5ad9e671..2cf554e35 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PortalFeatures { pub customer_update: stripe_billing::PortalCustomerUpdate, pub invoice_history: stripe_billing::PortalInvoiceList, @@ -7,3 +9,126 @@ pub struct PortalFeatures { pub subscription_pause: stripe_billing::PortalSubscriptionPause, pub subscription_update: stripe_billing::PortalSubscriptionUpdate, } +#[doc(hidden)] +pub struct PortalFeaturesBuilder { + customer_update: Option, + invoice_history: Option, + payment_method_update: Option, + subscription_cancel: Option, + subscription_pause: Option, + subscription_update: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalFeaturesBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + customer_update: self.customer_update.take()?, + invoice_history: self.invoice_history?, + payment_method_update: self.payment_method_update?, + subscription_cancel: self.subscription_cancel.take()?, + subscription_pause: self.subscription_pause?, + subscription_update: self.subscription_update.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..5631f301f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PortalFlowsAfterCompletionHostedConfirmation { /// A custom message to display to the customer after the flow is completed. pub custom_message: Option, } +#[doc(hidden)] +pub struct PortalFlowsAfterCompletionHostedConfirmationBuilder { + custom_message: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalFlowsAfterCompletionHostedConfirmationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { custom_message: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { custom_message: self.custom_message.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..e4d3b26a5 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PortalFlowsAfterCompletionRedirect { /// The URL the customer will be redirected to after the flow is completed. pub return_url: String, } +#[doc(hidden)] +pub struct PortalFlowsAfterCompletionRedirectBuilder { + return_url: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalFlowsAfterCompletionRedirectBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { return_url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { return_url: self.return_url.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..19800227e 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PortalFlowsCouponOffer { /// The ID of the coupon to be offered. pub coupon: String, } +#[doc(hidden)] +pub struct PortalFlowsCouponOfferBuilder { + coupon: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalFlowsCouponOfferBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { coupon: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { coupon: self.coupon.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..ba3a9ff8b 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PortalFlowsFlow { pub after_completion: stripe_billing::PortalFlowsFlowAfterCompletion, /// Configuration when `flow.type=subscription_cancel`. @@ -9,9 +11,128 @@ pub struct PortalFlowsFlow { pub subscription_update_confirm: Option, /// Type of flow that the customer will go through. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: PortalFlowsFlowType, } +#[doc(hidden)] +pub struct PortalFlowsFlowBuilder { + after_completion: Option, + subscription_cancel: Option>, + subscription_update: Option>, + subscription_update_confirm: + Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalFlowsFlowBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + after_completion: self.after_completion.take()?, + subscription_cancel: self.subscription_cancel.take()?, + subscription_update: self.subscription_update.take()?, + subscription_update_confirm: self.subscription_update_confirm.take()?, + type_: self.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 { + 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 { @@ -56,6 +177,7 @@ impl std::fmt::Debug for PortalFlowsFlowType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PortalFlowsFlowType { fn serialize(&self, serializer: S) -> Result where @@ -64,6 +186,22 @@ impl serde::Serialize for PortalFlowsFlowType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PortalFlowsFlowType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PortalFlowsFlowType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PortalFlowsFlowType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PortalFlowsFlowType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..0e72a70df 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,118 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PortalFlowsFlowAfterCompletion { /// Configuration when `after_completion.type=hosted_confirmation`. pub hosted_confirmation: Option, /// Configuration when `after_completion.type=redirect`. pub redirect: Option, /// The specified type of behavior after the flow is completed. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: PortalFlowsFlowAfterCompletionType, } +#[doc(hidden)] +pub struct PortalFlowsFlowAfterCompletionBuilder { + hosted_confirmation: + Option>, + redirect: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalFlowsFlowAfterCompletionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + hosted_confirmation: Deserialize::default(), + redirect: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + hosted_confirmation: self.hosted_confirmation.take()?, + redirect: self.redirect.take()?, + type_: self.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 { + 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 { @@ -49,6 +154,7 @@ impl std::fmt::Debug for PortalFlowsFlowAfterCompletionType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PortalFlowsFlowAfterCompletionType { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +163,23 @@ impl serde::Serialize for PortalFlowsFlowAfterCompletionType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PortalFlowsFlowAfterCompletionType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(PortalFlowsFlowAfterCompletionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PortalFlowsFlowAfterCompletionType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PortalFlowsFlowAfterCompletionType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..e087d19e1 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,101 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PortalFlowsFlowSubscriptionCancel { /// Specify a retention strategy to be used in the cancellation flow. pub retention: Option, /// The ID of the subscription to be canceled. pub subscription: String, } +#[doc(hidden)] +pub struct PortalFlowsFlowSubscriptionCancelBuilder { + retention: Option>, + subscription: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalFlowsFlowSubscriptionCancelBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { retention: Deserialize::default(), subscription: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + retention: self.retention.take()?, + subscription: self.subscription.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..d60f2f74a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PortalFlowsFlowSubscriptionUpdate { /// The ID of the subscription to be updated. pub subscription: String, } +#[doc(hidden)] +pub struct PortalFlowsFlowSubscriptionUpdateBuilder { + subscription: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalFlowsFlowSubscriptionUpdateBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { subscription: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { subscription: self.subscription.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..73a5c5292 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,103 @@ pub struct PortalFlowsFlowSubscriptionUpdateConfirm { /// The ID of the subscription to be updated. pub subscription: String, } +#[doc(hidden)] +pub struct PortalFlowsFlowSubscriptionUpdateConfirmBuilder { + discounts: Option>>, + items: Option>, + subscription: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalFlowsFlowSubscriptionUpdateConfirmBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + discounts: Deserialize::default(), + items: Deserialize::default(), + subscription: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + discounts: self.discounts.take()?, + items: self.items.take()?, + subscription: self.subscription.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..f3c2a546e 100644 --- a/generated/stripe_billing/src/portal_flows_retention.rs +++ b/generated/stripe_billing/src/portal_flows_retention.rs @@ -1,11 +1,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PortalFlowsRetention { /// Configuration when `retention.type=coupon_offer`. pub coupon_offer: Option, /// Type of retention strategy that will be used. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: PortalFlowsRetentionType, } +#[doc(hidden)] +pub struct PortalFlowsRetentionBuilder { + coupon_offer: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalFlowsRetentionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { coupon_offer: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { coupon_offer: self.coupon_offer.take()?, type_: self.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 { + 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 { @@ -41,6 +132,7 @@ impl std::fmt::Debug for PortalFlowsRetentionType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PortalFlowsRetentionType { fn serialize(&self, serializer: S) -> Result where @@ -49,6 +141,22 @@ impl serde::Serialize for PortalFlowsRetentionType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PortalFlowsRetentionType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PortalFlowsRetentionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PortalFlowsRetentionType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PortalFlowsRetentionType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..dcbf71507 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,101 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PortalFlowsSubscriptionUpdateConfirmDiscount { /// The ID of the coupon to apply to this subscription update. pub coupon: Option, /// The ID of a promotion code to apply to this subscription update. pub promotion_code: Option, } +#[doc(hidden)] +pub struct PortalFlowsSubscriptionUpdateConfirmDiscountBuilder { + coupon: Option>, + promotion_code: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalFlowsSubscriptionUpdateConfirmDiscountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { coupon: Deserialize::default(), promotion_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + coupon: self.coupon.take()?, + promotion_code: self.promotion_code.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..64ca04417 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -6,9 +8,108 @@ 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, /// [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, } +#[doc(hidden)] +pub struct PortalFlowsSubscriptionUpdateConfirmItemBuilder { + id: Option>, + price: Option>, + quantity: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalFlowsSubscriptionUpdateConfirmItemBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + id: Deserialize::default(), + price: Deserialize::default(), + quantity: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + id: self.id.take()?, + price: self.price.take()?, + quantity: self.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 { + 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; 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..0430b67f0 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PortalInvoiceList { /// Whether the feature is enabled. pub enabled: bool, } +#[doc(hidden)] +pub struct PortalInvoiceListBuilder { + enabled: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalInvoiceListBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.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 { + 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..9981ceb6d 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,92 @@ 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, } +#[doc(hidden)] +pub struct PortalLoginPageBuilder { + enabled: Option, + url: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalLoginPageBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default(), url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.enabled?, url: self.url.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..e5b6d9e75 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PortalPaymentMethodUpdate { /// Whether the feature is enabled. pub enabled: bool, } +#[doc(hidden)] +pub struct PortalPaymentMethodUpdateBuilder { + enabled: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalPaymentMethodUpdateBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.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 { + 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..70d02bfca 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PortalSubscriptionCancel { pub cancellation_reason: stripe_billing::PortalSubscriptionCancellationReason, /// Whether the feature is enabled. @@ -9,6 +11,115 @@ pub struct PortalSubscriptionCancel { /// Possible values are `none` and `create_prorations`. pub proration_behavior: PortalSubscriptionCancelProrationBehavior, } +#[doc(hidden)] +pub struct PortalSubscriptionCancelBuilder { + cancellation_reason: Option, + enabled: Option, + mode: Option, + proration_behavior: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalSubscriptionCancelBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + cancellation_reason: self.cancellation_reason.take()?, + enabled: self.enabled?, + mode: self.mode?, + proration_behavior: self.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 { + 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 { @@ -47,6 +158,7 @@ impl std::fmt::Debug for PortalSubscriptionCancelMode { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PortalSubscriptionCancelMode { fn serialize(&self, serializer: S) -> Result where @@ -55,6 +167,22 @@ impl serde::Serialize for PortalSubscriptionCancelMode { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PortalSubscriptionCancelMode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PortalSubscriptionCancelMode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PortalSubscriptionCancelMode); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PortalSubscriptionCancelMode { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -105,6 +233,7 @@ impl std::fmt::Debug for PortalSubscriptionCancelProrationBehavior { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PortalSubscriptionCancelProrationBehavior { fn serialize(&self, serializer: S) -> Result where @@ -113,6 +242,24 @@ impl serde::Serialize for PortalSubscriptionCancelProrationBehavior { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PortalSubscriptionCancelProrationBehavior { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PortalSubscriptionCancelProrationBehavior::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PortalSubscriptionCancelProrationBehavior); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PortalSubscriptionCancelProrationBehavior { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_billing/src/portal_subscription_cancellation_reason.rs b/generated/stripe_billing/src/portal_subscription_cancellation_reason.rs index 689eb829c..57594ddf1 100644 --- a/generated/stripe_billing/src/portal_subscription_cancellation_reason.rs +++ b/generated/stripe_billing/src/portal_subscription_cancellation_reason.rs @@ -1,10 +1,101 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct PortalSubscriptionCancellationReasonBuilder { + enabled: Option, + options: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalSubscriptionCancellationReasonBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default(), options: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.enabled?, options: self.options.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -61,6 +152,7 @@ impl std::fmt::Debug for PortalSubscriptionCancellationReasonOptions { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PortalSubscriptionCancellationReasonOptions { fn serialize(&self, serializer: S) -> Result where @@ -69,6 +161,25 @@ impl serde::Serialize for PortalSubscriptionCancellationReasonOptions { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PortalSubscriptionCancellationReasonOptions { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PortalSubscriptionCancellationReasonOptions::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PortalSubscriptionCancellationReasonOptions); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PortalSubscriptionCancellationReasonOptions { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_billing/src/portal_subscription_pause.rs b/generated/stripe_billing/src/portal_subscription_pause.rs index edb26171c..e2e81abae 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PortalSubscriptionPause { /// Whether the feature is enabled. pub enabled: bool, } +#[doc(hidden)] +pub struct PortalSubscriptionPauseBuilder { + enabled: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalSubscriptionPauseBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.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 { + 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..4fbbcc757 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,115 @@ pub struct PortalSubscriptionUpdate { /// Valid values are `none`, `create_prorations`, and `always_invoice`. pub proration_behavior: PortalSubscriptionUpdateProrationBehavior, } +#[doc(hidden)] +pub struct PortalSubscriptionUpdateBuilder { + default_allowed_updates: Option>, + enabled: Option, + products: Option>>, + proration_behavior: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalSubscriptionUpdateBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + default_allowed_updates: self.default_allowed_updates.take()?, + enabled: self.enabled?, + products: self.products.take()?, + proration_behavior: self.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 { + 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)] @@ -53,6 +164,7 @@ impl std::fmt::Debug for PortalSubscriptionUpdateDefaultAllowedUpdates { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PortalSubscriptionUpdateDefaultAllowedUpdates { fn serialize(&self, serializer: S) -> Result where @@ -61,6 +173,25 @@ impl serde::Serialize for PortalSubscriptionUpdateDefaultAllowedUpdates { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PortalSubscriptionUpdateDefaultAllowedUpdates { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PortalSubscriptionUpdateDefaultAllowedUpdates::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PortalSubscriptionUpdateDefaultAllowedUpdates); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PortalSubscriptionUpdateDefaultAllowedUpdates { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -114,6 +245,7 @@ impl std::fmt::Debug for PortalSubscriptionUpdateProrationBehavior { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PortalSubscriptionUpdateProrationBehavior { fn serialize(&self, serializer: S) -> Result where @@ -122,6 +254,24 @@ impl serde::Serialize for PortalSubscriptionUpdateProrationBehavior { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PortalSubscriptionUpdateProrationBehavior { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PortalSubscriptionUpdateProrationBehavior::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PortalSubscriptionUpdateProrationBehavior); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PortalSubscriptionUpdateProrationBehavior { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_billing/src/portal_subscription_update_product.rs b/generated/stripe_billing/src/portal_subscription_update_product.rs index 6eb5cf77c..6d607f71c 100644 --- a/generated/stripe_billing/src/portal_subscription_update_product.rs +++ b/generated/stripe_billing/src/portal_subscription_update_product.rs @@ -1,7 +1,98 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PortalSubscriptionUpdateProduct { /// The list of price IDs which, when subscribed to, a subscription can be updated. pub prices: Vec, /// The product ID. pub product: String, } +#[doc(hidden)] +pub struct PortalSubscriptionUpdateProductBuilder { + prices: Option>, + product: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PortalSubscriptionUpdateProductBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { prices: Deserialize::default(), product: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { prices: self.prices.take()?, product: self.product.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..5063a7caa 100644 --- a/generated/stripe_billing/src/quote/requests.rs +++ b/generated/stripe_billing/src/quote/requests.rs @@ -321,6 +321,16 @@ impl serde::Serialize for CreateQuoteAutomaticTaxLiabilityType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateQuoteAutomaticTaxLiabilityType { + fn deserialize>(deserializer: D) -> 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 CreateQuoteAutomaticTaxLiabilityType") + }) + } +} /// 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`. @@ -416,6 +426,16 @@ impl serde::Serialize for CreateQuoteInvoiceSettingsIssuerType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateQuoteInvoiceSettingsIssuerType { + fn deserialize>(deserializer: D) -> 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 CreateQuoteInvoiceSettingsIssuerType") + }) + } +} /// 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)] @@ -546,6 +566,18 @@ impl serde::Serialize for CreateQuoteLineItemsPriceDataRecurringInterval { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateQuoteLineItemsPriceDataRecurringInterval { + fn deserialize>(deserializer: D) -> 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 CreateQuoteLineItemsPriceDataRecurringInterval", + ) + }) + } +} /// 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`. @@ -598,6 +630,16 @@ impl serde::Serialize for CreateQuoteLineItemsPriceDataTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateQuoteLineItemsPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 CreateQuoteLineItemsPriceDataTaxBehavior") + }) + } +} /// When creating a subscription or subscription schedule, the specified configuration data will be used. /// There must be at least one line item with a recurring price for a subscription or subscription schedule to be created. /// A subscription schedule is created if `subscription_data[effective_date]` is present and in the future, otherwise a subscription is created. @@ -802,6 +844,16 @@ impl serde::Serialize for UpdateQuoteAutomaticTaxLiabilityType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateQuoteAutomaticTaxLiabilityType { + fn deserialize>(deserializer: D) -> 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 UpdateQuoteAutomaticTaxLiabilityType") + }) + } +} /// All invoices will be billed using the specified settings. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateQuoteInvoiceSettings<'a> { @@ -881,6 +933,16 @@ impl serde::Serialize for UpdateQuoteInvoiceSettingsIssuerType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateQuoteInvoiceSettingsIssuerType { + fn deserialize>(deserializer: D) -> 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 UpdateQuoteInvoiceSettingsIssuerType") + }) + } +} /// 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)] @@ -1014,6 +1076,18 @@ impl serde::Serialize for UpdateQuoteLineItemsPriceDataRecurringInterval { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateQuoteLineItemsPriceDataRecurringInterval { + fn deserialize>(deserializer: D) -> 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 UpdateQuoteLineItemsPriceDataRecurringInterval", + ) + }) + } +} /// 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`. @@ -1066,6 +1140,16 @@ impl serde::Serialize for UpdateQuoteLineItemsPriceDataTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateQuoteLineItemsPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 UpdateQuoteLineItemsPriceDataTaxBehavior") + }) + } +} /// When creating a subscription or subscription schedule, the specified configuration data will be used. /// There must be at least one line item with a recurring price for a subscription or subscription schedule to be created. /// A subscription schedule is created if `subscription_data[effective_date]` is present and in the future, otherwise a subscription is created. diff --git a/generated/stripe_billing/src/subscription/requests.rs b/generated/stripe_billing/src/subscription/requests.rs index 42f686a8a..a82876047 100644 --- a/generated/stripe_billing/src/subscription/requests.rs +++ b/generated/stripe_billing/src/subscription/requests.rs @@ -97,6 +97,18 @@ impl serde::Serialize for CancelSubscriptionCancellationDetailsFeedback { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CancelSubscriptionCancellationDetailsFeedback { + fn deserialize>(deserializer: D) -> 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 CancelSubscriptionCancellationDetailsFeedback", + ) + }) + } +} impl<'a> CancelSubscription<'a> { /// Cancels a customer’s subscription immediately. /// The customer will not be charged again for the subscription. @@ -285,6 +297,15 @@ impl serde::Serialize for ListSubscriptionStatus { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ListSubscriptionStatus { + fn deserialize>(deserializer: D) -> 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 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`. @@ -363,7 +384,7 @@ impl<'a> SearchSubscription<'a> { stripe::ListPaginator::from_search_params("/subscriptions/search", self) } } -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(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. /// You may pass up to 20 items. @@ -671,6 +692,18 @@ impl serde::Serialize for CreateSubscriptionAddInvoiceItemsPriceDataTaxBehavior serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionAddInvoiceItemsPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 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)] @@ -751,6 +784,18 @@ impl serde::Serialize for CreateSubscriptionAutomaticTaxLiabilityType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionAutomaticTaxLiabilityType { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionAutomaticTaxLiabilityType", + ) + }) + } +} /// 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)] @@ -854,6 +899,18 @@ impl serde::Serialize for CreateSubscriptionInvoiceSettingsIssuerType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionInvoiceSettingsIssuerType { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionInvoiceSettingsIssuerType", + ) + }) + } +} /// A list of up to 20 subscription items, each with an attached price. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateSubscriptionItems<'a> { @@ -998,6 +1055,18 @@ impl serde::Serialize for CreateSubscriptionItemsPriceDataRecurringInterval { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionItemsPriceDataRecurringInterval { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionItemsPriceDataRecurringInterval", + ) + }) + } +} /// 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`. @@ -1050,6 +1119,18 @@ impl serde::Serialize for CreateSubscriptionItemsPriceDataTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionItemsPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionItemsPriceDataTaxBehavior", + ) + }) + } +} /// Only applies to subscriptions with `collection_method=charge_automatically`. /// /// Use `allow_incomplete` to create subscriptions with `status=incomplete` if the first invoice cannot be paid. @@ -1123,8 +1204,18 @@ impl serde::Serialize for CreateSubscriptionPaymentBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionPaymentBehavior { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionPaymentBehavior") + }) + } +} /// Payment settings to pass to invoices created by the subscription. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(Clone, Debug, Default, serde::Serialize)] pub struct CreateSubscriptionPaymentSettings<'a> { /// Payment-method-specific configuration to provide to invoices created by the subscription. #[serde(skip_serializing_if = "Option::is_none")] @@ -1146,7 +1237,7 @@ impl<'a> CreateSubscriptionPaymentSettings<'a> { } } /// Payment-method-specific configuration to provide to invoices created by the subscription. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(Clone, Debug, Default, serde::Serialize)] pub struct CreateSubscriptionPaymentSettingsPaymentMethodOptions<'a> { /// 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")] @@ -1162,7 +1253,8 @@ pub struct CreateSubscriptionPaymentSettingsPaymentMethodOptions<'a> { pub customer_balance: Option>, /// 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 konbini: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub konbini: Option, /// 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: @@ -1259,6 +1351,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType +{ + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType")) + } +} /// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { @@ -1316,6 +1418,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod")) + } +} /// 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 CreateSubscriptionPaymentSettingsPaymentMethodOptionsBancontact { @@ -1389,6 +1501,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage +{ + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage")) + } +} /// 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 CreateSubscriptionPaymentSettingsPaymentMethodOptionsCard<'a> { @@ -1490,6 +1612,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType +{ + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType")) + } +} /// 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. @@ -1565,6 +1697,16 @@ impl serde::Serialize for CreateSubscriptionPaymentSettingsPaymentMethodOptionsC serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork +{ + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork")) + } +} /// 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. @@ -1624,6 +1766,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure +{ + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure")) + } +} /// 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 CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccount<'a> { @@ -1717,6 +1869,14 @@ impl serde::Serialize for CreateSubscriptionPaymentSettingsPaymentMethodOptionsU serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions")) + } +} /// List of data features that you would like to retrieve upon account creation. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch @@ -1764,6 +1924,14 @@ impl serde::Serialize for CreateSubscriptionPaymentSettingsPaymentMethodOptionsU serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch")) + } +} /// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { @@ -1821,6 +1989,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod")) + } +} /// 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). @@ -1945,6 +2123,14 @@ impl serde::Serialize for CreateSubscriptionPaymentSettingsPaymentMethodTypes { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionPaymentSettingsPaymentMethodTypes { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Either `off`, or `on_subscription`. /// With `on_subscription` Stripe updates `subscription.default_payment_method` when a subscription payment succeeds. #[derive(Copy, Clone, Eq, PartialEq)] @@ -1992,6 +2178,18 @@ impl serde::Serialize for CreateSubscriptionPaymentSettingsSaveDefaultPaymentMet serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionPaymentSettingsSaveDefaultPaymentMethod { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionPaymentSettingsSaveDefaultPaymentMethod", + ) + }) + } +} /// 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. #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -2061,6 +2259,18 @@ impl serde::Serialize for CreateSubscriptionPendingInvoiceItemIntervalInterval { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionPendingInvoiceItemIntervalInterval { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionPendingInvoiceItemIntervalInterval", + ) + }) + } +} /// Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) resulting from the `billing_cycle_anchor`. /// If no value is passed, the default is `create_prorations`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -2111,6 +2321,16 @@ impl serde::Serialize for CreateSubscriptionProrationBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionProrationBehavior { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionProrationBehavior") + }) + } +} /// Unix timestamp representing the end of the trial period the customer will get before being charged for the first time. /// If set, trial_end will override the default trial period of the plan the customer is being subscribed to. /// The special value `now` can be provided to end the customer's trial immediately. @@ -2195,6 +2415,20 @@ impl serde::Serialize for CreateSubscriptionTrialSettingsEndBehaviorMissingPayme serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSubscriptionTrialSettingsEndBehaviorMissingPaymentMethod +{ + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionTrialSettingsEndBehaviorMissingPaymentMethod", + ) + }) + } +} impl<'a> CreateSubscription<'a> { /// Creates a new subscription on an existing customer. /// Each customer can have up to 500 active or scheduled subscriptions. @@ -2282,6 +2516,16 @@ impl serde::Serialize for ResumeSubscriptionBillingCycleAnchor { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ResumeSubscriptionBillingCycleAnchor { + fn deserialize>(deserializer: D) -> 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 ResumeSubscriptionBillingCycleAnchor") + }) + } +} /// 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)] @@ -2332,6 +2576,16 @@ impl serde::Serialize for ResumeSubscriptionProrationBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ResumeSubscriptionProrationBehavior { + fn deserialize>(deserializer: D) -> 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 ResumeSubscriptionProrationBehavior") + }) + } +} 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. @@ -2349,7 +2603,7 @@ impl<'a> ResumeSubscription<'a> { ) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(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. @@ -2610,6 +2864,18 @@ impl serde::Serialize for UpdateSubscriptionAddInvoiceItemsPriceDataTaxBehavior serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionAddInvoiceItemsPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 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)] @@ -2690,6 +2956,18 @@ impl serde::Serialize for UpdateSubscriptionAutomaticTaxLiabilityType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionAutomaticTaxLiabilityType { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionAutomaticTaxLiabilityType", + ) + }) + } +} /// 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). @@ -2738,6 +3016,16 @@ impl serde::Serialize for UpdateSubscriptionBillingCycleAnchor { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionBillingCycleAnchor { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionBillingCycleAnchor") + }) + } +} /// Details about why this subscription was cancelled #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateSubscriptionCancellationDetails<'a> { @@ -2817,6 +3105,18 @@ impl serde::Serialize for UpdateSubscriptionCancellationDetailsFeedback { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionCancellationDetailsFeedback { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionCancellationDetailsFeedback", + ) + }) + } +} /// All invoices will be billed using the specified settings. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateSubscriptionInvoiceSettings<'a> { @@ -2896,6 +3196,18 @@ impl serde::Serialize for UpdateSubscriptionInvoiceSettingsIssuerType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionInvoiceSettingsIssuerType { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionInvoiceSettingsIssuerType", + ) + }) + } +} /// A list of up to 20 subscription items, each with an attached price. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateSubscriptionItems<'a> { @@ -3051,6 +3363,18 @@ impl serde::Serialize for UpdateSubscriptionItemsPriceDataRecurringInterval { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionItemsPriceDataRecurringInterval { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionItemsPriceDataRecurringInterval", + ) + }) + } +} /// 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`. @@ -3103,6 +3427,18 @@ impl serde::Serialize for UpdateSubscriptionItemsPriceDataTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionItemsPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionItemsPriceDataTaxBehavior", + ) + }) + } +} /// If specified, payment collection for this subscription will be paused. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdateSubscriptionPauseCollection { @@ -3168,6 +3504,16 @@ impl serde::Serialize for UpdateSubscriptionPauseCollectionBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionPauseCollectionBehavior { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionPauseCollectionBehavior") + }) + } +} /// Use `allow_incomplete` to transition the subscription to `status=past_due` if a payment is required but cannot be paid. /// This allows you to manage scenarios where additional user actions are needed to pay a subscription's invoice. /// For example, SCA regulation may require 3DS authentication to complete payment. @@ -3236,8 +3582,18 @@ impl serde::Serialize for UpdateSubscriptionPaymentBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionPaymentBehavior { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionPaymentBehavior") + }) + } +} /// Payment settings to pass to invoices created by the subscription. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(Clone, Debug, Default, serde::Serialize)] pub struct UpdateSubscriptionPaymentSettings<'a> { /// Payment-method-specific configuration to provide to invoices created by the subscription. #[serde(skip_serializing_if = "Option::is_none")] @@ -3259,7 +3615,7 @@ impl<'a> UpdateSubscriptionPaymentSettings<'a> { } } /// Payment-method-specific configuration to provide to invoices created by the subscription. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(Clone, Debug, Default, serde::Serialize)] pub struct UpdateSubscriptionPaymentSettingsPaymentMethodOptions<'a> { /// 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")] @@ -3275,7 +3631,8 @@ pub struct UpdateSubscriptionPaymentSettingsPaymentMethodOptions<'a> { pub customer_balance: Option>, /// 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 konbini: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub konbini: Option, /// 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: @@ -3372,6 +3729,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType +{ + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitMandateOptionsTransactionType")) + } +} /// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod { @@ -3429,6 +3796,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionPaymentSettingsPaymentMethodOptionsAcssDebitVerificationMethod")) + } +} /// 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 UpdateSubscriptionPaymentSettingsPaymentMethodOptionsBancontact { @@ -3502,6 +3879,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage +{ + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionPaymentSettingsPaymentMethodOptionsBancontactPreferredLanguage")) + } +} /// 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 UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCard<'a> { @@ -3603,6 +3990,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType +{ + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardMandateOptionsAmountType")) + } +} /// 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. @@ -3678,6 +4075,16 @@ impl serde::Serialize for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsC serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork +{ + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardNetwork")) + } +} /// 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. @@ -3737,6 +4144,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure +{ + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionPaymentSettingsPaymentMethodOptionsCardRequestThreeDSecure")) + } +} /// 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 UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccount<'a> { @@ -3830,6 +4247,14 @@ impl serde::Serialize for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsU serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions")) + } +} /// List of data features that you would like to retrieve upon account creation. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch @@ -3877,6 +4302,14 @@ impl serde::Serialize for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsU serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch")) + } +} /// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod { @@ -3934,6 +4367,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionPaymentSettingsPaymentMethodOptionsUsBankAccountVerificationMethod")) + } +} /// 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). @@ -4058,6 +4501,14 @@ impl serde::Serialize for UpdateSubscriptionPaymentSettingsPaymentMethodTypes { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionPaymentSettingsPaymentMethodTypes { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Either `off`, or `on_subscription`. /// With `on_subscription` Stripe updates `subscription.default_payment_method` when a subscription payment succeeds. #[derive(Copy, Clone, Eq, PartialEq)] @@ -4105,6 +4556,18 @@ impl serde::Serialize for UpdateSubscriptionPaymentSettingsSaveDefaultPaymentMet serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionPaymentSettingsSaveDefaultPaymentMethod { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionPaymentSettingsSaveDefaultPaymentMethod", + ) + }) + } +} /// 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. #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -4174,6 +4637,18 @@ impl serde::Serialize for UpdateSubscriptionPendingInvoiceItemIntervalInterval { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionPendingInvoiceItemIntervalInterval { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionPendingInvoiceItemIntervalInterval", + ) + }) + } +} /// 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)] @@ -4224,6 +4699,16 @@ impl serde::Serialize for UpdateSubscriptionProrationBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionProrationBehavior { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionProrationBehavior") + }) + } +} /// Unix timestamp representing the end of the trial period the customer will get before being charged for the first time. /// This will always overwrite any trials that might apply via a subscribed plan. /// If set, trial_end will override the default trial period of the plan the customer is being subscribed to. @@ -4308,6 +4793,20 @@ impl serde::Serialize for UpdateSubscriptionTrialSettingsEndBehaviorMissingPayme serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSubscriptionTrialSettingsEndBehaviorMissingPaymentMethod +{ + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionTrialSettingsEndBehaviorMissingPaymentMethod", + ) + }) + } +} impl<'a> UpdateSubscription<'a> { /// Updates an existing subscription to match the specified parameters. /// When changing prices or quantities, we optionally prorate the price we charge next month to make up for any price changes. diff --git a/generated/stripe_billing/src/subscription_item/requests.rs b/generated/stripe_billing/src/subscription_item/requests.rs index e56045b5e..efcd62b39 100644 --- a/generated/stripe_billing/src/subscription_item/requests.rs +++ b/generated/stripe_billing/src/subscription_item/requests.rs @@ -68,6 +68,16 @@ impl serde::Serialize for DeleteSubscriptionItemProrationBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeleteSubscriptionItemProrationBehavior { + fn deserialize>(deserializer: D) -> 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 DeleteSubscriptionItemProrationBehavior") + }) + } +} impl DeleteSubscriptionItem { /// Deletes an item from the subscription. /// Removing a subscription item from a subscription will not cancel the subscription. @@ -341,6 +351,16 @@ impl serde::Serialize for CreateSubscriptionItemPaymentBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionItemPaymentBehavior { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionItemPaymentBehavior") + }) + } +} /// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateSubscriptionItemPriceData<'a> { @@ -449,6 +469,18 @@ impl serde::Serialize for CreateSubscriptionItemPriceDataRecurringInterval { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionItemPriceDataRecurringInterval { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionItemPriceDataRecurringInterval", + ) + }) + } +} /// 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`. @@ -501,6 +533,16 @@ impl serde::Serialize for CreateSubscriptionItemPriceDataTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionItemPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionItemPriceDataTaxBehavior") + }) + } +} /// 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)] @@ -551,6 +593,16 @@ impl serde::Serialize for CreateSubscriptionItemProrationBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionItemProrationBehavior { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionItemProrationBehavior") + }) + } +} impl<'a> CreateSubscriptionItem<'a> { /// Adds a new item to an existing subscription. No existing items will be changed or replaced. pub fn send( @@ -697,6 +749,16 @@ impl serde::Serialize for UpdateSubscriptionItemPaymentBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionItemPaymentBehavior { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionItemPaymentBehavior") + }) + } +} /// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdateSubscriptionItemPriceData<'a> { @@ -805,6 +867,18 @@ impl serde::Serialize for UpdateSubscriptionItemPriceDataRecurringInterval { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionItemPriceDataRecurringInterval { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionItemPriceDataRecurringInterval", + ) + }) + } +} /// 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`. @@ -857,6 +931,16 @@ impl serde::Serialize for UpdateSubscriptionItemPriceDataTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionItemPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionItemPriceDataTaxBehavior") + }) + } +} /// 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)] @@ -907,6 +991,16 @@ impl serde::Serialize for UpdateSubscriptionItemProrationBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionItemProrationBehavior { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionItemProrationBehavior") + }) + } +} impl<'a> UpdateSubscriptionItem<'a> { /// Updates the plan or quantity of an item on a current subscription. pub fn send( diff --git a/generated/stripe_billing/src/subscription_schedule/requests.rs b/generated/stripe_billing/src/subscription_schedule/requests.rs index a3e60f65e..915775789 100644 --- a/generated/stripe_billing/src/subscription_schedule/requests.rs +++ b/generated/stripe_billing/src/subscription_schedule/requests.rs @@ -252,6 +252,16 @@ impl serde::Serialize for CreateSubscriptionScheduleDefaultSettingsAutomaticTaxL serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType +{ + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType")) + } +} /// 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). @@ -300,6 +310,18 @@ impl serde::Serialize for CreateSubscriptionScheduleDefaultSettingsBillingCycleA serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionScheduleDefaultSettingsBillingCycleAnchor { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionScheduleDefaultSettingsBillingCycleAnchor", + ) + }) + } +} /// 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`. @@ -349,6 +371,18 @@ impl serde::Serialize for CreateSubscriptionScheduleDefaultSettingsCollectionMet serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionScheduleDefaultSettingsCollectionMethod { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionScheduleDefaultSettingsCollectionMethod", + ) + }) + } +} /// All invoices will be billed using the specified settings. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateSubscriptionScheduleDefaultSettingsInvoiceSettings<'a> { @@ -432,6 +466,16 @@ impl serde::Serialize for CreateSubscriptionScheduleDefaultSettingsInvoiceSettin serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType +{ + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType")) + } +} /// 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. @@ -653,6 +697,16 @@ impl serde::Serialize for CreateSubscriptionSchedulePhasesAddInvoiceItemsPriceDa serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSubscriptionSchedulePhasesAddInvoiceItemsPriceDataTaxBehavior +{ + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionSchedulePhasesAddInvoiceItemsPriceDataTaxBehavior")) + } +} /// Automatic tax settings for this phase. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateSubscriptionSchedulePhasesAutomaticTax<'a> { @@ -732,6 +786,18 @@ impl serde::Serialize for CreateSubscriptionSchedulePhasesAutomaticTaxLiabilityT serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionSchedulePhasesAutomaticTaxLiabilityType { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionSchedulePhasesAutomaticTaxLiabilityType", + ) + }) + } +} /// 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). @@ -780,6 +846,18 @@ impl serde::Serialize for CreateSubscriptionSchedulePhasesBillingCycleAnchor { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionSchedulePhasesBillingCycleAnchor { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionSchedulePhasesBillingCycleAnchor", + ) + }) + } +} /// 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`. @@ -829,6 +907,18 @@ impl serde::Serialize for CreateSubscriptionSchedulePhasesCollectionMethod { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionSchedulePhasesCollectionMethod { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionSchedulePhasesCollectionMethod", + ) + }) + } +} /// All invoices will be billed using the specified settings. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateSubscriptionSchedulePhasesInvoiceSettings<'a> { @@ -912,6 +1002,18 @@ impl serde::Serialize for CreateSubscriptionSchedulePhasesInvoiceSettingsIssuerT serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionSchedulePhasesInvoiceSettingsIssuerType { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionSchedulePhasesInvoiceSettingsIssuerType", + ) + }) + } +} /// 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> { @@ -1057,6 +1159,20 @@ impl serde::Serialize for CreateSubscriptionSchedulePhasesItemsPriceDataRecurrin serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSubscriptionSchedulePhasesItemsPriceDataRecurringInterval +{ + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionSchedulePhasesItemsPriceDataRecurringInterval", + ) + }) + } +} /// 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`. @@ -1109,6 +1225,18 @@ impl serde::Serialize for CreateSubscriptionSchedulePhasesItemsPriceDataTaxBehav serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionSchedulePhasesItemsPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionSchedulePhasesItemsPriceDataTaxBehavior", + ) + }) + } +} /// Whether the subscription schedule will create [prorations](https://stripe.com/docs/billing/subscriptions/prorations) when transitioning to this phase. /// The default value is `create_prorations`. /// This setting controls prorations when a phase is started asynchronously and it is persisted as a field on the phase. @@ -1161,6 +1289,18 @@ impl serde::Serialize for CreateSubscriptionSchedulePhasesProrationBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionSchedulePhasesProrationBehavior { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionSchedulePhasesProrationBehavior", + ) + }) + } +} /// When the subscription schedule starts. /// We recommend using `now` so that it starts the subscription immediately. /// You can also use a Unix timestamp to backdate the subscription so that it starts on a past date, or set a future date for the subscription to start on. @@ -1346,6 +1486,16 @@ impl serde::Serialize for UpdateSubscriptionScheduleDefaultSettingsAutomaticTaxL serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType +{ + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionScheduleDefaultSettingsAutomaticTaxLiabilityType")) + } +} /// 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). @@ -1394,6 +1544,18 @@ impl serde::Serialize for UpdateSubscriptionScheduleDefaultSettingsBillingCycleA serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionScheduleDefaultSettingsBillingCycleAnchor { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionScheduleDefaultSettingsBillingCycleAnchor", + ) + }) + } +} /// 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`. @@ -1443,6 +1605,18 @@ impl serde::Serialize for UpdateSubscriptionScheduleDefaultSettingsCollectionMet serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionScheduleDefaultSettingsCollectionMethod { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionScheduleDefaultSettingsCollectionMethod", + ) + }) + } +} /// All invoices will be billed using the specified settings. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateSubscriptionScheduleDefaultSettingsInvoiceSettings<'a> { @@ -1526,6 +1700,16 @@ impl serde::Serialize for UpdateSubscriptionScheduleDefaultSettingsInvoiceSettin serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType +{ + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionScheduleDefaultSettingsInvoiceSettingsIssuerType")) + } +} /// 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. @@ -1753,6 +1937,16 @@ impl serde::Serialize for UpdateSubscriptionSchedulePhasesAddInvoiceItemsPriceDa serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSubscriptionSchedulePhasesAddInvoiceItemsPriceDataTaxBehavior +{ + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionSchedulePhasesAddInvoiceItemsPriceDataTaxBehavior")) + } +} /// Automatic tax settings for this phase. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdateSubscriptionSchedulePhasesAutomaticTax<'a> { @@ -1832,6 +2026,18 @@ impl serde::Serialize for UpdateSubscriptionSchedulePhasesAutomaticTaxLiabilityT serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionSchedulePhasesAutomaticTaxLiabilityType { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionSchedulePhasesAutomaticTaxLiabilityType", + ) + }) + } +} /// 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). @@ -1880,6 +2086,18 @@ impl serde::Serialize for UpdateSubscriptionSchedulePhasesBillingCycleAnchor { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionSchedulePhasesBillingCycleAnchor { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionSchedulePhasesBillingCycleAnchor", + ) + }) + } +} /// 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`. @@ -1929,6 +2147,18 @@ impl serde::Serialize for UpdateSubscriptionSchedulePhasesCollectionMethod { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionSchedulePhasesCollectionMethod { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionSchedulePhasesCollectionMethod", + ) + }) + } +} /// The date at which this phase of the subscription schedule ends. /// If set, `iterations` must not be set. #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -2020,6 +2250,18 @@ impl serde::Serialize for UpdateSubscriptionSchedulePhasesInvoiceSettingsIssuerT serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionSchedulePhasesInvoiceSettingsIssuerType { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionSchedulePhasesInvoiceSettingsIssuerType", + ) + }) + } +} /// 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> { @@ -2165,6 +2407,20 @@ impl serde::Serialize for UpdateSubscriptionSchedulePhasesItemsPriceDataRecurrin serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSubscriptionSchedulePhasesItemsPriceDataRecurringInterval +{ + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionSchedulePhasesItemsPriceDataRecurringInterval", + ) + }) + } +} /// 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`. @@ -2217,6 +2473,18 @@ impl serde::Serialize for UpdateSubscriptionSchedulePhasesItemsPriceDataTaxBehav serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionSchedulePhasesItemsPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionSchedulePhasesItemsPriceDataTaxBehavior", + ) + }) + } +} /// Whether the subscription schedule will create [prorations](https://stripe.com/docs/billing/subscriptions/prorations) when transitioning to this phase. /// The default value is `create_prorations`. /// This setting controls prorations when a phase is started asynchronously and it is persisted as a field on the phase. @@ -2269,6 +2537,18 @@ impl serde::Serialize for UpdateSubscriptionSchedulePhasesProrationBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionSchedulePhasesProrationBehavior { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionSchedulePhasesProrationBehavior", + ) + }) + } +} /// The date at which this phase of the subscription schedule starts or `now`. /// Must be set on the first phase. #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -2335,6 +2615,18 @@ impl serde::Serialize for UpdateSubscriptionScheduleProrationBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSubscriptionScheduleProrationBehavior { + fn deserialize>(deserializer: D) -> 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 UpdateSubscriptionScheduleProrationBehavior", + ) + }) + } +} impl<'a> UpdateSubscriptionSchedule<'a> { /// Updates an existing subscription schedule. pub fn send( diff --git a/generated/stripe_billing/src/tax_id/requests.rs b/generated/stripe_billing/src/tax_id/requests.rs index 89de3b060..d79437daf 100644 --- a/generated/stripe_billing/src/tax_id/requests.rs +++ b/generated/stripe_billing/src/tax_id/requests.rs @@ -198,6 +198,15 @@ impl serde::Serialize for ListTaxIdOwnerType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ListTaxIdOwnerType { + fn deserialize>(deserializer: D) -> 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 ListTaxIdOwnerType")) + } +} impl<'a> ListTaxId<'a> { /// Returns a list of tax IDs. pub fn send( @@ -489,6 +498,14 @@ impl serde::Serialize for CreateCustomerTaxIdType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCustomerTaxIdType { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} impl<'a> CreateCustomerTaxId<'a> { /// Creates a new `tax_id` object for a customer. pub fn send( @@ -588,6 +605,15 @@ impl serde::Serialize for CreateTaxIdOwnerType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxIdOwnerType { + fn deserialize>(deserializer: D) -> 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 CreateTaxIdOwnerType")) + } +} /// 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] @@ -830,6 +856,14 @@ impl serde::Serialize for CreateTaxIdType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxIdType { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} impl<'a> CreateTaxId<'a> { /// Creates a new account or customer `tax_id` object. pub fn send(&self, client: &stripe::Client) -> stripe::Response { diff --git a/generated/stripe_billing/src/usage_record/requests.rs b/generated/stripe_billing/src/usage_record/requests.rs index f684d93eb..ca5efe3da 100644 --- a/generated/stripe_billing/src/usage_record/requests.rs +++ b/generated/stripe_billing/src/usage_record/requests.rs @@ -72,6 +72,16 @@ impl serde::Serialize for CreateSubscriptionItemUsageRecordAction { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSubscriptionItemUsageRecordAction { + fn deserialize>(deserializer: D) -> 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 CreateSubscriptionItemUsageRecordAction") + }) + } +} /// The timestamp for the usage event. /// This timestamp must be within the current billing period of the subscription of the provided `subscription_item`, and must not be in the future. /// When passing `"now"`, Stripe records usage for the current time. diff --git a/generated/stripe_billing/src/usage_record/types.rs b/generated/stripe_billing/src/usage_record/types.rs index 92c7a9fae..c2dd5ab45 100644 --- a/generated/stripe_billing/src/usage_record/types.rs +++ b/generated/stripe_billing/src/usage_record/types.rs @@ -4,12 +4,16 @@ /// Related guide: [Metered billing](https://stripe.com/docs/billing/subscriptions/metered-billing) /// /// For more details see <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct UsageRecord { /// Unique identifier for the object. pub id: stripe_billing::UsageRecordId, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: UsageRecordObject, /// The usage quantity for the specified date. pub quantity: u64, /// The ID of the subscription item this usage record contains data for. @@ -17,6 +21,189 @@ pub struct UsageRecord { /// The timestamp when this usage occurred. pub timestamp: stripe_types::Timestamp, } +#[doc(hidden)] +pub struct UsageRecordBuilder { + id: Option, + livemode: Option, + object: Option, + quantity: Option, + subscription_item: Option, + timestamp: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: UsageRecordBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "quantity" => Deserialize::begin(&mut self.quantity), + "subscription_item" => Deserialize::begin(&mut self.subscription_item), + "timestamp" => Deserialize::begin(&mut self.timestamp), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + id: Deserialize::default(), + livemode: Deserialize::default(), + object: Deserialize::default(), + quantity: Deserialize::default(), + subscription_item: Deserialize::default(), + timestamp: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + quantity: self.quantity?, + subscription_item: self.subscription_item.take()?, + timestamp: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum UsageRecordObject { + UsageRecord, +} +impl UsageRecordObject { + pub fn as_str(self) -> &'static str { + use UsageRecordObject::*; + match self { + UsageRecord => "usage_record", + } + } +} + +impl std::str::FromStr for UsageRecordObject { + type Err = (); + fn from_str(s: &str) -> Result { + use UsageRecordObject::*; + match s { + "usage_record" => Ok(UsageRecord), + _ => Err(()), + } + } +} +impl std::fmt::Display for UsageRecordObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for UsageRecordObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for UsageRecordObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for UsageRecordObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(UsageRecordObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(UsageRecordObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UsageRecordObject { + fn deserialize>(deserializer: D) -> 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 UsageRecordObject")) + } +} impl stripe_types::Object for UsageRecord { type Id = stripe_billing::UsageRecordId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_checkout/Cargo.toml b/generated/stripe_checkout/Cargo.toml index 11ffe804b..489c65c44 100644 --- a/generated/stripe_checkout/Cargo.toml +++ b/generated/stripe_checkout/Cargo.toml @@ -16,8 +16,9 @@ path = "src/mod.rs" [dependencies] serde.workspace = true -smol_str.workspace = true serde_json.workspace = true +smol_str.workspace = true +miniserde.workspace = true stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +serde = ["stripe_types/serde","stripe_shared/serde"] 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..971c7d4bb 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutAcssDebitMandateOptions { /// A URL for custom mandate text - #[serde(skip_serializing_if = "Option::is_none")] pub custom_mandate_url: Option, /// 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>, /// Description of the interval. /// Only required if the 'payment_schedule' parameter is 'interval' or 'combined'. @@ -15,6 +15,120 @@ pub struct CheckoutAcssDebitMandateOptions { /// Transaction type of the mandate. pub transaction_type: Option, } +#[doc(hidden)] +pub struct CheckoutAcssDebitMandateOptionsBuilder { + custom_mandate_url: Option>, + default_for: Option>>, + interval_description: Option>, + payment_schedule: Option>, + transaction_type: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutAcssDebitMandateOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + custom_mandate_url: self.custom_mandate_url.take()?, + default_for: self.default_for.take()?, + interval_description: self.interval_description.take()?, + payment_schedule: self.payment_schedule?, + transaction_type: self.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 { + 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)] @@ -54,6 +168,7 @@ impl std::fmt::Debug for CheckoutAcssDebitMandateOptionsDefaultFor { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutAcssDebitMandateOptionsDefaultFor { fn serialize(&self, serializer: S) -> Result where @@ -62,6 +177,24 @@ impl serde::Serialize for CheckoutAcssDebitMandateOptionsDefaultFor { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutAcssDebitMandateOptionsDefaultFor { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutAcssDebitMandateOptionsDefaultFor::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitMandateOptionsDefaultFor); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitMandateOptionsDefaultFor { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -112,6 +245,7 @@ impl std::fmt::Debug for CheckoutAcssDebitMandateOptionsPaymentSchedule { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutAcssDebitMandateOptionsPaymentSchedule { fn serialize(&self, serializer: S) -> Result where @@ -120,6 +254,25 @@ impl serde::Serialize for CheckoutAcssDebitMandateOptionsPaymentSchedule { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutAcssDebitMandateOptionsPaymentSchedule { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutAcssDebitMandateOptionsPaymentSchedule::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitMandateOptionsPaymentSchedule); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitMandateOptionsPaymentSchedule { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -169,6 +322,7 @@ impl std::fmt::Debug for CheckoutAcssDebitMandateOptionsTransactionType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutAcssDebitMandateOptionsTransactionType { fn serialize(&self, serializer: S) -> Result where @@ -177,6 +331,25 @@ impl serde::Serialize for CheckoutAcssDebitMandateOptionsTransactionType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutAcssDebitMandateOptionsTransactionType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutAcssDebitMandateOptionsTransactionType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitMandateOptionsTransactionType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitMandateOptionsTransactionType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..d6cfc891a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, - #[serde(skip_serializing_if = "Option::is_none")] pub mandate_options: Option, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -11,12 +11,119 @@ 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, /// Bank account verification method. - #[serde(skip_serializing_if = "Option::is_none")] pub verification_method: Option, } +#[doc(hidden)] +pub struct CheckoutAcssDebitPaymentMethodOptionsBuilder { + currency: Option>, + mandate_options: Option>, + setup_future_usage: Option>, + verification_method: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutAcssDebitPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + currency: self.currency?, + mandate_options: self.mandate_options.take()?, + setup_future_usage: self.setup_future_usage?, + verification_method: self.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 { + 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 { @@ -55,6 +162,7 @@ impl std::fmt::Debug for CheckoutAcssDebitPaymentMethodOptionsCurrency { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutAcssDebitPaymentMethodOptionsCurrency { fn serialize(&self, serializer: S) -> Result where @@ -63,6 +171,25 @@ impl serde::Serialize for CheckoutAcssDebitPaymentMethodOptionsCurrency { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutAcssDebitPaymentMethodOptionsCurrency { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutAcssDebitPaymentMethodOptionsCurrency::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitPaymentMethodOptionsCurrency); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitPaymentMethodOptionsCurrency { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -120,6 +247,7 @@ impl std::fmt::Debug for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -128,6 +256,27 @@ impl serde::Serialize for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -180,6 +329,7 @@ impl std::fmt::Debug for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod { fn serialize(&self, serializer: S) -> Result where @@ -188,6 +338,27 @@ impl serde::Serialize for CheckoutAcssDebitPaymentMethodOptionsVerificationMetho serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutAcssDebitPaymentMethodOptionsVerificationMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutAcssDebitPaymentMethodOptionsVerificationMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutAcssDebitPaymentMethodOptionsVerificationMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..d133ee4a8 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutAffirmPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct CheckoutAffirmPaymentMethodOptionsBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutAffirmPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for CheckoutAffirmPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutAffirmPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,25 @@ impl serde::Serialize for CheckoutAffirmPaymentMethodOptionsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutAffirmPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutAffirmPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutAffirmPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutAffirmPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..5ca7f1194 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutAfterpayClearpayPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,97 @@ 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, } +#[doc(hidden)] +pub struct CheckoutAfterpayClearpayPaymentMethodOptionsBuilder { + setup_future_usage: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutAfterpayClearpayPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +139,7 @@ impl std::fmt::Debug for CheckoutAfterpayClearpayPaymentMethodOptionsSetupFuture f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +148,29 @@ impl serde::Serialize for CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutur serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutAfterpayClearpayPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..5cb009626 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutAlipayPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct CheckoutAlipayPaymentMethodOptionsBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutAlipayPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for CheckoutAlipayPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutAlipayPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,25 @@ impl serde::Serialize for CheckoutAlipayPaymentMethodOptionsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutAlipayPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutAlipayPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutAlipayPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutAlipayPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..533e42b8c 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutAuBecsDebitPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct CheckoutAuBecsDebitPaymentMethodOptionsBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutAuBecsDebitPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,27 @@ impl serde::Serialize for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsag serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutAuBecsDebitPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..0f4a68e81 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutBacsDebitPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct CheckoutBacsDebitPaymentMethodOptionsBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutBacsDebitPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -55,6 +144,7 @@ impl std::fmt::Debug for CheckoutBacsDebitPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutBacsDebitPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -63,6 +153,27 @@ impl serde::Serialize for CheckoutBacsDebitPaymentMethodOptionsSetupFutureUsage serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutBacsDebitPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutBacsDebitPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutBacsDebitPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutBacsDebitPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..5e9a635fa 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutBancontactPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct CheckoutBancontactPaymentMethodOptionsBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutBancontactPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for CheckoutBancontactPaymentMethodOptionsSetupFutureUsage f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutBancontactPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,27 @@ impl serde::Serialize for CheckoutBancontactPaymentMethodOptionsSetupFutureUsage serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutBancontactPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutBancontactPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutBancontactPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutBancontactPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..b6828ff1e 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,107 @@ 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, } +#[doc(hidden)] +pub struct CheckoutBoletoPaymentMethodOptionsBuilder { + expires_after_days: Option, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutBoletoPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + expires_after_days: Deserialize::default(), + setup_future_usage: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + expires_after_days: self.expires_after_days?, + setup_future_usage: self.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 { + 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. @@ -58,6 +158,7 @@ impl std::fmt::Debug for CheckoutBoletoPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutBoletoPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -66,6 +167,25 @@ impl serde::Serialize for CheckoutBoletoPaymentMethodOptionsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutBoletoPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutBoletoPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutBoletoPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutBoletoPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_checkout/src/checkout_card_installments_options.rs b/generated/stripe_checkout/src/checkout_card_installments_options.rs index 369b58057..b1e10bd1b 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutCardInstallmentsOptions { /// Indicates if installments are enabled - #[serde(skip_serializing_if = "Option::is_none")] pub enabled: Option, } +#[doc(hidden)] +pub struct CheckoutCardInstallmentsOptionsBuilder { + enabled: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutCardInstallmentsOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.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 { + 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..2f8a06cf2 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutCardPaymentMethodOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub installments: Option, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -8,21 +9,133 @@ 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, /// 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, /// 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, } +#[doc(hidden)] +pub struct CheckoutCardPaymentMethodOptionsBuilder { + installments: Option>, + setup_future_usage: Option>, + statement_descriptor_suffix_kana: Option>, + statement_descriptor_suffix_kanji: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutCardPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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) + } + + _ => ::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 { + Some(Self::Out { + installments: self.installments?, + setup_future_usage: self.setup_future_usage?, + statement_descriptor_suffix_kana: self.statement_descriptor_suffix_kana.take()?, + statement_descriptor_suffix_kanji: self.statement_descriptor_suffix_kanji.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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. @@ -69,6 +182,7 @@ impl std::fmt::Debug for CheckoutCardPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutCardPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -77,6 +191,25 @@ impl serde::Serialize for CheckoutCardPaymentMethodOptionsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutCardPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutCardPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutCardPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutCardPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..0996499cd 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutCashappPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct CheckoutCashappPaymentMethodOptionsBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutCashappPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for CheckoutCashappPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutCashappPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,25 @@ impl serde::Serialize for CheckoutCashappPaymentMethodOptionsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutCashappPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutCashappPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutCashappPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutCashappPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..e31dcaed2 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,125 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutCustomerBalanceBankTransferPaymentMethodOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub eu_bank_transfer: Option, /// 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>, /// 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(feature = "serde", serde(rename = "type"))] pub type_: Option, } +#[doc(hidden)] +pub struct CheckoutCustomerBalanceBankTransferPaymentMethodOptionsBuilder { + eu_bank_transfer: + Option>, + requested_address_types: Option< + Option>, + >, + type_: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutCustomerBalanceBankTransferPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + eu_bank_transfer: self.eu_bank_transfer?, + requested_address_types: self.requested_address_types.take()?, + type_: self.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 { + 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. /// @@ -75,6 +182,7 @@ impl std::fmt::Debug f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes { @@ -85,6 +193,33 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes::from_str( + s, + ) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsRequestedAddressTypes { @@ -141,6 +276,7 @@ impl std::fmt::Debug for CheckoutCustomerBalanceBankTransferPaymentMethodOptions f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsType { fn serialize(&self, serializer: S) -> Result where @@ -149,6 +285,29 @@ impl serde::Serialize for CheckoutCustomerBalanceBankTransferPaymentMethodOption serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutCustomerBalanceBankTransferPaymentMethodOptionsType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + CheckoutCustomerBalanceBankTransferPaymentMethodOptionsType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutCustomerBalanceBankTransferPaymentMethodOptionsType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..eab42f167 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,6 +1,7 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutCustomerBalancePaymentMethodOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_transfer: Option, /// The funding method type to be used when there are not enough funds in the customer balance. @@ -12,9 +13,111 @@ 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, } +#[doc(hidden)] +pub struct CheckoutCustomerBalancePaymentMethodOptionsBuilder { + bank_transfer: + Option>, + funding_type: Option>, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutCustomerBalancePaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank_transfer: self.bank_transfer.take()?, + funding_type: self.funding_type?, + setup_future_usage: self.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 { + 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)] @@ -51,6 +154,7 @@ impl std::fmt::Debug for CheckoutCustomerBalancePaymentMethodOptionsFundingType f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutCustomerBalancePaymentMethodOptionsFundingType { fn serialize(&self, serializer: S) -> Result where @@ -59,6 +163,27 @@ impl serde::Serialize for CheckoutCustomerBalancePaymentMethodOptionsFundingType serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutCustomerBalancePaymentMethodOptionsFundingType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutCustomerBalancePaymentMethodOptionsFundingType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutCustomerBalancePaymentMethodOptionsFundingType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutCustomerBalancePaymentMethodOptionsFundingType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -110,6 +235,7 @@ impl std::fmt::Debug for CheckoutCustomerBalancePaymentMethodOptionsSetupFutureU f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutCustomerBalancePaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -118,6 +244,29 @@ impl serde::Serialize for CheckoutCustomerBalancePaymentMethodOptionsSetupFuture serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutCustomerBalancePaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutCustomerBalancePaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + CheckoutCustomerBalancePaymentMethodOptionsSetupFutureUsage +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutCustomerBalancePaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..5ee09a69d 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutEpsPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct CheckoutEpsPaymentMethodOptionsBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutEpsPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for CheckoutEpsPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutEpsPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,25 @@ impl serde::Serialize for CheckoutEpsPaymentMethodOptionsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutEpsPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutEpsPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutEpsPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutEpsPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..bfdf989f9 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutFpxPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct CheckoutFpxPaymentMethodOptionsBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutFpxPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for CheckoutFpxPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutFpxPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,25 @@ impl serde::Serialize for CheckoutFpxPaymentMethodOptionsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutFpxPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutFpxPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutFpxPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutFpxPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..265ef0119 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutGiropayPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct CheckoutGiropayPaymentMethodOptionsBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutGiropayPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for CheckoutGiropayPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutGiropayPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,25 @@ impl serde::Serialize for CheckoutGiropayPaymentMethodOptionsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutGiropayPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutGiropayPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutGiropayPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutGiropayPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..a67220ae4 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutGrabPayPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct CheckoutGrabPayPaymentMethodOptionsBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutGrabPayPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for CheckoutGrabPayPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutGrabPayPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,25 @@ impl serde::Serialize for CheckoutGrabPayPaymentMethodOptionsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutGrabPayPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutGrabPayPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutGrabPayPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutGrabPayPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..a180a0ca7 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutIdealPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct CheckoutIdealPaymentMethodOptionsBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutIdealPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for CheckoutIdealPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutIdealPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,25 @@ impl serde::Serialize for CheckoutIdealPaymentMethodOptionsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutIdealPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutIdealPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutIdealPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutIdealPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..9b32d39fb 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutKlarnaPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct CheckoutKlarnaPaymentMethodOptionsBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutKlarnaPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -55,6 +144,7 @@ impl std::fmt::Debug for CheckoutKlarnaPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutKlarnaPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -63,6 +153,25 @@ impl serde::Serialize for CheckoutKlarnaPaymentMethodOptionsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutKlarnaPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutKlarnaPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutKlarnaPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutKlarnaPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..5b0b597ee 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,107 @@ 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, } +#[doc(hidden)] +pub struct CheckoutKonbiniPaymentMethodOptionsBuilder { + expires_after_days: Option>, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutKonbiniPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + expires_after_days: Deserialize::default(), + setup_future_usage: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + expires_after_days: self.expires_after_days?, + setup_future_usage: self.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 { + 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. @@ -52,6 +152,7 @@ impl std::fmt::Debug for CheckoutKonbiniPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutKonbiniPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -60,6 +161,25 @@ impl serde::Serialize for CheckoutKonbiniPaymentMethodOptionsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutKonbiniPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutKonbiniPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutKonbiniPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutKonbiniPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..4d66ab627 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutLinkPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct CheckoutLinkPaymentMethodOptionsBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutLinkPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -52,6 +141,7 @@ impl std::fmt::Debug for CheckoutLinkPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutLinkPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -60,6 +150,25 @@ impl serde::Serialize for CheckoutLinkPaymentMethodOptionsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutLinkPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutLinkPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutLinkPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutLinkPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..d8a2f5649 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,107 @@ 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, } +#[doc(hidden)] +pub struct CheckoutOxxoPaymentMethodOptionsBuilder { + expires_after_days: Option, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutOxxoPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + expires_after_days: Deserialize::default(), + setup_future_usage: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + expires_after_days: self.expires_after_days?, + setup_future_usage: self.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 { + 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. @@ -52,6 +152,7 @@ impl std::fmt::Debug for CheckoutOxxoPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutOxxoPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -60,6 +161,25 @@ impl serde::Serialize for CheckoutOxxoPaymentMethodOptionsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutOxxoPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutOxxoPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutOxxoPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutOxxoPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..2fc2e4b56 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutP24PaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct CheckoutP24PaymentMethodOptionsBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutP24PaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for CheckoutP24PaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutP24PaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,25 @@ impl serde::Serialize for CheckoutP24PaymentMethodOptionsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutP24PaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutP24PaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutP24PaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutP24PaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..6953f8af5 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutPaynowPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct CheckoutPaynowPaymentMethodOptionsBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutPaynowPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for CheckoutPaynowPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutPaynowPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,25 @@ impl serde::Serialize for CheckoutPaynowPaymentMethodOptionsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutPaynowPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutPaynowPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutPaynowPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutPaynowPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..b017ab948 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// Preferred locale of the PayPal checkout page that the customer is redirected to. pub preferred_locale: Option, @@ -14,9 +15,115 @@ 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, } +#[doc(hidden)] +pub struct CheckoutPaypalPaymentMethodOptionsBuilder { + capture_method: Option>, + preferred_locale: Option>, + reference: Option>, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutPaypalPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + capture_method: self.capture_method?, + preferred_locale: self.preferred_locale.take()?, + reference: self.reference.take()?, + setup_future_usage: self.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 { + 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 { @@ -52,6 +159,7 @@ impl std::fmt::Debug for CheckoutPaypalPaymentMethodOptionsCaptureMethod { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutPaypalPaymentMethodOptionsCaptureMethod { fn serialize(&self, serializer: S) -> Result where @@ -60,6 +168,25 @@ impl serde::Serialize for CheckoutPaypalPaymentMethodOptionsCaptureMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutPaypalPaymentMethodOptionsCaptureMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutPaypalPaymentMethodOptionsCaptureMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutPaypalPaymentMethodOptionsCaptureMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutPaypalPaymentMethodOptionsCaptureMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -114,6 +241,7 @@ impl std::fmt::Debug for CheckoutPaypalPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutPaypalPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -122,6 +250,25 @@ impl serde::Serialize for CheckoutPaypalPaymentMethodOptionsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutPaypalPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutPaypalPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutPaypalPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutPaypalPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..a8264a83c 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,95 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutPixPaymentMethodOptions { /// The number of seconds after which Pix payment will expire. pub expires_after_seconds: Option, } +#[doc(hidden)] +pub struct CheckoutPixPaymentMethodOptionsBuilder { + expires_after_seconds: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutPixPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { expires_after_seconds: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { expires_after_seconds: self.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 { + 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..7c11c667d 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutRevolutPayPaymentMethodOptions {} +#[doc(hidden)] +pub struct CheckoutRevolutPayPaymentMethodOptionsBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutRevolutPayPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..6c2cdc8ee 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutSepaDebitPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct CheckoutSepaDebitPaymentMethodOptionsBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutSepaDebitPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -55,6 +144,7 @@ impl std::fmt::Debug for CheckoutSepaDebitPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutSepaDebitPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -63,6 +153,27 @@ impl serde::Serialize for CheckoutSepaDebitPaymentMethodOptionsSetupFutureUsage serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutSepaDebitPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutSepaDebitPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutSepaDebitPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutSepaDebitPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_checkout/src/checkout_session/requests.rs b/generated/stripe_checkout/src/checkout_session/requests.rs index d7bcb4a45..ac49e4501 100644 --- a/generated/stripe_checkout/src/checkout_session/requests.rs +++ b/generated/stripe_checkout/src/checkout_session/requests.rs @@ -440,6 +440,18 @@ impl serde::Serialize for CreateCheckoutSessionAutomaticTaxLiabilityType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionAutomaticTaxLiabilityType { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionAutomaticTaxLiabilityType", + ) + }) + } +} /// Configure fields for the Checkout Session to gather active consent from customers. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionConsentCollection { @@ -536,6 +548,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition")) + } +} /// 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 @@ -585,6 +607,18 @@ impl serde::Serialize for CreateCheckoutSessionConsentCollectionPromotions { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionConsentCollectionPromotions { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionConsentCollectionPromotions", + ) + }) + } +} /// If set to `required`, it requires customers to check a terms of service checkbox before being able to pay. /// There must be a valid terms of service URL set in your [Dashboard settings](https://dashboard.stripe.com/settings/public). #[derive(Copy, Clone, Eq, PartialEq)] @@ -632,6 +666,18 @@ impl serde::Serialize for CreateCheckoutSessionConsentCollectionTermsOfService { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionConsentCollectionTermsOfService { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionConsentCollectionTermsOfService", + ) + }) + } +} /// Collect additional information from your customer using custom fields. /// Up to 3 fields are supported. #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -749,6 +795,16 @@ impl serde::Serialize for CreateCheckoutSessionCustomFieldsLabelType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionCustomFieldsLabelType { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionCustomFieldsLabelType") + }) + } +} /// Configuration for `type=numeric` fields. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionCustomFieldsNumeric { @@ -828,6 +884,16 @@ impl serde::Serialize for CreateCheckoutSessionCustomFieldsType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionCustomFieldsType { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionCustomFieldsType") + }) + } +} /// Display additional text for your customers using custom text. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionCustomText<'a> { @@ -904,6 +970,16 @@ impl serde::Serialize for CreateCheckoutSessionCustomerCreation { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionCustomerCreation { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionCustomerCreation") + }) + } +} /// Controls what fields on Customer can be updated by the Checkout Session. /// Can only be provided when `customer` is provided. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -972,6 +1048,16 @@ impl serde::Serialize for CreateCheckoutSessionCustomerUpdateAddress { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionCustomerUpdateAddress { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionCustomerUpdateAddress") + }) + } +} /// Describes whether Checkout saves the name onto `customer.name`. Defaults to `never`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateCheckoutSessionCustomerUpdateName { @@ -1018,6 +1104,16 @@ impl serde::Serialize for CreateCheckoutSessionCustomerUpdateName { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionCustomerUpdateName { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionCustomerUpdateName") + }) + } +} /// Describes whether Checkout saves shipping information onto `customer.shipping`. /// To collect shipping information, use `shipping_address_collection`. Defaults to `never`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -1065,6 +1161,18 @@ impl serde::Serialize for CreateCheckoutSessionCustomerUpdateShipping { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionCustomerUpdateShipping { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionCustomerUpdateShipping", + ) + }) + } +} /// The coupon or promotion code to apply to this Session. Currently, only up to one may be specified. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionDiscounts<'a> { @@ -1204,6 +1312,18 @@ impl serde::Serialize for CreateCheckoutSessionInvoiceCreationInvoiceDataIssuerT serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionInvoiceCreationInvoiceDataIssuerType { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionInvoiceCreationInvoiceDataIssuerType", + ) + }) + } +} /// Default options for invoice PDF rendering for this customer. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionInvoiceCreationInvoiceDataRenderingOptions { @@ -1277,6 +1397,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay")) + } +} /// A list of items the customer is purchasing. /// Use this parameter to pass one-time or recurring [Prices](https://stripe.com/docs/api/prices). /// @@ -1475,6 +1605,18 @@ impl serde::Serialize for CreateCheckoutSessionLineItemsPriceDataRecurringInterv serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionLineItemsPriceDataRecurringInterval { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionLineItemsPriceDataRecurringInterval", + ) + }) + } +} /// 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`. @@ -1527,6 +1669,18 @@ impl serde::Serialize for CreateCheckoutSessionLineItemsPriceDataTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionLineItemsPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionLineItemsPriceDataTaxBehavior", + ) + }) + } +} /// A subset of parameters to be passed to PaymentIntent creation for Checkout Sessions in `payment` mode. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentIntentData<'a> { @@ -1653,6 +1807,18 @@ impl serde::Serialize for CreateCheckoutSessionPaymentIntentDataCaptureMethod { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionPaymentIntentDataCaptureMethod { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentIntentDataCaptureMethod", + ) + }) + } +} /// Indicates that you intend to [make future payments](https://stripe.com/docs/payments/payment-intents#future-usage) with the payment. /// method collected by this Checkout Session. /// @@ -1718,6 +1884,18 @@ impl serde::Serialize for CreateCheckoutSessionPaymentIntentDataSetupFutureUsage serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionPaymentIntentDataSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentIntentDataSetupFutureUsage", + ) + }) + } +} /// Shipping information for this payment. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateCheckoutSessionPaymentIntentDataShipping<'a> { @@ -1840,6 +2018,18 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodCollection { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionPaymentMethodCollection { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodCollection", + ) + }) + } +} /// Payment-method-specific configuration. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptions<'a> { @@ -2018,6 +2208,18 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsAcssDebitCurr serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionPaymentMethodOptionsAcssDebitCurrency { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsAcssDebitCurrency", + ) + }) + } +} /// Additional fields for Mandate creation #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptions<'a> { @@ -2104,6 +2306,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor")) + } +} /// Payment schedule for the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { @@ -2161,6 +2373,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule")) + } +} /// Transaction type of the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { @@ -2215,6 +2437,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsTransactionType +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsAcssDebitMandateOptionsTransactionType")) + } +} /// 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. @@ -2269,6 +2501,16 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsAcssDebitSetu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsAcssDebitSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsAcssDebitSetupFutureUsage")) + } +} /// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateCheckoutSessionPaymentMethodOptionsAcssDebitVerificationMethod { @@ -2318,6 +2560,16 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsAcssDebitVeri serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsAcssDebitVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsAcssDebitVerificationMethod")) + } +} /// contains details about the Affirm payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsAffirm { @@ -2383,6 +2635,20 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsAffirmSetupFu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsAffirmSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsAffirmSetupFutureUsage", + ) + }) + } +} /// contains details about the Afterpay Clearpay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsAfterpayClearpay { @@ -2455,6 +2721,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsAfterpayClearpaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsAfterpayClearpaySetupFutureUsage")) + } +} /// contains details about the Alipay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsAlipay { @@ -2520,6 +2796,20 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsAlipaySetupFu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsAlipaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsAlipaySetupFutureUsage", + ) + }) + } +} /// contains details about the AU Becs Debit payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsAuBecsDebit { @@ -2586,6 +2876,16 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsAuBecsDebitSe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsAuBecsDebitSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsAuBecsDebitSetupFutureUsage")) + } +} /// contains details about the Bacs Debit payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsBacsDebit { @@ -2658,6 +2958,16 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsBacsDebitSetu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsBacsDebitSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsBacsDebitSetupFutureUsage")) + } +} /// contains details about the Bancontact payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsBancontact { @@ -2724,6 +3034,16 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsBancontactSet serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsBancontactSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsBancontactSetupFutureUsage")) + } +} /// contains details about the Boleto payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsBoleto { @@ -2799,6 +3119,20 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsBoletoSetupFu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsBoletoSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsBoletoSetupFutureUsage", + ) + }) + } +} /// contains details about the Card payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsCard<'a> { @@ -2895,6 +3229,20 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsCardSetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsCardSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsCardSetupFutureUsage", + ) + }) + } +} /// contains details about the Cashapp Pay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsCashapp { @@ -2967,6 +3315,16 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsCashappSetupF serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsCashappSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsCashappSetupFutureUsage")) + } +} /// contains details about the Customer Balance payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsCustomerBalance<'a> { @@ -3101,6 +3459,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes")) + } +} /// The list of bank transfer types that this PaymentIntent is allowed to use for funding. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferType { @@ -3160,6 +3528,16 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsCustomerBalan serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferType +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceBankTransferType")) + } +} /// 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)] @@ -3204,6 +3582,16 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsCustomerBalan serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceFundingType +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceFundingType")) + } +} /// 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. @@ -3256,6 +3644,16 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsCustomerBalan serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsCustomerBalanceSetupFutureUsage")) + } +} /// contains details about the EPS payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsEps { @@ -3321,6 +3719,18 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsEpsSetupFutur serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionPaymentMethodOptionsEpsSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsEpsSetupFutureUsage", + ) + }) + } +} /// contains details about the FPX payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsFpx { @@ -3386,6 +3796,18 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsFpxSetupFutur serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionPaymentMethodOptionsFpxSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsFpxSetupFutureUsage", + ) + }) + } +} /// contains details about the Giropay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsGiropay { @@ -3452,6 +3874,16 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsGiropaySetupF serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsGiropaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsGiropaySetupFutureUsage")) + } +} /// contains details about the Grabpay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsGrabpay { @@ -3518,6 +3950,16 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsGrabpaySetupF serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsGrabpaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsGrabpaySetupFutureUsage")) + } +} /// contains details about the Ideal payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsIdeal { @@ -3583,6 +4025,20 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsIdealSetupFut serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsIdealSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsIdealSetupFutureUsage", + ) + }) + } +} /// contains details about the Klarna payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsKlarna { @@ -3648,6 +4104,20 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsKlarnaSetupFu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsKlarnaSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsKlarnaSetupFutureUsage", + ) + }) + } +} /// contains details about the Konbini payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsKonbini { @@ -3719,6 +4189,16 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsKonbiniSetupF serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsKonbiniSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsKonbiniSetupFutureUsage")) + } +} /// contains details about the Link payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsLink { @@ -3787,6 +4267,20 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsLinkSetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsLinkSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsLinkSetupFutureUsage", + ) + }) + } +} /// contains details about the OXXO payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsOxxo { @@ -3856,6 +4350,20 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsOxxoSetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsOxxoSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsOxxoSetupFutureUsage", + ) + }) + } +} /// contains details about the P24 payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsP24 { @@ -3924,6 +4432,18 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsP24SetupFutur serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionPaymentMethodOptionsP24SetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsP24SetupFutureUsage", + ) + }) + } +} /// contains details about the PayNow payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsPaynow { @@ -3989,6 +4509,20 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsPaynowSetupFu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsPaynowSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsPaynowSetupFutureUsage", + ) + }) + } +} /// contains details about the PayPal payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsPaypal<'a> { @@ -4064,6 +4598,18 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsPaypalCapture serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionPaymentMethodOptionsPaypalCaptureMethod { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsPaypalCaptureMethod", + ) + }) + } +} /// [Preferred locale](https://stripe.com/docs/payments/paypal/supported-locales) of the PayPal checkout page that the customer is redirected to. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -4171,6 +4717,16 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsPaypalPreferr serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsPaypalPreferredLocale +{ + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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. @@ -4224,6 +4780,20 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsPaypalSetupFu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsPaypalSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsPaypalSetupFutureUsage", + ) + }) + } +} /// contains details about the Pix payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsPix { @@ -4306,6 +4876,16 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsRevolutPaySet serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsRevolutPaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsRevolutPaySetupFutureUsage")) + } +} /// contains details about the Sepa Debit payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsSepaDebit { @@ -4378,6 +4958,16 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsSepaDebitSetu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsSepaDebitSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsSepaDebitSetupFutureUsage")) + } +} /// contains details about the Sofort payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsSofort { @@ -4443,6 +5033,20 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsSofortSetupFu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsSofortSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsSofortSetupFutureUsage", + ) + }) + } +} /// contains details about the Swish payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsSwish<'a> { @@ -4562,6 +5166,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions")) + } +} /// List of data features that you would like to retrieve upon account creation. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { @@ -4616,6 +5230,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch")) + } +} /// 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. @@ -4670,6 +5294,16 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsUsBankAccount serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsUsBankAccountSetupFutureUsage")) + } +} /// Verification method for the intent #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateCheckoutSessionPaymentMethodOptionsUsBankAccountVerificationMethod { @@ -4720,6 +5354,16 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsUsBankAccount serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsUsBankAccountVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsUsBankAccountVerificationMethod")) + } +} /// contains details about the WeChat Pay payment method options. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateCheckoutSessionPaymentMethodOptionsWechatPay<'a> { @@ -4792,6 +5436,18 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsWechatPayClie serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionPaymentMethodOptionsWechatPayClient { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsWechatPayClient", + ) + }) + } +} /// 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. @@ -4840,6 +5496,16 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodOptionsWechatPaySetu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionPaymentMethodOptionsWechatPaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionPaymentMethodOptionsWechatPaySetupFutureUsage")) + } +} /// A list of the types of payment methods (e.g., `card`) this Checkout Session can accept. /// /// You can omit this attribute to manage your payment methods from the [Stripe Dashboard](https://dashboard.stripe.com/settings/payment_methods). @@ -4993,6 +5659,14 @@ impl serde::Serialize for CreateCheckoutSessionPaymentMethodTypes { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionPaymentMethodTypes { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Controls phone number collection settings for the session. /// /// We recommend that you review your privacy policy and check with your legal contacts @@ -5801,6 +6475,16 @@ impl serde::Serialize for CreateCheckoutSessionShippingAddressCollectionAllowedC serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionShippingAddressCollectionAllowedCountries +{ + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// The shipping rate options to apply to this Session. Up to a maximum of 5. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionShippingOptions<'a> { @@ -5959,6 +6643,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMaximumUnit +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMaximumUnit")) + } +} /// The lower bound of the estimated range. If empty, represents no lower bound. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMinimum { @@ -6038,6 +6732,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMinimumUnit +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionShippingOptionsShippingRateDataDeliveryEstimateMinimumUnit")) + } +} /// Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmount<'a> { @@ -6137,6 +6841,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmountCurrencyOptionsTaxBehavior +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionShippingOptionsShippingRateDataFixedAmountCurrencyOptionsTaxBehavior")) + } +} /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. /// One of `inclusive`, `exclusive`, or `unspecified`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -6187,6 +6901,20 @@ impl serde::Serialize for CreateCheckoutSessionShippingOptionsShippingRateDataTa serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionShippingOptionsShippingRateDataTaxBehavior +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionShippingOptionsShippingRateDataTaxBehavior", + ) + }) + } +} /// The type of calculation to use on the shipping rate. Can only be `fixed_amount` for now. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateCheckoutSessionShippingOptionsShippingRateDataType { @@ -6230,6 +6958,18 @@ impl serde::Serialize for CreateCheckoutSessionShippingOptionsShippingRateDataTy serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionShippingOptionsShippingRateDataType { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionShippingOptionsShippingRateDataType", + ) + }) + } +} /// A subset of parameters to be passed to subscription creation for Checkout Sessions in `subscription` mode. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCheckoutSessionSubscriptionData<'a> { @@ -6364,6 +7104,20 @@ impl serde::Serialize for CreateCheckoutSessionSubscriptionDataInvoiceSettingsIs serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionSubscriptionDataInvoiceSettingsIssuerType +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionSubscriptionDataInvoiceSettingsIssuerType", + ) + }) + } +} /// 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)] @@ -6411,6 +7165,18 @@ impl serde::Serialize for CreateCheckoutSessionSubscriptionDataProrationBehavior serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCheckoutSessionSubscriptionDataProrationBehavior { + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionSubscriptionDataProrationBehavior", + ) + }) + } +} /// If specified, the funds from the subscription's invoices will be transferred to the destination and the ID of the resulting transfers will be found on the resulting charges. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateCheckoutSessionSubscriptionDataTransferData<'a> { @@ -6511,6 +7277,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod +{ + fn deserialize>(deserializer: D) -> 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 CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod")) + } +} /// Controls tax ID collection settings for the session. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateCheckoutSessionTaxIdCollection { diff --git a/generated/stripe_checkout/src/checkout_session/types.rs b/generated/stripe_checkout/src/checkout_session/types.rs index c3a08e6f4..a1fba0026 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutSession { /// When set, provides configuration for actions to take if this Checkout Session expires. pub after_expiration: Option, @@ -77,7 +79,6 @@ pub struct CheckoutSession { /// Details on the state of invoice creation for the Checkout Session. pub invoice_creation: Option, /// The line items purchased by the customer. - #[serde(skip_serializing_if = "Option::is_none")] pub line_items: Option>, /// 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, @@ -89,6 +90,8 @@ pub struct CheckoutSession { pub metadata: Option>, /// The mode of the Checkout Session. pub mode: stripe_checkout::CheckoutSessionMode, + /// String representing the object's type. Objects of the same type share the same value. + pub object: CheckoutSessionObject, /// The ID of the PaymentIntent for Checkout Sessions in `payment` mode. pub payment_intent: Option>, /// The ID of the Payment Link that created this Session. @@ -106,7 +109,6 @@ 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, /// The ID of the original expired Checkout Session that triggered the recovery flow. @@ -114,11 +116,9 @@ pub struct CheckoutSession { /// 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, /// 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, /// The ID of the SetupIntent for Checkout Sessions in `setup` mode. pub setup_intent: Option>, @@ -142,7 +142,6 @@ pub struct CheckoutSession { /// The URL the customer will be directed to after the payment or /// subscription creation is successful. pub success_url: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub tax_id_collection: Option, /// Tax and discount details for the computed total amount. pub total_details: Option, @@ -155,6 +154,401 @@ pub struct CheckoutSession { /// This value is only present when the session is active. pub url: Option, } +#[doc(hidden)] +pub struct CheckoutSessionBuilder { + after_expiration: Option>, + allow_promotion_codes: Option>, + amount_subtotal: Option>, + amount_total: Option>, + automatic_tax: Option, + billing_address_collection: + Option>, + cancel_url: Option>, + client_reference_id: Option>, + client_secret: Option>, + consent: Option>, + consent_collection: + Option>, + created: Option, + currency: Option>, + currency_conversion: + Option>, + custom_fields: Option>, + custom_text: Option, + customer: Option>>, + customer_creation: Option>, + customer_details: Option>, + customer_email: Option>, + expires_at: Option, + id: Option, + invoice: Option>>, + invoice_creation: Option>, + line_items: Option>>, + livemode: Option, + locale: Option>, + metadata: Option>>, + mode: Option, + object: Option, + payment_intent: Option>>, + payment_link: Option>>, + payment_method_collection: Option>, + payment_method_configuration_details: + Option>, + payment_method_options: Option>, + payment_method_types: Option>, + payment_status: Option, + phone_number_collection: + Option>, + recovered_from: Option>, + redirect_on_completion: Option>, + return_url: Option>, + setup_intent: Option>>, + shipping_address_collection: + Option>, + shipping_cost: Option>, + shipping_details: Option>, + shipping_options: Option>, + status: Option>, + submit_type: Option>, + subscription: Option>>, + success_url: Option>, + tax_id_collection: Option>, + total_details: Option>, + ui_mode: Option>, + url: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutSessionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + after_expiration: self.after_expiration.take()?, + allow_promotion_codes: self.allow_promotion_codes?, + amount_subtotal: self.amount_subtotal?, + amount_total: self.amount_total?, + automatic_tax: self.automatic_tax.take()?, + billing_address_collection: self.billing_address_collection?, + cancel_url: self.cancel_url.take()?, + client_reference_id: self.client_reference_id.take()?, + client_secret: self.client_secret.take()?, + consent: self.consent?, + consent_collection: self.consent_collection?, + created: self.created?, + currency: self.currency?, + currency_conversion: self.currency_conversion.take()?, + custom_fields: self.custom_fields.take()?, + custom_text: self.custom_text.take()?, + customer: self.customer.take()?, + customer_creation: self.customer_creation?, + customer_details: self.customer_details.take()?, + customer_email: self.customer_email.take()?, + expires_at: self.expires_at?, + id: self.id.take()?, + invoice: self.invoice.take()?, + invoice_creation: self.invoice_creation.take()?, + line_items: self.line_items.take()?, + livemode: self.livemode?, + locale: self.locale?, + metadata: self.metadata.take()?, + mode: self.mode?, + object: self.object?, + payment_intent: self.payment_intent.take()?, + payment_link: self.payment_link.take()?, + payment_method_collection: self.payment_method_collection?, + payment_method_configuration_details: self + .payment_method_configuration_details + .take()?, + payment_method_options: self.payment_method_options.take()?, + payment_method_types: self.payment_method_types.take()?, + payment_status: self.payment_status?, + phone_number_collection: self.phone_number_collection?, + recovered_from: self.recovered_from.take()?, + redirect_on_completion: self.redirect_on_completion?, + return_url: self.return_url.take()?, + setup_intent: self.setup_intent.take()?, + shipping_address_collection: self.shipping_address_collection.take()?, + shipping_cost: self.shipping_cost.take()?, + shipping_details: self.shipping_details.take()?, + shipping_options: self.shipping_options.take()?, + status: self.status?, + submit_type: self.submit_type?, + subscription: self.subscription.take()?, + success_url: self.success_url.take()?, + tax_id_collection: self.tax_id_collection?, + total_details: self.total_details.take()?, + ui_mode: self.ui_mode?, + url: self.url.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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 { @@ -193,6 +587,7 @@ impl std::fmt::Debug for CheckoutSessionCustomerCreation { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutSessionCustomerCreation { fn serialize(&self, serializer: S) -> Result where @@ -201,6 +596,23 @@ impl serde::Serialize for CheckoutSessionCustomerCreation { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutSessionCustomerCreation { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(CheckoutSessionCustomerCreation::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutSessionCustomerCreation); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutSessionCustomerCreation { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -210,6 +622,74 @@ impl<'de> serde::Deserialize<'de> for CheckoutSessionCustomerCreation { }) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum CheckoutSessionObject { + CheckoutSession, +} +impl CheckoutSessionObject { + pub fn as_str(self) -> &'static str { + use CheckoutSessionObject::*; + match self { + CheckoutSession => "checkout.session", + } + } +} + +impl std::str::FromStr for CheckoutSessionObject { + type Err = (); + fn from_str(s: &str) -> Result { + use CheckoutSessionObject::*; + match s { + "checkout.session" => Ok(CheckoutSession), + _ => Err(()), + } + } +} +impl std::fmt::Display for CheckoutSessionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for CheckoutSessionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for CheckoutSessionObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for CheckoutSessionObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSessionObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutSessionObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CheckoutSessionObject { + fn deserialize>(deserializer: D) -> 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 CheckoutSessionObject")) + } +} /// Configure whether a Checkout Session should collect a payment method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CheckoutSessionPaymentMethodCollection { @@ -248,6 +728,7 @@ impl std::fmt::Debug for CheckoutSessionPaymentMethodCollection { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutSessionPaymentMethodCollection { fn serialize(&self, serializer: S) -> Result where @@ -256,6 +737,24 @@ impl serde::Serialize for CheckoutSessionPaymentMethodCollection { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutSessionPaymentMethodCollection { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutSessionPaymentMethodCollection::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutSessionPaymentMethodCollection); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutSessionPaymentMethodCollection { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -307,6 +806,7 @@ impl std::fmt::Debug for CheckoutSessionPaymentStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutSessionPaymentStatus { fn serialize(&self, serializer: S) -> Result where @@ -315,6 +815,22 @@ impl serde::Serialize for CheckoutSessionPaymentStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutSessionPaymentStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSessionPaymentStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutSessionPaymentStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutSessionPaymentStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -375,6 +891,24 @@ impl serde::Serialize for CheckoutSessionBillingAddressCollection { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutSessionBillingAddressCollection { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutSessionBillingAddressCollection::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutSessionBillingAddressCollection); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutSessionBillingAddressCollection { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -550,11 +1084,28 @@ impl serde::Serialize for CheckoutSessionLocale { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutSessionLocale { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(CheckoutSessionLocale::from_str(s).unwrap_or(CheckoutSessionLocale::Unknown)); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutSessionLocale); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutSessionLocale { fn deserialize>(deserializer: D) -> Result { 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)) } } #[derive(Copy, Clone, Eq, PartialEq)] @@ -605,6 +1156,22 @@ impl serde::Serialize for CheckoutSessionMode { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutSessionMode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSessionMode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutSessionMode); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutSessionMode { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -661,6 +1228,23 @@ impl serde::Serialize for CheckoutSessionRedirectOnCompletion { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutSessionRedirectOnCompletion { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(CheckoutSessionRedirectOnCompletion::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutSessionRedirectOnCompletion); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutSessionRedirectOnCompletion { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -718,6 +1302,22 @@ impl serde::Serialize for CheckoutSessionStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutSessionStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSessionStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutSessionStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutSessionStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -777,6 +1377,22 @@ impl serde::Serialize for CheckoutSessionSubmitType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutSessionSubmitType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSessionSubmitType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutSessionSubmitType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutSessionSubmitType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -830,6 +1446,22 @@ impl serde::Serialize for CheckoutSessionUiMode { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutSessionUiMode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSessionUiMode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutSessionUiMode); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutSessionUiMode { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..37740b76b 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,265 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutSessionPaymentMethodOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub affirm: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub afterpay_clearpay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub alipay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bancontact: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cashapp: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub customer_balance: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub fpx: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub giropay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub grabpay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub konbini: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub oxxo: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub paynow: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub paypal: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pix: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub revolut_pay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub swish: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option, } +#[doc(hidden)] +pub struct CheckoutSessionPaymentMethodOptionsBuilder { + acss_debit: Option>, + affirm: Option>, + afterpay_clearpay: + Option>, + alipay: Option>, + au_becs_debit: Option>, + bacs_debit: Option>, + bancontact: Option>, + boleto: Option>, + card: Option>, + cashapp: Option>, + customer_balance: Option>, + eps: Option>, + fpx: Option>, + giropay: Option>, + grabpay: Option>, + ideal: Option>, + klarna: Option>, + konbini: Option>, + link: Option>, + oxxo: Option>, + p24: Option>, + paynow: Option>, + paypal: Option>, + pix: Option>, + revolut_pay: Option>, + sepa_debit: Option>, + sofort: Option>, + swish: Option>, + us_bank_account: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutSessionPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "swish" => Deserialize::begin(&mut self.swish), + "us_bank_account" => Deserialize::begin(&mut self.us_bank_account), + + _ => ::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(), + swish: Deserialize::default(), + us_bank_account: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + acss_debit: self.acss_debit.take()?, + affirm: self.affirm?, + afterpay_clearpay: self.afterpay_clearpay?, + alipay: self.alipay?, + au_becs_debit: self.au_becs_debit?, + bacs_debit: self.bacs_debit?, + bancontact: self.bancontact?, + boleto: self.boleto?, + card: self.card.take()?, + cashapp: self.cashapp?, + customer_balance: self.customer_balance.take()?, + eps: self.eps?, + fpx: self.fpx?, + giropay: self.giropay?, + grabpay: self.grabpay?, + ideal: self.ideal?, + klarna: self.klarna?, + konbini: self.konbini?, + link: self.link?, + oxxo: self.oxxo?, + p24: self.p24?, + paynow: self.paynow?, + paypal: self.paypal.take()?, + pix: self.pix?, + revolut_pay: self.revolut_pay?, + sepa_debit: self.sepa_debit?, + sofort: self.sofort?, + swish: self.swish.take()?, + us_bank_account: self.us_bank_account.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "swish" => b.swish = 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..a9d2539af 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutSofortPaymentMethodOptions { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct CheckoutSofortPaymentMethodOptionsBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutSofortPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for CheckoutSofortPaymentMethodOptionsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutSofortPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,25 @@ impl serde::Serialize for CheckoutSofortPaymentMethodOptionsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutSofortPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutSofortPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutSofortPaymentMethodOptionsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutSofortPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_checkout/src/checkout_swish_payment_method_options.rs b/generated/stripe_checkout/src/checkout_swish_payment_method_options.rs index 8e5b54650..45f3d4abb 100644 --- a/generated/stripe_checkout/src/checkout_swish_payment_method_options.rs +++ b/generated/stripe_checkout/src/checkout_swish_payment_method_options.rs @@ -1,6 +1,94 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct CheckoutSwishPaymentMethodOptionsBuilder { + reference: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CheckoutSwishPaymentMethodOptions { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutSwishPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: CheckoutSwishPaymentMethodOptionsBuilder::deser_default(), + })) + } + } + + impl MapBuilder for CheckoutSwishPaymentMethodOptionsBuilder { + type Out = CheckoutSwishPaymentMethodOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "reference" => Deserialize::begin(&mut self.reference), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { reference: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { reference: self.reference.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CheckoutSwishPaymentMethodOptions { + type Builder = CheckoutSwishPaymentMethodOptionsBuilder; + } + + impl FromValueOpt for CheckoutSwishPaymentMethodOptions { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CheckoutSwishPaymentMethodOptionsBuilder::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_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..44ad0e1dd 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutUsBankAccountPaymentMethodOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub financial_connections: Option, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -8,12 +9,117 @@ 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, /// Bank account verification method. - #[serde(skip_serializing_if = "Option::is_none")] pub verification_method: Option, } +#[doc(hidden)] +pub struct CheckoutUsBankAccountPaymentMethodOptionsBuilder { + financial_connections: Option>, + setup_future_usage: Option>, + verification_method: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutUsBankAccountPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + financial_connections: self.financial_connections.take()?, + setup_future_usage: self.setup_future_usage?, + verification_method: self.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 { + 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. @@ -60,6 +166,7 @@ impl std::fmt::Debug for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsa f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -68,6 +175,29 @@ impl serde::Serialize for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUs serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutUsBankAccountPaymentMethodOptionsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -117,6 +247,7 @@ impl std::fmt::Debug for CheckoutUsBankAccountPaymentMethodOptionsVerificationMe f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod { fn serialize(&self, serializer: S) -> Result where @@ -125,6 +256,29 @@ impl serde::Serialize for CheckoutUsBankAccountPaymentMethodOptionsVerificationM serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CheckoutUsBankAccountPaymentMethodOptionsVerificationMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_checkout/src/mod.rs b/generated/stripe_checkout/src/mod.rs index 4c6859829..45b211fb4 100644 --- a/generated/stripe_checkout/src/mod.rs +++ b/generated/stripe_checkout/src/mod.rs @@ -7,6 +7,8 @@ //! centered around [Checkout Sessions](https://stripe.com/docs/api/checkout/sessions). extern crate self as stripe_checkout; + +miniserde::make_place!(Place); pub use checkout_session::types::*; #[doc(hidden)] pub mod checkout_acss_debit_mandate_options; 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..0d83b5808 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionAfterExpiration { /// When set, configuration used to recover the Checkout Session on expiry. pub recovery: Option, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionAfterExpirationBuilder { + recovery: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionAfterExpirationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { recovery: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { recovery: self.recovery.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..d9964a456 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionAfterExpirationRecovery { /// Enables user redeemable promotion codes on the recovered Checkout Sessions. Defaults to `false` pub allow_promotion_codes: bool, @@ -11,3 +13,110 @@ pub struct PaymentPagesCheckoutSessionAfterExpirationRecovery { /// URL that creates a new Checkout Session when clicked that is a copy of this expired Checkout Session. pub url: Option, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionAfterExpirationRecoveryBuilder { + allow_promotion_codes: Option, + enabled: Option, + expires_at: Option>, + url: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionAfterExpirationRecoveryBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + allow_promotion_codes: self.allow_promotion_codes?, + enabled: self.enabled?, + expires_at: self.expires_at?, + url: self.url.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..9491b2bfe 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,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionAutomaticTax { /// Indicates whether automatic tax is enabled for the session pub enabled: bool, @@ -9,6 +11,106 @@ pub struct PaymentPagesCheckoutSessionAutomaticTax { /// The status of the most recent automated tax calculation for this session. pub status: Option, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionAutomaticTaxBuilder { + enabled: Option, + liability: Option>, + status: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionAutomaticTaxBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "liability" => Deserialize::begin(&mut self.liability), + "status" => Deserialize::begin(&mut self.status), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + enabled: Deserialize::default(), + liability: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + enabled: self.enabled?, + liability: self.liability.take()?, + status: self.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 { + 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)?), + "liability" => b.liability = 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 { @@ -50,6 +152,7 @@ impl std::fmt::Debug for PaymentPagesCheckoutSessionAutomaticTaxStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentPagesCheckoutSessionAutomaticTaxStatus { fn serialize(&self, serializer: S) -> Result where @@ -58,6 +161,25 @@ impl serde::Serialize for PaymentPagesCheckoutSessionAutomaticTaxStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentPagesCheckoutSessionAutomaticTaxStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentPagesCheckoutSessionAutomaticTaxStatus::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentPagesCheckoutSessionAutomaticTaxStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionAutomaticTaxStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..5b800b095 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionConsent { /// If `opt_in`, the customer consents to receiving promotional communications /// from the merchant about this Checkout Session. @@ -6,6 +8,98 @@ 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, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionConsentBuilder { + promotions: Option>, + terms_of_service: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionConsentBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { promotions: Deserialize::default(), terms_of_service: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + promotions: self.promotions?, + terms_of_service: self.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 { + 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)] @@ -45,6 +139,7 @@ impl std::fmt::Debug for PaymentPagesCheckoutSessionConsentPromotions { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentPagesCheckoutSessionConsentPromotions { fn serialize(&self, serializer: S) -> Result where @@ -53,6 +148,25 @@ impl serde::Serialize for PaymentPagesCheckoutSessionConsentPromotions { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentPagesCheckoutSessionConsentPromotions { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentPagesCheckoutSessionConsentPromotions::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentPagesCheckoutSessionConsentPromotions); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionConsentPromotions { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -99,6 +213,7 @@ impl std::fmt::Debug for PaymentPagesCheckoutSessionConsentTermsOfService { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentPagesCheckoutSessionConsentTermsOfService { fn serialize(&self, serializer: S) -> Result where @@ -107,6 +222,25 @@ impl serde::Serialize for PaymentPagesCheckoutSessionConsentTermsOfService { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentPagesCheckoutSessionConsentTermsOfService { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentPagesCheckoutSessionConsentTermsOfService::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentPagesCheckoutSessionConsentTermsOfService); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionConsentTermsOfService { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..a35bba458 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,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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: @@ -11,6 +13,111 @@ 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, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionConsentCollectionBuilder { + payment_method_reuse_agreement: + Option>, + promotions: Option>, + terms_of_service: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionConsentCollectionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + "payment_method_reuse_agreement" => { + Deserialize::begin(&mut self.payment_method_reuse_agreement) + } + "promotions" => Deserialize::begin(&mut self.promotions), + "terms_of_service" => Deserialize::begin(&mut self.terms_of_service), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + payment_method_reuse_agreement: Deserialize::default(), + promotions: Deserialize::default(), + terms_of_service: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + payment_method_reuse_agreement: self.payment_method_reuse_agreement?, + promotions: self.promotions?, + terms_of_service: self.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 { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionConsentCollectionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "payment_method_reuse_agreement" => { + b.payment_method_reuse_agreement = Some(FromValueOpt::from_value(v)?) + } + "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 @@ -52,6 +159,7 @@ impl std::fmt::Debug for PaymentPagesCheckoutSessionConsentCollectionPromotions f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentPagesCheckoutSessionConsentCollectionPromotions { fn serialize(&self, serializer: S) -> Result where @@ -60,6 +168,27 @@ impl serde::Serialize for PaymentPagesCheckoutSessionConsentCollectionPromotions serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentPagesCheckoutSessionConsentCollectionPromotions { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentPagesCheckoutSessionConsentCollectionPromotions::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentPagesCheckoutSessionConsentCollectionPromotions); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionConsentCollectionPromotions { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -109,6 +238,7 @@ impl std::fmt::Debug for PaymentPagesCheckoutSessionConsentCollectionTermsOfServ f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentPagesCheckoutSessionConsentCollectionTermsOfService { fn serialize(&self, serializer: S) -> Result where @@ -117,6 +247,29 @@ impl serde::Serialize for PaymentPagesCheckoutSessionConsentCollectionTermsOfSer serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentPagesCheckoutSessionConsentCollectionTermsOfService { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentPagesCheckoutSessionConsentCollectionTermsOfService::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentPagesCheckoutSessionConsentCollectionTermsOfService +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionConsentCollectionTermsOfService { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..420510dfd 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionCurrencyConversion { /// Total of all items in source currency before discounts or taxes are applied. pub amount_subtotal: i64, @@ -9,3 +11,108 @@ pub struct PaymentPagesCheckoutSessionCurrencyConversion { /// Creation currency of the CheckoutSession before localization pub source_currency: stripe_types::Currency, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionCurrencyConversionBuilder { + amount_subtotal: Option, + amount_total: Option, + fx_rate: Option, + source_currency: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionCurrencyConversionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount_subtotal: self.amount_subtotal?, + amount_total: self.amount_total?, + fx_rate: self.fx_rate.take()?, + source_currency: self.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 { + 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..4f5f57997 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,141 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionCustomFields { - #[serde(skip_serializing_if = "Option::is_none")] pub dropdown: Option, /// 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, /// 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, /// The type of the field. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: PaymentPagesCheckoutSessionCustomFieldsType, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionCustomFieldsBuilder { + dropdown: Option>, + key: Option, + label: Option, + numeric: Option>, + optional: Option, + text: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionCustomFieldsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + dropdown: self.dropdown.take()?, + key: self.key.take()?, + label: self.label.take()?, + numeric: self.numeric.take()?, + optional: self.optional?, + text: self.text.take()?, + type_: self.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 { + 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 { @@ -58,6 +177,7 @@ impl std::fmt::Debug for PaymentPagesCheckoutSessionCustomFieldsType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentPagesCheckoutSessionCustomFieldsType { fn serialize(&self, serializer: S) -> Result where @@ -66,6 +186,25 @@ impl serde::Serialize for PaymentPagesCheckoutSessionCustomFieldsType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentPagesCheckoutSessionCustomFieldsType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentPagesCheckoutSessionCustomFieldsType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentPagesCheckoutSessionCustomFieldsType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionCustomFieldsType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..84e0b396b 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,98 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionCustomFieldsDropdown { /// The options available for the customer to select. Up to 200 options allowed. pub options: Vec, /// The option selected by the customer. This will be the `value` for the option. pub value: Option, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionCustomFieldsDropdownBuilder { + options: Option>, + value: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionCustomFieldsDropdownBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { options: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { options: self.options.take()?, value: self.value.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..ff5ee6df5 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,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionCustomFieldsLabel { /// Custom text for the label, displayed to the customer. Up to 50 characters. pub custom: Option, /// The type of the label. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: PaymentPagesCheckoutSessionCustomFieldsLabelType, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionCustomFieldsLabelBuilder { + custom: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionCustomFieldsLabelBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { custom: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { custom: self.custom.take()?, type_: self.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 { + 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 { @@ -41,6 +132,7 @@ impl std::fmt::Debug for PaymentPagesCheckoutSessionCustomFieldsLabelType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentPagesCheckoutSessionCustomFieldsLabelType { fn serialize(&self, serializer: S) -> Result where @@ -49,6 +141,25 @@ impl serde::Serialize for PaymentPagesCheckoutSessionCustomFieldsLabelType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentPagesCheckoutSessionCustomFieldsLabelType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentPagesCheckoutSessionCustomFieldsLabelType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentPagesCheckoutSessionCustomFieldsLabelType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionCustomFieldsLabelType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..de57ebfa5 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionCustomFieldsNumeric { /// The maximum character length constraint for the customer's input. pub maximum_length: Option, @@ -7,3 +9,103 @@ pub struct PaymentPagesCheckoutSessionCustomFieldsNumeric { /// The value entered by the customer, containing only digits. pub value: Option, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionCustomFieldsNumericBuilder { + maximum_length: Option>, + minimum_length: Option>, + value: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionCustomFieldsNumericBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + maximum_length: Deserialize::default(), + minimum_length: Deserialize::default(), + value: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + maximum_length: self.maximum_length?, + minimum_length: self.minimum_length?, + value: self.value.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..c7ceec0b9 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionCustomFieldsOption { /// The label for the option, displayed to the customer. Up to 100 characters. pub label: String, @@ -6,3 +8,92 @@ pub struct PaymentPagesCheckoutSessionCustomFieldsOption { /// Must be unique to this option, alphanumeric, and up to 100 characters. pub value: String, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionCustomFieldsOptionBuilder { + label: Option, + value: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionCustomFieldsOptionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { label: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { label: self.label.take()?, value: self.value.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..4a0047c14 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionCustomFieldsText { /// The maximum character length constraint for the customer's input. pub maximum_length: Option, @@ -7,3 +9,103 @@ pub struct PaymentPagesCheckoutSessionCustomFieldsText { /// The value entered by the customer. pub value: Option, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionCustomFieldsTextBuilder { + maximum_length: Option>, + minimum_length: Option>, + value: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionCustomFieldsTextBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + maximum_length: Deserialize::default(), + minimum_length: Deserialize::default(), + value: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + maximum_length: self.maximum_length?, + minimum_length: self.minimum_length?, + value: self.value.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..93e738d4e 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,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionCustomText { /// Custom text that should be displayed after the payment confirmation button. pub after_submit: Option, @@ -10,3 +12,114 @@ pub struct PaymentPagesCheckoutSessionCustomText { pub terms_of_service_acceptance: Option, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionCustomTextBuilder { + after_submit: Option>, + shipping_address: + Option>, + submit: Option>, + terms_of_service_acceptance: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionCustomTextBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + "after_submit" => Deserialize::begin(&mut self.after_submit), + "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) + } + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + after_submit: Deserialize::default(), + shipping_address: Deserialize::default(), + submit: Deserialize::default(), + terms_of_service_acceptance: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + after_submit: self.after_submit.take()?, + shipping_address: self.shipping_address.take()?, + submit: self.submit.take()?, + terms_of_service_acceptance: self.terms_of_service_acceptance.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentPagesCheckoutSessionCustomTextBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "after_submit" => b.after_submit = Some(FromValueOpt::from_value(v)?), + "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..51968e620 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionCustomTextPosition { /// Text may be up to 1200 characters in length. pub message: String, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionCustomTextPositionBuilder { + message: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionCustomTextPositionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { message: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { message: self.message.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..3445c07ab 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,121 @@ pub struct PaymentPagesCheckoutSessionCustomerDetails { /// The customer’s tax IDs after a completed Checkout Session. pub tax_ids: Option>, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionCustomerDetailsBuilder { + address: Option>, + email: Option>, + name: Option>, + phone: Option>, + tax_exempt: Option>, + tax_ids: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionCustomerDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + address: self.address.take()?, + email: self.email.take()?, + name: self.name.take()?, + phone: self.phone.take()?, + tax_exempt: self.tax_exempt?, + tax_ids: self.tax_ids.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -57,6 +174,7 @@ impl std::fmt::Debug for PaymentPagesCheckoutSessionCustomerDetailsTaxExempt { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentPagesCheckoutSessionCustomerDetailsTaxExempt { fn serialize(&self, serializer: S) -> Result where @@ -65,6 +183,25 @@ impl serde::Serialize for PaymentPagesCheckoutSessionCustomerDetailsTaxExempt { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentPagesCheckoutSessionCustomerDetailsTaxExempt { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentPagesCheckoutSessionCustomerDetailsTaxExempt::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentPagesCheckoutSessionCustomerDetailsTaxExempt); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionCustomerDetailsTaxExempt { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..9f9cdfefc 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,97 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionInvoiceCreation { /// Indicates whether invoice creation is enabled for the Checkout Session. pub enabled: bool, pub invoice_data: stripe_checkout::PaymentPagesCheckoutSessionInvoiceSettings, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionInvoiceCreationBuilder { + enabled: Option, + invoice_data: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionInvoiceCreationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default(), invoice_data: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.enabled?, invoice_data: self.invoice_data.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..33e6571ec 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionInvoiceSettings { /// The account tax IDs associated with the invoice. pub account_tax_ids: Option>>, @@ -17,3 +19,123 @@ pub struct PaymentPagesCheckoutSessionInvoiceSettings { /// Options for invoice PDF rendering. pub rendering_options: Option, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionInvoiceSettingsBuilder { + account_tax_ids: Option>>>, + custom_fields: Option>>, + description: Option>, + footer: Option>, + issuer: Option>, + metadata: Option>>, + rendering_options: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionInvoiceSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "issuer" => Deserialize::begin(&mut self.issuer), + "metadata" => Deserialize::begin(&mut self.metadata), + "rendering_options" => Deserialize::begin(&mut self.rendering_options), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_tax_ids: Deserialize::default(), + custom_fields: Deserialize::default(), + description: Deserialize::default(), + footer: Deserialize::default(), + issuer: Deserialize::default(), + metadata: Deserialize::default(), + rendering_options: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account_tax_ids: self.account_tax_ids.take()?, + custom_fields: self.custom_fields.take()?, + description: self.description.take()?, + footer: self.footer.take()?, + issuer: self.issuer.take()?, + metadata: self.metadata.take()?, + rendering_options: self.rendering_options.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "issuer" => b.issuer = 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 index 67c8b855a..5a07f3430 100644 --- 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 @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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. @@ -6,6 +8,94 @@ pub struct PaymentPagesCheckoutSessionPaymentMethodReuseAgreement { /// When set to `hidden`, the payment method reuse agreement text will always be hidden in the UI. pub position: PaymentPagesCheckoutSessionPaymentMethodReuseAgreementPosition, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionPaymentMethodReuseAgreementBuilder { + position: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentPagesCheckoutSessionPaymentMethodReuseAgreement { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionPaymentMethodReuseAgreementBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: + PaymentPagesCheckoutSessionPaymentMethodReuseAgreementBuilder::deser_default(), + })) + } + } + + impl MapBuilder for PaymentPagesCheckoutSessionPaymentMethodReuseAgreementBuilder { + type Out = PaymentPagesCheckoutSessionPaymentMethodReuseAgreement; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "position" => Deserialize::begin(&mut self.position), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { position: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { position: self.position? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentPagesCheckoutSessionPaymentMethodReuseAgreement { + type Builder = PaymentPagesCheckoutSessionPaymentMethodReuseAgreementBuilder; + } + + impl FromValueOpt for PaymentPagesCheckoutSessionPaymentMethodReuseAgreement { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = + PaymentPagesCheckoutSessionPaymentMethodReuseAgreementBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "position" => b.position = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Determines the position and visibility of the payment method reuse agreement in the UI. /// When set to `auto`, Stripe's defaults will be used. /// @@ -47,6 +137,7 @@ impl std::fmt::Debug for PaymentPagesCheckoutSessionPaymentMethodReuseAgreementP f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentPagesCheckoutSessionPaymentMethodReuseAgreementPosition { fn serialize(&self, serializer: S) -> Result where @@ -55,6 +146,29 @@ impl serde::Serialize for PaymentPagesCheckoutSessionPaymentMethodReuseAgreement serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentPagesCheckoutSessionPaymentMethodReuseAgreementPosition { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentPagesCheckoutSessionPaymentMethodReuseAgreementPosition::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentPagesCheckoutSessionPaymentMethodReuseAgreementPosition +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> 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..6a90b28da 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionPhoneNumberCollection { /// Indicates whether phone number collection is enabled for the session pub enabled: bool, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionPhoneNumberCollectionBuilder { + enabled: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionPhoneNumberCollectionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.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 { + 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..67c7be28b 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,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionShippingAddressCollection { /// An array of two-letter ISO country codes representing which countries Checkout should provide as options for. /// shipping locations. @@ -6,6 +8,95 @@ pub struct PaymentPagesCheckoutSessionShippingAddressCollection { pub allowed_countries: Vec, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionShippingAddressCollectionBuilder { + allowed_countries: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionShippingAddressCollectionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { allowed_countries: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { allowed_countries: self.allowed_countries.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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`. @@ -755,6 +846,7 @@ impl std::fmt::Debug for PaymentPagesCheckoutSessionShippingAddressCollectionAll f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentPagesCheckoutSessionShippingAddressCollectionAllowedCountries { fn serialize(&self, serializer: S) -> Result where @@ -763,14 +855,39 @@ impl serde::Serialize for PaymentPagesCheckoutSessionShippingAddressCollectionAl serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for PaymentPagesCheckoutSessionShippingAddressCollectionAllowedCountries +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentPagesCheckoutSessionShippingAddressCollectionAllowedCountries::from_str(s) + .unwrap_or( + PaymentPagesCheckoutSessionShippingAddressCollectionAllowedCountries::Unknown, + ), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentPagesCheckoutSessionShippingAddressCollectionAllowedCountries +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionShippingAddressCollectionAllowedCountries { fn deserialize>(deserializer: D) -> Result { 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)) } } 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..8f12f3cf9 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionShippingCost { /// Total shipping cost before any discounts or taxes are applied. pub amount_subtotal: i64, @@ -9,6 +11,115 @@ pub struct PaymentPagesCheckoutSessionShippingCost { /// The ID of the ShippingRate for this order. pub shipping_rate: Option>, /// The taxes applied to the shipping rate. - #[serde(skip_serializing_if = "Option::is_none")] pub taxes: Option>, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionShippingCostBuilder { + amount_subtotal: Option, + amount_tax: Option, + amount_total: Option, + shipping_rate: Option>>, + taxes: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionShippingCostBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount_subtotal: self.amount_subtotal?, + amount_tax: self.amount_tax?, + amount_total: self.amount_total?, + shipping_rate: self.shipping_rate.take()?, + taxes: self.taxes.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..dfe815c63 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,101 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionShippingOptionBuilder { + shipping_amount: Option, + shipping_rate: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionShippingOptionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { shipping_amount: Deserialize::default(), shipping_rate: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + shipping_amount: self.shipping_amount?, + shipping_rate: self.shipping_rate.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..fa701573e 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,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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(feature = "serde", serde(rename = "type"))] pub type_: PaymentPagesCheckoutSessionTaxIdType, /// The value of the tax ID. pub value: Option, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionTaxIdBuilder { + type_: Option, + value: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionTaxIdBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { type_: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { type_: self.type_?, value: self.value.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -239,6 +330,7 @@ impl std::fmt::Debug for PaymentPagesCheckoutSessionTaxIdType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentPagesCheckoutSessionTaxIdType { fn serialize(&self, serializer: S) -> Result where @@ -247,6 +339,23 @@ impl serde::Serialize for PaymentPagesCheckoutSessionTaxIdType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentPagesCheckoutSessionTaxIdType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(PaymentPagesCheckoutSessionTaxIdType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentPagesCheckoutSessionTaxIdType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentPagesCheckoutSessionTaxIdType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..8ce468a46 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionTaxIdCollection { /// Indicates whether tax ID collection is enabled for the session pub enabled: bool, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionTaxIdCollectionBuilder { + enabled: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionTaxIdCollectionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.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 { + 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..5d6f59707 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionTotalDetails { /// This is the sum of all the discounts. pub amount_discount: i64, @@ -6,7 +8,112 @@ pub struct PaymentPagesCheckoutSessionTotalDetails { pub amount_shipping: Option, /// This is the sum of all the tax amounts. pub amount_tax: i64, - #[serde(skip_serializing_if = "Option::is_none")] pub breakdown: Option, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionTotalDetailsBuilder { + amount_discount: Option, + amount_shipping: Option>, + amount_tax: Option, + breakdown: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionTotalDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount_discount: self.amount_discount?, + amount_shipping: self.amount_shipping?, + amount_tax: self.amount_tax?, + breakdown: self.breakdown.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..1c48967b1 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,100 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentPagesCheckoutSessionTotalDetailsResourceBreakdown { /// The aggregated discounts. pub discounts: Vec, /// The aggregated tax amounts by rate. pub taxes: Vec, } +#[doc(hidden)] +pub struct PaymentPagesCheckoutSessionTotalDetailsResourceBreakdownBuilder { + discounts: Option>, + taxes: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentPagesCheckoutSessionTotalDetailsResourceBreakdownBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { discounts: Deserialize::default(), taxes: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { discounts: self.discounts.take()?, taxes: self.taxes.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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/Cargo.toml b/generated/stripe_connect/Cargo.toml index 095e49cd5..0bdb05ea0 100644 --- a/generated/stripe_connect/Cargo.toml +++ b/generated/stripe_connect/Cargo.toml @@ -16,8 +16,9 @@ path = "src/mod.rs" [dependencies] serde.workspace = true -smol_str.workspace = true serde_json.workspace = true +smol_str.workspace = true +miniserde.workspace = true stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +serde = ["stripe_types/serde","stripe_shared/serde"] 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..484cc9255 100644 --- a/generated/stripe_connect/src/account/requests.rs +++ b/generated/stripe_connect/src/account/requests.rs @@ -527,6 +527,14 @@ impl serde::Serialize for CreateAccountCompanyStructure { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateAccountCompanyStructure { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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. @@ -720,6 +728,16 @@ impl serde::Serialize for CreateAccountIndividualPoliticalExposure { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateAccountIndividualPoliticalExposure { + fn deserialize>(deserializer: D) -> 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 CreateAccountIndividualPoliticalExposure") + }) + } +} /// Options for customizing how the account functions within Stripe. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateAccountSettings<'a> { @@ -867,6 +885,18 @@ impl serde::Serialize for CreateAccountSettingsPayoutsScheduleInterval { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateAccountSettingsPayoutsScheduleInterval { + fn deserialize>(deserializer: D) -> 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 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)] @@ -929,6 +959,18 @@ impl serde::Serialize for CreateAccountSettingsPayoutsScheduleWeeklyAnchor { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateAccountSettingsPayoutsScheduleWeeklyAnchor { + fn deserialize>(deserializer: D) -> 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 CreateAccountSettingsPayoutsScheduleWeeklyAnchor", + ) + }) + } +} 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). @@ -1262,6 +1304,14 @@ impl serde::Serialize for UpdateAccountCompanyStructure { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateAccountCompanyStructure { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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. @@ -1455,6 +1505,16 @@ impl serde::Serialize for UpdateAccountIndividualPoliticalExposure { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateAccountIndividualPoliticalExposure { + fn deserialize>(deserializer: D) -> 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 UpdateAccountIndividualPoliticalExposure") + }) + } +} /// Options for customizing how the account functions within Stripe. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateAccountSettings<'a> { @@ -1618,6 +1678,18 @@ impl serde::Serialize for UpdateAccountSettingsPayoutsScheduleInterval { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateAccountSettingsPayoutsScheduleInterval { + fn deserialize>(deserializer: D) -> 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 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)] @@ -1680,6 +1752,18 @@ impl serde::Serialize for UpdateAccountSettingsPayoutsScheduleWeeklyAnchor { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateAccountSettingsPayoutsScheduleWeeklyAnchor { + fn deserialize>(deserializer: D) -> 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 UpdateAccountSettingsPayoutsScheduleWeeklyAnchor", + ) + }) + } +} 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. diff --git a/generated/stripe_connect/src/account_link/requests.rs b/generated/stripe_connect/src/account_link/requests.rs index 3491c04a2..1a0e6ec27 100644 --- a/generated/stripe_connect/src/account_link/requests.rs +++ b/generated/stripe_connect/src/account_link/requests.rs @@ -83,6 +83,15 @@ impl serde::Serialize for CreateAccountLinkCollect { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateAccountLinkCollect { + fn deserialize>(deserializer: D) -> 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 CreateAccountLinkCollect")) + } +} /// Specifies the requirements that Stripe collects from connected accounts in the Connect Onboarding flow. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateAccountLinkCollectionOptions { @@ -146,6 +155,16 @@ impl serde::Serialize for CreateAccountLinkCollectionOptionsFields { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateAccountLinkCollectionOptionsFields { + fn deserialize>(deserializer: D) -> 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 CreateAccountLinkCollectionOptionsFields") + }) + } +} /// Specifies whether the platform collects future_requirements in addition to requirements in Connect Onboarding. /// The default value is `omit`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -193,6 +212,18 @@ impl serde::Serialize for CreateAccountLinkCollectionOptionsFutureRequirements { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateAccountLinkCollectionOptionsFutureRequirements { + fn deserialize>(deserializer: D) -> 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 CreateAccountLinkCollectionOptionsFutureRequirements", + ) + }) + } +} /// The type of account link the user is requesting. /// Possible values are `account_onboarding` or `account_update`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -240,6 +271,15 @@ impl serde::Serialize for CreateAccountLinkType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateAccountLinkType { + fn deserialize>(deserializer: D) -> 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 CreateAccountLinkType")) + } +} impl<'a> CreateAccountLink<'a> { /// Creates an AccountLink object that includes a single-use Stripe URL that the platform can redirect their user to in order to take them through the Connect Onboarding flow. pub fn send(&self, client: &stripe::Client) -> stripe::Response { diff --git a/generated/stripe_connect/src/account_link/types.rs b/generated/stripe_connect/src/account_link/types.rs index 1ffdeab70..33e7974a7 100644 --- a/generated/stripe_connect/src/account_link/types.rs +++ b/generated/stripe_connect/src/account_link/types.rs @@ -4,12 +4,189 @@ /// Related guide: [Connect Onboarding](https://stripe.com/docs/connect/custom/hosted-onboarding) /// /// For more details see <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct AccountLink { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, /// The timestamp at which this account link will expire. pub expires_at: stripe_types::Timestamp, + /// String representing the object's type. Objects of the same type share the same value. + pub object: AccountLinkObject, /// The URL for the account link. pub url: String, } +#[doc(hidden)] +pub struct AccountLinkBuilder { + created: Option, + expires_at: Option, + object: Option, + url: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountLinkBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "url" => Deserialize::begin(&mut self.url), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + expires_at: Deserialize::default(), + object: Deserialize::default(), + url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + created: self.created?, + expires_at: self.expires_at?, + object: self.object?, + url: self.url.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum AccountLinkObject { + AccountLink, +} +impl AccountLinkObject { + pub fn as_str(self) -> &'static str { + use AccountLinkObject::*; + match self { + AccountLink => "account_link", + } + } +} + +impl std::str::FromStr for AccountLinkObject { + type Err = (); + fn from_str(s: &str) -> Result { + use AccountLinkObject::*; + match s { + "account_link" => Ok(AccountLink), + _ => Err(()), + } + } +} +impl std::fmt::Display for AccountLinkObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for AccountLinkObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for AccountLinkObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for AccountLinkObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(AccountLinkObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(AccountLinkObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for AccountLinkObject { + fn deserialize>(deserializer: D) -> 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 AccountLinkObject")) + } +} diff --git a/generated/stripe_connect/src/account_session/requests.rs b/generated/stripe_connect/src/account_session/requests.rs index 1cee91316..92acb0a06 100644 --- a/generated/stripe_connect/src/account_session/requests.rs +++ b/generated/stripe_connect/src/account_session/requests.rs @@ -1,26 +1,26 @@ -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] pub struct CreateAccountSession<'a> { /// The identifier of the account to create an Account Session for. 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> { +#[derive(Clone, Debug, Default, serde::Serialize)] +pub struct CreateAccountSessionComponents { /// Configuration for the account onboarding embedded component. #[serde(skip_serializing_if = "Option::is_none")] - pub account_onboarding: Option>, + pub account_onboarding: Option, /// Configuration for the payment details embedded component. #[serde(skip_serializing_if = "Option::is_none")] pub payment_details: Option, @@ -31,21 +31,22 @@ pub struct CreateAccountSessionComponents<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub payouts: Option, } -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> { +#[derive(Clone, Debug, serde::Serialize)] +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>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub features: Option, } -impl<'a> CreateAccountSessionComponentsAccountOnboarding<'a> { +impl CreateAccountSessionComponentsAccountOnboarding { 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..0450a66a9 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct AccountSession { /// The ID of the account the AccountSession was created for pub account: String, @@ -25,4 +27,189 @@ pub struct AccountSession { 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: AccountSessionObject, +} +#[doc(hidden)] +pub struct AccountSessionBuilder { + account: Option, + client_secret: Option, + components: Option, + expires_at: Option, + livemode: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountSessionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account: Deserialize::default(), + client_secret: Deserialize::default(), + components: Deserialize::default(), + expires_at: Deserialize::default(), + livemode: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account: self.account.take()?, + client_secret: self.client_secret.take()?, + components: self.components?, + expires_at: self.expires_at?, + livemode: self.livemode?, + object: self.object?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum AccountSessionObject { + AccountSession, +} +impl AccountSessionObject { + pub fn as_str(self) -> &'static str { + use AccountSessionObject::*; + match self { + AccountSession => "account_session", + } + } +} + +impl std::str::FromStr for AccountSessionObject { + type Err = (); + fn from_str(s: &str) -> Result { + use AccountSessionObject::*; + match s { + "account_session" => Ok(AccountSession), + _ => Err(()), + } + } +} +impl std::fmt::Display for AccountSessionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for AccountSessionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for AccountSessionObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for AccountSessionObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(AccountSessionObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(AccountSessionObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for AccountSessionObject { + fn deserialize>(deserializer: D) -> 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 AccountSessionObject")) + } } diff --git a/generated/stripe_connect/src/apps_secret/requests.rs b/generated/stripe_connect/src/apps_secret/requests.rs index b07f8cc58..4a692995b 100644 --- a/generated/stripe_connect/src/apps_secret/requests.rs +++ b/generated/stripe_connect/src/apps_secret/requests.rs @@ -89,6 +89,15 @@ impl serde::Serialize for ListAppsSecretScopeType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ListAppsSecretScopeType { + fn deserialize>(deserializer: D) -> 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 ListAppsSecretScopeType")) + } +} impl<'a> ListAppsSecret<'a> { /// List all secrets stored on the given scope. pub fn send( @@ -180,6 +189,15 @@ impl serde::Serialize for FindAppsSecretScopeType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for FindAppsSecretScopeType { + fn deserialize>(deserializer: D) -> 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 FindAppsSecretScopeType")) + } +} impl<'a> FindAppsSecret<'a> { /// Finds a secret in the secret store by name and scope. pub fn send(&self, client: &stripe::Client) -> stripe::Response { @@ -270,6 +288,15 @@ impl serde::Serialize for CreateAppsSecretScopeType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateAppsSecretScopeType { + fn deserialize>(deserializer: D) -> 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 CreateAppsSecretScopeType")) + } +} impl<'a> CreateAppsSecret<'a> { /// Create or replace a secret in the secret store. pub fn send(&self, client: &stripe::Client) -> stripe::Response { @@ -355,6 +382,16 @@ impl serde::Serialize for DeleteWhereAppsSecretScopeType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeleteWhereAppsSecretScopeType { + fn deserialize>(deserializer: D) -> 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 DeleteWhereAppsSecretScopeType") + }) + } +} impl<'a> DeleteWhereAppsSecret<'a> { /// Deletes a secret from the secret store by name and scope. pub fn send(&self, client: &stripe::Client) -> stripe::Response { diff --git a/generated/stripe_connect/src/apps_secret/types.rs b/generated/stripe_connect/src/apps_secret/types.rs index 968c90e49..78930e565 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// The Unix timestamp for the expiry time of the secret, after which the secret deletes. pub expires_at: Option, @@ -26,10 +27,210 @@ pub struct AppsSecret { pub livemode: bool, /// A name for the secret that's unique within the scope. pub name: String, + /// String representing the object's type. Objects of the same type share the same value. + pub object: AppsSecretObject, /// The plaintext secret value to be stored. pub payload: Option, pub scope: stripe_connect::SecretServiceResourceScope, } +#[doc(hidden)] +pub struct AppsSecretBuilder { + created: Option, + deleted: Option>, + expires_at: Option>, + id: Option, + livemode: Option, + name: Option, + object: Option, + payload: Option>, + scope: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AppsSecretBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "payload" => Deserialize::begin(&mut self.payload), + "scope" => Deserialize::begin(&mut self.scope), + + _ => ::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(), + object: Deserialize::default(), + payload: Deserialize::default(), + scope: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + created: self.created?, + deleted: self.deleted?, + expires_at: self.expires_at?, + id: self.id.take()?, + livemode: self.livemode?, + name: self.name.take()?, + object: self.object?, + payload: self.payload.take()?, + scope: self.scope.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "payload" => b.payload = Some(FromValueOpt::from_value(v)?), + "scope" => b.scope = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum AppsSecretObject { + AppsSecret, +} +impl AppsSecretObject { + pub fn as_str(self) -> &'static str { + use AppsSecretObject::*; + match self { + AppsSecret => "apps.secret", + } + } +} + +impl std::str::FromStr for AppsSecretObject { + type Err = (); + fn from_str(s: &str) -> Result { + use AppsSecretObject::*; + match s { + "apps.secret" => Ok(AppsSecret), + _ => Err(()), + } + } +} +impl std::fmt::Display for AppsSecretObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for AppsSecretObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for AppsSecretObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for AppsSecretObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(AppsSecretObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(AppsSecretObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for AppsSecretObject { + fn deserialize>(deserializer: D) -> 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 AppsSecretObject")) + } +} impl stripe_types::Object for AppsSecret { type Id = stripe_connect::AppsSecretId; fn id(&self) -> &Self::Id { 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..14d938605 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,116 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct ConnectEmbeddedAccountSessionCreateComponentsBuilder { + account_onboarding: Option, + payment_details: Option, + payments: Option, + payouts: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ConnectEmbeddedAccountSessionCreateComponentsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "payment_details" => Deserialize::begin(&mut self.payment_details), + "payments" => Deserialize::begin(&mut self.payments), + "payouts" => Deserialize::begin(&mut self.payouts), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_onboarding: Deserialize::default(), + payment_details: Deserialize::default(), + payments: Deserialize::default(), + payouts: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account_onboarding: self.account_onboarding?, + payment_details: self.payment_details?, + payments: self.payments?, + payouts: self.payouts?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?) + } + "payment_details" => b.payment_details = Some(FromValueOpt::from_value(v)?), + "payments" => b.payments = Some(FromValueOpt::from_value(v)?), + "payouts" => b.payouts = 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..2d032cbc0 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,97 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ConnectEmbeddedBaseConfigClaim { /// Whether the embedded component is enabled. pub enabled: bool, pub features: stripe_connect::ConnectEmbeddedBaseFeatures, } +#[doc(hidden)] +pub struct ConnectEmbeddedBaseConfigClaimBuilder { + enabled: Option, + features: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ConnectEmbeddedBaseConfigClaimBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "features" => Deserialize::begin(&mut self.features), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default(), features: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.enabled?, features: self.features? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "features" => b.features = 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 index ed9dae237..4ea19b6d6 100644 --- a/generated/stripe_connect/src/connect_embedded_base_features.rs +++ b/generated/stripe_connect/src/connect_embedded_base_features.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ConnectEmbeddedBaseFeatures {} +#[doc(hidden)] +pub struct ConnectEmbeddedBaseFeaturesBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ConnectEmbeddedBaseFeatures { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ConnectEmbeddedBaseFeaturesBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: ConnectEmbeddedBaseFeaturesBuilder::deser_default(), + })) + } + } + + impl MapBuilder for ConnectEmbeddedBaseFeaturesBuilder { + type Out = ConnectEmbeddedBaseFeatures; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 ConnectEmbeddedBaseFeatures { + type Builder = ConnectEmbeddedBaseFeaturesBuilder; + } + + impl FromValueOpt for ConnectEmbeddedBaseFeatures { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ConnectEmbeddedBaseFeaturesBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_connect/src/connect_embedded_payments_config.rs b/generated/stripe_connect/src/connect_embedded_payments_config.rs index 9279b697d..68d615798 100644 --- a/generated/stripe_connect/src/connect_embedded_payments_config.rs +++ b/generated/stripe_connect/src/connect_embedded_payments_config.rs @@ -1,6 +1,97 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ConnectEmbeddedPaymentsConfig { /// Whether the embedded component is enabled. pub enabled: bool, pub features: stripe_connect::ConnectEmbeddedPaymentsFeatures, } +#[doc(hidden)] +pub struct ConnectEmbeddedPaymentsConfigBuilder { + enabled: Option, + features: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ConnectEmbeddedPaymentsConfig { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ConnectEmbeddedPaymentsConfigBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: ConnectEmbeddedPaymentsConfigBuilder::deser_default(), + })) + } + } + + impl MapBuilder for ConnectEmbeddedPaymentsConfigBuilder { + type Out = ConnectEmbeddedPaymentsConfig; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + "features" => Deserialize::begin(&mut self.features), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default(), features: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.enabled?, features: self.features? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ConnectEmbeddedPaymentsConfig { + type Builder = ConnectEmbeddedPaymentsConfigBuilder; + } + + impl FromValueOpt for ConnectEmbeddedPaymentsConfig { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ConnectEmbeddedPaymentsConfigBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + "features" => b.features = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_connect/src/connect_embedded_payments_features.rs b/generated/stripe_connect/src/connect_embedded_payments_features.rs index 7f5bc6721..f89b46225 100644 --- a/generated/stripe_connect/src/connect_embedded_payments_features.rs +++ b/generated/stripe_connect/src/connect_embedded_payments_features.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ConnectEmbeddedPaymentsFeatures { /// Whether to allow capturing and cancelling payment intents. This is `true` by default. pub capture_payments: bool, @@ -8,3 +10,105 @@ pub struct ConnectEmbeddedPaymentsFeatures { /// Whether to allow sending refunds. This is `true` by default. pub refund_management: bool, } +#[doc(hidden)] +pub struct ConnectEmbeddedPaymentsFeaturesBuilder { + capture_payments: Option, + dispute_management: Option, + refund_management: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ConnectEmbeddedPaymentsFeatures { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ConnectEmbeddedPaymentsFeaturesBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: ConnectEmbeddedPaymentsFeaturesBuilder::deser_default(), + })) + } + } + + impl MapBuilder for ConnectEmbeddedPaymentsFeaturesBuilder { + type Out = ConnectEmbeddedPaymentsFeatures; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "capture_payments" => Deserialize::begin(&mut self.capture_payments), + "dispute_management" => Deserialize::begin(&mut self.dispute_management), + "refund_management" => Deserialize::begin(&mut self.refund_management), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + capture_payments: Deserialize::default(), + dispute_management: Deserialize::default(), + refund_management: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + capture_payments: self.capture_payments?, + dispute_management: self.dispute_management?, + refund_management: self.refund_management?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ConnectEmbeddedPaymentsFeatures { + type Builder = ConnectEmbeddedPaymentsFeaturesBuilder; + } + + impl FromValueOpt for ConnectEmbeddedPaymentsFeatures { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ConnectEmbeddedPaymentsFeaturesBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "capture_payments" => b.capture_payments = Some(FromValueOpt::from_value(v)?), + "dispute_management" => { + b.dispute_management = Some(FromValueOpt::from_value(v)?) + } + "refund_management" => b.refund_management = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_connect/src/connect_embedded_payouts_config.rs b/generated/stripe_connect/src/connect_embedded_payouts_config.rs index 7d4856264..b500550e2 100644 --- a/generated/stripe_connect/src/connect_embedded_payouts_config.rs +++ b/generated/stripe_connect/src/connect_embedded_payouts_config.rs @@ -1,6 +1,97 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ConnectEmbeddedPayoutsConfig { /// Whether the embedded component is enabled. pub enabled: bool, pub features: stripe_connect::ConnectEmbeddedPayoutsFeatures, } +#[doc(hidden)] +pub struct ConnectEmbeddedPayoutsConfigBuilder { + enabled: Option, + features: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ConnectEmbeddedPayoutsConfig { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ConnectEmbeddedPayoutsConfigBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: ConnectEmbeddedPayoutsConfigBuilder::deser_default(), + })) + } + } + + impl MapBuilder for ConnectEmbeddedPayoutsConfigBuilder { + type Out = ConnectEmbeddedPayoutsConfig; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + "features" => Deserialize::begin(&mut self.features), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default(), features: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.enabled?, features: self.features? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ConnectEmbeddedPayoutsConfig { + type Builder = ConnectEmbeddedPayoutsConfigBuilder; + } + + impl FromValueOpt for ConnectEmbeddedPayoutsConfig { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ConnectEmbeddedPayoutsConfigBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "enabled" => b.enabled = Some(FromValueOpt::from_value(v)?), + "features" => b.features = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_connect/src/connect_embedded_payouts_features.rs b/generated/stripe_connect/src/connect_embedded_payouts_features.rs index 0384aa102..d29f922bf 100644 --- a/generated/stripe_connect/src/connect_embedded_payouts_features.rs +++ b/generated/stripe_connect/src/connect_embedded_payouts_features.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ConnectEmbeddedPayoutsFeatures { /// Whether to allow payout schedule to be changed. /// Default `true` when Stripe owns Loss Liability, default `false` otherwise. @@ -10,3 +12,105 @@ pub struct ConnectEmbeddedPayoutsFeatures { /// Default `true` when Stripe owns Loss Liability, default `false` otherwise. pub standard_payouts: bool, } +#[doc(hidden)] +pub struct ConnectEmbeddedPayoutsFeaturesBuilder { + edit_payout_schedule: Option, + instant_payouts: Option, + standard_payouts: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ConnectEmbeddedPayoutsFeatures { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ConnectEmbeddedPayoutsFeaturesBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: ConnectEmbeddedPayoutsFeaturesBuilder::deser_default(), + })) + } + } + + impl MapBuilder for ConnectEmbeddedPayoutsFeaturesBuilder { + type Out = ConnectEmbeddedPayoutsFeatures; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "edit_payout_schedule" => Deserialize::begin(&mut self.edit_payout_schedule), + "instant_payouts" => Deserialize::begin(&mut self.instant_payouts), + "standard_payouts" => Deserialize::begin(&mut self.standard_payouts), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + edit_payout_schedule: Deserialize::default(), + instant_payouts: Deserialize::default(), + standard_payouts: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + edit_payout_schedule: self.edit_payout_schedule?, + instant_payouts: self.instant_payouts?, + standard_payouts: self.standard_payouts?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ConnectEmbeddedPayoutsFeatures { + type Builder = ConnectEmbeddedPayoutsFeaturesBuilder; + } + + impl FromValueOpt for ConnectEmbeddedPayoutsFeatures { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ConnectEmbeddedPayoutsFeaturesBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "edit_payout_schedule" => { + b.edit_payout_schedule = Some(FromValueOpt::from_value(v)?) + } + "instant_payouts" => b.instant_payouts = Some(FromValueOpt::from_value(v)?), + "standard_payouts" => b.standard_payouts = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_connect/src/country_spec/types.rs b/generated/stripe_connect/src/country_spec/types.rs index fb37dd7fa..6ded2f0b8 100644 --- a/generated/stripe_connect/src/country_spec/types.rs +++ b/generated/stripe_connect/src/country_spec/types.rs @@ -6,12 +6,16 @@ /// guide](/docs/connect/required-verification-information). /// /// For more details see <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CountrySpec { /// The default currency for this country. This applies to both payment methods and bank accounts. pub default_currency: stripe_types::Currency, /// Unique identifier for the object. Represented as the ISO country code for this country. pub id: stripe_connect::CountrySpecId, + /// String representing the object's type. Objects of the same type share the same value. + pub object: CountrySpecObject, /// Currencies that can be accepted in the specific country (for transfers). pub supported_bank_account_currencies: std::collections::HashMap>, /// Currencies that can be accepted in the specified country (for payments). @@ -24,6 +28,217 @@ pub struct CountrySpec { pub supported_transfer_countries: Vec, pub verification_fields: stripe_connect::CountrySpecVerificationFields, } +#[doc(hidden)] +pub struct CountrySpecBuilder { + default_currency: Option, + id: Option, + object: Option, + supported_bank_account_currencies: Option>>, + supported_payment_currencies: Option>, + supported_payment_methods: Option>, + supported_transfer_countries: Option>, + verification_fields: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CountrySpecBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + default_currency: Deserialize::default(), + id: Deserialize::default(), + object: 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 { + Some(Self::Out { + default_currency: self.default_currency?, + id: self.id.take()?, + object: self.object?, + supported_bank_account_currencies: self.supported_bank_account_currencies.take()?, + supported_payment_currencies: self.supported_payment_currencies.take()?, + supported_payment_methods: self.supported_payment_methods.take()?, + supported_transfer_countries: self.supported_transfer_countries.take()?, + verification_fields: self.verification_fields.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum CountrySpecObject { + CountrySpec, +} +impl CountrySpecObject { + pub fn as_str(self) -> &'static str { + use CountrySpecObject::*; + match self { + CountrySpec => "country_spec", + } + } +} + +impl std::str::FromStr for CountrySpecObject { + type Err = (); + fn from_str(s: &str) -> Result { + use CountrySpecObject::*; + match s { + "country_spec" => Ok(CountrySpec), + _ => Err(()), + } + } +} +impl std::fmt::Display for CountrySpecObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for CountrySpecObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for CountrySpecObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for CountrySpecObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CountrySpecObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CountrySpecObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CountrySpecObject { + fn deserialize>(deserializer: D) -> 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 CountrySpecObject")) + } +} 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..175e596bf 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,98 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CountrySpecVerificationFieldDetails { /// Additional fields which are only required for some users. pub additional: Vec, /// Fields which every account must eventually provide. pub minimum: Vec, } +#[doc(hidden)] +pub struct CountrySpecVerificationFieldDetailsBuilder { + additional: Option>, + minimum: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CountrySpecVerificationFieldDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { additional: Deserialize::default(), minimum: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { additional: self.additional.take()?, minimum: self.minimum.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..34baeafe4 100644 --- a/generated/stripe_connect/src/country_spec_verification_fields.rs +++ b/generated/stripe_connect/src/country_spec_verification_fields.rs @@ -1,5 +1,96 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CountrySpecVerificationFields { pub company: stripe_connect::CountrySpecVerificationFieldDetails, pub individual: stripe_connect::CountrySpecVerificationFieldDetails, } +#[doc(hidden)] +pub struct CountrySpecVerificationFieldsBuilder { + company: Option, + individual: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CountrySpecVerificationFieldsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { company: Deserialize::default(), individual: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { company: self.company.take()?, individual: self.individual.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..cc26679e0 100644 --- a/generated/stripe_connect/src/external_account/requests.rs +++ b/generated/stripe_connect/src/external_account/requests.rs @@ -94,6 +94,16 @@ impl serde::Serialize for ListAccountExternalAccountObject { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ListAccountExternalAccountObject { + fn deserialize>(deserializer: D) -> 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 ListAccountExternalAccountObject") + }) + } +} impl<'a> ListAccountExternalAccount<'a> { /// List external accounts for an account. pub fn send( @@ -278,6 +288,16 @@ impl serde::Serialize for UpdateExternalAccountAccountHolderType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateExternalAccountAccountHolderType { + fn deserialize>(deserializer: D) -> 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 UpdateExternalAccountAccountHolderType") + }) + } +} /// The bank account type. /// This can only be `checking` or `savings` in most countries. /// In Japan, this can only be `futsu` or `toza`. @@ -332,6 +352,16 @@ impl serde::Serialize for UpdateExternalAccountAccountType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateExternalAccountAccountType { + fn deserialize>(deserializer: D) -> 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 UpdateExternalAccountAccountType") + }) + } +} /// Documents that may be submitted to satisfy various informational requests. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateExternalAccountDocuments<'a> { diff --git a/generated/stripe_connect/src/login_link/types.rs b/generated/stripe_connect/src/login_link/types.rs index 6ee359ce8..d38b40563 100644 --- a/generated/stripe_connect/src/login_link/types.rs +++ b/generated/stripe_connect/src/login_link/types.rs @@ -1,10 +1,175 @@ /// Login Links are single-use login link for an Express account to access their Stripe dashboard. /// /// For more details see <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct LoginLink { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, + /// String representing the object's type. Objects of the same type share the same value. + pub object: LoginLinkObject, /// The URL for the login link. pub url: String, } +#[doc(hidden)] +pub struct LoginLinkBuilder { + created: Option, + object: Option, + url: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: LoginLinkBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "url" => Deserialize::begin(&mut self.url), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + object: Deserialize::default(), + url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { created: self.created?, object: self.object?, url: self.url.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum LoginLinkObject { + LoginLink, +} +impl LoginLinkObject { + pub fn as_str(self) -> &'static str { + use LoginLinkObject::*; + match self { + LoginLink => "login_link", + } + } +} + +impl std::str::FromStr for LoginLinkObject { + type Err = (); + fn from_str(s: &str) -> Result { + use LoginLinkObject::*; + match s { + "login_link" => Ok(LoginLink), + _ => Err(()), + } + } +} +impl std::fmt::Display for LoginLinkObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for LoginLinkObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for LoginLinkObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for LoginLinkObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(LoginLinkObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(LoginLinkObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for LoginLinkObject { + fn deserialize>(deserializer: D) -> 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 LoginLinkObject")) + } +} diff --git a/generated/stripe_connect/src/mod.rs b/generated/stripe_connect/src/mod.rs index 0a0cc93b8..01685044b 100644 --- a/generated/stripe_connect/src/mod.rs +++ b/generated/stripe_connect/src/mod.rs @@ -7,6 +7,8 @@ //! for requests mentioned in the `Connect` section of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_connect; + +miniserde::make_place!(Place); pub mod account; pub use account_link::types::*; pub use stripe_shared::account::*; diff --git a/generated/stripe_connect/src/secret_service_resource_scope.rs b/generated/stripe_connect/src/secret_service_resource_scope.rs index 406d9c7de..41b13e8fb 100644 --- a/generated/stripe_connect/src/secret_service_resource_scope.rs +++ b/generated/stripe_connect/src/secret_service_resource_scope.rs @@ -1,12 +1,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SecretServiceResourceScope { /// The secret scope type. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", 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, } +#[doc(hidden)] +pub struct SecretServiceResourceScopeBuilder { + type_: Option, + user: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SecretServiceResourceScopeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { type_: Deserialize::default(), user: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { type_: self.type_?, user: self.user.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -45,6 +135,7 @@ impl std::fmt::Debug for SecretServiceResourceScopeType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SecretServiceResourceScopeType { fn serialize(&self, serializer: S) -> Result where @@ -53,6 +144,22 @@ impl serde::Serialize for SecretServiceResourceScopeType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SecretServiceResourceScopeType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SecretServiceResourceScopeType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SecretServiceResourceScopeType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SecretServiceResourceScopeType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_connect/src/topup/requests.rs b/generated/stripe_connect/src/topup/requests.rs index 03f9763fc..f87b3adbc 100644 --- a/generated/stripe_connect/src/topup/requests.rs +++ b/generated/stripe_connect/src/topup/requests.rs @@ -87,6 +87,15 @@ impl serde::Serialize for ListTopupStatus { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ListTopupStatus { + fn deserialize>(deserializer: D) -> 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 ListTopupStatus")) + } +} impl<'a> ListTopup<'a> { /// Returns a list of top-ups. pub fn send( diff --git a/generated/stripe_connect/src/transfer/requests.rs b/generated/stripe_connect/src/transfer/requests.rs index 876c3fb8c..eadd323ff 100644 --- a/generated/stripe_connect/src/transfer/requests.rs +++ b/generated/stripe_connect/src/transfer/requests.rs @@ -169,6 +169,15 @@ impl serde::Serialize for CreateTransferSourceType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTransferSourceType { + fn deserialize>(deserializer: D) -> 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 CreateTransferSourceType")) + } +} impl<'a> CreateTransfer<'a> { /// To send funds from your Stripe account to a connected account, you create a new transfer object. /// Your [Stripe balance](https://stripe.com/docs/api#balance) must be able to cover the transfer amount, or you’ll receive an “Insufficient Funds” error. diff --git a/generated/stripe_core/Cargo.toml b/generated/stripe_core/Cargo.toml index 0a810ddff..7f98c3d58 100644 --- a/generated/stripe_core/Cargo.toml +++ b/generated/stripe_core/Cargo.toml @@ -16,8 +16,9 @@ path = "src/mod.rs" [dependencies] serde.workspace = true -smol_str.workspace = true serde_json.workspace = true +smol_str.workspace = true +miniserde.workspace = true stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +serde = ["stripe_types/serde","stripe_shared/serde"] 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_core/src/balance/types.rs b/generated/stripe_core/src/balance/types.rs index 8fda3090d..9d4abef37 100644 --- a/generated/stripe_core/src/balance/types.rs +++ b/generated/stripe_core/src/balance/types.rs @@ -11,23 +11,208 @@ /// Related guide: [Understanding Connect account balances](https://stripe.com/docs/connect/account-balances). /// /// For more details see <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// 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>, /// Funds that you can pay out using Instant Payouts. - #[serde(skip_serializing_if = "Option::is_none")] pub instant_available: Option>, - #[serde(skip_serializing_if = "Option::is_none")] pub issuing: Option, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: BalanceObject, /// Funds that aren't available in the balance yet. /// You can find the pending balance for each currency and each payment type in the `source_types` property. pub pending: Vec, } +#[doc(hidden)] +pub struct BalanceBuilder { + available: Option>, + connect_reserved: Option>>, + instant_available: Option>>, + issuing: Option>, + livemode: Option, + object: Option, + pending: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BalanceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "pending" => Deserialize::begin(&mut self.pending), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + available: Deserialize::default(), + connect_reserved: Deserialize::default(), + instant_available: Deserialize::default(), + issuing: Deserialize::default(), + livemode: Deserialize::default(), + object: Deserialize::default(), + pending: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + available: self.available.take()?, + connect_reserved: self.connect_reserved.take()?, + instant_available: self.instant_available.take()?, + issuing: self.issuing.take()?, + livemode: self.livemode?, + object: self.object?, + pending: self.pending.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "pending" => b.pending = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum BalanceObject { + Balance, +} +impl BalanceObject { + pub fn as_str(self) -> &'static str { + use BalanceObject::*; + match self { + Balance => "balance", + } + } +} + +impl std::str::FromStr for BalanceObject { + type Err = (); + fn from_str(s: &str) -> Result { + use BalanceObject::*; + match s { + "balance" => Ok(Balance), + _ => Err(()), + } + } +} +impl std::fmt::Display for BalanceObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for BalanceObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for BalanceObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for BalanceObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(BalanceObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(BalanceObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for BalanceObject { + fn deserialize>(deserializer: D) -> 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 BalanceObject")) + } +} diff --git a/generated/stripe_core/src/balance_amount.rs b/generated/stripe_core/src/balance_amount.rs index 4ced136aa..dac6cf209 100644 --- a/generated/stripe_core/src/balance_amount.rs +++ b/generated/stripe_core/src/balance_amount.rs @@ -1,10 +1,111 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct BalanceAmountBuilder { + amount: Option, + currency: Option, + source_types: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BalanceAmountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + currency: Deserialize::default(), + source_types: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + currency: self.currency?, + source_types: self.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 { + 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..e61893093 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,107 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct BalanceAmountBySourceType { /// Amount for bank account. - #[serde(skip_serializing_if = "Option::is_none")] pub bank_account: Option, /// Amount for card. - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option, /// Amount for FPX. - #[serde(skip_serializing_if = "Option::is_none")] pub fpx: Option, } +#[doc(hidden)] +pub struct BalanceAmountBySourceTypeBuilder { + bank_account: Option>, + card: Option>, + fpx: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BalanceAmountBySourceTypeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_account: Deserialize::default(), + card: Deserialize::default(), + fpx: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { bank_account: self.bank_account?, card: self.card?, fpx: self.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 { + 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..49dd009e4 100644 --- a/generated/stripe_core/src/balance_amount_net.rs +++ b/generated/stripe_core/src/balance_amount_net.rs @@ -1,10 +1,111 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct BalanceAmountNetBuilder { + amount: Option, + currency: Option, + source_types: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BalanceAmountNetBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + currency: Deserialize::default(), + source_types: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + currency: self.currency?, + source_types: self.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 { + 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..2af9d1279 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct BalanceDetail { /// Funds that are available for use. pub available: Vec, } +#[doc(hidden)] +pub struct BalanceDetailBuilder { + available: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BalanceDetailBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { available: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { available: self.available.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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/cash_balance/requests.rs b/generated/stripe_core/src/cash_balance/requests.rs index 48acee1ca..e799712d0 100644 --- a/generated/stripe_core/src/cash_balance/requests.rs +++ b/generated/stripe_core/src/cash_balance/requests.rs @@ -98,6 +98,18 @@ impl serde::Serialize for UpdateCashBalanceSettingsReconciliationMode { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateCashBalanceSettingsReconciliationMode { + fn deserialize>(deserializer: D) -> 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 UpdateCashBalanceSettingsReconciliationMode", + ) + }) + } +} impl<'a> UpdateCashBalance<'a> { /// Changes the settings on a customer’s cash balance. pub fn send( diff --git a/generated/stripe_core/src/charge/requests.rs b/generated/stripe_core/src/charge/requests.rs index cf495c77b..60367ba9e 100644 --- a/generated/stripe_core/src/charge/requests.rs +++ b/generated/stripe_core/src/charge/requests.rs @@ -360,6 +360,16 @@ impl serde::Serialize for UpdateChargeFraudDetailsUserReport { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateChargeFraudDetailsUserReport { + fn deserialize>(deserializer: D) -> 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 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. diff --git a/generated/stripe_core/src/customer/requests.rs b/generated/stripe_core/src/customer/requests.rs index f6917085a..4285a78c2 100644 --- a/generated/stripe_core/src/customer/requests.rs +++ b/generated/stripe_core/src/customer/requests.rs @@ -107,12 +107,86 @@ impl<'a> RetrieveCustomer<'a> { client.get_query(&format!("/customers/{customer}"), self) } } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(untagged))] pub enum RetrieveCustomerReturned { Customer(stripe_shared::Customer), DeletedCustomer(stripe_shared::DeletedCustomer), } + +#[derive(Default)] +pub struct RetrieveCustomerReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +const _: () = { + use 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, + builder: RetrieveCustomerReturnedBuilder, + } + + impl Deserialize for RetrieveCustomerReturned { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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 BalanceTransactionsCustomer<'a> { /// A cursor for use in pagination. @@ -333,6 +407,14 @@ impl serde::Serialize for ListPaymentMethodsCustomerType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ListPaymentMethodsCustomerType { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} impl<'a> ListPaymentMethodsCustomer<'a> { /// Returns a list of PaymentMethods for a given Customer pub fn send( @@ -578,6 +660,18 @@ impl serde::Serialize for CreateCustomerCashBalanceSettingsReconciliationMode { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCustomerCashBalanceSettingsReconciliationMode { + fn deserialize>(deserializer: D) -> 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 CreateCustomerCashBalanceSettingsReconciliationMode", + ) + }) + } +} /// Default invoice settings for this customer. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCustomerInvoiceSettings<'a> { @@ -664,6 +758,20 @@ impl serde::Serialize for CreateCustomerInvoiceSettingsRenderingOptionsAmountTax serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay +{ + fn deserialize>(deserializer: D) -> 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 CreateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay", + ) + }) + } +} /// Tax details about the customer. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateCustomerTax<'a> { @@ -729,6 +837,16 @@ impl serde::Serialize for CreateCustomerTaxValidateLocation { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCustomerTaxValidateLocation { + fn deserialize>(deserializer: D) -> 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 CreateCustomerTaxValidateLocation") + }) + } +} /// The customer's tax IDs. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateCustomerTaxIdData<'a> { @@ -985,6 +1103,14 @@ impl serde::Serialize for CreateCustomerTaxIdDataType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateCustomerTaxIdDataType { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} impl<'a> CreateCustomer<'a> { /// Creates a new customer object. pub fn send(&self, client: &stripe::Client) -> stripe::Response { @@ -1152,6 +1278,18 @@ impl serde::Serialize for UpdateCustomerCashBalanceSettingsReconciliationMode { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateCustomerCashBalanceSettingsReconciliationMode { + fn deserialize>(deserializer: D) -> 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 UpdateCustomerCashBalanceSettingsReconciliationMode", + ) + }) + } +} /// Default invoice settings for this customer. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateCustomerInvoiceSettings<'a> { @@ -1238,6 +1376,20 @@ impl serde::Serialize for UpdateCustomerInvoiceSettingsRenderingOptionsAmountTax serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay +{ + fn deserialize>(deserializer: D) -> 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 UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay", + ) + }) + } +} /// Tax details about the customer. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateCustomerTax<'a> { @@ -1303,6 +1455,16 @@ impl serde::Serialize for UpdateCustomerTaxValidateLocation { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateCustomerTaxValidateLocation { + fn deserialize>(deserializer: D) -> 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 UpdateCustomerTaxValidateLocation") + }) + } +} impl<'a> UpdateCustomer<'a> { /// Updates the specified customer by setting the values of the parameters passed. /// Any parameters not provided will be left unchanged. @@ -1431,6 +1593,16 @@ impl serde::Serialize for CreateFundingInstructionsCustomerBankTransferRequested serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateFundingInstructionsCustomerBankTransferRequestedAddressTypes +{ + fn deserialize>(deserializer: D) -> 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 CreateFundingInstructionsCustomerBankTransferRequestedAddressTypes")) + } +} /// The type of the `bank_transfer` #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateFundingInstructionsCustomerBankTransferType { @@ -1486,6 +1658,18 @@ impl serde::Serialize for CreateFundingInstructionsCustomerBankTransferType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateFundingInstructionsCustomerBankTransferType { + fn deserialize>(deserializer: D) -> 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 CreateFundingInstructionsCustomerBankTransferType", + ) + }) + } +} /// The `funding_type` to get the instructions for. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateFundingInstructionsCustomerFundingType { @@ -1529,6 +1713,18 @@ impl serde::Serialize for CreateFundingInstructionsCustomerFundingType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateFundingInstructionsCustomerFundingType { + fn deserialize>(deserializer: D) -> 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 CreateFundingInstructionsCustomerFundingType", + ) + }) + } +} impl<'a> CreateFundingInstructionsCustomer<'a> { /// Retrieve funding instructions for a customer cash balance. /// If funding instructions do not yet exist for the customer, new. diff --git a/generated/stripe_core/src/customer_session/types.rs b/generated/stripe_core/src/customer_session/types.rs index cbd2e4bb5..42ed65401 100644 --- a/generated/stripe_core/src/customer_session/types.rs +++ b/generated/stripe_core/src/customer_session/types.rs @@ -1,6 +1,8 @@ /// 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)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CustomerSession { /// The client secret of this customer session. /// Used on the client to set up secure access to the given `customer`. @@ -9,7 +11,6 @@ pub struct CustomerSession { /// 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, /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -19,4 +20,194 @@ pub struct CustomerSession { 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: CustomerSessionObject, +} +#[doc(hidden)] +pub struct CustomerSessionBuilder { + client_secret: Option, + components: Option>, + created: Option, + customer: Option>, + expires_at: Option, + livemode: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerSession { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerSessionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: CustomerSessionBuilder::deser_default(), + })) + } + } + + impl MapBuilder for CustomerSessionBuilder { + type Out = CustomerSession; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "client_secret" => Deserialize::begin(&mut self.client_secret), + "components" => Deserialize::begin(&mut self.components), + "created" => Deserialize::begin(&mut self.created), + "customer" => Deserialize::begin(&mut self.customer), + "expires_at" => Deserialize::begin(&mut self.expires_at), + "livemode" => Deserialize::begin(&mut self.livemode), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + client_secret: Deserialize::default(), + components: Deserialize::default(), + created: Deserialize::default(), + customer: Deserialize::default(), + expires_at: Deserialize::default(), + livemode: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + client_secret: self.client_secret.take()?, + components: self.components?, + created: self.created?, + customer: self.customer.take()?, + expires_at: self.expires_at?, + livemode: self.livemode?, + object: self.object?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerSession { + type Builder = CustomerSessionBuilder; + } + + impl FromValueOpt for CustomerSession { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerSessionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "client_secret" => b.client_secret = Some(FromValueOpt::from_value(v)?), + "components" => b.components = 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)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum CustomerSessionObject { + CustomerSession, +} +impl CustomerSessionObject { + pub fn as_str(self) -> &'static str { + use CustomerSessionObject::*; + match self { + CustomerSession => "customer_session", + } + } +} + +impl std::str::FromStr for CustomerSessionObject { + type Err = (); + fn from_str(s: &str) -> Result { + use CustomerSessionObject::*; + match s { + "customer_session" => Ok(CustomerSession), + _ => Err(()), + } + } +} +impl std::fmt::Display for CustomerSessionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for CustomerSessionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for CustomerSessionObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for CustomerSessionObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CustomerSessionObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CustomerSessionObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CustomerSessionObject { + fn deserialize>(deserializer: D) -> 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 CustomerSessionObject")) + } } diff --git a/generated/stripe_core/src/customer_session_resource_components.rs b/generated/stripe_core/src/customer_session_resource_components.rs index 2539e1437..38617311c 100644 --- a/generated/stripe_core/src/customer_session_resource_components.rs +++ b/generated/stripe_core/src/customer_session_resource_components.rs @@ -1,6 +1,97 @@ /// Configuration for the components supported by this customer session. -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CustomerSessionResourceComponents { pub buy_button: stripe_core::CustomerSessionResourceComponentsResourceBuyButton, pub pricing_table: stripe_core::CustomerSessionResourceComponentsResourcePricingTable, } +#[doc(hidden)] +pub struct CustomerSessionResourceComponentsBuilder { + buy_button: Option, + pricing_table: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerSessionResourceComponents { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerSessionResourceComponentsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: CustomerSessionResourceComponentsBuilder::deser_default(), + })) + } + } + + impl MapBuilder for CustomerSessionResourceComponentsBuilder { + type Out = CustomerSessionResourceComponents; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "buy_button" => Deserialize::begin(&mut self.buy_button), + "pricing_table" => Deserialize::begin(&mut self.pricing_table), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { buy_button: Deserialize::default(), pricing_table: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { buy_button: self.buy_button?, pricing_table: self.pricing_table? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerSessionResourceComponents { + type Builder = CustomerSessionResourceComponentsBuilder; + } + + impl FromValueOpt for CustomerSessionResourceComponents { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerSessionResourceComponentsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "buy_button" => b.buy_button = Some(FromValueOpt::from_value(v)?), + "pricing_table" => b.pricing_table = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; 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 index 748cb2ded..cbc358a7a 100644 --- 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 @@ -1,6 +1,94 @@ /// This hash contains whether the buy button is enabled. -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CustomerSessionResourceComponentsResourceBuyButton { /// Whether the buy button is enabled. pub enabled: bool, } +#[doc(hidden)] +pub struct CustomerSessionResourceComponentsResourceBuyButtonBuilder { + enabled: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerSessionResourceComponentsResourceBuyButton { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerSessionResourceComponentsResourceBuyButtonBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: CustomerSessionResourceComponentsResourceBuyButtonBuilder::deser_default(), + })) + } + } + + impl MapBuilder for CustomerSessionResourceComponentsResourceBuyButtonBuilder { + type Out = CustomerSessionResourceComponentsResourceBuyButton; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.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 CustomerSessionResourceComponentsResourceBuyButton { + type Builder = CustomerSessionResourceComponentsResourceBuyButtonBuilder; + } + + impl FromValueOpt for CustomerSessionResourceComponentsResourceBuyButton { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerSessionResourceComponentsResourceBuyButtonBuilder::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_core/src/customer_session_resource_components_resource_pricing_table.rs b/generated/stripe_core/src/customer_session_resource_components_resource_pricing_table.rs index 6f8dbc4ed..fa3ecd414 100644 --- 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 @@ -1,6 +1,96 @@ /// This hash contains whether the pricing table is enabled. -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CustomerSessionResourceComponentsResourcePricingTable { /// Whether the pricing table is enabled. pub enabled: bool, } +#[doc(hidden)] +pub struct CustomerSessionResourceComponentsResourcePricingTableBuilder { + enabled: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerSessionResourceComponentsResourcePricingTable { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerSessionResourceComponentsResourcePricingTableBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: + CustomerSessionResourceComponentsResourcePricingTableBuilder::deser_default(), + })) + } + } + + impl MapBuilder for CustomerSessionResourceComponentsResourcePricingTableBuilder { + type Out = CustomerSessionResourceComponentsResourcePricingTable; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "enabled" => Deserialize::begin(&mut self.enabled), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.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 CustomerSessionResourceComponentsResourcePricingTable { + type Builder = CustomerSessionResourceComponentsResourcePricingTableBuilder; + } + + impl FromValueOpt for CustomerSessionResourceComponentsResourcePricingTable { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = + CustomerSessionResourceComponentsResourcePricingTableBuilder::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_core/src/mod.rs b/generated/stripe_core/src/mod.rs index 45b93a5eb..7a0262539 100644 --- a/generated/stripe_core/src/mod.rs +++ b/generated/stripe_core/src/mod.rs @@ -7,6 +7,8 @@ //! for requests mentioned in the `Core Resources` section of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_core; + +miniserde::make_place!(Place); pub use balance::types::*; pub mod balance; #[doc(hidden)] diff --git a/generated/stripe_core/src/payment_intent/requests.rs b/generated/stripe_core/src/payment_intent/requests.rs index c56754f87..33375fa60 100644 --- a/generated/stripe_core/src/payment_intent/requests.rs +++ b/generated/stripe_core/src/payment_intent/requests.rs @@ -117,7 +117,7 @@ impl<'a> SearchPaymentIntent<'a> { stripe::ListPaginator::from_search_params("/payment_intents/search", self) } } -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] pub struct CreatePaymentIntent<'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). @@ -358,9 +358,21 @@ impl serde::Serialize for CreatePaymentIntentAutomaticPaymentMethodsAllowRedirec serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentAutomaticPaymentMethodsAllowRedirects { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentAutomaticPaymentMethodsAllowRedirects", + ) + }) + } +} /// This hash contains details about the Mandate to create. /// This parameter can only be used with [`confirm=true`](https://stripe.com/docs/api/payment_intents/create#create_payment_intent-confirm). -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] pub struct CreatePaymentIntentMandateData<'a> { /// This hash contains details about the customer acceptance of the Mandate. pub customer_acceptance: CreatePaymentIntentMandateDataCustomerAcceptance<'a>, @@ -371,14 +383,15 @@ impl<'a> CreatePaymentIntentMandateData<'a> { } } /// This hash contains details about the customer acceptance of the Mandate. -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] pub struct CreatePaymentIntentMandateDataCustomerAcceptance<'a> { /// The time at which the customer accepted the Mandate. #[serde(skip_serializing_if = "Option::is_none")] pub accepted_at: Option, /// If this is a Mandate accepted offline, this hash contains details about the offline acceptance. #[serde(skip_serializing_if = "Option::is_none")] - pub offline: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub offline: Option, /// If this is a Mandate accepted online, this hash contains details about the online acceptance. #[serde(skip_serializing_if = "Option::is_none")] pub online: Option>, @@ -439,6 +452,18 @@ impl serde::Serialize for CreatePaymentIntentMandateDataCustomerAcceptanceType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentMandateDataCustomerAcceptanceType { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentMandateDataCustomerAcceptanceType", + ) + }) + } +} /// Set to `true` to indicate that the customer isn't in your checkout flow during this payment attempt and can't authenticate. /// Use this parameter in scenarios where you collect card details and [charge them later](https://stripe.com/docs/payments/cards/charging-saved-cards). /// This parameter can only be used with [`confirm=true`](https://stripe.com/docs/api/payment_intents/create#create_payment_intent-confirm). @@ -452,20 +477,23 @@ pub enum CreatePaymentIntentOffSession { /// If provided, this hash will be used to create a PaymentMethod. The new PaymentMethod will appear /// in the [payment_method](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-payment_method). /// property on the PaymentIntent. -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodData<'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")] pub acss_debit: Option>, /// If this is an `affirm` PaymentMethod, this hash contains details about the Affirm payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub affirm: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub affirm: Option, /// If this is an `AfterpayClearpay` PaymentMethod, this hash contains details about the AfterpayClearpay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub afterpay_clearpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub afterpay_clearpay: Option, /// If this is an `Alipay` PaymentMethod, this hash contains details about the Alipay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub alipay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub alipay: Option, /// If this is an `au_becs_debit` PaymentMethod, this hash contains details about the bank account. #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option>, @@ -474,22 +502,26 @@ pub struct CreatePaymentIntentPaymentMethodData<'a> { pub bacs_debit: Option>, /// If this is a `bancontact` PaymentMethod, this hash contains details about the Bancontact payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub bancontact: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub bancontact: Option, /// 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>, /// If this is a `blik` PaymentMethod, this hash contains details about the BLIK payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub blik: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub blik: Option, /// If this is a `boleto` PaymentMethod, this hash contains details about the Boleto payment method. #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option>, /// If this is a `cashapp` PaymentMethod, this hash contains details about the Cash App Pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub cashapp: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub cashapp: Option, /// If this is a `customer_balance` PaymentMethod, this hash contains details about the CustomerBalance payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub customer_balance: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub customer_balance: Option, /// If this is an `eps` PaymentMethod, this hash contains details about the EPS payment method. #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option, @@ -498,25 +530,30 @@ pub struct CreatePaymentIntentPaymentMethodData<'a> { pub fpx: Option, /// If this is a `giropay` PaymentMethod, this hash contains details about the Giropay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub giropay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub giropay: Option, /// If this is a `grabpay` PaymentMethod, this hash contains details about the GrabPay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub grabpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub grabpay: Option, /// If this is an `ideal` PaymentMethod, this hash contains details about the iDEAL payment method. #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option, /// If this is an `interac_present` PaymentMethod, this hash contains details about the Interac Present payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub interac_present: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub interac_present: Option, /// If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method. #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option, /// If this is a `konbini` PaymentMethod, this hash contains details about the Konbini payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub konbini: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub konbini: Option, /// If this is an `Link` PaymentMethod, this hash contains details about the Link payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub link: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub link: Option, /// 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. @@ -525,29 +562,35 @@ pub struct CreatePaymentIntentPaymentMethodData<'a> { pub metadata: Option<&'a std::collections::HashMap>, /// If this is an `oxxo` PaymentMethod, this hash contains details about the OXXO payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub oxxo: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub oxxo: Option, /// If this is a `p24` PaymentMethod, this hash contains details about the P24 payment method. #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option, /// If this is a `paynow` PaymentMethod, this hash contains details about the PayNow payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub paynow: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub paynow: Option, /// If this is a `paypal` PaymentMethod, this hash contains details about the PayPal payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub paypal: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub paypal: Option, /// If this is a `pix` PaymentMethod, this hash contains details about the Pix payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub pix: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub pix: Option, /// If this is a `promptpay` PaymentMethod, this hash contains details about the PromptPay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub promptpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub promptpay: Option, /// Options to configure Radar. /// See [Radar Session](https://stripe.com/docs/radar/radar-session) for more information. #[serde(skip_serializing_if = "Option::is_none")] pub radar_options: Option>, /// If this is a `Revolut Pay` PaymentMethod, this hash contains details about the Revolut Pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub revolut_pay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub revolut_pay: Option, /// If this is a `sepa_debit` PaymentMethod, this hash contains details about the SEPA debit bank account. #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option>, @@ -556,7 +599,8 @@ pub struct CreatePaymentIntentPaymentMethodData<'a> { pub sofort: Option, /// 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>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub swish: Option, /// 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. @@ -567,10 +611,12 @@ pub struct CreatePaymentIntentPaymentMethodData<'a> { pub us_bank_account: Option>, /// If this is an `wechat_pay` PaymentMethod, this hash contains details about the wechat_pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub wechat_pay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub wechat_pay: Option, /// If this is a `zip` PaymentMethod, this hash contains details about the Zip payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub zip: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub zip: Option, } impl<'a> CreatePaymentIntentPaymentMethodData<'a> { pub fn new(type_: CreatePaymentIntentPaymentMethodDataType) -> Self { @@ -842,6 +888,14 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodDataEpsBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodDataEpsBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is an `fpx` PaymentMethod, this hash contains details about the FPX payment method. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodDataFpx { @@ -902,6 +956,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodDataFpxAccountHolderTy serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodDataFpxAccountHolderType { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodDataFpxAccountHolderType", + ) + }) + } +} /// The customer's bank. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -1012,6 +1078,14 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodDataFpxBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodDataFpxBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is an `ideal` PaymentMethod, this hash contains details about the iDEAL payment method. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodDataIdeal { @@ -1116,6 +1190,14 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodDataIdealBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodDataIdealBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodDataKlarna { @@ -1262,6 +1344,14 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodDataP24Bank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodDataP24Bank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Options to configure Radar. /// See [Radar Session](https://stripe.com/docs/radar/radar-session) for more information. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -1355,6 +1445,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodDataSofortCountry { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodDataSofortCountry { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodDataSofortCountry", + ) + }) + } +} /// 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. @@ -1497,6 +1599,14 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodDataType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodDataType { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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 CreatePaymentIntentPaymentMethodDataUsBankAccount<'a> { @@ -1568,6 +1678,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodDataUsBankAccountAccou serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodDataUsBankAccountAccountHolderType +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodDataUsBankAccountAccountHolderType")) + } +} /// Account type: checkings or savings. Defaults to checking if omitted. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodDataUsBankAccountAccountType { @@ -1614,8 +1734,20 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodDataUsBankAccountAccou serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodDataUsBankAccountAccountType { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodDataUsBankAccountAccountType", + ) + }) + } +} /// Payment method-specific configuration for this PaymentIntent. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptions<'a> { /// If this is a `acss_debit` PaymentMethod, this sub-hash contains details about the ACSS Debit payment method options. #[serde(skip_serializing_if = "Option::is_none")] @@ -1673,7 +1805,8 @@ pub struct CreatePaymentIntentPaymentMethodOptions<'a> { pub ideal: Option, /// If this is a `interac_present` PaymentMethod, this sub-hash contains details about the Card Present payment method options. #[serde(skip_serializing_if = "Option::is_none")] - pub interac_present: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub interac_present: Option, /// If this is a `klarna` PaymentMethod, this sub-hash contains details about the Klarna payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option, @@ -1706,7 +1839,7 @@ pub struct CreatePaymentIntentPaymentMethodOptions<'a> { pub revolut_pay: Option, /// If this is a `sepa_debit` PaymentIntent, this sub-hash contains details about the SEPA Debit payment method options. #[serde(skip_serializing_if = "Option::is_none")] - pub sepa_debit: Option>, + pub sepa_debit: Option, /// 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, @@ -1838,6 +1971,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule")) + } +} /// Transaction type of the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { @@ -1892,6 +2035,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType")) + } +} /// 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. @@ -1948,6 +2101,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsAcssDebitSetupF serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage")) + } +} /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod { @@ -1997,6 +2160,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsAcssDebitVerifi serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod")) + } +} /// If this is an `affirm` PaymentMethod, this sub-hash contains details about the Affirm payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsAffirm<'a> { @@ -2073,6 +2246,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsAffirmCaptureMe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsAffirmCaptureMethod { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsAffirmCaptureMethod", + ) + }) + } +} /// 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. @@ -2123,6 +2308,20 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsAffirmSetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsAffirmSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsAffirmSetupFutureUsage", + ) + }) + } +} /// If this is a `afterpay_clearpay` PaymentMethod, this sub-hash contains details about the Afterpay Clearpay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsAfterpayClearpay<'a> { @@ -2203,6 +2402,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsAfterpayClearpa serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsAfterpayClearpayCaptureMethod +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsAfterpayClearpayCaptureMethod")) + } +} /// 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. @@ -2253,6 +2462,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsAfterpayClearpa serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsAfterpayClearpaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsAfterpayClearpaySetupFutureUsage")) + } +} /// If this is a `alipay` PaymentMethod, this sub-hash contains details about the Alipay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsAlipay { @@ -2325,6 +2544,20 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsAlipaySetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsAlipaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsAlipaySetupFutureUsage", + ) + }) + } +} /// If this is a `au_becs_debit` PaymentMethod, this sub-hash contains details about the AU BECS Direct Debit payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsAuBecsDebit { @@ -2401,6 +2634,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsAuBecsDebitSetu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage")) + } +} /// If this is a `bacs_debit` PaymentMethod, this sub-hash contains details about the BACS Debit payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsBacsDebit { @@ -2477,6 +2720,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsBacsDebitSetupF serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsBacsDebitSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsBacsDebitSetupFutureUsage")) + } +} /// If this is a `bancontact` PaymentMethod, this sub-hash contains details about the Bancontact payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsBancontact { @@ -2553,6 +2806,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsBancontactPrefe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsBancontactPreferredLanguage +{ + fn deserialize>(deserializer: D) -> 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 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. @@ -2606,6 +2869,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsBancontactSetup serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsBancontactSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsBancontactSetupFutureUsage")) + } +} /// 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> { @@ -2679,6 +2952,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsBlikSetupFuture serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage", + ) + }) + } +} /// 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 { @@ -2758,6 +3043,20 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsBoletoSetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage", + ) + }) + } +} /// Configuration for any card payments attempted on this PaymentIntent. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsCard<'a> { @@ -2896,6 +3195,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardCaptureMeth serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsCardCaptureMethod { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsCardCaptureMethod", + ) + }) + } +} /// Installment configuration for payments attempted on this PaymentIntent (Mexico Only). /// /// For more information, see the [installments integration guide](https://stripe.com/docs/payments/installments). @@ -2982,6 +3293,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardInstallment serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanInterval +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanInterval")) + } +} /// Type of installment plan, one of `fixed_count`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanType { @@ -3025,6 +3346,20 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardInstallment serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanType +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanType", + ) + }) + } +} /// Configuration options for setting up an eMandate for cards issued in India. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsCardMandateOptions<'a> { @@ -3128,6 +3463,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardMandateOpti serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCardMandateOptionsAmountType +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsCardMandateOptionsAmountType")) + } +} /// Specifies payment frequency. One of `day`, `week`, `month`, `year`, or `sporadic`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsCardMandateOptionsInterval { @@ -3183,6 +3528,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardMandateOpti serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCardMandateOptionsInterval +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsCardMandateOptionsInterval")) + } +} /// Specifies the type of mandates supported. Possible values are `india`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes { @@ -3226,6 +3581,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardMandateOpti serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes")) + } +} /// Selected network to process this PaymentIntent on. /// Depends on the available networks of the card attached to the PaymentIntent. /// Can be only set confirm-time. @@ -3301,6 +3666,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardNetwork { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsCardNetwork { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsCardNetwork", + ) + }) + } +} /// 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 CreatePaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization { @@ -3347,6 +3724,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardRequestExte serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization")) + } +} /// Request ability to [increment the authorization](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { @@ -3401,6 +3788,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization")) + } +} /// Request ability to make [multiple captures](https://stripe.com/docs/payments/multicapture) for this PaymentIntent. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsCardRequestMulticapture { @@ -3447,6 +3844,20 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardRequestMult serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCardRequestMulticapture +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsCardRequestMulticapture", + ) + }) + } +} /// Request ability to [overcapture](https://stripe.com/docs/payments/overcapture) for this PaymentIntent. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsCardRequestOvercapture { @@ -3493,6 +3904,20 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardRequestOver serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCardRequestOvercapture +{ + fn deserialize>(deserializer: D) -> 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 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`. @@ -3545,6 +3970,20 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardRequestThre serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCardRequestThreeDSecure +{ + fn deserialize>(deserializer: D) -> 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 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. @@ -3601,6 +4040,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardSetupFuture serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsCardSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsCardSetupFutureUsage", + ) + }) + } +} /// 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)] @@ -3718,6 +4169,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecur serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus")) + } +} /// 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)] @@ -3782,6 +4243,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator")) + } +} /// The exemption requested via 3DS and accepted by the issuer at authentication time. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator { @@ -3834,6 +4305,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator +{ + fn deserialize>(deserializer: D) -> 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 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 @@ -3945,6 +4426,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo")) + } +} /// The version of 3D Secure that was performed. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { @@ -3994,6 +4485,20 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecur serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion", + ) + }) + } +} /// 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 { @@ -4067,6 +4572,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCashappCaptureM serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsCashappCaptureMethod { + fn deserialize>(deserializer: D) -> 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 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. @@ -4123,6 +4640,20 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCashappSetupFut serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage", + ) + }) + } +} /// 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> { @@ -4247,6 +4778,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes +{ + fn deserialize>(deserializer: D) -> 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 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`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType { @@ -4302,6 +4843,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCustomerBalance serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType")) + } +} /// 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)] @@ -4346,6 +4897,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCustomerBalance serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCustomerBalanceFundingType +{ + fn deserialize>(deserializer: D) -> 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 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. @@ -4396,6 +4957,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsCustomerBalance serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsCustomerBalanceSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsCustomerBalanceSetupFutureUsage")) + } +} /// If this is a `eps` PaymentMethod, this sub-hash contains details about the EPS payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsEps { @@ -4465,6 +5036,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsEpsSetupFutureU serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsEpsSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsEpsSetupFutureUsage", + ) + }) + } +} /// If this is a `fpx` PaymentMethod, this sub-hash contains details about the FPX payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsFpx { @@ -4534,6 +5117,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsFpxSetupFutureU serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsFpxSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsFpxSetupFutureUsage", + ) + }) + } +} /// If this is a `giropay` PaymentMethod, this sub-hash contains details about the Giropay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsGiropay { @@ -4603,6 +5198,20 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsGiropaySetupFut serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsGiropaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsGiropaySetupFutureUsage", + ) + }) + } +} /// If this is a `grabpay` PaymentMethod, this sub-hash contains details about the Grabpay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsGrabpay { @@ -4672,6 +5281,20 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsGrabpaySetupFut serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsGrabpaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsGrabpaySetupFutureUsage", + ) + }) + } +} /// If this is a `ideal` PaymentMethod, this sub-hash contains details about the Ideal payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsIdeal { @@ -4744,6 +5367,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsIdealSetupFutur serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsIdealSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsIdealSetupFutureUsage", + ) + }) + } +} /// If this is a `klarna` PaymentMethod, this sub-hash contains details about the Klarna payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsKlarna { @@ -4820,6 +5455,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsKlarnaCaptureMe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsKlarnaCaptureMethod { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsKlarnaCaptureMethod", + ) + }) + } +} /// Preferred language of the Klarna authorization page that the customer is redirected to #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -4996,6 +5643,14 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsKlarnaPreferred serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsKlarnaPreferredLocale { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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. @@ -5046,6 +5701,20 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsKlarnaSetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsKlarnaSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsKlarnaSetupFutureUsage", + ) + }) + } +} /// If this is a `konbini` PaymentMethod, this sub-hash contains details about the Konbini payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsKonbini<'a> { @@ -5132,6 +5801,20 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsKonbiniSetupFut serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsKonbiniSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsKonbiniSetupFutureUsage", + ) + }) + } +} /// If this is a `link` PaymentMethod, this sub-hash contains details about the Link payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsLink<'a> { @@ -5208,6 +5891,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsLinkCaptureMeth serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsLinkCaptureMethod { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsLinkCaptureMethod", + ) + }) + } +} /// 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. @@ -5261,6 +5956,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsLinkSetupFuture serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsLinkSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsLinkSetupFutureUsage", + ) + }) + } +} /// If this is a `oxxo` PaymentMethod, this sub-hash contains details about the OXXO payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsOxxo { @@ -5334,6 +6041,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsOxxoSetupFuture serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsOxxoSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsOxxoSetupFutureUsage", + ) + }) + } +} /// If this is a `p24` PaymentMethod, this sub-hash contains details about the Przelewy24 payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsP24 { @@ -5406,6 +6125,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsP24SetupFutureU serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsP24SetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsP24SetupFutureUsage", + ) + }) + } +} /// If this is a `paynow` PaymentMethod, this sub-hash contains details about the PayNow payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsPaynow { @@ -5475,6 +6206,20 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsPaynowSetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsPaynowSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsPaynowSetupFutureUsage", + ) + }) + } +} /// If this is a `paypal` PaymentMethod, this sub-hash contains details about the PayPal payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsPaypal<'a> { @@ -5550,6 +6295,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsPaypalCaptureMe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsPaypalCaptureMethod { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsPaypalCaptureMethod", + ) + }) + } +} /// [Preferred locale](https://stripe.com/docs/payments/paypal/supported-locales) of the PayPal checkout page that the customer is redirected to. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -5657,6 +6414,14 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsPaypalPreferred serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsPaypalPreferredLocale { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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. @@ -5710,6 +6475,20 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsPaypalSetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsPaypalSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsPaypalSetupFutureUsage", + ) + }) + } +} /// If this is a `pix` PaymentMethod, this sub-hash contains details about the Pix payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsPix { @@ -5787,6 +6566,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsPixSetupFutureU serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsPixSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsPixSetupFutureUsage", + ) + }) + } +} /// If this is a `promptpay` PaymentMethod, this sub-hash contains details about the PromptPay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsPromptpay { @@ -5857,6 +6648,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsPromptpaySetupF serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsPromptpaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsPromptpaySetupFutureUsage")) + } +} /// If this is a `revolut_pay` PaymentMethod, this sub-hash contains details about the Revolut Pay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsRevolutPay { @@ -5926,12 +6727,23 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsRevolutPaySetup serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsRevolutPaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsRevolutPaySetupFutureUsage")) + } +} /// If this is a `sepa_debit` PaymentIntent, this sub-hash contains details about the SEPA Debit payment method options. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreatePaymentIntentPaymentMethodOptionsSepaDebit<'a> { +#[derive(Clone, Debug, Default, serde::Serialize)] +pub struct CreatePaymentIntentPaymentMethodOptionsSepaDebit { /// Additional fields for Mandate creation #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub mandate_options: Option, /// 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. @@ -5944,7 +6756,7 @@ pub struct CreatePaymentIntentPaymentMethodOptionsSepaDebit<'a> { pub setup_future_usage: Option, } -impl<'a> CreatePaymentIntentPaymentMethodOptionsSepaDebit<'a> { +impl CreatePaymentIntentPaymentMethodOptionsSepaDebit { pub fn new() -> Self { Self::default() } @@ -6005,6 +6817,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsSepaDebitSetupF serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage")) + } +} /// If this is a `sofort` PaymentMethod, this sub-hash contains details about the SOFORT payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsSofort { @@ -6088,6 +6910,20 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsSofortPreferred serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsSofortPreferredLanguage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsSofortPreferredLanguage", + ) + }) + } +} /// 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. @@ -6141,6 +6977,20 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsSofortSetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsSofortSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsSofortSetupFutureUsage", + ) + }) + } +} /// 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 CreatePaymentIntentPaymentMethodOptionsSwish<'a> { @@ -6213,6 +7063,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsSwishSetupFutur serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage", + ) + }) + } +} /// 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> { @@ -6338,6 +7200,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions")) + } +} /// List of data features that you would like to retrieve upon account creation. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { @@ -6392,6 +7264,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch")) + } +} /// Additional fields for Mandate creation #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptions { @@ -6456,6 +7338,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod")) + } +} /// Additional fields for network related functions #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { @@ -6515,6 +7407,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsUsBankAccountNe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested")) + } +} /// Preferred transaction settlement speed #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { @@ -6569,6 +7471,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed +{ + fn deserialize>(deserializer: D) -> 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 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. @@ -6625,6 +7537,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsUsBankAccountSe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage")) + } +} /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod { @@ -6674,6 +7596,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsUsBankAccountVe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod")) + } +} /// If this is a `wechat_pay` PaymentMethod, this sub-hash contains details about the WeChat Pay payment method options. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsWechatPay<'a> { @@ -6748,6 +7680,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsWechatPayClient serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsWechatPayClient { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsWechatPayClient", + ) + }) + } +} /// 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. @@ -6798,6 +7742,16 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsWechatPaySetupF serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentIntentPaymentMethodOptionsWechatPaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsWechatPaySetupFutureUsage")) + } +} /// If this is a `zip` PaymentMethod, this sub-hash contains details about the Zip payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentIntentPaymentMethodOptionsZip { @@ -6867,6 +7821,18 @@ impl serde::Serialize for CreatePaymentIntentPaymentMethodOptionsZipSetupFutureU serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentIntentPaymentMethodOptionsZipSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 CreatePaymentIntentPaymentMethodOptionsZipSetupFutureUsage", + ) + }) + } +} /// Options to configure Radar. /// Learn more about [Radar Sessions](https://stripe.com/docs/radar/radar-session). #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -6969,7 +7935,7 @@ impl<'a> CreatePaymentIntent<'a> { client.send_form("/payment_intents", self, http_types::Method::Post) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(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). @@ -7071,20 +8037,23 @@ impl<'a> UpdatePaymentIntent<'a> { /// If provided, this hash will be used to create a PaymentMethod. The new PaymentMethod will appear /// in the [payment_method](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-payment_method). /// property on the PaymentIntent. -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodData<'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")] pub acss_debit: Option>, /// If this is an `affirm` PaymentMethod, this hash contains details about the Affirm payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub affirm: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub affirm: Option, /// If this is an `AfterpayClearpay` PaymentMethod, this hash contains details about the AfterpayClearpay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub afterpay_clearpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub afterpay_clearpay: Option, /// If this is an `Alipay` PaymentMethod, this hash contains details about the Alipay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub alipay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub alipay: Option, /// If this is an `au_becs_debit` PaymentMethod, this hash contains details about the bank account. #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option>, @@ -7093,22 +8062,26 @@ pub struct UpdatePaymentIntentPaymentMethodData<'a> { pub bacs_debit: Option>, /// If this is a `bancontact` PaymentMethod, this hash contains details about the Bancontact payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub bancontact: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub bancontact: Option, /// 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>, /// If this is a `blik` PaymentMethod, this hash contains details about the BLIK payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub blik: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub blik: Option, /// If this is a `boleto` PaymentMethod, this hash contains details about the Boleto payment method. #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option>, /// If this is a `cashapp` PaymentMethod, this hash contains details about the Cash App Pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub cashapp: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub cashapp: Option, /// If this is a `customer_balance` PaymentMethod, this hash contains details about the CustomerBalance payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub customer_balance: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub customer_balance: Option, /// If this is an `eps` PaymentMethod, this hash contains details about the EPS payment method. #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option, @@ -7117,25 +8090,30 @@ pub struct UpdatePaymentIntentPaymentMethodData<'a> { pub fpx: Option, /// If this is a `giropay` PaymentMethod, this hash contains details about the Giropay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub giropay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub giropay: Option, /// If this is a `grabpay` PaymentMethod, this hash contains details about the GrabPay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub grabpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub grabpay: Option, /// If this is an `ideal` PaymentMethod, this hash contains details about the iDEAL payment method. #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option, /// If this is an `interac_present` PaymentMethod, this hash contains details about the Interac Present payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub interac_present: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub interac_present: Option, /// If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method. #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option, /// If this is a `konbini` PaymentMethod, this hash contains details about the Konbini payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub konbini: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub konbini: Option, /// If this is an `Link` PaymentMethod, this hash contains details about the Link payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub link: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub link: Option, /// 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. @@ -7144,29 +8122,35 @@ pub struct UpdatePaymentIntentPaymentMethodData<'a> { pub metadata: Option<&'a std::collections::HashMap>, /// If this is an `oxxo` PaymentMethod, this hash contains details about the OXXO payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub oxxo: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub oxxo: Option, /// If this is a `p24` PaymentMethod, this hash contains details about the P24 payment method. #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option, /// If this is a `paynow` PaymentMethod, this hash contains details about the PayNow payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub paynow: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub paynow: Option, /// If this is a `paypal` PaymentMethod, this hash contains details about the PayPal payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub paypal: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub paypal: Option, /// If this is a `pix` PaymentMethod, this hash contains details about the Pix payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub pix: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub pix: Option, /// If this is a `promptpay` PaymentMethod, this hash contains details about the PromptPay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub promptpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub promptpay: Option, /// Options to configure Radar. /// See [Radar Session](https://stripe.com/docs/radar/radar-session) for more information. #[serde(skip_serializing_if = "Option::is_none")] pub radar_options: Option>, /// If this is a `Revolut Pay` PaymentMethod, this hash contains details about the Revolut Pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub revolut_pay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub revolut_pay: Option, /// If this is a `sepa_debit` PaymentMethod, this hash contains details about the SEPA debit bank account. #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option>, @@ -7175,7 +8159,8 @@ pub struct UpdatePaymentIntentPaymentMethodData<'a> { pub sofort: Option, /// 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>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub swish: Option, /// 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. @@ -7186,10 +8171,12 @@ pub struct UpdatePaymentIntentPaymentMethodData<'a> { pub us_bank_account: Option>, /// If this is an `wechat_pay` PaymentMethod, this hash contains details about the wechat_pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub wechat_pay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub wechat_pay: Option, /// If this is a `zip` PaymentMethod, this hash contains details about the Zip payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub zip: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub zip: Option, } impl<'a> UpdatePaymentIntentPaymentMethodData<'a> { pub fn new(type_: UpdatePaymentIntentPaymentMethodDataType) -> Self { @@ -7461,6 +8448,14 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodDataEpsBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodDataEpsBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is an `fpx` PaymentMethod, this hash contains details about the FPX payment method. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodDataFpx { @@ -7521,6 +8516,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodDataFpxAccountHolderTy serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodDataFpxAccountHolderType { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodDataFpxAccountHolderType", + ) + }) + } +} /// The customer's bank. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -7631,6 +8638,14 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodDataFpxBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodDataFpxBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is an `ideal` PaymentMethod, this hash contains details about the iDEAL payment method. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodDataIdeal { @@ -7735,6 +8750,14 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodDataIdealBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodDataIdealBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodDataKlarna { @@ -7881,6 +8904,14 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodDataP24Bank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodDataP24Bank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Options to configure Radar. /// See [Radar Session](https://stripe.com/docs/radar/radar-session) for more information. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -7974,6 +9005,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodDataSofortCountry { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodDataSofortCountry { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodDataSofortCountry", + ) + }) + } +} /// 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. @@ -8116,6 +9159,14 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodDataType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodDataType { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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 UpdatePaymentIntentPaymentMethodDataUsBankAccount<'a> { @@ -8187,8 +9238,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodDataUsBankAccountAccou serializer.serialize_str(self.as_str()) } } -/// Account type: checkings or savings. Defaults to checking if omitted. -#[derive(Copy, Clone, Eq, PartialEq)] +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodDataUsBankAccountAccountHolderType +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodDataUsBankAccountAccountHolderType")) + } +} +/// Account type: checkings or savings. Defaults to checking if omitted. +#[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodDataUsBankAccountAccountType { Checking, Savings, @@ -8233,8 +9294,20 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodDataUsBankAccountAccou serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodDataUsBankAccountAccountType { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodDataUsBankAccountAccountType", + ) + }) + } +} /// Payment-method-specific configuration for this PaymentIntent. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptions<'a> { /// If this is a `acss_debit` PaymentMethod, this sub-hash contains details about the ACSS Debit payment method options. #[serde(skip_serializing_if = "Option::is_none")] @@ -8292,7 +9365,8 @@ pub struct UpdatePaymentIntentPaymentMethodOptions<'a> { pub ideal: Option, /// If this is a `interac_present` PaymentMethod, this sub-hash contains details about the Card Present payment method options. #[serde(skip_serializing_if = "Option::is_none")] - pub interac_present: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub interac_present: Option, /// If this is a `klarna` PaymentMethod, this sub-hash contains details about the Klarna payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option, @@ -8325,7 +9399,7 @@ pub struct UpdatePaymentIntentPaymentMethodOptions<'a> { pub revolut_pay: Option, /// If this is a `sepa_debit` PaymentIntent, this sub-hash contains details about the SEPA Debit payment method options. #[serde(skip_serializing_if = "Option::is_none")] - pub sepa_debit: Option>, + pub sepa_debit: Option, /// 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, @@ -8457,6 +9531,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule")) + } +} /// Transaction type of the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { @@ -8511,6 +9595,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType")) + } +} /// 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. @@ -8567,6 +9661,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsAcssDebitSetupF serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage")) + } +} /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod { @@ -8616,6 +9720,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsAcssDebitVerifi serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod")) + } +} /// If this is an `affirm` PaymentMethod, this sub-hash contains details about the Affirm payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsAffirm<'a> { @@ -8692,6 +9806,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsAffirmCaptureMe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsAffirmCaptureMethod { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsAffirmCaptureMethod", + ) + }) + } +} /// 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. @@ -8742,6 +9868,20 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsAffirmSetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsAffirmSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsAffirmSetupFutureUsage", + ) + }) + } +} /// If this is a `afterpay_clearpay` PaymentMethod, this sub-hash contains details about the Afterpay Clearpay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsAfterpayClearpay<'a> { @@ -8822,6 +9962,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsAfterpayClearpa serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsAfterpayClearpayCaptureMethod +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsAfterpayClearpayCaptureMethod")) + } +} /// 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. @@ -8872,6 +10022,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsAfterpayClearpa serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsAfterpayClearpaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsAfterpayClearpaySetupFutureUsage")) + } +} /// If this is a `alipay` PaymentMethod, this sub-hash contains details about the Alipay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsAlipay { @@ -8944,6 +10104,20 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsAlipaySetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsAlipaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsAlipaySetupFutureUsage", + ) + }) + } +} /// If this is a `au_becs_debit` PaymentMethod, this sub-hash contains details about the AU BECS Direct Debit payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsAuBecsDebit { @@ -9020,6 +10194,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsAuBecsDebitSetu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage")) + } +} /// If this is a `bacs_debit` PaymentMethod, this sub-hash contains details about the BACS Debit payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsBacsDebit { @@ -9096,6 +10280,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsBacsDebitSetupF serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsBacsDebitSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsBacsDebitSetupFutureUsage")) + } +} /// If this is a `bancontact` PaymentMethod, this sub-hash contains details about the Bancontact payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsBancontact { @@ -9172,6 +10366,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsBancontactPrefe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsBancontactPreferredLanguage +{ + fn deserialize>(deserializer: D) -> 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 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. @@ -9225,6 +10429,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsBancontactSetup serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsBancontactSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsBancontactSetupFutureUsage")) + } +} /// 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> { @@ -9298,6 +10512,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsBlikSetupFuture serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsBlikSetupFutureUsage", + ) + }) + } +} /// 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 { @@ -9377,6 +10603,20 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsBoletoSetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage", + ) + }) + } +} /// Configuration for any card payments attempted on this PaymentIntent. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsCard<'a> { @@ -9515,6 +10755,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardCaptureMeth serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsCardCaptureMethod { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCardCaptureMethod", + ) + }) + } +} /// Installment configuration for payments attempted on this PaymentIntent (Mexico Only). /// /// For more information, see the [installments integration guide](https://stripe.com/docs/payments/installments). @@ -9601,6 +10853,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardInstallment serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanInterval +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanInterval")) + } +} /// Type of installment plan, one of `fixed_count`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanType { @@ -9644,6 +10906,20 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardInstallment serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanType +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCardInstallmentsPlanType", + ) + }) + } +} /// Configuration options for setting up an eMandate for cards issued in India. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsCardMandateOptions<'a> { @@ -9747,6 +11023,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardMandateOpti serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCardMandateOptionsAmountType +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCardMandateOptionsAmountType")) + } +} /// Specifies payment frequency. One of `day`, `week`, `month`, `year`, or `sporadic`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsCardMandateOptionsInterval { @@ -9802,6 +11088,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardMandateOpti serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCardMandateOptionsInterval +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCardMandateOptionsInterval")) + } +} /// Specifies the type of mandates supported. Possible values are `india`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes { @@ -9845,6 +11141,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardMandateOpti serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes")) + } +} /// Selected network to process this PaymentIntent on. /// Depends on the available networks of the card attached to the PaymentIntent. /// Can be only set confirm-time. @@ -9920,6 +11226,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardNetwork { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsCardNetwork { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCardNetwork", + ) + }) + } +} /// 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 UpdatePaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization { @@ -9966,6 +11284,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardRequestExte serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization")) + } +} /// Request ability to [increment the authorization](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { @@ -10020,6 +11348,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization")) + } +} /// Request ability to make [multiple captures](https://stripe.com/docs/payments/multicapture) for this PaymentIntent. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsCardRequestMulticapture { @@ -10066,6 +11404,20 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardRequestMult serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCardRequestMulticapture +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCardRequestMulticapture", + ) + }) + } +} /// Request ability to [overcapture](https://stripe.com/docs/payments/overcapture) for this PaymentIntent. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsCardRequestOvercapture { @@ -10112,6 +11464,20 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardRequestOver serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCardRequestOvercapture +{ + fn deserialize>(deserializer: D) -> 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 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`. @@ -10164,6 +11530,20 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardRequestThre serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCardRequestThreeDSecure +{ + fn deserialize>(deserializer: D) -> 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 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. @@ -10220,6 +11600,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardSetupFuture serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsCardSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCardSetupFutureUsage", + ) + }) + } +} /// 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)] @@ -10337,6 +11729,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecur serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus")) + } +} /// 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)] @@ -10401,6 +11803,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator")) + } +} /// The exemption requested via 3DS and accepted by the issuer at authentication time. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator { @@ -10453,6 +11865,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator +{ + fn deserialize>(deserializer: D) -> 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 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 @@ -10564,6 +11986,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo")) + } +} /// The version of 3D Secure that was performed. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { @@ -10613,6 +12045,20 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecur serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCardThreeDSecureVersion", + ) + }) + } +} /// 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 { @@ -10686,6 +12132,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCashappCaptureM serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsCashappCaptureMethod { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCashappCaptureMethod", + ) + }) + } +} /// 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. @@ -10742,6 +12200,20 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCashappSetupFut serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCashappSetupFutureUsage", + ) + }) + } +} /// 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 UpdatePaymentIntentPaymentMethodOptionsCustomerBalance<'a> { @@ -10866,6 +12338,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes +{ + fn deserialize>(deserializer: D) -> 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 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`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType { @@ -10921,6 +12403,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCustomerBalance serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType")) + } +} /// 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)] @@ -10965,6 +12457,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCustomerBalance serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceFundingType +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceFundingType")) + } +} /// 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. @@ -11015,6 +12517,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsCustomerBalance serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsCustomerBalanceSetupFutureUsage")) + } +} /// If this is a `eps` PaymentMethod, this sub-hash contains details about the EPS payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsEps { @@ -11084,6 +12596,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsEpsSetupFutureU serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsEpsSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsEpsSetupFutureUsage", + ) + }) + } +} /// If this is a `fpx` PaymentMethod, this sub-hash contains details about the FPX payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsFpx { @@ -11153,6 +12677,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsFpxSetupFutureU serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsFpxSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsFpxSetupFutureUsage", + ) + }) + } +} /// If this is a `giropay` PaymentMethod, this sub-hash contains details about the Giropay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsGiropay { @@ -11222,6 +12758,20 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsGiropaySetupFut serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsGiropaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsGiropaySetupFutureUsage", + ) + }) + } +} /// If this is a `grabpay` PaymentMethod, this sub-hash contains details about the Grabpay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsGrabpay { @@ -11291,6 +12841,20 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsGrabpaySetupFut serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsGrabpaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsGrabpaySetupFutureUsage", + ) + }) + } +} /// If this is a `ideal` PaymentMethod, this sub-hash contains details about the Ideal payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsIdeal { @@ -11363,6 +12927,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsIdealSetupFutur serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsIdealSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsIdealSetupFutureUsage", + ) + }) + } +} /// If this is a `klarna` PaymentMethod, this sub-hash contains details about the Klarna payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsKlarna { @@ -11439,6 +13015,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsKlarnaCaptureMe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsKlarnaCaptureMethod { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsKlarnaCaptureMethod", + ) + }) + } +} /// Preferred language of the Klarna authorization page that the customer is redirected to #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -11615,6 +13203,14 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsKlarnaPreferred serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsKlarnaPreferredLocale { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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. @@ -11665,6 +13261,20 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsKlarnaSetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsKlarnaSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsKlarnaSetupFutureUsage", + ) + }) + } +} /// If this is a `konbini` PaymentMethod, this sub-hash contains details about the Konbini payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsKonbini<'a> { @@ -11751,6 +13361,20 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsKonbiniSetupFut serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsKonbiniSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsKonbiniSetupFutureUsage", + ) + }) + } +} /// If this is a `link` PaymentMethod, this sub-hash contains details about the Link payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsLink<'a> { @@ -11827,6 +13451,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsLinkCaptureMeth serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsLinkCaptureMethod { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsLinkCaptureMethod", + ) + }) + } +} /// 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. @@ -11880,6 +13516,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsLinkSetupFuture serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsLinkSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsLinkSetupFutureUsage", + ) + }) + } +} /// If this is a `oxxo` PaymentMethod, this sub-hash contains details about the OXXO payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsOxxo { @@ -11953,6 +13601,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsOxxoSetupFuture serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsOxxoSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsOxxoSetupFutureUsage", + ) + }) + } +} /// If this is a `p24` PaymentMethod, this sub-hash contains details about the Przelewy24 payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsP24 { @@ -12025,6 +13685,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsP24SetupFutureU serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsP24SetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsP24SetupFutureUsage", + ) + }) + } +} /// If this is a `paynow` PaymentMethod, this sub-hash contains details about the PayNow payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsPaynow { @@ -12094,6 +13766,20 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsPaynowSetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsPaynowSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsPaynowSetupFutureUsage", + ) + }) + } +} /// If this is a `paypal` PaymentMethod, this sub-hash contains details about the PayPal payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsPaypal<'a> { @@ -12169,6 +13855,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsPaypalCaptureMe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsPaypalCaptureMethod { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsPaypalCaptureMethod", + ) + }) + } +} /// [Preferred locale](https://stripe.com/docs/payments/paypal/supported-locales) of the PayPal checkout page that the customer is redirected to. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -12276,6 +13974,14 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsPaypalPreferred serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsPaypalPreferredLocale { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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. @@ -12329,6 +14035,20 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsPaypalSetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsPaypalSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsPaypalSetupFutureUsage", + ) + }) + } +} /// If this is a `pix` PaymentMethod, this sub-hash contains details about the Pix payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsPix { @@ -12406,6 +14126,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsPixSetupFutureU serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsPixSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsPixSetupFutureUsage", + ) + }) + } +} /// If this is a `promptpay` PaymentMethod, this sub-hash contains details about the PromptPay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsPromptpay { @@ -12476,6 +14208,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsPromptpaySetupF serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsPromptpaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsPromptpaySetupFutureUsage")) + } +} /// If this is a `revolut_pay` PaymentMethod, this sub-hash contains details about the Revolut Pay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsRevolutPay { @@ -12545,12 +14287,23 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsRevolutPaySetup serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsRevolutPaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsRevolutPaySetupFutureUsage")) + } +} /// If this is a `sepa_debit` PaymentIntent, this sub-hash contains details about the SEPA Debit payment method options. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdatePaymentIntentPaymentMethodOptionsSepaDebit<'a> { +#[derive(Clone, Debug, Default, serde::Serialize)] +pub struct UpdatePaymentIntentPaymentMethodOptionsSepaDebit { /// Additional fields for Mandate creation #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub mandate_options: Option, /// 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. @@ -12563,7 +14316,7 @@ pub struct UpdatePaymentIntentPaymentMethodOptionsSepaDebit<'a> { pub setup_future_usage: Option, } -impl<'a> UpdatePaymentIntentPaymentMethodOptionsSepaDebit<'a> { +impl UpdatePaymentIntentPaymentMethodOptionsSepaDebit { pub fn new() -> Self { Self::default() } @@ -12624,6 +14377,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsSepaDebitSetupF serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage")) + } +} /// If this is a `sofort` PaymentMethod, this sub-hash contains details about the SOFORT payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsSofort { @@ -12707,6 +14470,20 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsSofortPreferred serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsSofortPreferredLanguage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsSofortPreferredLanguage", + ) + }) + } +} /// 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. @@ -12760,6 +14537,20 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsSofortSetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsSofortSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsSofortSetupFutureUsage", + ) + }) + } +} /// 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> { @@ -12832,6 +14623,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsSwishSetupFutur serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsSwishSetupFutureUsage", + ) + }) + } +} /// 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> { @@ -12957,6 +14760,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions")) + } +} /// List of data features that you would like to retrieve upon account creation. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { @@ -13011,6 +14824,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch")) + } +} /// Additional fields for Mandate creation #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptions { @@ -13075,6 +14898,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod")) + } +} /// Additional fields for network related functions #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { @@ -13134,6 +14967,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested")) + } +} /// Preferred transaction settlement speed #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { @@ -13188,6 +15031,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed +{ + fn deserialize>(deserializer: D) -> 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 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. @@ -13244,6 +15097,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountSe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage")) + } +} /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod { @@ -13293,6 +15156,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountVe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod")) + } +} /// If this is a `wechat_pay` PaymentMethod, this sub-hash contains details about the WeChat Pay payment method options. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsWechatPay<'a> { @@ -13367,6 +15240,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsWechatPayClient serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsWechatPayClient { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsWechatPayClient", + ) + }) + } +} /// 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. @@ -13417,6 +15302,16 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsWechatPaySetupF serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentIntentPaymentMethodOptionsWechatPaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsWechatPaySetupFutureUsage")) + } +} /// If this is a `zip` PaymentMethod, this sub-hash contains details about the Zip payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentIntentPaymentMethodOptionsZip { @@ -13486,6 +15381,18 @@ impl serde::Serialize for UpdatePaymentIntentPaymentMethodOptionsZipSetupFutureU serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentIntentPaymentMethodOptionsZipSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentIntentPaymentMethodOptionsZipSetupFutureUsage", + ) + }) + } +} /// Shipping information for this PaymentIntent. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdatePaymentIntentShipping<'a> { @@ -13658,6 +15565,16 @@ impl serde::Serialize for CancelPaymentIntentCancellationReason { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CancelPaymentIntentCancellationReason { + fn deserialize>(deserializer: D) -> 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 CancelPaymentIntentCancellationReason") + }) + } +} 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`. /// @@ -13745,7 +15662,7 @@ impl<'a> CapturePaymentIntent<'a> { ) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(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")] @@ -13812,13 +15729,13 @@ impl<'a> ConfirmPaymentIntent<'a> { Self::default() } } -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] #[serde(untagged)] pub enum ConfirmPaymentIntentMandateData<'a> { SecretKeyParam(ConfirmPaymentIntentSecretKeyParam<'a>), ClientKeyParam(ConfirmPaymentIntentClientKeyParam<'a>), } -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] pub struct ConfirmPaymentIntentSecretKeyParam<'a> { /// This hash contains details about the customer acceptance of the Mandate. pub customer_acceptance: ConfirmPaymentIntentSecretKeyParamCustomerAcceptance<'a>, @@ -13831,14 +15748,15 @@ impl<'a> ConfirmPaymentIntentSecretKeyParam<'a> { } } /// This hash contains details about the customer acceptance of the Mandate. -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] pub struct ConfirmPaymentIntentSecretKeyParamCustomerAcceptance<'a> { /// The time at which the customer accepted the Mandate. #[serde(skip_serializing_if = "Option::is_none")] pub accepted_at: Option, /// If this is a Mandate accepted offline, this hash contains details about the offline acceptance. #[serde(skip_serializing_if = "Option::is_none")] - pub offline: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub offline: Option, /// If this is a Mandate accepted online, this hash contains details about the online acceptance. #[serde(skip_serializing_if = "Option::is_none")] pub online: Option>, @@ -13899,6 +15817,18 @@ impl serde::Serialize for ConfirmPaymentIntentSecretKeyParamCustomerAcceptanceTy serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentSecretKeyParamCustomerAcceptanceType { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentSecretKeyParamCustomerAcceptanceType", + ) + }) + } +} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct ConfirmPaymentIntentClientKeyParam<'a> { /// This hash contains details about the customer acceptance of the Mandate. @@ -13986,6 +15916,18 @@ impl serde::Serialize for ConfirmPaymentIntentClientKeyParamCustomerAcceptanceTy serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentClientKeyParamCustomerAcceptanceType { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentClientKeyParamCustomerAcceptanceType", + ) + }) + } +} /// Set to `true` to indicate that the customer isn't in your checkout flow during this payment attempt and can't authenticate. /// Use this parameter in scenarios where you collect card details and [charge them later](https://stripe.com/docs/payments/cards/charging-saved-cards). #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -13998,20 +15940,23 @@ pub enum ConfirmPaymentIntentOffSession { /// If provided, this hash will be used to create a PaymentMethod. The new PaymentMethod will appear /// in the [payment_method](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-payment_method). /// property on the PaymentIntent. -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodData<'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")] pub acss_debit: Option>, /// If this is an `affirm` PaymentMethod, this hash contains details about the Affirm payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub affirm: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub affirm: Option, /// If this is an `AfterpayClearpay` PaymentMethod, this hash contains details about the AfterpayClearpay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub afterpay_clearpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub afterpay_clearpay: Option, /// If this is an `Alipay` PaymentMethod, this hash contains details about the Alipay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub alipay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub alipay: Option, /// If this is an `au_becs_debit` PaymentMethod, this hash contains details about the bank account. #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option>, @@ -14020,22 +15965,26 @@ pub struct ConfirmPaymentIntentPaymentMethodData<'a> { pub bacs_debit: Option>, /// If this is a `bancontact` PaymentMethod, this hash contains details about the Bancontact payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub bancontact: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub bancontact: Option, /// 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>, /// If this is a `blik` PaymentMethod, this hash contains details about the BLIK payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub blik: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub blik: Option, /// If this is a `boleto` PaymentMethod, this hash contains details about the Boleto payment method. #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option>, /// If this is a `cashapp` PaymentMethod, this hash contains details about the Cash App Pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub cashapp: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub cashapp: Option, /// If this is a `customer_balance` PaymentMethod, this hash contains details about the CustomerBalance payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub customer_balance: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub customer_balance: Option, /// If this is an `eps` PaymentMethod, this hash contains details about the EPS payment method. #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option, @@ -14044,25 +15993,30 @@ pub struct ConfirmPaymentIntentPaymentMethodData<'a> { pub fpx: Option, /// If this is a `giropay` PaymentMethod, this hash contains details about the Giropay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub giropay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub giropay: Option, /// If this is a `grabpay` PaymentMethod, this hash contains details about the GrabPay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub grabpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub grabpay: Option, /// If this is an `ideal` PaymentMethod, this hash contains details about the iDEAL payment method. #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option, /// If this is an `interac_present` PaymentMethod, this hash contains details about the Interac Present payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub interac_present: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub interac_present: Option, /// If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method. #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option, /// If this is a `konbini` PaymentMethod, this hash contains details about the Konbini payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub konbini: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub konbini: Option, /// If this is an `Link` PaymentMethod, this hash contains details about the Link payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub link: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub link: Option, /// 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. @@ -14071,29 +16025,35 @@ pub struct ConfirmPaymentIntentPaymentMethodData<'a> { pub metadata: Option<&'a std::collections::HashMap>, /// If this is an `oxxo` PaymentMethod, this hash contains details about the OXXO payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub oxxo: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub oxxo: Option, /// If this is a `p24` PaymentMethod, this hash contains details about the P24 payment method. #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option, /// If this is a `paynow` PaymentMethod, this hash contains details about the PayNow payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub paynow: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub paynow: Option, /// If this is a `paypal` PaymentMethod, this hash contains details about the PayPal payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub paypal: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub paypal: Option, /// If this is a `pix` PaymentMethod, this hash contains details about the Pix payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub pix: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub pix: Option, /// If this is a `promptpay` PaymentMethod, this hash contains details about the PromptPay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub promptpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub promptpay: Option, /// Options to configure Radar. /// See [Radar Session](https://stripe.com/docs/radar/radar-session) for more information. #[serde(skip_serializing_if = "Option::is_none")] pub radar_options: Option>, /// If this is a `Revolut Pay` PaymentMethod, this hash contains details about the Revolut Pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub revolut_pay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub revolut_pay: Option, /// If this is a `sepa_debit` PaymentMethod, this hash contains details about the SEPA debit bank account. #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option>, @@ -14102,7 +16062,8 @@ pub struct ConfirmPaymentIntentPaymentMethodData<'a> { pub sofort: Option, /// 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>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub swish: Option, /// 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. @@ -14113,10 +16074,12 @@ pub struct ConfirmPaymentIntentPaymentMethodData<'a> { pub us_bank_account: Option>, /// If this is an `wechat_pay` PaymentMethod, this hash contains details about the wechat_pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub wechat_pay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub wechat_pay: Option, /// If this is a `zip` PaymentMethod, this hash contains details about the Zip payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub zip: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub zip: Option, } impl<'a> ConfirmPaymentIntentPaymentMethodData<'a> { pub fn new(type_: ConfirmPaymentIntentPaymentMethodDataType) -> Self { @@ -14388,6 +16351,14 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodDataEpsBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodDataEpsBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is an `fpx` PaymentMethod, this hash contains details about the FPX payment method. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodDataFpx { @@ -14448,6 +16419,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodDataFpxAccountHolderT serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodDataFpxAccountHolderType { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodDataFpxAccountHolderType", + ) + }) + } +} /// The customer's bank. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -14558,6 +16541,14 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodDataFpxBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodDataFpxBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is an `ideal` PaymentMethod, this hash contains details about the iDEAL payment method. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodDataIdeal { @@ -14662,6 +16653,14 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodDataIdealBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodDataIdealBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodDataKlarna { @@ -14808,6 +16807,14 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodDataP24Bank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodDataP24Bank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Options to configure Radar. /// See [Radar Session](https://stripe.com/docs/radar/radar-session) for more information. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -14901,6 +16908,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodDataSofortCountry { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodDataSofortCountry { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodDataSofortCountry", + ) + }) + } +} /// 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. @@ -15043,6 +17062,14 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodDataType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodDataType { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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 ConfirmPaymentIntentPaymentMethodDataUsBankAccount<'a> { @@ -15114,6 +17141,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodDataUsBankAccountAcco serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodDataUsBankAccountAccountHolderType +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodDataUsBankAccountAccountHolderType")) + } +} /// Account type: checkings or savings. Defaults to checking if omitted. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodDataUsBankAccountAccountType { @@ -15160,8 +17197,22 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodDataUsBankAccountAcco serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodDataUsBankAccountAccountType +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodDataUsBankAccountAccountType", + ) + }) + } +} /// Payment method-specific configuration for this PaymentIntent. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptions<'a> { /// If this is a `acss_debit` PaymentMethod, this sub-hash contains details about the ACSS Debit payment method options. #[serde(skip_serializing_if = "Option::is_none")] @@ -15219,7 +17270,8 @@ pub struct ConfirmPaymentIntentPaymentMethodOptions<'a> { pub ideal: Option, /// If this is a `interac_present` PaymentMethod, this sub-hash contains details about the Card Present payment method options. #[serde(skip_serializing_if = "Option::is_none")] - pub interac_present: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub interac_present: Option, /// If this is a `klarna` PaymentMethod, this sub-hash contains details about the Klarna payment method options. #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option, @@ -15252,7 +17304,7 @@ pub struct ConfirmPaymentIntentPaymentMethodOptions<'a> { pub revolut_pay: Option, /// If this is a `sepa_debit` PaymentIntent, this sub-hash contains details about the SEPA Debit payment method options. #[serde(skip_serializing_if = "Option::is_none")] - pub sepa_debit: Option>, + pub sepa_debit: Option, /// 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, @@ -15385,6 +17437,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule")) + } +} /// Transaction type of the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { @@ -15439,6 +17501,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType")) + } +} /// 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. @@ -15495,6 +17567,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitSetup serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage")) + } +} /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod { @@ -15544,6 +17626,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitVerif serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod")) + } +} /// If this is an `affirm` PaymentMethod, this sub-hash contains details about the Affirm payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsAffirm<'a> { @@ -15620,6 +17712,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsAffirmCaptureM serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodOptionsAffirmCaptureMethod { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsAffirmCaptureMethod", + ) + }) + } +} /// 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. @@ -15670,6 +17774,20 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsAffirmSetupFut serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsAffirmSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsAffirmSetupFutureUsage", + ) + }) + } +} /// If this is a `afterpay_clearpay` PaymentMethod, this sub-hash contains details about the Afterpay Clearpay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearpay<'a> { @@ -15750,6 +17868,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearp serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearpayCaptureMethod +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearpayCaptureMethod")) + } +} /// 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. @@ -15804,6 +17932,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearp serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearpaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsAfterpayClearpaySetupFutureUsage")) + } +} /// If this is a `alipay` PaymentMethod, this sub-hash contains details about the Alipay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsAlipay { @@ -15876,6 +18014,20 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsAlipaySetupFut serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsAlipaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsAlipaySetupFutureUsage", + ) + }) + } +} /// If this is a `au_becs_debit` PaymentMethod, this sub-hash contains details about the AU BECS Direct Debit payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsAuBecsDebit { @@ -15952,6 +18104,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsAuBecsDebitSet serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage")) + } +} /// If this is a `bacs_debit` PaymentMethod, this sub-hash contains details about the BACS Debit payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsBacsDebit { @@ -16028,6 +18190,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsBacsDebitSetup serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsBacsDebitSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsBacsDebitSetupFutureUsage")) + } +} /// If this is a `bancontact` PaymentMethod, this sub-hash contains details about the Bancontact payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsBancontact { @@ -16104,6 +18276,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsBancontactPref serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsBancontactPreferredLanguage +{ + fn deserialize>(deserializer: D) -> 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 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. @@ -16157,6 +18339,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsBancontactSetu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsBancontactSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsBancontactSetupFutureUsage")) + } +} /// 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 ConfirmPaymentIntentPaymentMethodOptionsBlik<'a> { @@ -16230,6 +18422,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsBlikSetupFutur serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsBlikSetupFutureUsage", + ) + }) + } +} /// 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 { @@ -16309,6 +18513,20 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFut serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsBoletoSetupFutureUsage", + ) + }) + } +} /// Configuration for any card payments attempted on this PaymentIntent. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsCard<'a> { @@ -16447,6 +18665,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardCaptureMet serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodOptionsCardCaptureMethod { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCardCaptureMethod", + ) + }) + } +} /// Installment configuration for payments attempted on this PaymentIntent (Mexico Only). /// /// For more information, see the [installments integration guide](https://stripe.com/docs/payments/installments). @@ -16533,6 +18763,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardInstallmen serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCardInstallmentsPlanInterval +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCardInstallmentsPlanInterval")) + } +} /// Type of installment plan, one of `fixed_count`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsCardInstallmentsPlanType { @@ -16576,6 +18816,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardInstallmen serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCardInstallmentsPlanType +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCardInstallmentsPlanType")) + } +} /// Configuration options for setting up an eMandate for cards issued in India. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptions<'a> { @@ -16679,6 +18929,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardMandateOpt serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptionsAmountType +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptionsAmountType")) + } +} /// Specifies payment frequency. One of `day`, `week`, `month`, `year`, or `sporadic`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptionsInterval { @@ -16734,6 +18994,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardMandateOpt serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptionsInterval +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptionsInterval")) + } +} /// Specifies the type of mandates supported. Possible values are `india`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes { @@ -16781,6 +19051,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardMandateOpt serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes")) + } +} /// Selected network to process this PaymentIntent on. /// Depends on the available networks of the card attached to the PaymentIntent. /// Can be only set confirm-time. @@ -16856,6 +19136,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardNetwork { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodOptionsCardNetwork { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCardNetwork", + ) + }) + } +} /// 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 ConfirmPaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization { @@ -16906,6 +19198,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardRequestExt serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization")) + } +} /// Request ability to [increment the authorization](https://stripe.com/docs/payments/incremental-authorization) for this PaymentIntent. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { @@ -16960,6 +19262,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization")) + } +} /// Request ability to make [multiple captures](https://stripe.com/docs/payments/multicapture) for this PaymentIntent. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsCardRequestMulticapture { @@ -17006,6 +19318,20 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardRequestMul serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCardRequestMulticapture +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCardRequestMulticapture", + ) + }) + } +} /// Request ability to [overcapture](https://stripe.com/docs/payments/overcapture) for this PaymentIntent. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsCardRequestOvercapture { @@ -17052,6 +19378,20 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardRequestOve serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCardRequestOvercapture +{ + fn deserialize>(deserializer: D) -> 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 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`. @@ -17104,6 +19444,20 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardRequestThr serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCardRequestThreeDSecure +{ + fn deserialize>(deserializer: D) -> 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 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. @@ -17160,6 +19514,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardSetupFutur serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodOptionsCardSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCardSetupFutureUsage", + ) + }) + } +} /// 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)] @@ -17277,6 +19643,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus")) + } +} /// 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)] @@ -17341,6 +19717,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator")) + } +} /// The exemption requested via 3DS and accepted by the issuer at authentication time. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator { @@ -17395,6 +19781,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureExemptionIndicator +{ + fn deserialize>(deserializer: D) -> 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 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 @@ -17496,6 +19892,14 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo")) + } +} /// The version of 3D Secure that was performed. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureVersion { @@ -17545,6 +19949,20 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureVersion +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCardThreeDSecureVersion", + ) + }) + } +} /// 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 { @@ -17618,6 +20036,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCashappCapture serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodOptionsCashappCaptureMethod { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCashappCaptureMethod", + ) + }) + } +} /// 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. @@ -17674,6 +20104,20 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCashappSetupFu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCashappSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCashappSetupFutureUsage", + ) + }) + } +} /// 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 ConfirmPaymentIntentPaymentMethodOptionsCustomerBalance<'a> { @@ -17798,6 +20242,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes +{ + fn deserialize>(deserializer: D) -> 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 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`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType { @@ -17853,6 +20307,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanc serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceBankTransferType")) + } +} /// 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)] @@ -17897,6 +20361,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanc serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceFundingType +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceFundingType")) + } +} /// 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. @@ -17947,6 +20421,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanc serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsCustomerBalanceSetupFutureUsage")) + } +} /// If this is a `eps` PaymentMethod, this sub-hash contains details about the EPS payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsEps { @@ -18016,6 +20500,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsEpsSetupFuture serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodOptionsEpsSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsEpsSetupFutureUsage", + ) + }) + } +} /// If this is a `fpx` PaymentMethod, this sub-hash contains details about the FPX payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsFpx { @@ -18085,6 +20581,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsFpxSetupFuture serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodOptionsFpxSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsFpxSetupFutureUsage", + ) + }) + } +} /// If this is a `giropay` PaymentMethod, this sub-hash contains details about the Giropay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsGiropay { @@ -18154,6 +20662,20 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsGiropaySetupFu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsGiropaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsGiropaySetupFutureUsage", + ) + }) + } +} /// If this is a `grabpay` PaymentMethod, this sub-hash contains details about the Grabpay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsGrabpay { @@ -18223,6 +20745,20 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsGrabpaySetupFu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsGrabpaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsGrabpaySetupFutureUsage", + ) + }) + } +} /// If this is a `ideal` PaymentMethod, this sub-hash contains details about the Ideal payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsIdeal { @@ -18295,6 +20831,20 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsIdealSetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsIdealSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsIdealSetupFutureUsage", + ) + }) + } +} /// If this is a `klarna` PaymentMethod, this sub-hash contains details about the Klarna payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsKlarna { @@ -18371,6 +20921,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsKlarnaCaptureM serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodOptionsKlarnaCaptureMethod { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsKlarnaCaptureMethod", + ) + }) + } +} /// Preferred language of the Klarna authorization page that the customer is redirected to #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -18547,6 +21109,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsKlarnaPreferre serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsKlarnaPreferredLocale +{ + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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. @@ -18597,6 +21169,20 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsKlarnaSetupFut serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsKlarnaSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsKlarnaSetupFutureUsage", + ) + }) + } +} /// If this is a `konbini` PaymentMethod, this sub-hash contains details about the Konbini payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsKonbini<'a> { @@ -18683,6 +21269,20 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsKonbiniSetupFu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsKonbiniSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsKonbiniSetupFutureUsage", + ) + }) + } +} /// If this is a `link` PaymentMethod, this sub-hash contains details about the Link payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsLink<'a> { @@ -18759,6 +21359,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsLinkCaptureMet serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodOptionsLinkCaptureMethod { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsLinkCaptureMethod", + ) + }) + } +} /// 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. @@ -18812,6 +21424,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsLinkSetupFutur serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodOptionsLinkSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsLinkSetupFutureUsage", + ) + }) + } +} /// If this is a `oxxo` PaymentMethod, this sub-hash contains details about the OXXO payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsOxxo { @@ -18885,6 +21509,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsOxxoSetupFutur serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodOptionsOxxoSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsOxxoSetupFutureUsage", + ) + }) + } +} /// If this is a `p24` PaymentMethod, this sub-hash contains details about the Przelewy24 payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsP24 { @@ -18957,6 +21593,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsP24SetupFuture serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodOptionsP24SetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsP24SetupFutureUsage", + ) + }) + } +} /// If this is a `paynow` PaymentMethod, this sub-hash contains details about the PayNow payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsPaynow { @@ -19026,6 +21674,20 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsPaynowSetupFut serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsPaynowSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsPaynowSetupFutureUsage", + ) + }) + } +} /// If this is a `paypal` PaymentMethod, this sub-hash contains details about the PayPal payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsPaypal<'a> { @@ -19101,6 +21763,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsPaypalCaptureM serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodOptionsPaypalCaptureMethod { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsPaypalCaptureMethod", + ) + }) + } +} /// [Preferred locale](https://stripe.com/docs/payments/paypal/supported-locales) of the PayPal checkout page that the customer is redirected to. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -19208,6 +21882,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsPaypalPreferre serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsPaypalPreferredLocale +{ + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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. @@ -19261,6 +21945,20 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsPaypalSetupFut serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsPaypalSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsPaypalSetupFutureUsage", + ) + }) + } +} /// If this is a `pix` PaymentMethod, this sub-hash contains details about the Pix payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsPix { @@ -19338,6 +22036,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsPixSetupFuture serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodOptionsPixSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsPixSetupFutureUsage", + ) + }) + } +} /// If this is a `promptpay` PaymentMethod, this sub-hash contains details about the PromptPay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsPromptpay { @@ -19408,6 +22118,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsPromptpaySetup serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsPromptpaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsPromptpaySetupFutureUsage")) + } +} /// If this is a `revolut_pay` PaymentMethod, this sub-hash contains details about the Revolut Pay payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsRevolutPay { @@ -19477,12 +22197,23 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsRevolutPaySetu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsRevolutPaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsRevolutPaySetupFutureUsage")) + } +} /// If this is a `sepa_debit` PaymentIntent, this sub-hash contains details about the SEPA Debit payment method options. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ConfirmPaymentIntentPaymentMethodOptionsSepaDebit<'a> { +#[derive(Clone, Debug, Default, serde::Serialize)] +pub struct ConfirmPaymentIntentPaymentMethodOptionsSepaDebit { /// Additional fields for Mandate creation #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub mandate_options: Option, /// 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. @@ -19495,7 +22226,7 @@ pub struct ConfirmPaymentIntentPaymentMethodOptionsSepaDebit<'a> { pub setup_future_usage: Option, } -impl<'a> ConfirmPaymentIntentPaymentMethodOptionsSepaDebit<'a> { +impl ConfirmPaymentIntentPaymentMethodOptionsSepaDebit { pub fn new() -> Self { Self::default() } @@ -19556,6 +22287,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsSepaDebitSetup serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage")) + } +} /// If this is a `sofort` PaymentMethod, this sub-hash contains details about the SOFORT payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsSofort { @@ -19639,6 +22380,20 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsSofortPreferre serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsSofortPreferredLanguage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsSofortPreferredLanguage", + ) + }) + } +} /// 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. @@ -19692,6 +22447,20 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsSofortSetupFut serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsSofortSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsSofortSetupFutureUsage", + ) + }) + } +} /// 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> { @@ -19764,6 +22533,20 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsSwishSetupFutu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsSwishSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsSwishSetupFutureUsage", + ) + }) + } +} /// 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> { @@ -19887,6 +22670,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions")) + } +} /// List of data features that you would like to retrieve upon account creation. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { @@ -19941,6 +22734,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch")) + } +} /// Additional fields for Mandate creation #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountMandateOptions { @@ -20005,6 +22808,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod")) + } +} /// Additional fields for network related functions #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { @@ -20064,6 +22877,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountN serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountNetworksRequested")) + } +} /// Preferred transaction settlement speed #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { @@ -20118,6 +22941,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed +{ + fn deserialize>(deserializer: D) -> 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 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. @@ -20174,6 +23007,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountS serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage")) + } +} /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod { @@ -20223,6 +23066,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountV serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod")) + } +} /// If this is a `wechat_pay` PaymentMethod, this sub-hash contains details about the WeChat Pay payment method options. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsWechatPay<'a> { @@ -20297,6 +23150,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsWechatPayClien serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodOptionsWechatPayClient { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsWechatPayClient", + ) + }) + } +} /// 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. @@ -20347,6 +23212,16 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsWechatPaySetup serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmPaymentIntentPaymentMethodOptionsWechatPaySetupFutureUsage +{ + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsWechatPaySetupFutureUsage")) + } +} /// If this is a `zip` PaymentMethod, this sub-hash contains details about the Zip payment method options. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmPaymentIntentPaymentMethodOptionsZip { @@ -20416,6 +23291,18 @@ impl serde::Serialize for ConfirmPaymentIntentPaymentMethodOptionsZipSetupFuture serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmPaymentIntentPaymentMethodOptionsZipSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 ConfirmPaymentIntentPaymentMethodOptionsZipSetupFutureUsage", + ) + }) + } +} /// Options to configure Radar. /// Learn more about [Radar Sessions](https://stripe.com/docs/radar/radar-session). #[derive(Copy, Clone, Debug, Default, serde::Serialize)] diff --git a/generated/stripe_core/src/payout/requests.rs b/generated/stripe_core/src/payout/requests.rs index 48cad35dd..c1ecd08c0 100644 --- a/generated/stripe_core/src/payout/requests.rs +++ b/generated/stripe_core/src/payout/requests.rs @@ -173,6 +173,15 @@ impl serde::Serialize for CreatePayoutMethod { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePayoutMethod { + fn deserialize>(deserializer: D) -> 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 CreatePayoutMethod")) + } +} /// The balance type of your Stripe balance to draw this payout from. /// Balances for different payment sources are kept separately. /// You can find the amounts with the Balances API. @@ -225,6 +234,15 @@ impl serde::Serialize for CreatePayoutSourceType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePayoutSourceType { + fn deserialize>(deserializer: D) -> 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 CreatePayoutSourceType")) + } +} impl<'a> CreatePayout<'a> { /// To send funds to your own bank account, create a new payout object. /// Your [Stripe balance](https://stripe.com/docs/api#balance) must cover the payout amount. diff --git a/generated/stripe_core/src/refund/requests.rs b/generated/stripe_core/src/refund/requests.rs index da81c81d0..3068770ed 100644 --- a/generated/stripe_core/src/refund/requests.rs +++ b/generated/stripe_core/src/refund/requests.rs @@ -163,6 +163,15 @@ impl serde::Serialize for CreateRefundOrigin { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateRefundOrigin { + fn deserialize>(deserializer: D) -> 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 CreateRefundOrigin")) + } +} /// String indicating the reason for the refund. /// If set, possible values are `duplicate`, `fraudulent`, and `requested_by_customer`. /// If you believe the charge to be fraudulent, specifying `fraudulent` as the reason will add the associated card and email to your [block lists](https://stripe.com/docs/radar/lists), and will also help us improve our fraud detection algorithms. @@ -214,6 +223,15 @@ impl serde::Serialize for CreateRefundReason { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateRefundReason { + fn deserialize>(deserializer: D) -> 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 CreateRefundReason")) + } +} impl<'a> CreateRefund<'a> { /// When you create a new refund, you must specify a Charge or a PaymentIntent object on which to create it. /// diff --git a/generated/stripe_core/src/setup_intent/requests.rs b/generated/stripe_core/src/setup_intent/requests.rs index c1a6a0d16..e84f9ad31 100644 --- a/generated/stripe_core/src/setup_intent/requests.rs +++ b/generated/stripe_core/src/setup_intent/requests.rs @@ -82,7 +82,7 @@ impl<'a> RetrieveSetupIntent<'a> { client.get_query(&format!("/setup_intents/{intent}"), self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(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. /// @@ -234,9 +234,21 @@ impl serde::Serialize for CreateSetupIntentAutomaticPaymentMethodsAllowRedirects serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSetupIntentAutomaticPaymentMethodsAllowRedirects { + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentAutomaticPaymentMethodsAllowRedirects", + ) + }) + } +} /// This hash contains details about the mandate to create. /// This parameter can only be used with [`confirm=true`](https://stripe.com/docs/api/setup_intents/create#create_setup_intent-confirm). -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] pub struct CreateSetupIntentMandateData<'a> { /// This hash contains details about the customer acceptance of the Mandate. pub customer_acceptance: CreateSetupIntentMandateDataCustomerAcceptance<'a>, @@ -247,14 +259,15 @@ impl<'a> CreateSetupIntentMandateData<'a> { } } /// This hash contains details about the customer acceptance of the Mandate. -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] pub struct CreateSetupIntentMandateDataCustomerAcceptance<'a> { /// The time at which the customer accepted the Mandate. #[serde(skip_serializing_if = "Option::is_none")] pub accepted_at: Option, /// If this is a Mandate accepted offline, this hash contains details about the offline acceptance. #[serde(skip_serializing_if = "Option::is_none")] - pub offline: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub offline: Option, /// If this is a Mandate accepted online, this hash contains details about the online acceptance. #[serde(skip_serializing_if = "Option::is_none")] pub online: Option>, @@ -315,22 +328,37 @@ impl serde::Serialize for CreateSetupIntentMandateDataCustomerAcceptanceType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSetupIntentMandateDataCustomerAcceptanceType { + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentMandateDataCustomerAcceptanceType", + ) + }) + } +} /// When included, this hash creates a PaymentMethod that is set as the [`payment_method`](https://stripe.com/docs/api/setup_intents/object#setup_intent_object-payment_method). /// value in the SetupIntent. -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] pub struct CreateSetupIntentPaymentMethodData<'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")] pub acss_debit: Option>, /// If this is an `affirm` PaymentMethod, this hash contains details about the Affirm payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub affirm: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub affirm: Option, /// If this is an `AfterpayClearpay` PaymentMethod, this hash contains details about the AfterpayClearpay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub afterpay_clearpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub afterpay_clearpay: Option, /// If this is an `Alipay` PaymentMethod, this hash contains details about the Alipay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub alipay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub alipay: Option, /// If this is an `au_becs_debit` PaymentMethod, this hash contains details about the bank account. #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option>, @@ -339,22 +367,26 @@ pub struct CreateSetupIntentPaymentMethodData<'a> { pub bacs_debit: Option>, /// If this is a `bancontact` PaymentMethod, this hash contains details about the Bancontact payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub bancontact: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub bancontact: Option, /// 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>, /// If this is a `blik` PaymentMethod, this hash contains details about the BLIK payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub blik: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub blik: Option, /// If this is a `boleto` PaymentMethod, this hash contains details about the Boleto payment method. #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option>, /// If this is a `cashapp` PaymentMethod, this hash contains details about the Cash App Pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub cashapp: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub cashapp: Option, /// If this is a `customer_balance` PaymentMethod, this hash contains details about the CustomerBalance payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub customer_balance: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub customer_balance: Option, /// If this is an `eps` PaymentMethod, this hash contains details about the EPS payment method. #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option, @@ -363,25 +395,30 @@ pub struct CreateSetupIntentPaymentMethodData<'a> { pub fpx: Option, /// If this is a `giropay` PaymentMethod, this hash contains details about the Giropay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub giropay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub giropay: Option, /// If this is a `grabpay` PaymentMethod, this hash contains details about the GrabPay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub grabpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub grabpay: Option, /// If this is an `ideal` PaymentMethod, this hash contains details about the iDEAL payment method. #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option, /// If this is an `interac_present` PaymentMethod, this hash contains details about the Interac Present payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub interac_present: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub interac_present: Option, /// If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method. #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option, /// If this is a `konbini` PaymentMethod, this hash contains details about the Konbini payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub konbini: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub konbini: Option, /// If this is an `Link` PaymentMethod, this hash contains details about the Link payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub link: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub link: Option, /// 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. @@ -390,29 +427,35 @@ pub struct CreateSetupIntentPaymentMethodData<'a> { pub metadata: Option<&'a std::collections::HashMap>, /// If this is an `oxxo` PaymentMethod, this hash contains details about the OXXO payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub oxxo: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub oxxo: Option, /// If this is a `p24` PaymentMethod, this hash contains details about the P24 payment method. #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option, /// If this is a `paynow` PaymentMethod, this hash contains details about the PayNow payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub paynow: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub paynow: Option, /// If this is a `paypal` PaymentMethod, this hash contains details about the PayPal payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub paypal: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub paypal: Option, /// If this is a `pix` PaymentMethod, this hash contains details about the Pix payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub pix: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub pix: Option, /// If this is a `promptpay` PaymentMethod, this hash contains details about the PromptPay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub promptpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub promptpay: Option, /// Options to configure Radar. /// See [Radar Session](https://stripe.com/docs/radar/radar-session) for more information. #[serde(skip_serializing_if = "Option::is_none")] pub radar_options: Option>, /// If this is a `Revolut Pay` PaymentMethod, this hash contains details about the Revolut Pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub revolut_pay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub revolut_pay: Option, /// If this is a `sepa_debit` PaymentMethod, this hash contains details about the SEPA debit bank account. #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option>, @@ -421,7 +464,8 @@ pub struct CreateSetupIntentPaymentMethodData<'a> { pub sofort: Option, /// 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>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub swish: Option, /// 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. @@ -432,10 +476,12 @@ pub struct CreateSetupIntentPaymentMethodData<'a> { pub us_bank_account: Option>, /// If this is an `wechat_pay` PaymentMethod, this hash contains details about the wechat_pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub wechat_pay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub wechat_pay: Option, /// If this is a `zip` PaymentMethod, this hash contains details about the Zip payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub zip: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub zip: Option, } impl<'a> CreateSetupIntentPaymentMethodData<'a> { pub fn new(type_: CreateSetupIntentPaymentMethodDataType) -> Self { @@ -659,6 +705,14 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodDataEpsBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSetupIntentPaymentMethodDataEpsBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is an `fpx` PaymentMethod, this hash contains details about the FPX payment method. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateSetupIntentPaymentMethodDataFpx { @@ -719,6 +773,18 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodDataFpxAccountHolderType serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSetupIntentPaymentMethodDataFpxAccountHolderType { + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodDataFpxAccountHolderType", + ) + }) + } +} /// The customer's bank. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -829,6 +895,14 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodDataFpxBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSetupIntentPaymentMethodDataFpxBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is an `ideal` PaymentMethod, this hash contains details about the iDEAL payment method. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateSetupIntentPaymentMethodDataIdeal { @@ -933,6 +1007,14 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodDataIdealBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSetupIntentPaymentMethodDataIdealBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateSetupIntentPaymentMethodDataKlarna { @@ -1079,6 +1161,14 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodDataP24Bank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSetupIntentPaymentMethodDataP24Bank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is a `sepa_debit` PaymentMethod, this hash contains details about the SEPA debit bank account. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateSetupIntentPaymentMethodDataSepaDebit<'a> { @@ -1159,6 +1249,18 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodDataSofortCountry { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSetupIntentPaymentMethodDataSofortCountry { + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodDataSofortCountry", + ) + }) + } +} /// 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. @@ -1301,6 +1403,14 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodDataType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSetupIntentPaymentMethodDataType { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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 CreateSetupIntentPaymentMethodDataUsBankAccount<'a> { @@ -1372,6 +1482,16 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodDataUsBankAccountAccount serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSetupIntentPaymentMethodDataUsBankAccountAccountHolderType +{ + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodDataUsBankAccountAccountHolderType")) + } +} /// Account type: checkings or savings. Defaults to checking if omitted. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateSetupIntentPaymentMethodDataUsBankAccountAccountType { @@ -1418,8 +1538,20 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodDataUsBankAccountAccount serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSetupIntentPaymentMethodDataUsBankAccountAccountType { + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodDataUsBankAccountAccountType", + ) + }) + } +} /// Payment method-specific configuration for this SetupIntent. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(Clone, Debug, Default, serde::Serialize)] pub struct CreateSetupIntentPaymentMethodOptions<'a> { /// If this is a `acss_debit` SetupIntent, this sub-hash contains details about the ACSS Debit payment method options. #[serde(skip_serializing_if = "Option::is_none")] @@ -1435,7 +1567,7 @@ pub struct CreateSetupIntentPaymentMethodOptions<'a> { pub paypal: Option>, /// If this is a `sepa_debit` SetupIntent, this sub-hash contains details about the SEPA Debit payment method options. #[serde(skip_serializing_if = "Option::is_none")] - pub sepa_debit: Option>, + pub sepa_debit: Option, /// If this is a `us_bank_account` SetupIntent, 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>, @@ -1512,6 +1644,18 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsAcssDebitCurrency serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSetupIntentPaymentMethodOptionsAcssDebitCurrency { + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodOptionsAcssDebitCurrency", + ) + }) + } +} /// Additional fields for Mandate creation #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptions<'a> { @@ -1588,6 +1732,16 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateO serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor +{ + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor")) + } +} /// Payment schedule for the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { @@ -1645,6 +1799,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule +{ + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule")) + } +} /// Transaction type of the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { @@ -1699,6 +1863,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType +{ + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType")) + } +} /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateSetupIntentPaymentMethodOptionsAcssDebitVerificationMethod { @@ -1748,6 +1922,16 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsAcssDebitVerifica serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSetupIntentPaymentMethodOptionsAcssDebitVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodOptionsAcssDebitVerificationMethod")) + } +} /// Configuration for any card setup attempted on this SetupIntent. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateSetupIntentPaymentMethodOptionsCard<'a> { @@ -1890,6 +2074,16 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsCardMandateOption serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSetupIntentPaymentMethodOptionsCardMandateOptionsAmountType +{ + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodOptionsCardMandateOptionsAmountType")) + } +} /// Specifies payment frequency. One of `day`, `week`, `month`, `year`, or `sporadic`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateSetupIntentPaymentMethodOptionsCardMandateOptionsInterval { @@ -1945,6 +2139,20 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsCardMandateOption serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSetupIntentPaymentMethodOptionsCardMandateOptionsInterval +{ + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodOptionsCardMandateOptionsInterval", + ) + }) + } +} /// Specifies the type of mandates supported. Possible values are `india`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateSetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes { @@ -1988,6 +2196,16 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsCardMandateOption serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes +{ + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes")) + } +} /// Selected network to process this SetupIntent on. /// Depends on the available networks of the card attached to the SetupIntent. /// Can be only set confirm-time. @@ -2063,6 +2281,18 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsCardNetwork { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSetupIntentPaymentMethodOptionsCardNetwork { + fn deserialize>(deserializer: D) -> 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 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`. @@ -2115,6 +2345,18 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsCardRequestThreeD serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSetupIntentPaymentMethodOptionsCardRequestThreeDSecure { + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodOptionsCardRequestThreeDSecure", + ) + }) + } +} /// 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)] @@ -2218,6 +2460,16 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureA serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus +{ + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus")) + } +} /// 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)] @@ -2282,6 +2534,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator +{ + fn deserialize>(deserializer: D) -> 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 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 @@ -2393,6 +2655,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo +{ + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo")) + } +} /// The version of 3D Secure that was performed. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { @@ -2442,14 +2714,27 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureV serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion", + ) + }) + } +} /// 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> { +#[derive(Clone, Debug, Default, serde::Serialize)] +pub struct CreateSetupIntentPaymentMethodOptionsSepaDebit { /// Additional fields for Mandate creation #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub mandate_options: Option, } -impl<'a> CreateSetupIntentPaymentMethodOptionsSepaDebit<'a> { +impl CreateSetupIntentPaymentMethodOptionsSepaDebit { pub fn new() -> Self { Self::default() } @@ -2564,6 +2849,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions +{ + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions")) + } +} /// List of data features that you would like to retrieve upon account creation. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { @@ -2618,6 +2913,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch +{ + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch")) + } +} /// Additional fields for Mandate creation #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptions { @@ -2682,6 +2987,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod +{ + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod")) + } +} /// Additional fields for network related functions #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { @@ -2741,6 +3056,16 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsUsBankAccountNetw serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested +{ + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested")) + } +} /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateSetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod { @@ -2790,6 +3115,16 @@ impl serde::Serialize for CreateSetupIntentPaymentMethodOptionsUsBankAccountVeri serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateSetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod")) + } +} /// If you populate this hash, this SetupIntent generates a `single_use` mandate after successful completion. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateSetupIntentSingleUse { @@ -2854,6 +3189,15 @@ impl serde::Serialize for CreateSetupIntentUsage { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSetupIntentUsage { + fn deserialize>(deserializer: D) -> 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 CreateSetupIntentUsage")) + } +} impl<'a> CreateSetupIntent<'a> { /// Creates a SetupIntent object. /// @@ -2863,7 +3207,7 @@ impl<'a> CreateSetupIntent<'a> { client.send_form("/setup_intents", self, http_types::Method::Post) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(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. /// @@ -2921,20 +3265,23 @@ impl<'a> UpdateSetupIntent<'a> { } /// When included, this hash creates a PaymentMethod that is set as the [`payment_method`](https://stripe.com/docs/api/setup_intents/object#setup_intent_object-payment_method). /// value in the SetupIntent. -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] pub struct UpdateSetupIntentPaymentMethodData<'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")] pub acss_debit: Option>, /// If this is an `affirm` PaymentMethod, this hash contains details about the Affirm payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub affirm: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub affirm: Option, /// If this is an `AfterpayClearpay` PaymentMethod, this hash contains details about the AfterpayClearpay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub afterpay_clearpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub afterpay_clearpay: Option, /// If this is an `Alipay` PaymentMethod, this hash contains details about the Alipay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub alipay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub alipay: Option, /// If this is an `au_becs_debit` PaymentMethod, this hash contains details about the bank account. #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option>, @@ -2943,22 +3290,26 @@ pub struct UpdateSetupIntentPaymentMethodData<'a> { pub bacs_debit: Option>, /// If this is a `bancontact` PaymentMethod, this hash contains details about the Bancontact payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub bancontact: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub bancontact: Option, /// 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>, /// If this is a `blik` PaymentMethod, this hash contains details about the BLIK payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub blik: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub blik: Option, /// If this is a `boleto` PaymentMethod, this hash contains details about the Boleto payment method. #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option>, /// If this is a `cashapp` PaymentMethod, this hash contains details about the Cash App Pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub cashapp: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub cashapp: Option, /// If this is a `customer_balance` PaymentMethod, this hash contains details about the CustomerBalance payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub customer_balance: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub customer_balance: Option, /// If this is an `eps` PaymentMethod, this hash contains details about the EPS payment method. #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option, @@ -2967,25 +3318,30 @@ pub struct UpdateSetupIntentPaymentMethodData<'a> { pub fpx: Option, /// If this is a `giropay` PaymentMethod, this hash contains details about the Giropay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub giropay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub giropay: Option, /// If this is a `grabpay` PaymentMethod, this hash contains details about the GrabPay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub grabpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub grabpay: Option, /// If this is an `ideal` PaymentMethod, this hash contains details about the iDEAL payment method. #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option, /// If this is an `interac_present` PaymentMethod, this hash contains details about the Interac Present payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub interac_present: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub interac_present: Option, /// If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method. #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option, /// If this is a `konbini` PaymentMethod, this hash contains details about the Konbini payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub konbini: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub konbini: Option, /// If this is an `Link` PaymentMethod, this hash contains details about the Link payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub link: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub link: Option, /// 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. @@ -2994,29 +3350,35 @@ pub struct UpdateSetupIntentPaymentMethodData<'a> { pub metadata: Option<&'a std::collections::HashMap>, /// If this is an `oxxo` PaymentMethod, this hash contains details about the OXXO payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub oxxo: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub oxxo: Option, /// If this is a `p24` PaymentMethod, this hash contains details about the P24 payment method. #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option, /// If this is a `paynow` PaymentMethod, this hash contains details about the PayNow payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub paynow: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub paynow: Option, /// If this is a `paypal` PaymentMethod, this hash contains details about the PayPal payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub paypal: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub paypal: Option, /// If this is a `pix` PaymentMethod, this hash contains details about the Pix payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub pix: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub pix: Option, /// If this is a `promptpay` PaymentMethod, this hash contains details about the PromptPay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub promptpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub promptpay: Option, /// Options to configure Radar. /// See [Radar Session](https://stripe.com/docs/radar/radar-session) for more information. #[serde(skip_serializing_if = "Option::is_none")] pub radar_options: Option>, /// If this is a `Revolut Pay` PaymentMethod, this hash contains details about the Revolut Pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub revolut_pay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub revolut_pay: Option, /// If this is a `sepa_debit` PaymentMethod, this hash contains details about the SEPA debit bank account. #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option>, @@ -3025,7 +3387,8 @@ pub struct UpdateSetupIntentPaymentMethodData<'a> { pub sofort: Option, /// 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>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub swish: Option, /// 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. @@ -3036,10 +3399,12 @@ pub struct UpdateSetupIntentPaymentMethodData<'a> { pub us_bank_account: Option>, /// If this is an `wechat_pay` PaymentMethod, this hash contains details about the wechat_pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub wechat_pay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub wechat_pay: Option, /// If this is a `zip` PaymentMethod, this hash contains details about the Zip payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub zip: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub zip: Option, } impl<'a> UpdateSetupIntentPaymentMethodData<'a> { pub fn new(type_: UpdateSetupIntentPaymentMethodDataType) -> Self { @@ -3263,6 +3628,14 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodDataEpsBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSetupIntentPaymentMethodDataEpsBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is an `fpx` PaymentMethod, this hash contains details about the FPX payment method. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdateSetupIntentPaymentMethodDataFpx { @@ -3323,6 +3696,18 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodDataFpxAccountHolderType serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSetupIntentPaymentMethodDataFpxAccountHolderType { + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodDataFpxAccountHolderType", + ) + }) + } +} /// The customer's bank. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -3433,6 +3818,14 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodDataFpxBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSetupIntentPaymentMethodDataFpxBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is an `ideal` PaymentMethod, this hash contains details about the iDEAL payment method. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateSetupIntentPaymentMethodDataIdeal { @@ -3537,6 +3930,14 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodDataIdealBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSetupIntentPaymentMethodDataIdealBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateSetupIntentPaymentMethodDataKlarna { @@ -3683,6 +4084,14 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodDataP24Bank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSetupIntentPaymentMethodDataP24Bank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is a `sepa_debit` PaymentMethod, this hash contains details about the SEPA debit bank account. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdateSetupIntentPaymentMethodDataSepaDebit<'a> { @@ -3763,6 +4172,18 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodDataSofortCountry { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSetupIntentPaymentMethodDataSofortCountry { + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodDataSofortCountry", + ) + }) + } +} /// 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. @@ -3905,6 +4326,14 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodDataType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSetupIntentPaymentMethodDataType { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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 UpdateSetupIntentPaymentMethodDataUsBankAccount<'a> { @@ -3976,6 +4405,16 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodDataUsBankAccountAccount serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSetupIntentPaymentMethodDataUsBankAccountAccountHolderType +{ + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodDataUsBankAccountAccountHolderType")) + } +} /// Account type: checkings or savings. Defaults to checking if omitted. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateSetupIntentPaymentMethodDataUsBankAccountAccountType { @@ -4022,8 +4461,20 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodDataUsBankAccountAccount serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSetupIntentPaymentMethodDataUsBankAccountAccountType { + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodDataUsBankAccountAccountType", + ) + }) + } +} /// Payment method-specific configuration for this SetupIntent. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(Clone, Debug, Default, serde::Serialize)] pub struct UpdateSetupIntentPaymentMethodOptions<'a> { /// If this is a `acss_debit` SetupIntent, this sub-hash contains details about the ACSS Debit payment method options. #[serde(skip_serializing_if = "Option::is_none")] @@ -4039,7 +4490,7 @@ pub struct UpdateSetupIntentPaymentMethodOptions<'a> { pub paypal: Option>, /// If this is a `sepa_debit` SetupIntent, this sub-hash contains details about the SEPA Debit payment method options. #[serde(skip_serializing_if = "Option::is_none")] - pub sepa_debit: Option>, + pub sepa_debit: Option, /// If this is a `us_bank_account` SetupIntent, 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>, @@ -4116,6 +4567,18 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsAcssDebitCurrency serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSetupIntentPaymentMethodOptionsAcssDebitCurrency { + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodOptionsAcssDebitCurrency", + ) + }) + } +} /// Additional fields for Mandate creation #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptions<'a> { @@ -4192,6 +4655,16 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateO serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor +{ + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor")) + } +} /// Payment schedule for the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { @@ -4249,6 +4722,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule +{ + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule")) + } +} /// Transaction type of the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { @@ -4303,6 +4786,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType +{ + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType")) + } +} /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateSetupIntentPaymentMethodOptionsAcssDebitVerificationMethod { @@ -4352,6 +4845,16 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsAcssDebitVerifica serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSetupIntentPaymentMethodOptionsAcssDebitVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodOptionsAcssDebitVerificationMethod")) + } +} /// Configuration for any card setup attempted on this SetupIntent. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateSetupIntentPaymentMethodOptionsCard<'a> { @@ -4494,6 +4997,16 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsCardMandateOption serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSetupIntentPaymentMethodOptionsCardMandateOptionsAmountType +{ + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodOptionsCardMandateOptionsAmountType")) + } +} /// Specifies payment frequency. One of `day`, `week`, `month`, `year`, or `sporadic`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateSetupIntentPaymentMethodOptionsCardMandateOptionsInterval { @@ -4549,6 +5062,20 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsCardMandateOption serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSetupIntentPaymentMethodOptionsCardMandateOptionsInterval +{ + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodOptionsCardMandateOptionsInterval", + ) + }) + } +} /// Specifies the type of mandates supported. Possible values are `india`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateSetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes { @@ -4592,6 +5119,16 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsCardMandateOption serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes +{ + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes")) + } +} /// Selected network to process this SetupIntent on. /// Depends on the available networks of the card attached to the SetupIntent. /// Can be only set confirm-time. @@ -4667,6 +5204,18 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsCardNetwork { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSetupIntentPaymentMethodOptionsCardNetwork { + fn deserialize>(deserializer: D) -> 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 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`. @@ -4719,6 +5268,18 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsCardRequestThreeD serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSetupIntentPaymentMethodOptionsCardRequestThreeDSecure { + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodOptionsCardRequestThreeDSecure", + ) + }) + } +} /// 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)] @@ -4822,6 +5383,16 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureA serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus +{ + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus")) + } +} /// 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)] @@ -4886,6 +5457,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator +{ + fn deserialize>(deserializer: D) -> 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 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 @@ -4997,6 +5578,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo +{ + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo")) + } +} /// The version of 3D Secure that was performed. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { @@ -5046,14 +5637,27 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureV serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodOptionsCardThreeDSecureVersion", + ) + }) + } +} /// 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> { +#[derive(Clone, Debug, Default, serde::Serialize)] +pub struct UpdateSetupIntentPaymentMethodOptionsSepaDebit { /// Additional fields for Mandate creation #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub mandate_options: Option, } -impl<'a> UpdateSetupIntentPaymentMethodOptionsSepaDebit<'a> { +impl UpdateSetupIntentPaymentMethodOptionsSepaDebit { pub fn new() -> Self { Self::default() } @@ -5168,6 +5772,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions +{ + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions")) + } +} /// List of data features that you would like to retrieve upon account creation. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { @@ -5222,6 +5836,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch +{ + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch")) + } +} /// Additional fields for Mandate creation #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptions { @@ -5286,6 +5910,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod +{ + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod")) + } +} /// Additional fields for network related functions #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateSetupIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { @@ -5345,6 +5979,16 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsUsBankAccountNetw serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested +{ + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested")) + } +} /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateSetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod { @@ -5394,6 +6038,16 @@ impl serde::Serialize for UpdateSetupIntentPaymentMethodOptionsUsBankAccountVeri serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateSetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 UpdateSetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod")) + } +} impl<'a> UpdateSetupIntent<'a> { /// Updates a SetupIntent object. pub fn send( @@ -5432,7 +6086,7 @@ impl<'a> CancelSetupIntent<'a> { client.send_form(&format!("/setup_intents/{intent}/cancel"), self, http_types::Method::Post) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(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")] @@ -5463,13 +6117,13 @@ impl<'a> ConfirmSetupIntent<'a> { Self::default() } } -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] #[serde(untagged)] pub enum ConfirmSetupIntentMandateData<'a> { SecretKeyParam(ConfirmSetupIntentSecretKeyParam<'a>), ClientKeyParam(ConfirmSetupIntentClientKeyParam<'a>), } -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] pub struct ConfirmSetupIntentSecretKeyParam<'a> { /// This hash contains details about the customer acceptance of the Mandate. pub customer_acceptance: ConfirmSetupIntentSecretKeyParamCustomerAcceptance<'a>, @@ -5482,14 +6136,15 @@ impl<'a> ConfirmSetupIntentSecretKeyParam<'a> { } } /// This hash contains details about the customer acceptance of the Mandate. -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] pub struct ConfirmSetupIntentSecretKeyParamCustomerAcceptance<'a> { /// The time at which the customer accepted the Mandate. #[serde(skip_serializing_if = "Option::is_none")] pub accepted_at: Option, /// If this is a Mandate accepted offline, this hash contains details about the offline acceptance. #[serde(skip_serializing_if = "Option::is_none")] - pub offline: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub offline: Option, /// If this is a Mandate accepted online, this hash contains details about the online acceptance. #[serde(skip_serializing_if = "Option::is_none")] pub online: Option>, @@ -5550,6 +6205,18 @@ impl serde::Serialize for ConfirmSetupIntentSecretKeyParamCustomerAcceptanceType serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmSetupIntentSecretKeyParamCustomerAcceptanceType { + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentSecretKeyParamCustomerAcceptanceType", + ) + }) + } +} #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct ConfirmSetupIntentClientKeyParam<'a> { /// This hash contains details about the customer acceptance of the Mandate. @@ -5637,22 +6304,37 @@ impl serde::Serialize for ConfirmSetupIntentClientKeyParamCustomerAcceptanceType serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmSetupIntentClientKeyParamCustomerAcceptanceType { + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentClientKeyParamCustomerAcceptanceType", + ) + }) + } +} /// When included, this hash creates a PaymentMethod that is set as the [`payment_method`](https://stripe.com/docs/api/setup_intents/object#setup_intent_object-payment_method). /// value in the SetupIntent. -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] pub struct ConfirmSetupIntentPaymentMethodData<'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")] pub acss_debit: Option>, /// If this is an `affirm` PaymentMethod, this hash contains details about the Affirm payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub affirm: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub affirm: Option, /// If this is an `AfterpayClearpay` PaymentMethod, this hash contains details about the AfterpayClearpay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub afterpay_clearpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub afterpay_clearpay: Option, /// If this is an `Alipay` PaymentMethod, this hash contains details about the Alipay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub alipay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub alipay: Option, /// If this is an `au_becs_debit` PaymentMethod, this hash contains details about the bank account. #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option>, @@ -5661,22 +6343,26 @@ pub struct ConfirmSetupIntentPaymentMethodData<'a> { pub bacs_debit: Option>, /// If this is a `bancontact` PaymentMethod, this hash contains details about the Bancontact payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub bancontact: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub bancontact: Option, /// 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>, /// If this is a `blik` PaymentMethod, this hash contains details about the BLIK payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub blik: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub blik: Option, /// If this is a `boleto` PaymentMethod, this hash contains details about the Boleto payment method. #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option>, /// If this is a `cashapp` PaymentMethod, this hash contains details about the Cash App Pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub cashapp: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub cashapp: Option, /// If this is a `customer_balance` PaymentMethod, this hash contains details about the CustomerBalance payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub customer_balance: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub customer_balance: Option, /// If this is an `eps` PaymentMethod, this hash contains details about the EPS payment method. #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option, @@ -5685,25 +6371,30 @@ pub struct ConfirmSetupIntentPaymentMethodData<'a> { pub fpx: Option, /// If this is a `giropay` PaymentMethod, this hash contains details about the Giropay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub giropay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub giropay: Option, /// If this is a `grabpay` PaymentMethod, this hash contains details about the GrabPay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub grabpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub grabpay: Option, /// If this is an `ideal` PaymentMethod, this hash contains details about the iDEAL payment method. #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option, /// If this is an `interac_present` PaymentMethod, this hash contains details about the Interac Present payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub interac_present: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub interac_present: Option, /// If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method. #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option, /// If this is a `konbini` PaymentMethod, this hash contains details about the Konbini payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub konbini: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub konbini: Option, /// If this is an `Link` PaymentMethod, this hash contains details about the Link payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub link: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub link: Option, /// 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. @@ -5712,29 +6403,35 @@ pub struct ConfirmSetupIntentPaymentMethodData<'a> { pub metadata: Option<&'a std::collections::HashMap>, /// If this is an `oxxo` PaymentMethod, this hash contains details about the OXXO payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub oxxo: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub oxxo: Option, /// If this is a `p24` PaymentMethod, this hash contains details about the P24 payment method. #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option, /// If this is a `paynow` PaymentMethod, this hash contains details about the PayNow payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub paynow: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub paynow: Option, /// If this is a `paypal` PaymentMethod, this hash contains details about the PayPal payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub paypal: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub paypal: Option, /// If this is a `pix` PaymentMethod, this hash contains details about the Pix payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub pix: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub pix: Option, /// If this is a `promptpay` PaymentMethod, this hash contains details about the PromptPay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub promptpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub promptpay: Option, /// Options to configure Radar. /// See [Radar Session](https://stripe.com/docs/radar/radar-session) for more information. #[serde(skip_serializing_if = "Option::is_none")] pub radar_options: Option>, /// If this is a `Revolut Pay` PaymentMethod, this hash contains details about the Revolut Pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub revolut_pay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub revolut_pay: Option, /// If this is a `sepa_debit` PaymentMethod, this hash contains details about the SEPA debit bank account. #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option>, @@ -5743,7 +6440,8 @@ pub struct ConfirmSetupIntentPaymentMethodData<'a> { pub sofort: Option, /// 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>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub swish: Option, /// 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. @@ -5754,10 +6452,12 @@ pub struct ConfirmSetupIntentPaymentMethodData<'a> { pub us_bank_account: Option>, /// If this is an `wechat_pay` PaymentMethod, this hash contains details about the wechat_pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub wechat_pay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub wechat_pay: Option, /// If this is a `zip` PaymentMethod, this hash contains details about the Zip payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub zip: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub zip: Option, } impl<'a> ConfirmSetupIntentPaymentMethodData<'a> { pub fn new(type_: ConfirmSetupIntentPaymentMethodDataType) -> Self { @@ -5981,6 +6681,14 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodDataEpsBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmSetupIntentPaymentMethodDataEpsBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is an `fpx` PaymentMethod, this hash contains details about the FPX payment method. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct ConfirmSetupIntentPaymentMethodDataFpx { @@ -6041,6 +6749,18 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodDataFpxAccountHolderTyp serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmSetupIntentPaymentMethodDataFpxAccountHolderType { + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodDataFpxAccountHolderType", + ) + }) + } +} /// The customer's bank. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -6151,6 +6871,14 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodDataFpxBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmSetupIntentPaymentMethodDataFpxBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is an `ideal` PaymentMethod, this hash contains details about the iDEAL payment method. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmSetupIntentPaymentMethodDataIdeal { @@ -6255,6 +6983,14 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodDataIdealBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmSetupIntentPaymentMethodDataIdealBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmSetupIntentPaymentMethodDataKlarna { @@ -6401,6 +7137,14 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodDataP24Bank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmSetupIntentPaymentMethodDataP24Bank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is a `sepa_debit` PaymentMethod, this hash contains details about the SEPA debit bank account. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct ConfirmSetupIntentPaymentMethodDataSepaDebit<'a> { @@ -6481,6 +7225,18 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodDataSofortCountry { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmSetupIntentPaymentMethodDataSofortCountry { + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodDataSofortCountry", + ) + }) + } +} /// 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. @@ -6623,6 +7379,14 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodDataType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmSetupIntentPaymentMethodDataType { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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 ConfirmSetupIntentPaymentMethodDataUsBankAccount<'a> { @@ -6694,6 +7458,16 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodDataUsBankAccountAccoun serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmSetupIntentPaymentMethodDataUsBankAccountAccountHolderType +{ + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodDataUsBankAccountAccountHolderType")) + } +} /// Account type: checkings or savings. Defaults to checking if omitted. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmSetupIntentPaymentMethodDataUsBankAccountAccountType { @@ -6740,8 +7514,20 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodDataUsBankAccountAccoun serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmSetupIntentPaymentMethodDataUsBankAccountAccountType { + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodDataUsBankAccountAccountType", + ) + }) + } +} /// Payment method-specific configuration for this SetupIntent. -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(Clone, Debug, Default, serde::Serialize)] pub struct ConfirmSetupIntentPaymentMethodOptions<'a> { /// If this is a `acss_debit` SetupIntent, this sub-hash contains details about the ACSS Debit payment method options. #[serde(skip_serializing_if = "Option::is_none")] @@ -6757,7 +7543,7 @@ pub struct ConfirmSetupIntentPaymentMethodOptions<'a> { pub paypal: Option>, /// If this is a `sepa_debit` SetupIntent, this sub-hash contains details about the SEPA Debit payment method options. #[serde(skip_serializing_if = "Option::is_none")] - pub sepa_debit: Option>, + pub sepa_debit: Option, /// If this is a `us_bank_account` SetupIntent, 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>, @@ -6834,6 +7620,18 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsAcssDebitCurrenc serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmSetupIntentPaymentMethodOptionsAcssDebitCurrency { + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodOptionsAcssDebitCurrency", + ) + }) + } +} /// Additional fields for Mandate creation #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptions<'a> { @@ -6910,6 +7708,16 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandate serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor +{ + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsDefaultFor")) + } +} /// Payment schedule for the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule { @@ -6967,6 +7775,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule +{ + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsPaymentSchedule")) + } +} /// Transaction type of the mandate. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType { @@ -7021,6 +7839,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType +{ + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodOptionsAcssDebitMandateOptionsTransactionType")) + } +} /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmSetupIntentPaymentMethodOptionsAcssDebitVerificationMethod { @@ -7070,6 +7898,16 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsAcssDebitVerific serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmSetupIntentPaymentMethodOptionsAcssDebitVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodOptionsAcssDebitVerificationMethod")) + } +} /// Configuration for any card setup attempted on this SetupIntent. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmSetupIntentPaymentMethodOptionsCard<'a> { @@ -7212,6 +8050,16 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsCardMandateOptio serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmSetupIntentPaymentMethodOptionsCardMandateOptionsAmountType +{ + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodOptionsCardMandateOptionsAmountType")) + } +} /// Specifies payment frequency. One of `day`, `week`, `month`, `year`, or `sporadic`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmSetupIntentPaymentMethodOptionsCardMandateOptionsInterval { @@ -7267,6 +8115,16 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsCardMandateOptio serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmSetupIntentPaymentMethodOptionsCardMandateOptionsInterval +{ + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodOptionsCardMandateOptionsInterval")) + } +} /// Specifies the type of mandates supported. Possible values are `india`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmSetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes { @@ -7310,6 +8168,16 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsCardMandateOptio serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmSetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes +{ + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes")) + } +} /// Selected network to process this SetupIntent on. /// Depends on the available networks of the card attached to the SetupIntent. /// Can be only set confirm-time. @@ -7385,6 +8253,18 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsCardNetwork { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConfirmSetupIntentPaymentMethodOptionsCardNetwork { + fn deserialize>(deserializer: D) -> 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 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`. @@ -7437,6 +8317,20 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsCardRequestThree serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmSetupIntentPaymentMethodOptionsCardRequestThreeDSecure +{ + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodOptionsCardRequestThreeDSecure", + ) + }) + } +} /// 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)] @@ -7540,6 +8434,16 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecure serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus +{ + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureAresTransStatus")) + } +} /// 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)] @@ -7604,6 +8508,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureElectronicCommerceIndicator +{ + fn deserialize>(deserializer: D) -> 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 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 @@ -7715,6 +8629,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo +{ + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureNetworkOptionsCartesBancairesCbAvalgo")) + } +} /// The version of 3D Secure that was performed. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureVersion { @@ -7764,14 +8688,29 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecure serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureVersion +{ + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodOptionsCardThreeDSecureVersion", + ) + }) + } +} /// 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> { +#[derive(Clone, Debug, Default, serde::Serialize)] +pub struct ConfirmSetupIntentPaymentMethodOptionsSepaDebit { /// Additional fields for Mandate creation #[serde(skip_serializing_if = "Option::is_none")] - pub mandate_options: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub mandate_options: Option, } -impl<'a> ConfirmSetupIntentPaymentMethodOptionsSepaDebit<'a> { +impl ConfirmSetupIntentPaymentMethodOptionsSepaDebit { pub fn new() -> Self { Self::default() } @@ -7886,6 +8825,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions +{ + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPermissions")) + } +} /// List of data features that you would like to retrieve upon account creation. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch { @@ -7940,6 +8889,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch +{ + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodOptionsUsBankAccountFinancialConnectionsPrefetch")) + } +} /// Additional fields for Mandate creation #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmSetupIntentPaymentMethodOptionsUsBankAccountMandateOptions { @@ -8004,6 +8963,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod +{ + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod")) + } +} /// Additional fields for network related functions #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct ConfirmSetupIntentPaymentMethodOptionsUsBankAccountNetworks<'a> { @@ -8063,6 +9032,16 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountNet serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested +{ + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodOptionsUsBankAccountNetworksRequested")) + } +} /// Bank account verification method. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConfirmSetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod { @@ -8112,6 +9091,16 @@ impl serde::Serialize for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountVer serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ConfirmSetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod +{ + fn deserialize>(deserializer: D) -> 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 ConfirmSetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod")) + } +} impl<'a> ConfirmSetupIntent<'a> { /// Confirm that your customer intends to set up the current or /// provided payment method. For example, you would confirm a SetupIntent diff --git a/generated/stripe_core/src/token/requests.rs b/generated/stripe_core/src/token/requests.rs index 6271ce0f9..a07e30273 100644 --- a/generated/stripe_core/src/token/requests.rs +++ b/generated/stripe_core/src/token/requests.rs @@ -129,6 +129,16 @@ impl serde::Serialize for CreateTokenAccountBusinessType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTokenAccountBusinessType { + fn deserialize>(deserializer: D) -> 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 CreateTokenAccountBusinessType") + }) + } +} /// Information about the company or business. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateTokenAccountCompany<'a> { @@ -399,6 +409,14 @@ impl serde::Serialize for CreateTokenAccountCompanyStructure { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTokenAccountCompanyStructure { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Information on the verification state of the company. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateTokenAccountCompanyVerification<'a> { @@ -619,6 +637,18 @@ impl serde::Serialize for CreateTokenAccountIndividualPoliticalExposure { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTokenAccountIndividualPoliticalExposure { + fn deserialize>(deserializer: D) -> 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 CreateTokenAccountIndividualPoliticalExposure", + ) + }) + } +} /// Describes the person’s relationship to the account. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateTokenAccountIndividualRelationship<'a> { @@ -735,6 +765,16 @@ impl serde::Serialize for CreateTokenBankAccountAccountHolderType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTokenBankAccountAccountHolderType { + fn deserialize>(deserializer: D) -> 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 CreateTokenBankAccountAccountHolderType") + }) + } +} /// The bank account type. /// This can only be `checking` or `savings` in most countries. /// In Japan, this can only be `futsu` or `toza`. @@ -789,6 +829,16 @@ impl serde::Serialize for CreateTokenBankAccountAccountType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTokenBankAccountAccountType { + fn deserialize>(deserializer: D) -> 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 CreateTokenBankAccountAccountType") + }) + } +} /// The card this token will represent. /// If you also pass in a customer, the card must be the ID of a card belonging to the customer. /// Otherwise, if you do not pass in a customer, this is a dictionary containing a user's credit card details, with the options described below. diff --git a/generated/stripe_core/src/token/types.rs b/generated/stripe_core/src/token/types.rs index 384f47e6c..8603ba909 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Token { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_account: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option, /// IP address of the client that generates the token. pub client_ip: Option, @@ -34,12 +34,208 @@ pub struct Token { pub id: stripe_core::TokenId, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: TokenObject, /// Type of the token: `account`, `bank_account`, `card`, or `pii`. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: String, /// Determines if you have already used this token (you can only use tokens once). pub used: bool, } +#[doc(hidden)] +pub struct TokenBuilder { + bank_account: Option>, + card: Option>, + client_ip: Option>, + created: Option, + id: Option, + livemode: Option, + object: Option, + type_: Option, + used: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TokenBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "type" => Deserialize::begin(&mut self.type_), + "used" => Deserialize::begin(&mut self.used), + + _ => ::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(), + object: Deserialize::default(), + type_: Deserialize::default(), + used: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + bank_account: self.bank_account.take()?, + card: self.card.take()?, + client_ip: self.client_ip.take()?, + created: self.created?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + type_: self.type_.take()?, + used: self.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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + "used" => b.used = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TokenObject { + Token, +} +impl TokenObject { + pub fn as_str(self) -> &'static str { + use TokenObject::*; + match self { + Token => "token", + } + } +} + +impl std::str::FromStr for TokenObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TokenObject::*; + match s { + "token" => Ok(Token), + _ => Err(()), + } + } +} +impl std::fmt::Display for TokenObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TokenObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TokenObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TokenObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TokenObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TokenObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TokenObject { + fn deserialize>(deserializer: D) -> 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 TokenObject")) + } +} impl stripe_types::Object for Token { type Id = stripe_core::TokenId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_fraud/Cargo.toml b/generated/stripe_fraud/Cargo.toml index 98787509d..2f4f4bc73 100644 --- a/generated/stripe_fraud/Cargo.toml +++ b/generated/stripe_fraud/Cargo.toml @@ -16,8 +16,9 @@ path = "src/mod.rs" [dependencies] serde.workspace = true -smol_str.workspace = true serde_json.workspace = true +smol_str.workspace = true +miniserde.workspace = true stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +serde = ["stripe_types/serde","stripe_shared/serde"] 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..f9692e1ee 100644 --- a/generated/stripe_fraud/src/deleted_radar_value_list.rs +++ b/generated/stripe_fraud/src/deleted_radar_value_list.rs @@ -1,9 +1,178 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedRadarValueListObject, +} +#[doc(hidden)] +pub struct DeletedRadarValueListBuilder { + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedRadarValueListBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deleted: self.deleted?, id: self.id.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedRadarValueListObject { + RadarValueList, +} +impl DeletedRadarValueListObject { + pub fn as_str(self) -> &'static str { + use DeletedRadarValueListObject::*; + match self { + RadarValueList => "radar.value_list", + } + } +} + +impl std::str::FromStr for DeletedRadarValueListObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedRadarValueListObject::*; + match s { + "radar.value_list" => Ok(RadarValueList), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedRadarValueListObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedRadarValueListObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedRadarValueListObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedRadarValueListObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DeletedRadarValueListObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedRadarValueListObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedRadarValueListObject { + fn deserialize>(deserializer: D) -> 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 DeletedRadarValueListObject")) + } } impl stripe_types::Object for DeletedRadarValueList { type Id = stripe_fraud::RadarValueListId; 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..fa57b1a8c 100644 --- a/generated/stripe_fraud/src/deleted_radar_value_list_item.rs +++ b/generated/stripe_fraud/src/deleted_radar_value_list_item.rs @@ -1,9 +1,180 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedRadarValueListItemObject, +} +#[doc(hidden)] +pub struct DeletedRadarValueListItemBuilder { + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedRadarValueListItemBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deleted: self.deleted?, id: self.id.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedRadarValueListItemObject { + RadarValueListItem, +} +impl DeletedRadarValueListItemObject { + pub fn as_str(self) -> &'static str { + use DeletedRadarValueListItemObject::*; + match self { + RadarValueListItem => "radar.value_list_item", + } + } +} + +impl std::str::FromStr for DeletedRadarValueListItemObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedRadarValueListItemObject::*; + match s { + "radar.value_list_item" => Ok(RadarValueListItem), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedRadarValueListItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedRadarValueListItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedRadarValueListItemObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedRadarValueListItemObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(DeletedRadarValueListItemObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedRadarValueListItemObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedRadarValueListItemObject { + fn deserialize>(deserializer: D) -> 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 DeletedRadarValueListItemObject") + }) + } } impl stripe_types::Object for DeletedRadarValueListItem { type Id = stripe_fraud::RadarValueListItemId; diff --git a/generated/stripe_fraud/src/mod.rs b/generated/stripe_fraud/src/mod.rs index a578f3a4e..78d51b0d9 100644 --- a/generated/stripe_fraud/src/mod.rs +++ b/generated/stripe_fraud/src/mod.rs @@ -7,6 +7,8 @@ //! for requests mentioned in the `Fraud` section of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_fraud; + +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/types.rs b/generated/stripe_fraud/src/radar_early_fraud_warning/types.rs index 2c4a2aac7..279107b50 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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. @@ -18,10 +20,204 @@ pub struct RadarEarlyFraudWarning { pub id: stripe_fraud::RadarEarlyFraudWarningId, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: RadarEarlyFraudWarningObject, /// ID of the Payment Intent this early fraud warning is for, optionally expanded. - #[serde(skip_serializing_if = "Option::is_none")] pub payment_intent: Option>, } +#[doc(hidden)] +pub struct RadarEarlyFraudWarningBuilder { + actionable: Option, + charge: Option>, + created: Option, + fraud_type: Option, + id: Option, + livemode: Option, + object: Option, + payment_intent: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: RadarEarlyFraudWarningBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "payment_intent" => Deserialize::begin(&mut self.payment_intent), + + _ => ::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(), + object: Deserialize::default(), + payment_intent: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + actionable: self.actionable?, + charge: self.charge.take()?, + created: self.created?, + fraud_type: self.fraud_type.take()?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + payment_intent: self.payment_intent.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "payment_intent" => b.payment_intent = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum RadarEarlyFraudWarningObject { + RadarEarlyFraudWarning, +} +impl RadarEarlyFraudWarningObject { + pub fn as_str(self) -> &'static str { + use RadarEarlyFraudWarningObject::*; + match self { + RadarEarlyFraudWarning => "radar.early_fraud_warning", + } + } +} + +impl std::str::FromStr for RadarEarlyFraudWarningObject { + type Err = (); + fn from_str(s: &str) -> Result { + use RadarEarlyFraudWarningObject::*; + match s { + "radar.early_fraud_warning" => Ok(RadarEarlyFraudWarning), + _ => Err(()), + } + } +} +impl std::fmt::Display for RadarEarlyFraudWarningObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for RadarEarlyFraudWarningObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for RadarEarlyFraudWarningObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for RadarEarlyFraudWarningObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(RadarEarlyFraudWarningObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(RadarEarlyFraudWarningObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for RadarEarlyFraudWarningObject { + fn deserialize>(deserializer: D) -> 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 RadarEarlyFraudWarningObject")) + } +} 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/types.rs b/generated/stripe_fraud/src/radar_value_list/types.rs index 0039ce9cf..e46f67bd8 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct RadarValueList { /// The name of the value list for use in rules. pub alias: String, @@ -25,6 +27,211 @@ pub struct RadarValueList { pub metadata: std::collections::HashMap, /// The name of the value list. pub name: String, + /// String representing the object's type. Objects of the same type share the same value. + pub object: RadarValueListObject, +} +#[doc(hidden)] +pub struct RadarValueListBuilder { + alias: Option, + created: Option, + created_by: Option, + id: Option, + item_type: Option, + list_items: Option>, + livemode: Option, + metadata: Option>, + name: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: RadarValueListBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::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(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + alias: self.alias.take()?, + created: self.created?, + created_by: self.created_by.take()?, + id: self.id.take()?, + item_type: self.item_type?, + list_items: self.list_items.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + name: self.name.take()?, + object: self.object?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum RadarValueListObject { + RadarValueList, +} +impl RadarValueListObject { + pub fn as_str(self) -> &'static str { + use RadarValueListObject::*; + match self { + RadarValueList => "radar.value_list", + } + } +} + +impl std::str::FromStr for RadarValueListObject { + type Err = (); + fn from_str(s: &str) -> Result { + use RadarValueListObject::*; + match s { + "radar.value_list" => Ok(RadarValueList), + _ => Err(()), + } + } +} +impl std::fmt::Display for RadarValueListObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for RadarValueListObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for RadarValueListObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for RadarValueListObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(RadarValueListObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(RadarValueListObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for RadarValueListObject { + fn deserialize>(deserializer: D) -> 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 RadarValueListObject")) + } } impl stripe_types::Object for RadarValueList { type Id = stripe_fraud::RadarValueListId; @@ -102,6 +309,22 @@ impl serde::Serialize for RadarValueListItemType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for RadarValueListItemType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(RadarValueListItemType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(RadarValueListItemType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for RadarValueListItemType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..09658ec34 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct RadarValueListItem { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -13,11 +15,201 @@ pub struct RadarValueListItem { pub id: stripe_fraud::RadarValueListItemId, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: RadarValueListItemObject, /// The value of the item. pub value: String, /// The identifier of the value list this item belongs to. pub value_list: String, } +#[doc(hidden)] +pub struct RadarValueListItemBuilder { + created: Option, + created_by: Option, + id: Option, + livemode: Option, + object: Option, + value: Option, + value_list: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: RadarValueListItemBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "value" => Deserialize::begin(&mut self.value), + "value_list" => Deserialize::begin(&mut self.value_list), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + created_by: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + object: Deserialize::default(), + value: Deserialize::default(), + value_list: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + created: self.created?, + created_by: self.created_by.take()?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + value: self.value.take()?, + value_list: self.value_list.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum RadarValueListItemObject { + RadarValueListItem, +} +impl RadarValueListItemObject { + pub fn as_str(self) -> &'static str { + use RadarValueListItemObject::*; + match self { + RadarValueListItem => "radar.value_list_item", + } + } +} + +impl std::str::FromStr for RadarValueListItemObject { + type Err = (); + fn from_str(s: &str) -> Result { + use RadarValueListItemObject::*; + match s { + "radar.value_list_item" => Ok(RadarValueListItem), + _ => Err(()), + } + } +} +impl std::fmt::Display for RadarValueListItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for RadarValueListItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for RadarValueListItemObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for RadarValueListItemObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(RadarValueListItemObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(RadarValueListItemObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for RadarValueListItemObject { + fn deserialize>(deserializer: D) -> 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 RadarValueListItemObject")) + } +} impl stripe_types::Object for RadarValueListItem { type Id = stripe_fraud::RadarValueListItemId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_issuing/Cargo.toml b/generated/stripe_issuing/Cargo.toml index 30e00b043..c10ac4f76 100644 --- a/generated/stripe_issuing/Cargo.toml +++ b/generated/stripe_issuing/Cargo.toml @@ -16,8 +16,9 @@ path = "src/mod.rs" [dependencies] serde.workspace = true -smol_str.workspace = true serde_json.workspace = true +smol_str.workspace = true +miniserde.workspace = true stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +serde = ["stripe_types/serde","stripe_shared/serde"] 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..22a362ce6 100644 --- a/generated/stripe_issuing/src/issuing_authorization/requests.rs +++ b/generated/stripe_issuing/src/issuing_authorization/requests.rs @@ -1307,6 +1307,14 @@ impl serde::Serialize for CreateIssuingAuthorizationMerchantDataCategory { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingAuthorizationMerchantDataCategory { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Details about the authorization, such as identifiers, set by the card network. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateIssuingAuthorizationNetworkData<'a> { @@ -1397,6 +1405,18 @@ impl serde::Serialize for CreateIssuingAuthorizationVerificationDataAddressLine1 serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingAuthorizationVerificationDataAddressLine1Check { + fn deserialize>(deserializer: D) -> 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 CreateIssuingAuthorizationVerificationDataAddressLine1Check", + ) + }) + } +} /// 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 CreateIssuingAuthorizationVerificationDataAddressPostalCodeCheck { @@ -1446,6 +1466,16 @@ impl serde::Serialize for CreateIssuingAuthorizationVerificationDataAddressPosta serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateIssuingAuthorizationVerificationDataAddressPostalCodeCheck +{ + fn deserialize>(deserializer: D) -> 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 CreateIssuingAuthorizationVerificationDataAddressPostalCodeCheck")) + } +} /// The exemption applied to this authorization. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateIssuingAuthorizationVerificationDataAuthenticationExemption { @@ -1517,6 +1547,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateIssuingAuthorizationVerificationDataAuthenticationExemptionClaimedBy +{ + fn deserialize>(deserializer: D) -> 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 CreateIssuingAuthorizationVerificationDataAuthenticationExemptionClaimedBy")) + } +} /// The specific exemption claimed for this authorization. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateIssuingAuthorizationVerificationDataAuthenticationExemptionType { @@ -1566,6 +1606,16 @@ impl serde::Serialize for CreateIssuingAuthorizationVerificationDataAuthenticati serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateIssuingAuthorizationVerificationDataAuthenticationExemptionType +{ + fn deserialize>(deserializer: D) -> 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 CreateIssuingAuthorizationVerificationDataAuthenticationExemptionType")) + } +} /// Whether the cardholder provided a CVC and if it matched Stripe’s record. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateIssuingAuthorizationVerificationDataCvcCheck { @@ -1615,6 +1665,18 @@ impl serde::Serialize for CreateIssuingAuthorizationVerificationDataCvcCheck { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingAuthorizationVerificationDataCvcCheck { + fn deserialize>(deserializer: D) -> 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 CreateIssuingAuthorizationVerificationDataCvcCheck", + ) + }) + } +} /// Whether the cardholder provided an expiry date and if it matched Stripe’s record. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateIssuingAuthorizationVerificationDataExpiryCheck { @@ -1664,6 +1726,18 @@ impl serde::Serialize for CreateIssuingAuthorizationVerificationDataExpiryCheck serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingAuthorizationVerificationDataExpiryCheck { + fn deserialize>(deserializer: D) -> 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 CreateIssuingAuthorizationVerificationDataExpiryCheck", + ) + }) + } +} /// 3D Secure details. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateIssuingAuthorizationVerificationDataThreeDSecure { @@ -1727,6 +1801,18 @@ impl serde::Serialize for CreateIssuingAuthorizationVerificationDataThreeDSecure serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingAuthorizationVerificationDataThreeDSecureResult { + fn deserialize>(deserializer: D) -> 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 CreateIssuingAuthorizationVerificationDataThreeDSecureResult", + ) + }) + } +} /// The digital wallet used for this transaction. /// One of `apple_pay`, `google_pay`, or `samsung_pay`. /// Will populate as `null` when no digital wallet was utilized. @@ -1778,6 +1864,16 @@ impl serde::Serialize for CreateIssuingAuthorizationWallet { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingAuthorizationWallet { + fn deserialize>(deserializer: D) -> 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 CreateIssuingAuthorizationWallet") + }) + } +} impl<'a> CreateIssuingAuthorization<'a> { /// Create a test-mode authorization. pub fn send( @@ -1965,6 +2061,18 @@ impl serde::Serialize for CaptureIssuingAuthorizationPurchaseDetailsFuelType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CaptureIssuingAuthorizationPurchaseDetailsFuelType { + fn deserialize>(deserializer: D) -> 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 CaptureIssuingAuthorizationPurchaseDetailsFuelType", + ) + }) + } +} /// The units for `volume_decimal`. One of `us_gallon` or `liter`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CaptureIssuingAuthorizationPurchaseDetailsFuelUnit { @@ -2011,6 +2119,18 @@ impl serde::Serialize for CaptureIssuingAuthorizationPurchaseDetailsFuelUnit { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CaptureIssuingAuthorizationPurchaseDetailsFuelUnit { + fn deserialize>(deserializer: D) -> 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 CaptureIssuingAuthorizationPurchaseDetailsFuelUnit", + ) + }) + } +} /// Information about lodging that was purchased with this transaction. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CaptureIssuingAuthorizationPurchaseDetailsLodging { diff --git a/generated/stripe_issuing/src/issuing_card/requests.rs b/generated/stripe_issuing/src/issuing_card/requests.rs index fc21ffa15..b487d45a4 100644 --- a/generated/stripe_issuing/src/issuing_card/requests.rs +++ b/generated/stripe_issuing/src/issuing_card/requests.rs @@ -262,6 +262,16 @@ impl serde::Serialize for CreateIssuingCardShippingService { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingCardShippingService { + fn deserialize>(deserializer: D) -> 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 CreateIssuingCardShippingService") + }) + } +} /// Packaging options. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateIssuingCardShippingType { @@ -308,6 +318,16 @@ impl serde::Serialize for CreateIssuingCardShippingType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingCardShippingType { + fn deserialize>(deserializer: D) -> 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 CreateIssuingCardShippingType") + }) + } +} /// 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)] @@ -1354,6 +1374,14 @@ impl serde::Serialize for CreateIssuingCardSpendingControlsAllowedCategories { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingCardSpendingControlsAllowedCategories { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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`. @@ -2377,6 +2405,14 @@ impl serde::Serialize for CreateIssuingCardSpendingControlsBlockedCategories { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingCardSpendingControlsBlockedCategories { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Limit spending with amount-based rules that apply across any cards this card replaced (i.e., its `replacement_for` card and _that_ card's `replacement_for` card, up the chain). #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateIssuingCardSpendingControlsSpendingLimits<'a> { @@ -3419,6 +3455,14 @@ impl serde::Serialize for CreateIssuingCardSpendingControlsSpendingLimitsCategor serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingCardSpendingControlsSpendingLimitsCategories { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Interval (or event) to which the amount applies. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateIssuingCardSpendingControlsSpendingLimitsInterval { @@ -3477,6 +3521,18 @@ impl serde::Serialize for CreateIssuingCardSpendingControlsSpendingLimitsInterva serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingCardSpendingControlsSpendingLimitsInterval { + fn deserialize>(deserializer: D) -> 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 CreateIssuingCardSpendingControlsSpendingLimitsInterval", + ) + }) + } +} /// Whether authorizations can be approved on this card. /// May be blocked from activating cards depending on past-due Cardholder requirements. /// Defaults to `inactive`. @@ -3525,6 +3581,15 @@ impl serde::Serialize for CreateIssuingCardStatus { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingCardStatus { + fn deserialize>(deserializer: D) -> 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 CreateIssuingCardStatus")) + } +} impl<'a> CreateIssuingCard<'a> { /// Creates an Issuing `Card` object. pub fn send(&self, client: &stripe::Client) -> stripe::Response { @@ -3610,6 +3675,16 @@ impl serde::Serialize for UpdateIssuingCardCancellationReason { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateIssuingCardCancellationReason { + fn deserialize>(deserializer: D) -> 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 UpdateIssuingCardCancellationReason") + }) + } +} /// 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)] @@ -4656,6 +4731,14 @@ impl serde::Serialize for UpdateIssuingCardSpendingControlsAllowedCategories { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateIssuingCardSpendingControlsAllowedCategories { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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`. @@ -5679,6 +5762,14 @@ impl serde::Serialize for UpdateIssuingCardSpendingControlsBlockedCategories { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateIssuingCardSpendingControlsBlockedCategories { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Limit spending with amount-based rules that apply across any cards this card replaced (i.e., its `replacement_for` card and _that_ card's `replacement_for` card, up the chain). #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdateIssuingCardSpendingControlsSpendingLimits<'a> { @@ -6721,6 +6812,14 @@ impl serde::Serialize for UpdateIssuingCardSpendingControlsSpendingLimitsCategor serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateIssuingCardSpendingControlsSpendingLimitsCategories { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Interval (or event) to which the amount applies. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateIssuingCardSpendingControlsSpendingLimitsInterval { @@ -6779,6 +6878,18 @@ impl serde::Serialize for UpdateIssuingCardSpendingControlsSpendingLimitsInterva serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateIssuingCardSpendingControlsSpendingLimitsInterval { + fn deserialize>(deserializer: D) -> 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 UpdateIssuingCardSpendingControlsSpendingLimitsInterval", + ) + }) + } +} 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. diff --git a/generated/stripe_issuing/src/issuing_cardholder/requests.rs b/generated/stripe_issuing/src/issuing_cardholder/requests.rs index fe09025bd..11efa662f 100644 --- a/generated/stripe_issuing/src/issuing_cardholder/requests.rs +++ b/generated/stripe_issuing/src/issuing_cardholder/requests.rs @@ -1193,6 +1193,14 @@ impl serde::Serialize for CreateIssuingCardholderSpendingControlsAllowedCategori serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingCardholderSpendingControlsAllowedCategories { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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`. @@ -2216,6 +2224,14 @@ impl serde::Serialize for CreateIssuingCardholderSpendingControlsBlockedCategori serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingCardholderSpendingControlsBlockedCategories { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Limit spending with amount-based rules that apply across this cardholder's cards. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateIssuingCardholderSpendingControlsSpendingLimits<'a> { @@ -3258,6 +3274,16 @@ impl serde::Serialize for CreateIssuingCardholderSpendingControlsSpendingLimitsC serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateIssuingCardholderSpendingControlsSpendingLimitsCategories +{ + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Interval (or event) to which the amount applies. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateIssuingCardholderSpendingControlsSpendingLimitsInterval { @@ -3316,6 +3342,20 @@ impl serde::Serialize for CreateIssuingCardholderSpendingControlsSpendingLimitsI serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateIssuingCardholderSpendingControlsSpendingLimitsInterval +{ + fn deserialize>(deserializer: D) -> 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 CreateIssuingCardholderSpendingControlsSpendingLimitsInterval", + ) + }) + } +} /// Specifies whether to permit authorizations on this cardholder's cards. Defaults to `active`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateIssuingCardholderStatus { @@ -3362,6 +3402,16 @@ impl serde::Serialize for CreateIssuingCardholderStatus { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingCardholderStatus { + fn deserialize>(deserializer: D) -> 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 CreateIssuingCardholderStatus") + }) + } +} impl<'a> CreateIssuingCardholder<'a> { /// Creates a new Issuing `Cardholder` object that can be issued cards. pub fn send( @@ -4466,6 +4516,14 @@ impl serde::Serialize for UpdateIssuingCardholderSpendingControlsAllowedCategori serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateIssuingCardholderSpendingControlsAllowedCategories { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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`. @@ -5489,6 +5547,14 @@ impl serde::Serialize for UpdateIssuingCardholderSpendingControlsBlockedCategori serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateIssuingCardholderSpendingControlsBlockedCategories { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Limit spending with amount-based rules that apply across this cardholder's cards. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdateIssuingCardholderSpendingControlsSpendingLimits<'a> { @@ -6531,6 +6597,16 @@ impl serde::Serialize for UpdateIssuingCardholderSpendingControlsSpendingLimitsC serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateIssuingCardholderSpendingControlsSpendingLimitsCategories +{ + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Interval (or event) to which the amount applies. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateIssuingCardholderSpendingControlsSpendingLimitsInterval { @@ -6589,6 +6665,20 @@ impl serde::Serialize for UpdateIssuingCardholderSpendingControlsSpendingLimitsI serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateIssuingCardholderSpendingControlsSpendingLimitsInterval +{ + fn deserialize>(deserializer: D) -> 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 UpdateIssuingCardholderSpendingControlsSpendingLimitsInterval", + ) + }) + } +} /// Specifies whether to permit authorizations on this cardholder's cards. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateIssuingCardholderStatus { @@ -6635,6 +6725,16 @@ impl serde::Serialize for UpdateIssuingCardholderStatus { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateIssuingCardholderStatus { + fn deserialize>(deserializer: D) -> 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 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. diff --git a/generated/stripe_issuing/src/issuing_dispute/requests.rs b/generated/stripe_issuing/src/issuing_dispute/requests.rs index 7d993bcb9..35260ae4e 100644 --- a/generated/stripe_issuing/src/issuing_dispute/requests.rs +++ b/generated/stripe_issuing/src/issuing_dispute/requests.rs @@ -218,6 +218,18 @@ impl serde::Serialize for CreateIssuingDisputeEvidenceCanceledProductType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingDisputeEvidenceCanceledProductType { + fn deserialize>(deserializer: D) -> 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 CreateIssuingDisputeEvidenceCanceledProductType", + ) + }) + } +} /// Result of cardholder's attempt to return the product. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateIssuingDisputeEvidenceCanceledReturnStatus { @@ -264,6 +276,18 @@ impl serde::Serialize for CreateIssuingDisputeEvidenceCanceledReturnStatus { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingDisputeEvidenceCanceledReturnStatus { + fn deserialize>(deserializer: D) -> 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 CreateIssuingDisputeEvidenceCanceledReturnStatus", + ) + }) + } +} /// Evidence provided when `reason` is 'merchandise_not_as_described'. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateIssuingDisputeEvidenceMerchandiseNotAsDescribed<'a> { @@ -337,6 +361,16 @@ impl serde::Serialize for CreateIssuingDisputeEvidenceMerchandiseNotAsDescribedR serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateIssuingDisputeEvidenceMerchandiseNotAsDescribedReturnStatus +{ + fn deserialize>(deserializer: D) -> 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 CreateIssuingDisputeEvidenceMerchandiseNotAsDescribedReturnStatus")) + } +} /// Evidence provided when `reason` is 'not_received'. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateIssuingDisputeEvidenceNotReceived<'a> { @@ -407,6 +441,18 @@ impl serde::Serialize for CreateIssuingDisputeEvidenceNotReceivedProductType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingDisputeEvidenceNotReceivedProductType { + fn deserialize>(deserializer: D) -> 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 CreateIssuingDisputeEvidenceNotReceivedProductType", + ) + }) + } +} /// Evidence provided when `reason` is 'other'. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateIssuingDisputeEvidenceOther<'a> { @@ -474,6 +520,18 @@ impl serde::Serialize for CreateIssuingDisputeEvidenceOtherProductType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingDisputeEvidenceOtherProductType { + fn deserialize>(deserializer: D) -> 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 CreateIssuingDisputeEvidenceOtherProductType", + ) + }) + } +} /// The reason for filing the dispute. The evidence should be submitted in the field of the same name. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateIssuingDisputeEvidenceReason { @@ -535,6 +593,16 @@ impl serde::Serialize for CreateIssuingDisputeEvidenceReason { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIssuingDisputeEvidenceReason { + fn deserialize>(deserializer: D) -> 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 CreateIssuingDisputeEvidenceReason") + }) + } +} /// Params for disputes related to Treasury FinancialAccounts #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateIssuingDisputeTreasury<'a> { @@ -697,6 +765,18 @@ impl serde::Serialize for UpdateIssuingDisputeEvidenceCanceledProductType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateIssuingDisputeEvidenceCanceledProductType { + fn deserialize>(deserializer: D) -> 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 UpdateIssuingDisputeEvidenceCanceledProductType", + ) + }) + } +} /// Result of cardholder's attempt to return the product. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateIssuingDisputeEvidenceCanceledReturnStatus { @@ -743,6 +823,18 @@ impl serde::Serialize for UpdateIssuingDisputeEvidenceCanceledReturnStatus { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateIssuingDisputeEvidenceCanceledReturnStatus { + fn deserialize>(deserializer: D) -> 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 UpdateIssuingDisputeEvidenceCanceledReturnStatus", + ) + }) + } +} /// Evidence provided when `reason` is 'merchandise_not_as_described'. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateIssuingDisputeEvidenceMerchandiseNotAsDescribed<'a> { @@ -816,6 +908,16 @@ impl serde::Serialize for UpdateIssuingDisputeEvidenceMerchandiseNotAsDescribedR serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateIssuingDisputeEvidenceMerchandiseNotAsDescribedReturnStatus +{ + fn deserialize>(deserializer: D) -> 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 UpdateIssuingDisputeEvidenceMerchandiseNotAsDescribedReturnStatus")) + } +} /// Evidence provided when `reason` is 'not_received'. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateIssuingDisputeEvidenceNotReceived<'a> { @@ -886,6 +988,18 @@ impl serde::Serialize for UpdateIssuingDisputeEvidenceNotReceivedProductType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateIssuingDisputeEvidenceNotReceivedProductType { + fn deserialize>(deserializer: D) -> 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 UpdateIssuingDisputeEvidenceNotReceivedProductType", + ) + }) + } +} /// Evidence provided when `reason` is 'other'. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateIssuingDisputeEvidenceOther<'a> { @@ -953,6 +1067,18 @@ impl serde::Serialize for UpdateIssuingDisputeEvidenceOtherProductType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateIssuingDisputeEvidenceOtherProductType { + fn deserialize>(deserializer: D) -> 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 UpdateIssuingDisputeEvidenceOtherProductType", + ) + }) + } +} /// The reason for filing the dispute. The evidence should be submitted in the field of the same name. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateIssuingDisputeEvidenceReason { @@ -1014,6 +1140,16 @@ impl serde::Serialize for UpdateIssuingDisputeEvidenceReason { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateIssuingDisputeEvidenceReason { + fn deserialize>(deserializer: D) -> 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 UpdateIssuingDisputeEvidenceReason") + }) + } +} 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. diff --git a/generated/stripe_issuing/src/issuing_token/requests.rs b/generated/stripe_issuing/src/issuing_token/requests.rs index cb01672aa..2ec92ef12 100644 --- a/generated/stripe_issuing/src/issuing_token/requests.rs +++ b/generated/stripe_issuing/src/issuing_token/requests.rs @@ -136,6 +136,15 @@ impl serde::Serialize for UpdateIssuingTokenStatus { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateIssuingTokenStatus { + fn deserialize>(deserializer: D) -> 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 UpdateIssuingTokenStatus")) + } +} impl<'a> UpdateIssuingToken<'a> { /// Attempts to update the specified Issuing `Token` object to the status specified. pub fn send( diff --git a/generated/stripe_issuing/src/issuing_transaction/requests.rs b/generated/stripe_issuing/src/issuing_transaction/requests.rs index d4381d15b..6dd1cdb48 100644 --- a/generated/stripe_issuing/src/issuing_transaction/requests.rs +++ b/generated/stripe_issuing/src/issuing_transaction/requests.rs @@ -1225,6 +1225,14 @@ impl serde::Serialize for CreateForceCaptureIssuingTransactionMerchantDataCatego serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateForceCaptureIssuingTransactionMerchantDataCategory { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Additional purchase information that is optionally provided by the merchant. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateForceCaptureIssuingTransactionPurchaseDetails<'a> { @@ -1328,6 +1336,18 @@ impl serde::Serialize for CreateForceCaptureIssuingTransactionPurchaseDetailsFue serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateForceCaptureIssuingTransactionPurchaseDetailsFuelType { + fn deserialize>(deserializer: D) -> 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 CreateForceCaptureIssuingTransactionPurchaseDetailsFuelType", + ) + }) + } +} /// The units for `volume_decimal`. One of `us_gallon` or `liter`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateForceCaptureIssuingTransactionPurchaseDetailsFuelUnit { @@ -1374,6 +1394,18 @@ impl serde::Serialize for CreateForceCaptureIssuingTransactionPurchaseDetailsFue serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateForceCaptureIssuingTransactionPurchaseDetailsFuelUnit { + fn deserialize>(deserializer: D) -> 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 CreateForceCaptureIssuingTransactionPurchaseDetailsFuelUnit", + ) + }) + } +} impl<'a> CreateForceCaptureIssuingTransaction<'a> { /// Allows the user to capture an arbitrary amount, also known as a forced capture. pub fn send( @@ -2479,6 +2511,14 @@ impl serde::Serialize for CreateUnlinkedRefundIssuingTransactionMerchantDataCate serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateUnlinkedRefundIssuingTransactionMerchantDataCategory { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Additional purchase information that is optionally provided by the merchant. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateUnlinkedRefundIssuingTransactionPurchaseDetails<'a> { @@ -2582,6 +2622,20 @@ impl serde::Serialize for CreateUnlinkedRefundIssuingTransactionPurchaseDetailsF serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateUnlinkedRefundIssuingTransactionPurchaseDetailsFuelType +{ + fn deserialize>(deserializer: D) -> 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 CreateUnlinkedRefundIssuingTransactionPurchaseDetailsFuelType", + ) + }) + } +} /// The units for `volume_decimal`. One of `us_gallon` or `liter`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateUnlinkedRefundIssuingTransactionPurchaseDetailsFuelUnit { @@ -2628,6 +2682,20 @@ impl serde::Serialize for CreateUnlinkedRefundIssuingTransactionPurchaseDetailsF serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateUnlinkedRefundIssuingTransactionPurchaseDetailsFuelUnit +{ + fn deserialize>(deserializer: D) -> 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 CreateUnlinkedRefundIssuingTransactionPurchaseDetailsFuelUnit", + ) + }) + } +} impl<'a> CreateUnlinkedRefundIssuingTransaction<'a> { /// Allows the user to refund an arbitrary amount, also known as a unlinked refund. pub fn send( diff --git a/generated/stripe_issuing/src/mod.rs b/generated/stripe_issuing/src/mod.rs index 4d3172cd4..d549a4269 100644 --- a/generated/stripe_issuing/src/mod.rs +++ b/generated/stripe_issuing/src/mod.rs @@ -7,6 +7,8 @@ //! for requests mentioned in the `Issuing` section of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_issuing; + +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/Cargo.toml b/generated/stripe_misc/Cargo.toml index 6d58514f3..39de7bc1a 100644 --- a/generated/stripe_misc/Cargo.toml +++ b/generated/stripe_misc/Cargo.toml @@ -16,8 +16,9 @@ path = "src/mod.rs" [dependencies] serde.workspace = true -smol_str.workspace = true serde_json.workspace = true +smol_str.workspace = true +miniserde.workspace = true stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +serde = ["stripe_types/serde","stripe_shared/serde"] 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_misc/src/apple_pay_domain/types.rs b/generated/stripe_misc/src/apple_pay_domain/types.rs index d7f2f4fab..b97fa36fc 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ApplePayDomain { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -7,6 +9,186 @@ pub struct ApplePayDomain { pub id: stripe_misc::ApplePayDomainId, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: ApplePayDomainObject, +} +#[doc(hidden)] +pub struct ApplePayDomainBuilder { + created: Option, + domain_name: Option, + id: Option, + livemode: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ApplePayDomainBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + domain_name: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + created: self.created?, + domain_name: self.domain_name.take()?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ApplePayDomainObject { + ApplePayDomain, +} +impl ApplePayDomainObject { + pub fn as_str(self) -> &'static str { + use ApplePayDomainObject::*; + match self { + ApplePayDomain => "apple_pay_domain", + } + } +} + +impl std::str::FromStr for ApplePayDomainObject { + type Err = (); + fn from_str(s: &str) -> Result { + use ApplePayDomainObject::*; + match s { + "apple_pay_domain" => Ok(ApplePayDomain), + _ => Err(()), + } + } +} +impl std::fmt::Display for ApplePayDomainObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ApplePayDomainObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for ApplePayDomainObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for ApplePayDomainObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ApplePayDomainObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ApplePayDomainObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ApplePayDomainObject { + fn deserialize>(deserializer: D) -> 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 ApplePayDomainObject")) + } } impl stripe_types::Object for ApplePayDomain { type Id = stripe_misc::ApplePayDomainId; diff --git a/generated/stripe_misc/src/bank_connections_resource_accountholder.rs b/generated/stripe_misc/src/bank_connections_resource_accountholder.rs index c66ab8910..3befcc830 100644 --- a/generated/stripe_misc/src/bank_connections_resource_accountholder.rs +++ b/generated/stripe_misc/src/bank_connections_resource_accountholder.rs @@ -1,17 +1,117 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, /// 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>, /// Type of account holder that this account belongs to. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: BankConnectionsResourceAccountholderType, } +#[doc(hidden)] +pub struct BankConnectionsResourceAccountholderBuilder { + account: Option>>, + customer: Option>>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BankConnectionsResourceAccountholderBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account: Deserialize::default(), + customer: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account: self.account.take()?, + customer: self.customer.take()?, + type_: self.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 { + 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 { @@ -50,6 +150,7 @@ impl std::fmt::Debug for BankConnectionsResourceAccountholderType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for BankConnectionsResourceAccountholderType { fn serialize(&self, serializer: S) -> Result where @@ -58,6 +159,24 @@ impl serde::Serialize for BankConnectionsResourceAccountholderType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for BankConnectionsResourceAccountholderType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + BankConnectionsResourceAccountholderType::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(BankConnectionsResourceAccountholderType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for BankConnectionsResourceAccountholderType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/bank_connections_resource_balance.rs b/generated/stripe_misc/src/bank_connections_resource_balance.rs index b7c084010..b73fac020 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, - #[serde(skip_serializing_if = "Option::is_none")] pub credit: Option, /// The balances owed to (or by) the account holder. /// @@ -17,9 +17,119 @@ pub struct BankConnectionsResourceBalance { pub current: std::collections::HashMap, /// The `type` of the balance. /// An additional hash is included on the balance with a name matching this value. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: BankConnectionsResourceBalanceType, } +#[doc(hidden)] +pub struct BankConnectionsResourceBalanceBuilder { + as_of: Option, + cash: Option>, + credit: Option>, + current: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BankConnectionsResourceBalanceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + as_of: self.as_of?, + cash: self.cash.take()?, + credit: self.credit.take()?, + current: self.current.take()?, + type_: self.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 { + 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)] @@ -59,6 +169,7 @@ impl std::fmt::Debug for BankConnectionsResourceBalanceType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for BankConnectionsResourceBalanceType { fn serialize(&self, serializer: S) -> Result where @@ -67,6 +178,23 @@ impl serde::Serialize for BankConnectionsResourceBalanceType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for BankConnectionsResourceBalanceType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(BankConnectionsResourceBalanceType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(BankConnectionsResourceBalanceType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for BankConnectionsResourceBalanceType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..4b29d8433 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct BankConnectionsResourceBalanceApiResourceCashBalance { /// The funds available to the account holder. Typically this is the current balance less any holds. /// @@ -9,3 +11,91 @@ pub struct BankConnectionsResourceBalanceApiResourceCashBalance { /// A negative amount indicates money owed by the account holder. pub available: Option>, } +#[doc(hidden)] +pub struct BankConnectionsResourceBalanceApiResourceCashBalanceBuilder { + available: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BankConnectionsResourceBalanceApiResourceCashBalanceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { available: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { available: self.available.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..b1dc6a4ec 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct BankConnectionsResourceBalanceApiResourceCreditBalance { /// The credit that has been used by the account holder. /// @@ -9,3 +11,91 @@ pub struct BankConnectionsResourceBalanceApiResourceCreditBalance { /// A negative amount indicates money owed by the account holder. pub used: Option>, } +#[doc(hidden)] +pub struct BankConnectionsResourceBalanceApiResourceCreditBalanceBuilder { + used: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BankConnectionsResourceBalanceApiResourceCreditBalanceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { used: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { used: self.used.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..20ddc8702 100644 --- a/generated/stripe_misc/src/bank_connections_resource_balance_refresh.rs +++ b/generated/stripe_misc/src/bank_connections_resource_balance_refresh.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -9,6 +11,110 @@ pub struct BankConnectionsResourceBalanceRefresh { /// The status of the last refresh attempt. pub status: BankConnectionsResourceBalanceRefreshStatus, } +#[doc(hidden)] +pub struct BankConnectionsResourceBalanceRefreshBuilder { + last_attempted_at: Option, + next_refresh_available_at: Option>, + status: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BankConnectionsResourceBalanceRefreshBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "next_refresh_available_at" => { + Deserialize::begin(&mut self.next_refresh_available_at) + } + "status" => Deserialize::begin(&mut self.status), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + last_attempted_at: Deserialize::default(), + next_refresh_available_at: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + last_attempted_at: self.last_attempted_at?, + next_refresh_available_at: self.next_refresh_available_at?, + status: self.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 { + 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)?), + "next_refresh_available_at" => { + b.next_refresh_available_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 { @@ -50,6 +156,7 @@ impl std::fmt::Debug for BankConnectionsResourceBalanceRefreshStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for BankConnectionsResourceBalanceRefreshStatus { fn serialize(&self, serializer: S) -> Result where @@ -58,6 +165,25 @@ impl serde::Serialize for BankConnectionsResourceBalanceRefreshStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for BankConnectionsResourceBalanceRefreshStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + BankConnectionsResourceBalanceRefreshStatus::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(BankConnectionsResourceBalanceRefreshStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for BankConnectionsResourceBalanceRefreshStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..b5fc4d99c 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct BankConnectionsResourceLinkAccountSessionFilters { /// List of countries from which to filter accounts. pub countries: Option>, } +#[doc(hidden)] +pub struct BankConnectionsResourceLinkAccountSessionFiltersBuilder { + countries: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BankConnectionsResourceLinkAccountSessionFiltersBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { countries: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { countries: self.countries.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..2eebe5365 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,101 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct BankConnectionsResourceOwnershipRefreshBuilder { + last_attempted_at: Option, + status: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BankConnectionsResourceOwnershipRefreshBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { last_attempted_at: Deserialize::default(), status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { last_attempted_at: self.last_attempted_at?, status: self.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 { + 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 { @@ -46,6 +137,7 @@ impl std::fmt::Debug for BankConnectionsResourceOwnershipRefreshStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for BankConnectionsResourceOwnershipRefreshStatus { fn serialize(&self, serializer: S) -> Result where @@ -54,6 +146,25 @@ impl serde::Serialize for BankConnectionsResourceOwnershipRefreshStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for BankConnectionsResourceOwnershipRefreshStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + BankConnectionsResourceOwnershipRefreshStatus::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(BankConnectionsResourceOwnershipRefreshStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for BankConnectionsResourceOwnershipRefreshStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/bank_connections_resource_transaction_refresh.rs b/generated/stripe_misc/src/bank_connections_resource_transaction_refresh.rs index f42f5591a..eaa0cb34e 100644 --- a/generated/stripe_misc/src/bank_connections_resource_transaction_refresh.rs +++ b/generated/stripe_misc/src/bank_connections_resource_transaction_refresh.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct BankConnectionsResourceTransactionRefresh { /// Unique identifier for the object. pub id: stripe_misc::BankConnectionsResourceTransactionRefreshId, @@ -11,6 +13,115 @@ pub struct BankConnectionsResourceTransactionRefresh { /// The status of the last refresh attempt. pub status: BankConnectionsResourceTransactionRefreshStatus, } +#[doc(hidden)] +pub struct BankConnectionsResourceTransactionRefreshBuilder { + id: Option, + last_attempted_at: Option, + next_refresh_available_at: Option>, + status: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for BankConnectionsResourceTransactionRefresh { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BankConnectionsResourceTransactionRefreshBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: BankConnectionsResourceTransactionRefreshBuilder::deser_default(), + })) + } + } + + impl MapBuilder for BankConnectionsResourceTransactionRefreshBuilder { + type Out = BankConnectionsResourceTransactionRefresh; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "id" => Deserialize::begin(&mut self.id), + "last_attempted_at" => Deserialize::begin(&mut self.last_attempted_at), + "next_refresh_available_at" => { + Deserialize::begin(&mut self.next_refresh_available_at) + } + "status" => Deserialize::begin(&mut self.status), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + id: Deserialize::default(), + last_attempted_at: Deserialize::default(), + next_refresh_available_at: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + id: self.id.take()?, + last_attempted_at: self.last_attempted_at?, + next_refresh_available_at: self.next_refresh_available_at?, + status: self.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 BankConnectionsResourceTransactionRefresh { + type Builder = BankConnectionsResourceTransactionRefreshBuilder; + } + + impl FromValueOpt for BankConnectionsResourceTransactionRefresh { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = BankConnectionsResourceTransactionRefreshBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "last_attempted_at" => b.last_attempted_at = Some(FromValueOpt::from_value(v)?), + "next_refresh_available_at" => { + b.next_refresh_available_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 BankConnectionsResourceTransactionRefreshStatus { @@ -52,6 +163,7 @@ impl std::fmt::Debug for BankConnectionsResourceTransactionRefreshStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for BankConnectionsResourceTransactionRefreshStatus { fn serialize(&self, serializer: S) -> Result where @@ -60,6 +172,25 @@ impl serde::Serialize for BankConnectionsResourceTransactionRefreshStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for BankConnectionsResourceTransactionRefreshStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + BankConnectionsResourceTransactionRefreshStatus::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(BankConnectionsResourceTransactionRefreshStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for BankConnectionsResourceTransactionRefreshStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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 index cfbe46044..dfcfde0fd 100644 --- 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 @@ -1,7 +1,99 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct BankConnectionsResourceTransactionResourceStatusTransitions { /// Time at which this transaction posted. Measured in seconds since the Unix epoch. pub posted_at: Option, /// Time at which this transaction was voided. Measured in seconds since the Unix epoch. pub void_at: Option, } +#[doc(hidden)] +pub struct BankConnectionsResourceTransactionResourceStatusTransitionsBuilder { + posted_at: Option>, + void_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for BankConnectionsResourceTransactionResourceStatusTransitions { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BankConnectionsResourceTransactionResourceStatusTransitionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: BankConnectionsResourceTransactionResourceStatusTransitionsBuilder::deser_default(), + })) + } + } + + impl MapBuilder for BankConnectionsResourceTransactionResourceStatusTransitionsBuilder { + type Out = BankConnectionsResourceTransactionResourceStatusTransitions; + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { posted_at: Deserialize::default(), void_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { posted_at: self.posted_at?, void_at: self.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 BankConnectionsResourceTransactionResourceStatusTransitions { + type Builder = BankConnectionsResourceTransactionResourceStatusTransitionsBuilder; + } + + impl FromValueOpt for BankConnectionsResourceTransactionResourceStatusTransitions { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = + BankConnectionsResourceTransactionResourceStatusTransitionsBuilder::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_misc/src/climate_order/types.rs b/generated/stripe_misc/src/climate_order/types.rs index bf65955ee..2045f104c 100644 --- a/generated/stripe_misc/src/climate_order/types.rs +++ b/generated/stripe_misc/src/climate_order/types.rs @@ -1,7 +1,9 @@ /// 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)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ClimateOrder { /// Total amount of [Frontier](https://frontierclimate.com/)'s service fees in the currency's smallest unit. pub amount_fees: i64, @@ -9,7 +11,6 @@ pub struct ClimateOrder { 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, /// Time at which the order was canceled. Measured in seconds since the Unix epoch. pub canceled_at: Option, @@ -41,6 +42,8 @@ pub struct ClimateOrder { pub metadata: std::collections::HashMap, /// Quantity of carbon removal that is included in this order. pub metric_tons: String, + /// String representing the object's type. Objects of the same type share the same value. + pub object: ClimateOrderObject, /// Unique ID for the Climate `Product` this order is purchasing. pub product: stripe_types::Expandable, /// Time at which the order's product was substituted for a different product. @@ -49,6 +52,207 @@ pub struct ClimateOrder { /// The current status of this order. pub status: ClimateOrderStatus, } +#[doc(hidden)] +pub struct ClimateOrderBuilder { + amount_fees: Option, + amount_subtotal: Option, + amount_total: Option, + beneficiary: Option>, + canceled_at: Option>, + cancellation_reason: Option>, + certificate: Option>, + confirmed_at: Option>, + created: Option, + currency: Option, + delayed_at: Option>, + delivered_at: Option>, + delivery_details: Option>, + expected_delivery_year: Option, + id: Option, + livemode: Option, + metadata: Option>, + metric_tons: Option, + object: Option, + product: Option>, + product_substituted_at: Option>, + status: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ClimateOrder { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ClimateOrderBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: ClimateOrderBuilder::deser_default(), + })) + } + } + + impl MapBuilder for ClimateOrderBuilder { + type Out = ClimateOrder; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_fees" => Deserialize::begin(&mut self.amount_fees), + "amount_subtotal" => Deserialize::begin(&mut self.amount_subtotal), + "amount_total" => Deserialize::begin(&mut self.amount_total), + "beneficiary" => Deserialize::begin(&mut self.beneficiary), + "canceled_at" => Deserialize::begin(&mut self.canceled_at), + "cancellation_reason" => Deserialize::begin(&mut self.cancellation_reason), + "certificate" => Deserialize::begin(&mut self.certificate), + "confirmed_at" => Deserialize::begin(&mut self.confirmed_at), + "created" => Deserialize::begin(&mut self.created), + "currency" => Deserialize::begin(&mut self.currency), + "delayed_at" => Deserialize::begin(&mut self.delayed_at), + "delivered_at" => Deserialize::begin(&mut self.delivered_at), + "delivery_details" => Deserialize::begin(&mut self.delivery_details), + "expected_delivery_year" => Deserialize::begin(&mut self.expected_delivery_year), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "metric_tons" => Deserialize::begin(&mut self.metric_tons), + "object" => Deserialize::begin(&mut self.object), + "product" => Deserialize::begin(&mut self.product), + "product_substituted_at" => Deserialize::begin(&mut self.product_substituted_at), + "status" => Deserialize::begin(&mut self.status), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount_fees: Deserialize::default(), + amount_subtotal: Deserialize::default(), + amount_total: Deserialize::default(), + beneficiary: Deserialize::default(), + canceled_at: Deserialize::default(), + cancellation_reason: Deserialize::default(), + certificate: Deserialize::default(), + confirmed_at: Deserialize::default(), + created: Deserialize::default(), + currency: Deserialize::default(), + delayed_at: Deserialize::default(), + delivered_at: Deserialize::default(), + delivery_details: Deserialize::default(), + expected_delivery_year: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + metric_tons: Deserialize::default(), + object: Deserialize::default(), + product: Deserialize::default(), + product_substituted_at: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount_fees: self.amount_fees?, + amount_subtotal: self.amount_subtotal?, + amount_total: self.amount_total?, + beneficiary: self.beneficiary.take()?, + canceled_at: self.canceled_at?, + cancellation_reason: self.cancellation_reason?, + certificate: self.certificate.take()?, + confirmed_at: self.confirmed_at?, + created: self.created?, + currency: self.currency?, + delayed_at: self.delayed_at?, + delivered_at: self.delivered_at?, + delivery_details: self.delivery_details.take()?, + expected_delivery_year: self.expected_delivery_year?, + id: self.id.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + metric_tons: self.metric_tons.take()?, + object: self.object?, + product: self.product.take()?, + product_substituted_at: self.product_substituted_at?, + status: self.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 ClimateOrder { + type Builder = ClimateOrderBuilder; + } + + impl FromValueOpt for ClimateOrder { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ClimateOrderBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_fees" => b.amount_fees = 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)?), + "beneficiary" => b.beneficiary = 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)?) + } + "certificate" => b.certificate = Some(FromValueOpt::from_value(v)?), + "confirmed_at" => b.confirmed_at = Some(FromValueOpt::from_value(v)?), + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "delayed_at" => b.delayed_at = Some(FromValueOpt::from_value(v)?), + "delivered_at" => b.delivered_at = Some(FromValueOpt::from_value(v)?), + "delivery_details" => b.delivery_details = Some(FromValueOpt::from_value(v)?), + "expected_delivery_year" => { + b.expected_delivery_year = 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)?), + "metric_tons" => b.metric_tons = Some(FromValueOpt::from_value(v)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "product" => b.product = Some(FromValueOpt::from_value(v)?), + "product_substituted_at" => { + b.product_substituted_at = Some(FromValueOpt::from_value(v)?) + } + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Reason for the cancellation of this order. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ClimateOrderCancellationReason { @@ -90,6 +294,7 @@ impl std::fmt::Debug for ClimateOrderCancellationReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ClimateOrderCancellationReason { fn serialize(&self, serializer: S) -> Result where @@ -98,6 +303,22 @@ impl serde::Serialize for ClimateOrderCancellationReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ClimateOrderCancellationReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ClimateOrderCancellationReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ClimateOrderCancellationReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ClimateOrderCancellationReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -107,6 +328,74 @@ impl<'de> serde::Deserialize<'de> for ClimateOrderCancellationReason { }) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ClimateOrderObject { + ClimateOrder, +} +impl ClimateOrderObject { + pub fn as_str(self) -> &'static str { + use ClimateOrderObject::*; + match self { + ClimateOrder => "climate.order", + } + } +} + +impl std::str::FromStr for ClimateOrderObject { + type Err = (); + fn from_str(s: &str) -> Result { + use ClimateOrderObject::*; + match s { + "climate.order" => Ok(ClimateOrder), + _ => Err(()), + } + } +} +impl std::fmt::Display for ClimateOrderObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ClimateOrderObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for ClimateOrderObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for ClimateOrderObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ClimateOrderObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ClimateOrderObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ClimateOrderObject { + fn deserialize>(deserializer: D) -> 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 ClimateOrderObject")) + } +} /// The current status of this order. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ClimateOrderStatus { @@ -154,6 +443,7 @@ impl std::fmt::Debug for ClimateOrderStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ClimateOrderStatus { fn serialize(&self, serializer: S) -> Result where @@ -162,6 +452,22 @@ impl serde::Serialize for ClimateOrderStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ClimateOrderStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ClimateOrderStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ClimateOrderStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ClimateOrderStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/climate_product/types.rs b/generated/stripe_misc/src/climate_product/types.rs index dd2efbada..7a6e30b7f 100644 --- a/generated/stripe_misc/src/climate_product/types.rs +++ b/generated/stripe_misc/src/climate_product/types.rs @@ -1,6 +1,8 @@ /// 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)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ClimateProduct { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -20,9 +22,216 @@ pub struct ClimateProduct { pub metric_tons_available: String, /// The Climate product's name. pub name: String, + /// String representing the object's type. Objects of the same type share the same value. + pub object: ClimateProductObject, /// The carbon removal suppliers that fulfill orders for this Climate product. pub suppliers: Vec, } +#[doc(hidden)] +pub struct ClimateProductBuilder { + created: Option, + current_prices_per_metric_ton: + Option>, + delivery_year: Option>, + id: Option, + livemode: Option, + metric_tons_available: Option, + name: Option, + object: Option, + suppliers: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ClimateProduct { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ClimateProductBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: ClimateProductBuilder::deser_default(), + })) + } + } + + impl MapBuilder for ClimateProductBuilder { + type Out = ClimateProduct; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "created" => Deserialize::begin(&mut self.created), + "current_prices_per_metric_ton" => { + Deserialize::begin(&mut self.current_prices_per_metric_ton) + } + "delivery_year" => Deserialize::begin(&mut self.delivery_year), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "metric_tons_available" => Deserialize::begin(&mut self.metric_tons_available), + "name" => Deserialize::begin(&mut self.name), + "object" => Deserialize::begin(&mut self.object), + "suppliers" => Deserialize::begin(&mut self.suppliers), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + current_prices_per_metric_ton: Deserialize::default(), + delivery_year: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + metric_tons_available: Deserialize::default(), + name: Deserialize::default(), + object: Deserialize::default(), + suppliers: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + created: self.created?, + current_prices_per_metric_ton: self.current_prices_per_metric_ton.take()?, + delivery_year: self.delivery_year?, + id: self.id.take()?, + livemode: self.livemode?, + metric_tons_available: self.metric_tons_available.take()?, + name: self.name.take()?, + object: self.object?, + suppliers: self.suppliers.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ClimateProduct { + type Builder = ClimateProductBuilder; + } + + impl FromValueOpt for ClimateProduct { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ClimateProductBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "created" => b.created = Some(FromValueOpt::from_value(v)?), + "current_prices_per_metric_ton" => { + b.current_prices_per_metric_ton = Some(FromValueOpt::from_value(v)?) + } + "delivery_year" => b.delivery_year = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metric_tons_available" => { + b.metric_tons_available = Some(FromValueOpt::from_value(v)?) + } + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "suppliers" => b.suppliers = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ClimateProductObject { + ClimateProduct, +} +impl ClimateProductObject { + pub fn as_str(self) -> &'static str { + use ClimateProductObject::*; + match self { + ClimateProduct => "climate.product", + } + } +} + +impl std::str::FromStr for ClimateProductObject { + type Err = (); + fn from_str(s: &str) -> Result { + use ClimateProductObject::*; + match s { + "climate.product" => Ok(ClimateProduct), + _ => Err(()), + } + } +} +impl std::fmt::Display for ClimateProductObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ClimateProductObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for ClimateProductObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for ClimateProductObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ClimateProductObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ClimateProductObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ClimateProductObject { + fn deserialize>(deserializer: D) -> 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 ClimateProductObject")) + } +} impl stripe_types::Object for ClimateProduct { type Id = stripe_misc::ClimateProductId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_misc/src/climate_removals_beneficiary.rs b/generated/stripe_misc/src/climate_removals_beneficiary.rs index f0860a5fc..4644b3dc1 100644 --- a/generated/stripe_misc/src/climate_removals_beneficiary.rs +++ b/generated/stripe_misc/src/climate_removals_beneficiary.rs @@ -1,5 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ClimateRemovalsBeneficiary { /// Publicly displayable name for the end beneficiary of carbon removal. pub public_name: String, } +#[doc(hidden)] +pub struct ClimateRemovalsBeneficiaryBuilder { + public_name: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ClimateRemovalsBeneficiary { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ClimateRemovalsBeneficiaryBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: ClimateRemovalsBeneficiaryBuilder::deser_default(), + })) + } + } + + impl MapBuilder for ClimateRemovalsBeneficiaryBuilder { + type Out = ClimateRemovalsBeneficiary; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "public_name" => Deserialize::begin(&mut self.public_name), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { public_name: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { public_name: self.public_name.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ClimateRemovalsBeneficiary { + type Builder = ClimateRemovalsBeneficiaryBuilder; + } + + impl FromValueOpt for ClimateRemovalsBeneficiary { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ClimateRemovalsBeneficiaryBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "public_name" => b.public_name = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/climate_removals_location.rs b/generated/stripe_misc/src/climate_removals_location.rs index 7fa39bc14..afe6c084d 100644 --- a/generated/stripe_misc/src/climate_removals_location.rs +++ b/generated/stripe_misc/src/climate_removals_location.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ClimateRemovalsLocation { /// The city where the supplier is located. pub city: Option, @@ -11,3 +13,113 @@ pub struct ClimateRemovalsLocation { /// The state/county/province/region where the supplier is located. pub region: Option, } +#[doc(hidden)] +pub struct ClimateRemovalsLocationBuilder { + city: Option>, + country: Option, + latitude: Option>, + longitude: Option>, + region: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ClimateRemovalsLocation { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ClimateRemovalsLocationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: ClimateRemovalsLocationBuilder::deser_default(), + })) + } + } + + impl MapBuilder for ClimateRemovalsLocationBuilder { + type Out = ClimateRemovalsLocation; + 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), + + _ => ::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 { + Some(Self::Out { + city: self.city.take()?, + country: self.country.take()?, + latitude: self.latitude?, + longitude: self.longitude?, + region: self.region.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ClimateRemovalsLocation { + type Builder = ClimateRemovalsLocationBuilder; + } + + impl FromValueOpt for ClimateRemovalsLocation { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ClimateRemovalsLocationBuilder::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_misc/src/climate_removals_order_deliveries.rs b/generated/stripe_misc/src/climate_removals_order_deliveries.rs index 5dab0ff00..fa2972c62 100644 --- a/generated/stripe_misc/src/climate_removals_order_deliveries.rs +++ b/generated/stripe_misc/src/climate_removals_order_deliveries.rs @@ -1,5 +1,7 @@ /// The delivery of a specified quantity of carbon for an order. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ClimateRemovalsOrderDeliveries { /// Time at which the delivery occurred. Measured in seconds since the Unix epoch. pub delivered_at: stripe_types::Timestamp, @@ -11,3 +13,113 @@ pub struct ClimateRemovalsOrderDeliveries { pub registry_url: Option, pub supplier: stripe_misc::ClimateSupplier, } +#[doc(hidden)] +pub struct ClimateRemovalsOrderDeliveriesBuilder { + delivered_at: Option, + location: Option>, + metric_tons: Option, + registry_url: Option>, + supplier: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ClimateRemovalsOrderDeliveries { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ClimateRemovalsOrderDeliveriesBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: ClimateRemovalsOrderDeliveriesBuilder::deser_default(), + })) + } + } + + impl MapBuilder for ClimateRemovalsOrderDeliveriesBuilder { + type Out = ClimateRemovalsOrderDeliveries; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "delivered_at" => Deserialize::begin(&mut self.delivered_at), + "location" => Deserialize::begin(&mut self.location), + "metric_tons" => Deserialize::begin(&mut self.metric_tons), + "registry_url" => Deserialize::begin(&mut self.registry_url), + "supplier" => Deserialize::begin(&mut self.supplier), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + delivered_at: Deserialize::default(), + location: Deserialize::default(), + metric_tons: Deserialize::default(), + registry_url: Deserialize::default(), + supplier: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + delivered_at: self.delivered_at?, + location: self.location.take()?, + metric_tons: self.metric_tons.take()?, + registry_url: self.registry_url.take()?, + supplier: self.supplier.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ClimateRemovalsOrderDeliveries { + type Builder = ClimateRemovalsOrderDeliveriesBuilder; + } + + impl FromValueOpt for ClimateRemovalsOrderDeliveries { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ClimateRemovalsOrderDeliveriesBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "delivered_at" => b.delivered_at = Some(FromValueOpt::from_value(v)?), + "location" => b.location = Some(FromValueOpt::from_value(v)?), + "metric_tons" => b.metric_tons = Some(FromValueOpt::from_value(v)?), + "registry_url" => b.registry_url = Some(FromValueOpt::from_value(v)?), + "supplier" => b.supplier = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/climate_removals_products_price.rs b/generated/stripe_misc/src/climate_removals_products_price.rs index 13fb83ed5..f51e3ca36 100644 --- a/generated/stripe_misc/src/climate_removals_products_price.rs +++ b/generated/stripe_misc/src/climate_removals_products_price.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ClimateRemovalsProductsPrice { /// Fees for one metric ton of carbon removal in the currency's smallest unit. pub amount_fees: i64, @@ -7,3 +9,103 @@ pub struct ClimateRemovalsProductsPrice { /// Total for one metric ton of carbon removal (including fees) in the currency's smallest unit. pub amount_total: i64, } +#[doc(hidden)] +pub struct ClimateRemovalsProductsPriceBuilder { + amount_fees: Option, + amount_subtotal: Option, + amount_total: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ClimateRemovalsProductsPrice { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ClimateRemovalsProductsPriceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: ClimateRemovalsProductsPriceBuilder::deser_default(), + })) + } + } + + impl MapBuilder for ClimateRemovalsProductsPriceBuilder { + type Out = ClimateRemovalsProductsPrice; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "amount_fees" => Deserialize::begin(&mut self.amount_fees), + "amount_subtotal" => Deserialize::begin(&mut self.amount_subtotal), + "amount_total" => Deserialize::begin(&mut self.amount_total), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount_fees: Deserialize::default(), + amount_subtotal: Deserialize::default(), + amount_total: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount_fees: self.amount_fees?, + amount_subtotal: self.amount_subtotal?, + amount_total: self.amount_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 ClimateRemovalsProductsPrice { + type Builder = ClimateRemovalsProductsPriceBuilder; + } + + impl FromValueOpt for ClimateRemovalsProductsPrice { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ClimateRemovalsProductsPriceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "amount_fees" => b.amount_fees = 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)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_misc/src/climate_supplier/types.rs b/generated/stripe_misc/src/climate_supplier/types.rs index 5f4a13f13..a466e9d85 100644 --- a/generated/stripe_misc/src/climate_supplier/types.rs +++ b/generated/stripe_misc/src/climate_supplier/types.rs @@ -1,5 +1,7 @@ /// A supplier of carbon removal. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ClimateSupplier { /// Unique identifier for the object. pub id: stripe_misc::ClimateSupplierId, @@ -11,9 +13,199 @@ pub struct ClimateSupplier { pub locations: Vec, /// Name of this carbon removal supplier. pub name: String, + /// String representing the object’s type. Objects of the same type share the same value. + pub object: ClimateSupplierObject, /// The scientific pathway used for carbon removal. pub removal_pathway: ClimateSupplierRemovalPathway, } +#[doc(hidden)] +pub struct ClimateSupplierBuilder { + id: Option, + info_url: Option, + livemode: Option, + locations: Option>, + name: Option, + object: Option, + removal_pathway: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ClimateSupplier { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ClimateSupplierBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: ClimateSupplierBuilder::deser_default(), + })) + } + } + + impl MapBuilder for ClimateSupplierBuilder { + type Out = ClimateSupplier; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "id" => Deserialize::begin(&mut self.id), + "info_url" => Deserialize::begin(&mut self.info_url), + "livemode" => Deserialize::begin(&mut self.livemode), + "locations" => Deserialize::begin(&mut self.locations), + "name" => Deserialize::begin(&mut self.name), + "object" => Deserialize::begin(&mut self.object), + "removal_pathway" => Deserialize::begin(&mut self.removal_pathway), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + id: Deserialize::default(), + info_url: Deserialize::default(), + livemode: Deserialize::default(), + locations: Deserialize::default(), + name: Deserialize::default(), + object: Deserialize::default(), + removal_pathway: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + id: self.id.take()?, + info_url: self.info_url.take()?, + livemode: self.livemode?, + locations: self.locations.take()?, + name: self.name.take()?, + object: self.object?, + removal_pathway: self.removal_pathway?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for ClimateSupplier { + type Builder = ClimateSupplierBuilder; + } + + impl FromValueOpt for ClimateSupplier { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ClimateSupplierBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "info_url" => b.info_url = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "locations" => b.locations = Some(FromValueOpt::from_value(v)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "removal_pathway" => b.removal_pathway = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object’s type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ClimateSupplierObject { + ClimateSupplier, +} +impl ClimateSupplierObject { + pub fn as_str(self) -> &'static str { + use ClimateSupplierObject::*; + match self { + ClimateSupplier => "climate.supplier", + } + } +} + +impl std::str::FromStr for ClimateSupplierObject { + type Err = (); + fn from_str(s: &str) -> Result { + use ClimateSupplierObject::*; + match s { + "climate.supplier" => Ok(ClimateSupplier), + _ => Err(()), + } + } +} +impl std::fmt::Display for ClimateSupplierObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ClimateSupplierObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for ClimateSupplierObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for ClimateSupplierObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ClimateSupplierObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ClimateSupplierObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ClimateSupplierObject { + fn deserialize>(deserializer: D) -> 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 ClimateSupplierObject")) + } +} /// The scientific pathway used for carbon removal. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ClimateSupplierRemovalPathway { @@ -55,6 +247,7 @@ impl std::fmt::Debug for ClimateSupplierRemovalPathway { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ClimateSupplierRemovalPathway { fn serialize(&self, serializer: S) -> Result where @@ -63,6 +256,22 @@ impl serde::Serialize for ClimateSupplierRemovalPathway { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ClimateSupplierRemovalPathway { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ClimateSupplierRemovalPathway::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ClimateSupplierRemovalPathway); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ClimateSupplierRemovalPathway { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/deleted_apple_pay_domain.rs b/generated/stripe_misc/src/deleted_apple_pay_domain.rs index 666770f23..89c416dd7 100644 --- a/generated/stripe_misc/src/deleted_apple_pay_domain.rs +++ b/generated/stripe_misc/src/deleted_apple_pay_domain.rs @@ -1,9 +1,178 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedApplePayDomainObject, +} +#[doc(hidden)] +pub struct DeletedApplePayDomainBuilder { + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedApplePayDomainBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deleted: self.deleted?, id: self.id.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedApplePayDomainObject { + ApplePayDomain, +} +impl DeletedApplePayDomainObject { + pub fn as_str(self) -> &'static str { + use DeletedApplePayDomainObject::*; + match self { + ApplePayDomain => "apple_pay_domain", + } + } +} + +impl std::str::FromStr for DeletedApplePayDomainObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedApplePayDomainObject::*; + match s { + "apple_pay_domain" => Ok(ApplePayDomain), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedApplePayDomainObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedApplePayDomainObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedApplePayDomainObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedApplePayDomainObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DeletedApplePayDomainObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedApplePayDomainObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedApplePayDomainObject { + fn deserialize>(deserializer: D) -> 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 DeletedApplePayDomainObject")) + } } impl stripe_types::Object for DeletedApplePayDomain { type Id = stripe_misc::ApplePayDomainId; diff --git a/generated/stripe_misc/src/deleted_webhook_endpoint.rs b/generated/stripe_misc/src/deleted_webhook_endpoint.rs index c327e5e37..d2dd16187 100644 --- a/generated/stripe_misc/src/deleted_webhook_endpoint.rs +++ b/generated/stripe_misc/src/deleted_webhook_endpoint.rs @@ -1,9 +1,178 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedWebhookEndpointObject, +} +#[doc(hidden)] +pub struct DeletedWebhookEndpointBuilder { + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedWebhookEndpointBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deleted: self.deleted?, id: self.id.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedWebhookEndpointObject { + WebhookEndpoint, +} +impl DeletedWebhookEndpointObject { + pub fn as_str(self) -> &'static str { + use DeletedWebhookEndpointObject::*; + match self { + WebhookEndpoint => "webhook_endpoint", + } + } +} + +impl std::str::FromStr for DeletedWebhookEndpointObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedWebhookEndpointObject::*; + match s { + "webhook_endpoint" => Ok(WebhookEndpoint), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedWebhookEndpointObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedWebhookEndpointObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedWebhookEndpointObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedWebhookEndpointObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DeletedWebhookEndpointObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedWebhookEndpointObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedWebhookEndpointObject { + fn deserialize>(deserializer: D) -> 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 DeletedWebhookEndpointObject")) + } } impl stripe_types::Object for DeletedWebhookEndpoint { type Id = stripe_misc::WebhookEndpointId; diff --git a/generated/stripe_misc/src/ephemeral_key/types.rs b/generated/stripe_misc/src/ephemeral_key/types.rs index 524bd3190..def560cd0 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct EphemeralKey { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -8,10 +10,194 @@ pub struct EphemeralKey { pub id: stripe_misc::EphemeralKeyId, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: EphemeralKeyObject, /// 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, } +#[doc(hidden)] +pub struct EphemeralKeyBuilder { + created: Option, + expires: Option, + id: Option, + livemode: Option, + object: Option, + secret: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: EphemeralKeyBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "secret" => Deserialize::begin(&mut self.secret), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + expires: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + object: Deserialize::default(), + secret: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + created: self.created?, + expires: self.expires?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + secret: self.secret.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "secret" => b.secret = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum EphemeralKeyObject { + EphemeralKey, +} +impl EphemeralKeyObject { + pub fn as_str(self) -> &'static str { + use EphemeralKeyObject::*; + match self { + EphemeralKey => "ephemeral_key", + } + } +} + +impl std::str::FromStr for EphemeralKeyObject { + type Err = (); + fn from_str(s: &str) -> Result { + use EphemeralKeyObject::*; + match s { + "ephemeral_key" => Ok(EphemeralKey), + _ => Err(()), + } + } +} +impl std::fmt::Display for EphemeralKeyObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for EphemeralKeyObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for EphemeralKeyObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for EphemeralKeyObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(EphemeralKeyObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(EphemeralKeyObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for EphemeralKeyObject { + fn deserialize>(deserializer: D) -> 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 EphemeralKeyObject")) + } +} 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/types.rs b/generated/stripe_misc/src/exchange_rate/types.rs index 1d6b8a176..7a28e00f6 100644 --- a/generated/stripe_misc/src/exchange_rate/types.rs +++ b/generated/stripe_misc/src/exchange_rate/types.rs @@ -26,14 +26,182 @@ /// - *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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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. pub id: stripe_misc::ExchangeRateId, + /// String representing the object's type. Objects of the same type share the same value. + pub object: ExchangeRateObject, /// 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, } +#[doc(hidden)] +pub struct ExchangeRateBuilder { + id: Option, + object: Option, + rates: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ExchangeRateBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "rates" => Deserialize::begin(&mut self.rates), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + id: Deserialize::default(), + object: Deserialize::default(), + rates: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { id: self.id.take()?, object: self.object?, rates: self.rates.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "rates" => b.rates = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ExchangeRateObject { + ExchangeRate, +} +impl ExchangeRateObject { + pub fn as_str(self) -> &'static str { + use ExchangeRateObject::*; + match self { + ExchangeRate => "exchange_rate", + } + } +} + +impl std::str::FromStr for ExchangeRateObject { + type Err = (); + fn from_str(s: &str) -> Result { + use ExchangeRateObject::*; + match s { + "exchange_rate" => Ok(ExchangeRate), + _ => Err(()), + } + } +} +impl std::fmt::Display for ExchangeRateObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ExchangeRateObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for ExchangeRateObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for ExchangeRateObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ExchangeRateObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ExchangeRateObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ExchangeRateObject { + fn deserialize>(deserializer: D) -> 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 ExchangeRateObject")) + } +} 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..45e67f090 100644 --- a/generated/stripe_misc/src/financial_connections_account/requests.rs +++ b/generated/stripe_misc/src/financial_connections_account/requests.rs @@ -217,6 +217,16 @@ impl serde::Serialize for RefreshFinancialConnectionsAccountFeatures { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for RefreshFinancialConnectionsAccountFeatures { + fn deserialize>(deserializer: D) -> 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 RefreshFinancialConnectionsAccountFeatures") + }) + } +} impl<'a> RefreshFinancialConnectionsAccount<'a> { /// Refreshes the data associated with a Financial Connections `Account`. pub fn send( @@ -287,6 +297,18 @@ impl serde::Serialize for SubscribeFinancialConnectionsAccountFeatures { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for SubscribeFinancialConnectionsAccountFeatures { + fn deserialize>(deserializer: D) -> 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 SubscribeFinancialConnectionsAccountFeatures", + ) + }) + } +} impl<'a> SubscribeFinancialConnectionsAccount<'a> { /// Subscribes to periodic refreshes of data associated with a Financial Connections `Account`. pub fn send( @@ -357,6 +379,18 @@ impl serde::Serialize for UnsubscribeFinancialConnectionsAccountFeatures { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UnsubscribeFinancialConnectionsAccountFeatures { + fn deserialize>(deserializer: D) -> 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 UnsubscribeFinancialConnectionsAccountFeatures", + ) + }) + } +} impl<'a> UnsubscribeFinancialConnectionsAccount<'a> { /// Unsubscribes from periodic refreshes of data associated with a Financial Connections `Account`. pub fn send( diff --git a/generated/stripe_misc/src/financial_connections_account/types.rs b/generated/stripe_misc/src/financial_connections_account/types.rs index c1751e37f..ced64869b 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct FinancialConnectionsAccount { /// The account holder that this account belongs to. pub account_holder: Option, @@ -23,6 +25,8 @@ pub struct FinancialConnectionsAccount { pub last4: Option, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: FinancialConnectionsAccountObject, /// The most recent information about the account's owners. pub ownership: Option>, @@ -54,6 +58,194 @@ pub struct FinancialConnectionsAccount { /// The state of the most recent attempt to refresh the account transactions. pub transaction_refresh: Option, } +#[doc(hidden)] +pub struct FinancialConnectionsAccountBuilder { + account_holder: Option>, + balance: Option>, + balance_refresh: Option>, + category: Option, + created: Option, + display_name: Option>, + id: Option, + institution_name: Option, + last4: Option>, + livemode: Option, + object: Option, + ownership: + Option>>, + ownership_refresh: Option>, + permissions: Option>>, + status: Option, + subcategory: Option, + subscriptions: Option>>, + supported_payment_method_types: + Option>, + transaction_refresh: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: FinancialConnectionsAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + "subscriptions" => Deserialize::begin(&mut self.subscriptions), + "supported_payment_method_types" => { + Deserialize::begin(&mut self.supported_payment_method_types) + } + "transaction_refresh" => Deserialize::begin(&mut self.transaction_refresh), + + _ => ::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(), + object: Deserialize::default(), + ownership: Deserialize::default(), + ownership_refresh: Deserialize::default(), + permissions: Deserialize::default(), + status: Deserialize::default(), + subcategory: Deserialize::default(), + subscriptions: Deserialize::default(), + supported_payment_method_types: Deserialize::default(), + transaction_refresh: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account_holder: self.account_holder.take()?, + balance: self.balance.take()?, + balance_refresh: self.balance_refresh?, + category: self.category?, + created: self.created?, + display_name: self.display_name.take()?, + id: self.id.take()?, + institution_name: self.institution_name.take()?, + last4: self.last4.take()?, + livemode: self.livemode?, + object: self.object?, + ownership: self.ownership.take()?, + ownership_refresh: self.ownership_refresh?, + permissions: self.permissions.take()?, + status: self.status?, + subcategory: self.subcategory?, + subscriptions: self.subscriptions.take()?, + supported_payment_method_types: self.supported_payment_method_types.take()?, + transaction_refresh: self.transaction_refresh.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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)?), + "subscriptions" => b.subscriptions = Some(FromValueOpt::from_value(v)?), + "supported_payment_method_types" => { + b.supported_payment_method_types = Some(FromValueOpt::from_value(v)?) + } + "transaction_refresh" => { + b.transaction_refresh = 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 { @@ -98,6 +290,7 @@ impl std::fmt::Debug for FinancialConnectionsAccountCategory { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for FinancialConnectionsAccountCategory { fn serialize(&self, serializer: S) -> Result where @@ -106,6 +299,23 @@ impl serde::Serialize for FinancialConnectionsAccountCategory { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for FinancialConnectionsAccountCategory { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(FinancialConnectionsAccountCategory::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsAccountCategory); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for FinancialConnectionsAccountCategory { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -115,6 +325,76 @@ impl<'de> serde::Deserialize<'de> for FinancialConnectionsAccountCategory { }) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum FinancialConnectionsAccountObject { + FinancialConnectionsAccount, +} +impl FinancialConnectionsAccountObject { + pub fn as_str(self) -> &'static str { + use FinancialConnectionsAccountObject::*; + match self { + FinancialConnectionsAccount => "financial_connections.account", + } + } +} + +impl std::str::FromStr for FinancialConnectionsAccountObject { + type Err = (); + fn from_str(s: &str) -> Result { + use FinancialConnectionsAccountObject::*; + match s { + "financial_connections.account" => Ok(FinancialConnectionsAccount), + _ => Err(()), + } + } +} +impl std::fmt::Display for FinancialConnectionsAccountObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for FinancialConnectionsAccountObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for FinancialConnectionsAccountObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for FinancialConnectionsAccountObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(FinancialConnectionsAccountObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsAccountObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for FinancialConnectionsAccountObject { + fn deserialize>(deserializer: D) -> 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 FinancialConnectionsAccountObject") + }) + } +} /// The list of permissions granted by this account. #[derive(Copy, Clone, Eq, PartialEq)] pub enum FinancialConnectionsAccountPermissions { @@ -159,6 +439,7 @@ impl std::fmt::Debug for FinancialConnectionsAccountPermissions { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for FinancialConnectionsAccountPermissions { fn serialize(&self, serializer: S) -> Result where @@ -167,6 +448,24 @@ impl serde::Serialize for FinancialConnectionsAccountPermissions { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for FinancialConnectionsAccountPermissions { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + FinancialConnectionsAccountPermissions::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsAccountPermissions); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for FinancialConnectionsAccountPermissions { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -217,6 +516,7 @@ impl std::fmt::Debug for FinancialConnectionsAccountStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for FinancialConnectionsAccountStatus { fn serialize(&self, serializer: S) -> Result where @@ -225,6 +525,23 @@ impl serde::Serialize for FinancialConnectionsAccountStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for FinancialConnectionsAccountStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(FinancialConnectionsAccountStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsAccountStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for FinancialConnectionsAccountStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -297,6 +614,7 @@ impl std::fmt::Debug for FinancialConnectionsAccountSubcategory { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for FinancialConnectionsAccountSubcategory { fn serialize(&self, serializer: S) -> Result where @@ -305,6 +623,24 @@ impl serde::Serialize for FinancialConnectionsAccountSubcategory { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for FinancialConnectionsAccountSubcategory { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + FinancialConnectionsAccountSubcategory::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsAccountSubcategory); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for FinancialConnectionsAccountSubcategory { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -349,6 +685,7 @@ impl std::fmt::Debug for FinancialConnectionsAccountSubscriptions { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for FinancialConnectionsAccountSubscriptions { fn serialize(&self, serializer: S) -> Result where @@ -357,6 +694,24 @@ impl serde::Serialize for FinancialConnectionsAccountSubscriptions { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for FinancialConnectionsAccountSubscriptions { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + FinancialConnectionsAccountSubscriptions::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsAccountSubscriptions); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for FinancialConnectionsAccountSubscriptions { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -404,6 +759,7 @@ impl std::fmt::Debug for FinancialConnectionsAccountSupportedPaymentMethodTypes f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for FinancialConnectionsAccountSupportedPaymentMethodTypes { fn serialize(&self, serializer: S) -> Result where @@ -412,6 +768,27 @@ impl serde::Serialize for FinancialConnectionsAccountSupportedPaymentMethodTypes serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for FinancialConnectionsAccountSupportedPaymentMethodTypes { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + FinancialConnectionsAccountSupportedPaymentMethodTypes::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsAccountSupportedPaymentMethodTypes); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for FinancialConnectionsAccountSupportedPaymentMethodTypes { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/financial_connections_account_owner.rs b/generated/stripe_misc/src/financial_connections_account_owner.rs index 02630032d..8136110d5 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct FinancialConnectionsAccountOwner { /// The email address of the owner. pub email: Option, @@ -7,6 +9,8 @@ pub struct FinancialConnectionsAccountOwner { pub id: stripe_misc::FinancialConnectionsAccountOwnerId, /// The full name of the owner. pub name: String, + /// String representing the object's type. Objects of the same type share the same value. + pub object: FinancialConnectionsAccountOwnerObject, /// The ownership object that this owner belongs to. pub ownership: String, /// The raw phone number of the owner. @@ -16,6 +20,202 @@ pub struct FinancialConnectionsAccountOwner { /// The timestamp of the refresh that updated this owner. pub refreshed_at: Option, } +#[doc(hidden)] +pub struct FinancialConnectionsAccountOwnerBuilder { + email: Option>, + id: Option, + name: Option, + object: Option, + ownership: Option, + phone: Option>, + raw_address: Option>, + refreshed_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: FinancialConnectionsAccountOwnerBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + email: Deserialize::default(), + id: Deserialize::default(), + name: Deserialize::default(), + object: Deserialize::default(), + ownership: Deserialize::default(), + phone: Deserialize::default(), + raw_address: Deserialize::default(), + refreshed_at: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + email: self.email.take()?, + id: self.id.take()?, + name: self.name.take()?, + object: self.object?, + ownership: self.ownership.take()?, + phone: self.phone.take()?, + raw_address: self.raw_address.take()?, + refreshed_at: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum FinancialConnectionsAccountOwnerObject { + FinancialConnectionsAccountOwner, +} +impl FinancialConnectionsAccountOwnerObject { + pub fn as_str(self) -> &'static str { + use FinancialConnectionsAccountOwnerObject::*; + match self { + FinancialConnectionsAccountOwner => "financial_connections.account_owner", + } + } +} + +impl std::str::FromStr for FinancialConnectionsAccountOwnerObject { + type Err = (); + fn from_str(s: &str) -> Result { + use FinancialConnectionsAccountOwnerObject::*; + match s { + "financial_connections.account_owner" => Ok(FinancialConnectionsAccountOwner), + _ => Err(()), + } + } +} +impl std::fmt::Display for FinancialConnectionsAccountOwnerObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for FinancialConnectionsAccountOwnerObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for FinancialConnectionsAccountOwnerObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for FinancialConnectionsAccountOwnerObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + FinancialConnectionsAccountOwnerObject::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsAccountOwnerObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for FinancialConnectionsAccountOwnerObject { + fn deserialize>(deserializer: D) -> 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 FinancialConnectionsAccountOwnerObject") + }) + } +} 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..345da5c12 100644 --- a/generated/stripe_misc/src/financial_connections_account_ownership.rs +++ b/generated/stripe_misc/src/financial_connections_account_ownership.rs @@ -1,13 +1,194 @@ /// 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct FinancialConnectionsAccountOwnership { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, /// Unique identifier for the object. pub id: stripe_misc::FinancialConnectionsAccountOwnershipId, + /// String representing the object's type. Objects of the same type share the same value. + pub object: FinancialConnectionsAccountOwnershipObject, /// A paginated list of owners for this account. pub owners: stripe_types::List, } +#[doc(hidden)] +pub struct FinancialConnectionsAccountOwnershipBuilder { + created: Option, + id: Option, + object: Option, + owners: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: FinancialConnectionsAccountOwnershipBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "owners" => Deserialize::begin(&mut self.owners), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + owners: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + created: self.created?, + id: self.id.take()?, + object: self.object?, + owners: self.owners.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "owners" => b.owners = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum FinancialConnectionsAccountOwnershipObject { + FinancialConnectionsAccountOwnership, +} +impl FinancialConnectionsAccountOwnershipObject { + pub fn as_str(self) -> &'static str { + use FinancialConnectionsAccountOwnershipObject::*; + match self { + FinancialConnectionsAccountOwnership => "financial_connections.account_ownership", + } + } +} + +impl std::str::FromStr for FinancialConnectionsAccountOwnershipObject { + type Err = (); + fn from_str(s: &str) -> Result { + use FinancialConnectionsAccountOwnershipObject::*; + match s { + "financial_connections.account_ownership" => Ok(FinancialConnectionsAccountOwnership), + _ => Err(()), + } + } +} +impl std::fmt::Display for FinancialConnectionsAccountOwnershipObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for FinancialConnectionsAccountOwnershipObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for FinancialConnectionsAccountOwnershipObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for FinancialConnectionsAccountOwnershipObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + FinancialConnectionsAccountOwnershipObject::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsAccountOwnershipObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for FinancialConnectionsAccountOwnershipObject { + fn deserialize>(deserializer: D) -> 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 FinancialConnectionsAccountOwnershipObject") + }) + } +} 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..41ca5e995 100644 --- a/generated/stripe_misc/src/financial_connections_session/requests.rs +++ b/generated/stripe_misc/src/financial_connections_session/requests.rs @@ -122,6 +122,18 @@ impl serde::Serialize for CreateFinancialConnectionsSessionAccountHolderType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateFinancialConnectionsSessionAccountHolderType { + fn deserialize>(deserializer: D) -> 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 CreateFinancialConnectionsSessionAccountHolderType", + ) + }) + } +} /// Filters to restrict the kinds of accounts to collect. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateFinancialConnectionsSessionFilters<'a> { diff --git a/generated/stripe_misc/src/financial_connections_session/types.rs b/generated/stripe_misc/src/financial_connections_session/types.rs index 9890e5288..a50a950f3 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct FinancialConnectionsSession { /// The account holder for whom accounts are collected in this session. pub account_holder: Option, @@ -9,21 +11,226 @@ pub struct FinancialConnectionsSession { pub accounts: stripe_types::List, /// 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, /// Unique identifier for the object. pub id: stripe_misc::FinancialConnectionsSessionId, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: FinancialConnectionsSessionObject, /// Permissions requested for accounts collected during this session. pub permissions: Vec, /// Data features requested to be retrieved upon account creation. pub prefetch: Option>, /// 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, } +#[doc(hidden)] +pub struct FinancialConnectionsSessionBuilder { + account_holder: Option>, + accounts: Option>, + client_secret: Option, + filters: Option>, + id: Option, + livemode: Option, + object: Option, + permissions: Option>, + prefetch: Option>>, + return_url: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: FinancialConnectionsSessionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "permissions" => Deserialize::begin(&mut self.permissions), + "prefetch" => Deserialize::begin(&mut self.prefetch), + "return_url" => Deserialize::begin(&mut self.return_url), + + _ => ::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(), + object: Deserialize::default(), + permissions: Deserialize::default(), + prefetch: Deserialize::default(), + return_url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account_holder: self.account_holder.take()?, + accounts: self.accounts.take()?, + client_secret: self.client_secret.take()?, + filters: self.filters.take()?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + permissions: self.permissions.take()?, + prefetch: self.prefetch.take()?, + return_url: self.return_url.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum FinancialConnectionsSessionObject { + FinancialConnectionsSession, +} +impl FinancialConnectionsSessionObject { + pub fn as_str(self) -> &'static str { + use FinancialConnectionsSessionObject::*; + match self { + FinancialConnectionsSession => "financial_connections.session", + } + } +} + +impl std::str::FromStr for FinancialConnectionsSessionObject { + type Err = (); + fn from_str(s: &str) -> Result { + use FinancialConnectionsSessionObject::*; + match s { + "financial_connections.session" => Ok(FinancialConnectionsSession), + _ => Err(()), + } + } +} +impl std::fmt::Display for FinancialConnectionsSessionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for FinancialConnectionsSessionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for FinancialConnectionsSessionObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for FinancialConnectionsSessionObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(FinancialConnectionsSessionObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsSessionObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for FinancialConnectionsSessionObject { + fn deserialize>(deserializer: D) -> 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 FinancialConnectionsSessionObject") + }) + } +} impl stripe_types::Object for FinancialConnectionsSession { type Id = stripe_misc::FinancialConnectionsSessionId; fn id(&self) -> &Self::Id { @@ -82,6 +289,24 @@ impl serde::Serialize for FinancialConnectionsSessionPermissions { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for FinancialConnectionsSessionPermissions { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + FinancialConnectionsSessionPermissions::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsSessionPermissions); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for FinancialConnectionsSessionPermissions { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -139,6 +364,23 @@ impl serde::Serialize for FinancialConnectionsSessionPrefetch { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for FinancialConnectionsSessionPrefetch { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(FinancialConnectionsSessionPrefetch::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsSessionPrefetch); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for FinancialConnectionsSessionPrefetch { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/financial_connections_transaction/types.rs b/generated/stripe_misc/src/financial_connections_transaction/types.rs index 774426515..c27e779bd 100644 --- a/generated/stripe_misc/src/financial_connections_transaction/types.rs +++ b/generated/stripe_misc/src/financial_connections_transaction/types.rs @@ -1,5 +1,7 @@ /// A Transaction represents a real transaction that affects a Financial Connections Account balance. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct FinancialConnectionsTransaction { /// The ID of the Financial Connections Account this transaction belongs to. pub account: String, @@ -14,6 +16,8 @@ pub struct FinancialConnectionsTransaction { 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: FinancialConnectionsTransactionObject, /// The status of the transaction. pub status: FinancialConnectionsTransactionStatus, pub status_transitions: @@ -25,6 +29,226 @@ pub struct FinancialConnectionsTransaction { /// Time at which the object was last updated. Measured in seconds since the Unix epoch. pub updated: stripe_types::Timestamp, } +#[doc(hidden)] +pub struct FinancialConnectionsTransactionBuilder { + account: Option, + amount: Option, + currency: Option, + description: Option, + id: Option, + livemode: Option, + object: Option, + status: Option, + status_transitions: + Option, + transacted_at: Option, + transaction_refresh: Option, + updated: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for FinancialConnectionsTransaction { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: FinancialConnectionsTransactionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: FinancialConnectionsTransactionBuilder::deser_default(), + })) + } + } + + impl MapBuilder for FinancialConnectionsTransactionBuilder { + type Out = FinancialConnectionsTransaction; + 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), + "currency" => Deserialize::begin(&mut self.currency), + "description" => Deserialize::begin(&mut self.description), + "id" => Deserialize::begin(&mut self.id), + "livemode" => Deserialize::begin(&mut self.livemode), + "object" => Deserialize::begin(&mut self.object), + "status" => Deserialize::begin(&mut self.status), + "status_transitions" => Deserialize::begin(&mut self.status_transitions), + "transacted_at" => Deserialize::begin(&mut self.transacted_at), + "transaction_refresh" => Deserialize::begin(&mut self.transaction_refresh), + "updated" => Deserialize::begin(&mut self.updated), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account: Deserialize::default(), + amount: Deserialize::default(), + currency: Deserialize::default(), + description: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + object: Deserialize::default(), + status: Deserialize::default(), + status_transitions: Deserialize::default(), + transacted_at: Deserialize::default(), + transaction_refresh: Deserialize::default(), + updated: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account: self.account.take()?, + amount: self.amount?, + currency: self.currency?, + description: self.description.take()?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + status: self.status?, + status_transitions: self.status_transitions?, + transacted_at: self.transacted_at?, + transaction_refresh: self.transaction_refresh.take()?, + updated: self.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 FinancialConnectionsTransaction { + type Builder = FinancialConnectionsTransactionBuilder; + } + + impl FromValueOpt for FinancialConnectionsTransaction { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = FinancialConnectionsTransactionBuilder::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)?), + "currency" => b.currency = Some(FromValueOpt::from_value(v)?), + "description" => b.description = Some(FromValueOpt::from_value(v)?), + "id" => b.id = Some(FromValueOpt::from_value(v)?), + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + "status_transitions" => { + b.status_transitions = Some(FromValueOpt::from_value(v)?) + } + "transacted_at" => b.transacted_at = Some(FromValueOpt::from_value(v)?), + "transaction_refresh" => { + b.transaction_refresh = Some(FromValueOpt::from_value(v)?) + } + "updated" => b.updated = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum FinancialConnectionsTransactionObject { + FinancialConnectionsTransaction, +} +impl FinancialConnectionsTransactionObject { + pub fn as_str(self) -> &'static str { + use FinancialConnectionsTransactionObject::*; + match self { + FinancialConnectionsTransaction => "financial_connections.transaction", + } + } +} + +impl std::str::FromStr for FinancialConnectionsTransactionObject { + type Err = (); + fn from_str(s: &str) -> Result { + use FinancialConnectionsTransactionObject::*; + match s { + "financial_connections.transaction" => Ok(FinancialConnectionsTransaction), + _ => Err(()), + } + } +} +impl std::fmt::Display for FinancialConnectionsTransactionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for FinancialConnectionsTransactionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for FinancialConnectionsTransactionObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for FinancialConnectionsTransactionObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(FinancialConnectionsTransactionObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsTransactionObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for FinancialConnectionsTransactionObject { + fn deserialize>(deserializer: D) -> 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 FinancialConnectionsTransactionObject") + }) + } +} /// The status of the transaction. #[derive(Copy, Clone, Eq, PartialEq)] pub enum FinancialConnectionsTransactionStatus { @@ -66,6 +290,7 @@ impl std::fmt::Debug for FinancialConnectionsTransactionStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for FinancialConnectionsTransactionStatus { fn serialize(&self, serializer: S) -> Result where @@ -74,6 +299,23 @@ impl serde::Serialize for FinancialConnectionsTransactionStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for FinancialConnectionsTransactionStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(FinancialConnectionsTransactionStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FinancialConnectionsTransactionStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for FinancialConnectionsTransactionStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..50c1ff339 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,153 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, /// Connected account ID by which to filter the report run. - #[serde(skip_serializing_if = "Option::is_none")] pub connected_account: Option, /// Currency of objects to be included in the report run. - #[serde(skip_serializing_if = "Option::is_none")] pub currency: Option, /// 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, /// 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, /// Payout ID by which to filter the report run. - #[serde(skip_serializing_if = "Option::is_none")] pub payout: Option, /// Category of balance transactions to be included in the report run. - #[serde(skip_serializing_if = "Option::is_none")] pub reporting_category: Option, /// 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, } +#[doc(hidden)] +pub struct FinancialReportingFinanceReportRunRunParametersBuilder { + columns: Option>>, + connected_account: Option>, + currency: Option>, + interval_end: Option>, + interval_start: Option>, + payout: Option>, + reporting_category: Option>, + timezone: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: FinancialReportingFinanceReportRunRunParametersBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + columns: self.columns.take()?, + connected_account: self.connected_account.take()?, + currency: self.currency?, + interval_end: self.interval_end?, + interval_start: self.interval_start?, + payout: self.payout.take()?, + reporting_category: self.reporting_category.take()?, + timezone: self.timezone.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..5170f83fe 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct GelatoDataDocumentReportDateOfBirth { /// Numerical day between 1 and 31. pub day: Option, @@ -8,3 +10,99 @@ pub struct GelatoDataDocumentReportDateOfBirth { /// The four-digit year. pub year: Option, } +#[doc(hidden)] +pub struct GelatoDataDocumentReportDateOfBirthBuilder { + day: Option>, + month: Option>, + year: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoDataDocumentReportDateOfBirthBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + day: Deserialize::default(), + month: Deserialize::default(), + year: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { day: self.day?, month: self.month?, year: self.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 { + 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..674a671c2 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct GelatoDataDocumentReportExpirationDate { /// Numerical day between 1 and 31. pub day: Option, @@ -8,3 +10,99 @@ pub struct GelatoDataDocumentReportExpirationDate { /// The four-digit year. pub year: Option, } +#[doc(hidden)] +pub struct GelatoDataDocumentReportExpirationDateBuilder { + day: Option>, + month: Option>, + year: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoDataDocumentReportExpirationDateBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + day: Deserialize::default(), + month: Deserialize::default(), + year: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { day: self.day?, month: self.month?, year: self.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 { + 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..2ad293ecc 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct GelatoDataDocumentReportIssuedDate { /// Numerical day between 1 and 31. pub day: Option, @@ -8,3 +10,99 @@ pub struct GelatoDataDocumentReportIssuedDate { /// The four-digit year. pub year: Option, } +#[doc(hidden)] +pub struct GelatoDataDocumentReportIssuedDateBuilder { + day: Option>, + month: Option>, + year: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoDataDocumentReportIssuedDateBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + day: Deserialize::default(), + month: Deserialize::default(), + year: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { day: self.day?, month: self.month?, year: self.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 { + 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..ff355d6e3 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct GelatoDataIdNumberReportDate { /// Numerical day between 1 and 31. pub day: Option, @@ -8,3 +10,99 @@ pub struct GelatoDataIdNumberReportDate { /// The four-digit year. pub year: Option, } +#[doc(hidden)] +pub struct GelatoDataIdNumberReportDateBuilder { + day: Option>, + month: Option>, + year: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoDataIdNumberReportDateBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + day: Deserialize::default(), + month: Deserialize::default(), + year: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { day: self.day?, month: self.month?, year: self.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 { + 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..663020a47 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct GelatoDataVerifiedOutputsDate { /// Numerical day between 1 and 31. pub day: Option, @@ -8,3 +10,99 @@ pub struct GelatoDataVerifiedOutputsDate { /// The four-digit year. pub year: Option, } +#[doc(hidden)] +pub struct GelatoDataVerifiedOutputsDateBuilder { + day: Option>, + month: Option>, + year: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoDataVerifiedOutputsDateBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + day: Deserialize::default(), + month: Deserialize::default(), + year: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { day: self.day?, month: self.month?, year: self.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 { + 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..ae790558f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct GelatoDocumentReport { /// Address as it appears in the document. pub address: Option, @@ -24,9 +26,154 @@ pub struct GelatoDocumentReport { /// Status of this `document` check. pub status: GelatoDocumentReportStatus, /// Type of the document. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: Option, } +#[doc(hidden)] +pub struct GelatoDocumentReportBuilder { + address: Option>, + dob: Option>, + error: Option>, + expiration_date: Option>, + files: Option>>, + first_name: Option>, + issued_date: Option>, + issuing_country: Option>, + last_name: Option>, + number: Option>, + status: Option, + type_: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoDocumentReportBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + address: self.address.take()?, + dob: self.dob?, + error: self.error.take()?, + expiration_date: self.expiration_date?, + files: self.files.take()?, + first_name: self.first_name.take()?, + issued_date: self.issued_date?, + issuing_country: self.issuing_country.take()?, + last_name: self.last_name.take()?, + number: self.number.take()?, + status: self.status?, + type_: self.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 { + 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 { @@ -65,6 +212,7 @@ impl std::fmt::Debug for GelatoDocumentReportStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for GelatoDocumentReportStatus { fn serialize(&self, serializer: S) -> Result where @@ -73,6 +221,22 @@ impl serde::Serialize for GelatoDocumentReportStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for GelatoDocumentReportStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoDocumentReportStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(GelatoDocumentReportStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for GelatoDocumentReportStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -122,6 +286,7 @@ impl std::fmt::Debug for GelatoDocumentReportType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for GelatoDocumentReportType { fn serialize(&self, serializer: S) -> Result where @@ -130,6 +295,22 @@ impl serde::Serialize for GelatoDocumentReportType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for GelatoDocumentReportType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoDocumentReportType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(GelatoDocumentReportType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for GelatoDocumentReportType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/gelato_document_report_error.rs b/generated/stripe_misc/src/gelato_document_report_error.rs index cb6845bcf..8c8ca7239 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct GelatoDocumentReportError { /// A short machine-readable string giving the reason for the verification failure. pub code: Option, @@ -6,6 +8,95 @@ pub struct GelatoDocumentReportError { /// These messages can be shown to your users. pub reason: Option, } +#[doc(hidden)] +pub struct GelatoDocumentReportErrorBuilder { + code: Option>, + reason: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoDocumentReportErrorBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { code: Deserialize::default(), reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { code: self.code?, reason: self.reason.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -47,6 +138,7 @@ impl std::fmt::Debug for GelatoDocumentReportErrorCode { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for GelatoDocumentReportErrorCode { fn serialize(&self, serializer: S) -> Result where @@ -55,6 +147,22 @@ impl serde::Serialize for GelatoDocumentReportErrorCode { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for GelatoDocumentReportErrorCode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoDocumentReportErrorCode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(GelatoDocumentReportErrorCode); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for GelatoDocumentReportErrorCode { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/gelato_id_number_report.rs b/generated/stripe_misc/src/gelato_id_number_report.rs index 9f0a3bbeb..1faabc35a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct GelatoIdNumberReport { /// Date of birth. pub dob: Option, @@ -16,6 +18,126 @@ pub struct GelatoIdNumberReport { /// Status of this `id_number` check. pub status: GelatoIdNumberReportStatus, } +#[doc(hidden)] +pub struct GelatoIdNumberReportBuilder { + dob: Option>, + error: Option>, + first_name: Option>, + id_number: Option>, + id_number_type: Option>, + last_name: Option>, + status: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoIdNumberReportBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + dob: self.dob?, + error: self.error.take()?, + first_name: self.first_name.take()?, + id_number: self.id_number.take()?, + id_number_type: self.id_number_type?, + last_name: self.last_name.take()?, + status: self.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 { + 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 { @@ -57,6 +179,7 @@ impl std::fmt::Debug for GelatoIdNumberReportIdNumberType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for GelatoIdNumberReportIdNumberType { fn serialize(&self, serializer: S) -> Result where @@ -65,6 +188,23 @@ impl serde::Serialize for GelatoIdNumberReportIdNumberType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for GelatoIdNumberReportIdNumberType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(GelatoIdNumberReportIdNumberType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(GelatoIdNumberReportIdNumberType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for GelatoIdNumberReportIdNumberType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -112,6 +252,7 @@ impl std::fmt::Debug for GelatoIdNumberReportStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for GelatoIdNumberReportStatus { fn serialize(&self, serializer: S) -> Result where @@ -120,6 +261,22 @@ impl serde::Serialize for GelatoIdNumberReportStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for GelatoIdNumberReportStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoIdNumberReportStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(GelatoIdNumberReportStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for GelatoIdNumberReportStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..8d24429a3 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct GelatoIdNumberReportError { /// A short machine-readable string giving the reason for the verification failure. pub code: Option, @@ -6,6 +8,95 @@ pub struct GelatoIdNumberReportError { /// These messages can be shown to your users. pub reason: Option, } +#[doc(hidden)] +pub struct GelatoIdNumberReportErrorBuilder { + code: Option>, + reason: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoIdNumberReportErrorBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { code: Deserialize::default(), reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { code: self.code?, reason: self.reason.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -47,6 +138,7 @@ impl std::fmt::Debug for GelatoIdNumberReportErrorCode { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for GelatoIdNumberReportErrorCode { fn serialize(&self, serializer: S) -> Result where @@ -55,6 +147,22 @@ impl serde::Serialize for GelatoIdNumberReportErrorCode { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for GelatoIdNumberReportErrorCode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoIdNumberReportErrorCode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(GelatoIdNumberReportErrorCode); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for GelatoIdNumberReportErrorCode { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/gelato_report_document_options.rs b/generated/stripe_misc/src/gelato_report_document_options.rs index d64cf9535..b02ccf782 100644 --- a/generated/stripe_misc/src/gelato_report_document_options.rs +++ b/generated/stripe_misc/src/gelato_report_document_options.rs @@ -1,20 +1,127 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, /// 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, /// 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, /// 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, } +#[doc(hidden)] +pub struct GelatoReportDocumentOptionsBuilder { + allowed_types: Option>>, + require_id_number: Option>, + require_live_capture: Option>, + require_matching_selfie: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoReportDocumentOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + allowed_types: self.allowed_types.take()?, + require_id_number: self.require_id_number?, + require_live_capture: self.require_live_capture?, + require_matching_selfie: self.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 { + 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)] @@ -57,6 +164,7 @@ impl std::fmt::Debug for GelatoReportDocumentOptionsAllowedTypes { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for GelatoReportDocumentOptionsAllowedTypes { fn serialize(&self, serializer: S) -> Result where @@ -65,6 +173,24 @@ impl serde::Serialize for GelatoReportDocumentOptionsAllowedTypes { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for GelatoReportDocumentOptionsAllowedTypes { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + GelatoReportDocumentOptionsAllowedTypes::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(GelatoReportDocumentOptionsAllowedTypes); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for GelatoReportDocumentOptionsAllowedTypes { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..c10f12b9f 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct GelatoReportIdNumberOptions {} +#[doc(hidden)] +pub struct GelatoReportIdNumberOptionsBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoReportIdNumberOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..b3d3d1c69 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -10,6 +12,111 @@ pub struct GelatoSelfieReport { /// Status of this `selfie` check. pub status: GelatoSelfieReportStatus, } +#[doc(hidden)] +pub struct GelatoSelfieReportBuilder { + document: Option>, + error: Option>, + selfie: Option>, + status: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoSelfieReportBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + document: Deserialize::default(), + error: Deserialize::default(), + selfie: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + document: self.document.take()?, + error: self.error.take()?, + selfie: self.selfie.take()?, + status: self.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 { + 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 { @@ -48,6 +155,7 @@ impl std::fmt::Debug for GelatoSelfieReportStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for GelatoSelfieReportStatus { fn serialize(&self, serializer: S) -> Result where @@ -56,6 +164,22 @@ impl serde::Serialize for GelatoSelfieReportStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for GelatoSelfieReportStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoSelfieReportStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(GelatoSelfieReportStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for GelatoSelfieReportStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/gelato_selfie_report_error.rs b/generated/stripe_misc/src/gelato_selfie_report_error.rs index 068e3dd79..1adb7ef0c 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct GelatoSelfieReportError { /// A short machine-readable string giving the reason for the verification failure. pub code: Option, @@ -6,6 +8,95 @@ pub struct GelatoSelfieReportError { /// These messages can be shown to your users. pub reason: Option, } +#[doc(hidden)] +pub struct GelatoSelfieReportErrorBuilder { + code: Option>, + reason: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoSelfieReportErrorBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { code: Deserialize::default(), reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { code: self.code?, reason: self.reason.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -50,6 +141,7 @@ impl std::fmt::Debug for GelatoSelfieReportErrorCode { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for GelatoSelfieReportErrorCode { fn serialize(&self, serializer: S) -> Result where @@ -58,6 +150,22 @@ impl serde::Serialize for GelatoSelfieReportErrorCode { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for GelatoSelfieReportErrorCode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(GelatoSelfieReportErrorCode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(GelatoSelfieReportErrorCode); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for GelatoSelfieReportErrorCode { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/gelato_session_document_options.rs b/generated/stripe_misc/src/gelato_session_document_options.rs index ca96e161a..de0530ea2 100644 --- a/generated/stripe_misc/src/gelato_session_document_options.rs +++ b/generated/stripe_misc/src/gelato_session_document_options.rs @@ -1,20 +1,127 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, /// 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, /// 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, /// 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, } +#[doc(hidden)] +pub struct GelatoSessionDocumentOptionsBuilder { + allowed_types: Option>>, + require_id_number: Option>, + require_live_capture: Option>, + require_matching_selfie: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoSessionDocumentOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + allowed_types: self.allowed_types.take()?, + require_id_number: self.require_id_number?, + require_live_capture: self.require_live_capture?, + require_matching_selfie: self.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 { + 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)] @@ -57,6 +164,7 @@ impl std::fmt::Debug for GelatoSessionDocumentOptionsAllowedTypes { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for GelatoSessionDocumentOptionsAllowedTypes { fn serialize(&self, serializer: S) -> Result where @@ -65,6 +173,24 @@ impl serde::Serialize for GelatoSessionDocumentOptionsAllowedTypes { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for GelatoSessionDocumentOptionsAllowedTypes { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + GelatoSessionDocumentOptionsAllowedTypes::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(GelatoSessionDocumentOptionsAllowedTypes); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for GelatoSessionDocumentOptionsAllowedTypes { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..822da0dca 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct GelatoSessionIdNumberOptions {} +#[doc(hidden)] +pub struct GelatoSessionIdNumberOptionsBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoSessionIdNumberOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..c639708da 100644 --- a/generated/stripe_misc/src/gelato_session_last_error.rs +++ b/generated/stripe_misc/src/gelato_session_last_error.rs @@ -1,11 +1,102 @@ /// Shows last VerificationSession error -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct GelatoSessionLastError { /// A short machine-readable string giving the reason for the verification or user-session failure. pub code: Option, /// A message that explains the reason for verification or user-session failure. pub reason: Option, } +#[doc(hidden)] +pub struct GelatoSessionLastErrorBuilder { + code: Option>, + reason: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoSessionLastErrorBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { code: Deserialize::default(), reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { code: self.code?, reason: self.reason.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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] @@ -87,6 +178,7 @@ impl std::fmt::Debug for GelatoSessionLastErrorCode { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for GelatoSessionLastErrorCode { fn serialize(&self, serializer: S) -> Result where @@ -95,10 +187,28 @@ impl serde::Serialize for GelatoSessionLastErrorCode { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for GelatoSessionLastErrorCode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + GelatoSessionLastErrorCode::from_str(s).unwrap_or(GelatoSessionLastErrorCode::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(GelatoSessionLastErrorCode); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for GelatoSessionLastErrorCode { fn deserialize>(deserializer: D) -> Result { 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)) } } diff --git a/generated/stripe_misc/src/gelato_verification_report_options.rs b/generated/stripe_misc/src/gelato_verification_report_options.rs index 84bb33614..5c0a10481 100644 --- a/generated/stripe_misc/src/gelato_verification_report_options.rs +++ b/generated/stripe_misc/src/gelato_verification_report_options.rs @@ -1,7 +1,96 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct GelatoVerificationReportOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub document: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub id_number: Option, } +#[doc(hidden)] +pub struct GelatoVerificationReportOptionsBuilder { + document: Option>, + id_number: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoVerificationReportOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { document: Deserialize::default(), id_number: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { document: self.document.take()?, id_number: self.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 { + 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..04341a10b 100644 --- a/generated/stripe_misc/src/gelato_verification_session_options.rs +++ b/generated/stripe_misc/src/gelato_verification_session_options.rs @@ -1,7 +1,96 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct GelatoVerificationSessionOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub document: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub id_number: Option, } +#[doc(hidden)] +pub struct GelatoVerificationSessionOptionsBuilder { + document: Option>, + id_number: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoVerificationSessionOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { document: Deserialize::default(), id_number: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { document: self.document.take()?, id_number: self.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 { + 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..c9b76699a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct GelatoVerifiedOutputs { /// The user's verified address. pub address: Option, @@ -13,6 +15,121 @@ pub struct GelatoVerifiedOutputs { /// The user's verified last name. pub last_name: Option, } +#[doc(hidden)] +pub struct GelatoVerifiedOutputsBuilder { + address: Option>, + dob: Option>, + first_name: Option>, + id_number: Option>, + id_number_type: Option>, + last_name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: GelatoVerifiedOutputsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + address: self.address.take()?, + dob: self.dob?, + first_name: self.first_name.take()?, + id_number: self.id_number.take()?, + id_number_type: self.id_number_type?, + last_name: self.last_name.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -54,6 +171,7 @@ impl std::fmt::Debug for GelatoVerifiedOutputsIdNumberType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for GelatoVerifiedOutputsIdNumberType { fn serialize(&self, serializer: S) -> Result where @@ -62,6 +180,23 @@ impl serde::Serialize for GelatoVerifiedOutputsIdNumberType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for GelatoVerifiedOutputsIdNumberType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(GelatoVerifiedOutputsIdNumberType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(GelatoVerifiedOutputsIdNumberType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for GelatoVerifiedOutputsIdNumberType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/identity_verification_report/types.rs b/generated/stripe_misc/src/identity_verification_report/types.rs index b2d14646d..85bcb056a 100644 --- a/generated/stripe_misc/src/identity_verification_report/types.rs +++ b/generated/stripe_misc/src/identity_verification_report/types.rs @@ -11,29 +11,235 @@ /// Related guides: [Accessing verification results](https://stripe.com/docs/identity/verification-sessions#results). /// /// For more details see <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// Unique identifier for the object. pub id: stripe_misc::IdentityVerificationReportId, - #[serde(skip_serializing_if = "Option::is_none")] pub id_number: Option, /// 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")] + /// String representing the object's type. Objects of the same type share the same value. + pub object: IdentityVerificationReportObject, pub options: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub selfie: Option, /// Type of report. - #[serde(rename = "type")] - #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: Option, /// ID of the VerificationSession that created this report. pub verification_session: Option, } +#[doc(hidden)] +pub struct IdentityVerificationReportBuilder { + created: Option, + document: Option>, + id: Option, + id_number: Option>, + livemode: Option, + object: Option, + options: Option>, + selfie: Option>, + type_: Option>, + verification_session: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IdentityVerificationReportBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + document: Deserialize::default(), + id: Deserialize::default(), + id_number: Deserialize::default(), + livemode: Deserialize::default(), + object: Deserialize::default(), + options: Deserialize::default(), + selfie: Deserialize::default(), + type_: Deserialize::default(), + verification_session: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + created: self.created?, + document: self.document.take()?, + id: self.id.take()?, + id_number: self.id_number.take()?, + livemode: self.livemode?, + object: self.object?, + options: self.options.take()?, + selfie: self.selfie.take()?, + type_: self.type_?, + verification_session: self.verification_session.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum IdentityVerificationReportObject { + IdentityVerificationReport, +} +impl IdentityVerificationReportObject { + pub fn as_str(self) -> &'static str { + use IdentityVerificationReportObject::*; + match self { + IdentityVerificationReport => "identity.verification_report", + } + } +} + +impl std::str::FromStr for IdentityVerificationReportObject { + type Err = (); + fn from_str(s: &str) -> Result { + use IdentityVerificationReportObject::*; + match s { + "identity.verification_report" => Ok(IdentityVerificationReport), + _ => Err(()), + } + } +} +impl std::fmt::Display for IdentityVerificationReportObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for IdentityVerificationReportObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for IdentityVerificationReportObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for IdentityVerificationReportObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(IdentityVerificationReportObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IdentityVerificationReportObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for IdentityVerificationReportObject { + fn deserialize>(deserializer: D) -> 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 IdentityVerificationReportObject") + }) + } +} impl stripe_types::Object for IdentityVerificationReport { type Id = stripe_misc::IdentityVerificationReportId; fn id(&self) -> &Self::Id { @@ -86,6 +292,22 @@ impl serde::Serialize for IdentityVerificationReportType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IdentityVerificationReportType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IdentityVerificationReportType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IdentityVerificationReportType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IdentityVerificationReportType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/identity_verification_session/requests.rs b/generated/stripe_misc/src/identity_verification_session/requests.rs index efbfed561..113ccd31f 100644 --- a/generated/stripe_misc/src/identity_verification_session/requests.rs +++ b/generated/stripe_misc/src/identity_verification_session/requests.rs @@ -178,6 +178,18 @@ impl serde::Serialize for CreateIdentityVerificationSessionOptionsDocumentAllowe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateIdentityVerificationSessionOptionsDocumentAllowedTypes { + fn deserialize>(deserializer: D) -> 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 CreateIdentityVerificationSessionOptionsDocumentAllowedTypes", + ) + }) + } +} impl<'a> CreateIdentityVerificationSession<'a> { /// Creates a VerificationSession object. /// @@ -302,6 +314,18 @@ impl serde::Serialize for UpdateIdentityVerificationSessionOptionsDocumentAllowe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes { + fn deserialize>(deserializer: D) -> 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 UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes", + ) + }) + } +} impl<'a> UpdateIdentityVerificationSession<'a> { /// Updates a VerificationSession object. /// diff --git a/generated/stripe_misc/src/identity_verification_session/types.rs b/generated/stripe_misc/src/identity_verification_session/types.rs index f1526e239..8376ed5a8 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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. @@ -34,6 +36,8 @@ pub struct IdentityVerificationSession { /// 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 representing the object's type. Objects of the same type share the same value. + pub object: IdentityVerificationSessionObject, /// A set of options for the session’s verification checks. pub options: Option, /// Redaction status of this VerificationSession. @@ -43,7 +47,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(feature = "serde", serde(rename = "type"))] pub type_: Option, /// 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 +57,236 @@ pub struct IdentityVerificationSession { /// The user’s verified data. pub verified_outputs: Option, } +#[doc(hidden)] +pub struct IdentityVerificationSessionBuilder { + client_secret: Option>, + created: Option, + id: Option, + last_error: Option>, + last_verification_report: + Option>>, + livemode: Option, + metadata: Option>, + object: Option, + options: Option>, + redaction: Option>, + status: Option, + type_: Option>, + url: Option>, + verified_outputs: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IdentityVerificationSessionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + client_secret: self.client_secret.take()?, + created: self.created?, + id: self.id.take()?, + last_error: self.last_error.take()?, + last_verification_report: self.last_verification_report.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + options: self.options.take()?, + redaction: self.redaction?, + status: self.status?, + type_: self.type_?, + url: self.url.take()?, + verified_outputs: self.verified_outputs.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum IdentityVerificationSessionObject { + IdentityVerificationSession, +} +impl IdentityVerificationSessionObject { + pub fn as_str(self) -> &'static str { + use IdentityVerificationSessionObject::*; + match self { + IdentityVerificationSession => "identity.verification_session", + } + } +} + +impl std::str::FromStr for IdentityVerificationSessionObject { + type Err = (); + fn from_str(s: &str) -> Result { + use IdentityVerificationSessionObject::*; + match s { + "identity.verification_session" => Ok(IdentityVerificationSession), + _ => Err(()), + } + } +} +impl std::fmt::Display for IdentityVerificationSessionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for IdentityVerificationSessionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for IdentityVerificationSessionObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for IdentityVerificationSessionObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(IdentityVerificationSessionObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IdentityVerificationSessionObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for IdentityVerificationSessionObject { + fn deserialize>(deserializer: D) -> 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 IdentityVerificationSessionObject") + }) + } +} impl stripe_types::Object for IdentityVerificationSession { type Id = stripe_misc::IdentityVerificationSessionId; fn id(&self) -> &Self::Id { @@ -111,6 +345,23 @@ impl serde::Serialize for IdentityVerificationSessionStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IdentityVerificationSessionStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(IdentityVerificationSessionStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IdentityVerificationSessionStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IdentityVerificationSessionStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -165,6 +416,23 @@ impl serde::Serialize for IdentityVerificationSessionType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IdentityVerificationSessionType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(IdentityVerificationSessionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IdentityVerificationSessionType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IdentityVerificationSessionType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/mod.rs b/generated/stripe_misc/src/mod.rs index 35e7c18a4..8a72548c8 100644 --- a/generated/stripe_misc/src/mod.rs +++ b/generated/stripe_misc/src/mod.rs @@ -8,6 +8,8 @@ //! and `Webhooks` sections of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_misc; + +miniserde::make_place!(Place); pub use apple_pay_domain::types::*; pub mod apple_pay_domain; #[doc(hidden)] diff --git a/generated/stripe_misc/src/reporting_report_run/requests.rs b/generated/stripe_misc/src/reporting_report_run/requests.rs index 2cdf5e17c..d3ef1d0fc 100644 --- a/generated/stripe_misc/src/reporting_report_run/requests.rs +++ b/generated/stripe_misc/src/reporting_report_run/requests.rs @@ -270,6 +270,14 @@ impl serde::Serialize for CreateReportingReportRunParametersReportingCategory { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateReportingReportRunParametersReportingCategory { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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). @@ -2111,6 +2119,14 @@ impl serde::Serialize for CreateReportingReportRunParametersTimezone { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateReportingReportRunParametersTimezone { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} 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).). diff --git a/generated/stripe_misc/src/reporting_report_run/types.rs b/generated/stripe_misc/src/reporting_report_run/types.rs index 0282fc92d..b6ade420f 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ReportingReportRun { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -19,6 +21,8 @@ pub struct ReportingReportRun { pub id: stripe_misc::ReportingReportRunId, /// `true` if the report is run on live mode data and `false` if it is run on test mode data. pub livemode: bool, + /// String representing the object's type. Objects of the same type share the same value. + pub object: ReportingReportRunObject, pub parameters: stripe_misc::FinancialReportingFinanceReportRunRunParameters, /// The ID of the [report type](https://stripe.com/docs/reports/report-types) to run, such as `"balance.summary.1"`. pub report_type: String, @@ -33,6 +37,209 @@ pub struct ReportingReportRun { /// `status=succeeded`). Measured in seconds since the Unix epoch. pub succeeded_at: Option, } +#[doc(hidden)] +pub struct ReportingReportRunBuilder { + created: Option, + error: Option>, + id: Option, + livemode: Option, + object: Option, + parameters: Option, + report_type: Option, + result: Option>, + status: Option, + succeeded_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ReportingReportRunBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + error: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + object: 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 { + Some(Self::Out { + created: self.created?, + error: self.error.take()?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + parameters: self.parameters.take()?, + report_type: self.report_type.take()?, + result: self.result.take()?, + status: self.status.take()?, + succeeded_at: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ReportingReportRunObject { + ReportingReportRun, +} +impl ReportingReportRunObject { + pub fn as_str(self) -> &'static str { + use ReportingReportRunObject::*; + match self { + ReportingReportRun => "reporting.report_run", + } + } +} + +impl std::str::FromStr for ReportingReportRunObject { + type Err = (); + fn from_str(s: &str) -> Result { + use ReportingReportRunObject::*; + match s { + "reporting.report_run" => Ok(ReportingReportRun), + _ => Err(()), + } + } +} +impl std::fmt::Display for ReportingReportRunObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ReportingReportRunObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for ReportingReportRunObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for ReportingReportRunObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ReportingReportRunObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ReportingReportRunObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ReportingReportRunObject { + fn deserialize>(deserializer: D) -> 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 ReportingReportRunObject")) + } +} 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/types.rs b/generated/stripe_misc/src/reporting_report_type/types.rs index fe66c52fe..6ab45ed8e 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -23,12 +25,216 @@ pub struct ReportingReportType { pub livemode: bool, /// Human-readable name of the Report Type pub name: String, + /// String representing the object's type. Objects of the same type share the same value. + pub object: ReportingReportTypeObject, /// When this Report Type was latest updated. Measured in seconds since the Unix epoch. pub updated: stripe_types::Timestamp, /// Version of the Report Type. /// 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, } +#[doc(hidden)] +pub struct ReportingReportTypeBuilder { + data_available_end: Option, + data_available_start: Option, + default_columns: Option>>, + id: Option, + livemode: Option, + name: Option, + object: Option, + updated: Option, + version: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ReportingReportTypeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "updated" => Deserialize::begin(&mut self.updated), + "version" => Deserialize::begin(&mut self.version), + + _ => ::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(), + object: Deserialize::default(), + updated: Deserialize::default(), + version: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + data_available_end: self.data_available_end?, + data_available_start: self.data_available_start?, + default_columns: self.default_columns.take()?, + id: self.id.take()?, + livemode: self.livemode?, + name: self.name.take()?, + object: self.object?, + updated: self.updated?, + version: self.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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "updated" => b.updated = Some(FromValueOpt::from_value(v)?), + "version" => b.version = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ReportingReportTypeObject { + ReportingReportType, +} +impl ReportingReportTypeObject { + pub fn as_str(self) -> &'static str { + use ReportingReportTypeObject::*; + match self { + ReportingReportType => "reporting.report_type", + } + } +} + +impl std::str::FromStr for ReportingReportTypeObject { + type Err = (); + fn from_str(s: &str) -> Result { + use ReportingReportTypeObject::*; + match s { + "reporting.report_type" => Ok(ReportingReportType), + _ => Err(()), + } + } +} +impl std::fmt::Display for ReportingReportTypeObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ReportingReportTypeObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for ReportingReportTypeObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for ReportingReportTypeObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ReportingReportTypeObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ReportingReportTypeObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ReportingReportTypeObject { + fn deserialize>(deserializer: D) -> 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 ReportingReportTypeObject")) + } +} 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/types.rs b/generated/stripe_misc/src/scheduled_query_run/types.rs index 171b45dcf..914b9f46a 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// The file object representing the results of the query. pub file: Option, @@ -18,6 +19,8 @@ pub struct ScheduledQueryRun { pub id: stripe_misc::ScheduledQueryRunId, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: ScheduledQueryRunObject, /// Time at which the result expires and is no longer available for download. pub result_available_until: stripe_types::Timestamp, /// SQL for the query. @@ -27,6 +30,216 @@ pub struct ScheduledQueryRun { /// Title of the query. pub title: String, } +#[doc(hidden)] +pub struct ScheduledQueryRunBuilder { + created: Option, + data_load_time: Option, + error: Option>, + file: Option>, + id: Option, + livemode: Option, + object: Option, + result_available_until: Option, + sql: Option, + status: Option, + title: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ScheduledQueryRunBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: Deserialize::default(), + result_available_until: Deserialize::default(), + sql: Deserialize::default(), + status: Deserialize::default(), + title: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + created: self.created?, + data_load_time: self.data_load_time?, + error: self.error.take()?, + file: self.file.take()?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + result_available_until: self.result_available_until?, + sql: self.sql.take()?, + status: self.status.take()?, + title: self.title.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ScheduledQueryRunObject { + ScheduledQueryRun, +} +impl ScheduledQueryRunObject { + pub fn as_str(self) -> &'static str { + use ScheduledQueryRunObject::*; + match self { + ScheduledQueryRun => "scheduled_query_run", + } + } +} + +impl std::str::FromStr for ScheduledQueryRunObject { + type Err = (); + fn from_str(s: &str) -> Result { + use ScheduledQueryRunObject::*; + match s { + "scheduled_query_run" => Ok(ScheduledQueryRun), + _ => Err(()), + } + } +} +impl std::fmt::Display for ScheduledQueryRunObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ScheduledQueryRunObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for ScheduledQueryRunObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for ScheduledQueryRunObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ScheduledQueryRunObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ScheduledQueryRunObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ScheduledQueryRunObject { + fn deserialize>(deserializer: D) -> 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 ScheduledQueryRunObject")) + } +} 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..715379698 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SigmaScheduledQueryRunError { /// Information about the run failure. pub message: String, } +#[doc(hidden)] +pub struct SigmaScheduledQueryRunErrorBuilder { + message: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SigmaScheduledQueryRunErrorBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { message: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { message: self.message.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..d7af9164d 100644 --- a/generated/stripe_misc/src/tax_calculation/requests.rs +++ b/generated/stripe_misc/src/tax_calculation/requests.rs @@ -185,6 +185,18 @@ impl serde::Serialize for CreateTaxCalculationCustomerDetailsAddressSource { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxCalculationCustomerDetailsAddressSource { + fn deserialize>(deserializer: D) -> 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 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. @@ -443,6 +455,14 @@ impl serde::Serialize for CreateTaxCalculationCustomerDetailsTaxIdsType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxCalculationCustomerDetailsTaxIdsType { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Overrides the tax calculation result to allow you to not collect tax from your customer. /// Use this if you've manually checked your customer's tax exemptions. /// Prefer providing the customer's `tax_ids` where possible, which automatically determines whether `reverse_charge` applies. @@ -494,6 +514,18 @@ impl serde::Serialize for CreateTaxCalculationCustomerDetailsTaxabilityOverride serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxCalculationCustomerDetailsTaxabilityOverride { + fn deserialize>(deserializer: D) -> 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 CreateTaxCalculationCustomerDetailsTaxabilityOverride", + ) + }) + } +} /// A list of items the customer is purchasing. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxCalculationLineItems<'a> { @@ -580,6 +612,16 @@ impl serde::Serialize for CreateTaxCalculationLineItemsTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxCalculationLineItemsTaxBehavior { + fn deserialize>(deserializer: D) -> 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 CreateTaxCalculationLineItemsTaxBehavior") + }) + } +} /// Shipping cost details to be used for the calculation. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateTaxCalculationShippingCost<'a> { @@ -655,6 +697,18 @@ impl serde::Serialize for CreateTaxCalculationShippingCostTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxCalculationShippingCostTaxBehavior { + fn deserialize>(deserializer: D) -> 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 CreateTaxCalculationShippingCostTaxBehavior", + ) + }) + } +} impl<'a> CreateTaxCalculation<'a> { /// Calculates tax based on input and returns a Tax `Calculation` object. pub fn send(&self, client: &stripe::Client) -> stripe::Response { diff --git a/generated/stripe_misc/src/tax_calculation/types.rs b/generated/stripe_misc/src/tax_calculation/types.rs index 1e26a782c..349797f2e 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxCalculation { /// Total after taxes. pub amount_total: i64, @@ -21,6 +23,8 @@ pub struct TaxCalculation { pub line_items: Option>, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: TaxCalculationObject, /// The shipping cost details for the calculation. pub shipping_cost: Option, /// The amount of tax to be collected on top of the line item prices. @@ -32,6 +36,233 @@ 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, } +#[doc(hidden)] +pub struct TaxCalculationBuilder { + amount_total: Option, + currency: Option, + customer: Option>, + customer_details: Option, + expires_at: Option>, + id: Option>, + line_items: Option>>, + livemode: Option, + object: Option, + shipping_cost: Option>, + tax_amount_exclusive: Option, + tax_amount_inclusive: Option, + tax_breakdown: Option>, + tax_date: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxCalculationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + amount_total: self.amount_total?, + currency: self.currency?, + customer: self.customer.take()?, + customer_details: self.customer_details.take()?, + expires_at: self.expires_at?, + id: self.id.take()?, + line_items: self.line_items.take()?, + livemode: self.livemode?, + object: self.object?, + shipping_cost: self.shipping_cost.take()?, + tax_amount_exclusive: self.tax_amount_exclusive?, + tax_amount_inclusive: self.tax_amount_inclusive?, + tax_breakdown: self.tax_breakdown.take()?, + tax_date: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TaxCalculationObject { + TaxCalculation, +} +impl TaxCalculationObject { + pub fn as_str(self) -> &'static str { + use TaxCalculationObject::*; + match self { + TaxCalculation => "tax.calculation", + } + } +} + +impl std::str::FromStr for TaxCalculationObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TaxCalculationObject::*; + match s { + "tax.calculation" => Ok(TaxCalculation), + _ => Err(()), + } + } +} +impl std::fmt::Display for TaxCalculationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TaxCalculationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TaxCalculationObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TaxCalculationObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxCalculationObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxCalculationObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TaxCalculationObject { + fn deserialize>(deserializer: D) -> 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 TaxCalculationObject")) + } +} impl stripe_types::Object for TaxCalculation { type Id = Option; 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..f7beb7226 100644 --- a/generated/stripe_misc/src/tax_calculation_line_item.rs +++ b/generated/stripe_misc/src/tax_calculation_line_item.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxCalculationLineItem { /// The line item amount in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). /// If `tax_behavior=inclusive`, then this amount includes taxes. @@ -10,6 +12,8 @@ pub struct TaxCalculationLineItem { pub id: stripe_misc::TaxCalculationLineItemId, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: TaxCalculationLineItemObject, /// The ID of an existing [Product](https://stripe.com/docs/api/products/object). pub product: Option, /// The number of units of the item being purchased. For reversals, this is the quantity reversed. @@ -24,6 +28,214 @@ pub struct TaxCalculationLineItem { /// The [tax code](https://stripe.com/docs/tax/tax-categories) ID used for this resource. pub tax_code: String, } +#[doc(hidden)] +pub struct TaxCalculationLineItemBuilder { + amount: Option, + amount_tax: Option, + id: Option, + livemode: Option, + object: Option, + product: Option>, + quantity: Option, + reference: Option>, + tax_behavior: Option, + tax_breakdown: Option>>, + tax_code: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxCalculationLineItemBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_tax: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + object: 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 { + Some(Self::Out { + amount: self.amount?, + amount_tax: self.amount_tax?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + product: self.product.take()?, + quantity: self.quantity?, + reference: self.reference.take()?, + tax_behavior: self.tax_behavior?, + tax_breakdown: self.tax_breakdown.take()?, + tax_code: self.tax_code.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TaxCalculationLineItemObject { + TaxCalculationLineItem, +} +impl TaxCalculationLineItemObject { + pub fn as_str(self) -> &'static str { + use TaxCalculationLineItemObject::*; + match self { + TaxCalculationLineItem => "tax.calculation_line_item", + } + } +} + +impl std::str::FromStr for TaxCalculationLineItemObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TaxCalculationLineItemObject::*; + match s { + "tax.calculation_line_item" => Ok(TaxCalculationLineItem), + _ => Err(()), + } + } +} +impl std::fmt::Display for TaxCalculationLineItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TaxCalculationLineItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TaxCalculationLineItemObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TaxCalculationLineItemObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxCalculationLineItemObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxCalculationLineItemObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TaxCalculationLineItemObject { + fn deserialize>(deserializer: D) -> 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 TaxCalculationLineItemObject")) + } +} /// Specifies whether the `amount` includes taxes. /// If `tax_behavior=inclusive`, then the amount includes taxes. #[derive(Copy, Clone, Eq, PartialEq)] @@ -63,6 +275,7 @@ impl std::fmt::Debug for TaxCalculationLineItemTaxBehavior { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxCalculationLineItemTaxBehavior { fn serialize(&self, serializer: S) -> Result where @@ -71,6 +284,23 @@ impl serde::Serialize for TaxCalculationLineItemTaxBehavior { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxCalculationLineItemTaxBehavior { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(TaxCalculationLineItemTaxBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxCalculationLineItemTaxBehavior); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxCalculationLineItemTaxBehavior { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..b9d0ce06c 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,384 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductRegistrationsResourceCountryOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub ae: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub at: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub au: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub be: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bg: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub ca: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub ch: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cl: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub co: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cy: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cz: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub de: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub dk: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub ee: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub es: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub fi: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub fr: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub gb: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub gr: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub hr: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub hu: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub id: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub ie: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub is: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub it: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub jp: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub kr: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub lt: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub lu: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub lv: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub mt: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub mx: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub my: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub nl: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub no: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub nz: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pl: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pt: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub ro: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sa: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub se: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sg: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub si: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sk: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub th: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub tr: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub us: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub vn: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub za: Option, } +#[doc(hidden)] +pub struct TaxProductRegistrationsResourceCountryOptionsBuilder { + ae: Option>, + at: Option>, + au: Option>, + be: Option>, + bg: Option>, + ca: Option>, + ch: Option>, + cl: Option>, + co: Option>, + cy: Option>, + cz: Option>, + de: Option>, + dk: Option>, + ee: Option>, + es: Option>, + fi: Option>, + fr: Option>, + gb: Option>, + gr: Option>, + hr: Option>, + hu: Option>, + id: Option>, + ie: Option>, + is: Option>, + it: Option>, + jp: Option>, + kr: Option>, + lt: Option>, + lu: Option>, + lv: Option>, + mt: Option>, + mx: Option>, + my: Option>, + nl: Option>, + no: Option>, + nz: Option>, + pl: Option>, + pt: Option>, + ro: Option>, + sa: Option>, + se: Option>, + sg: Option>, + si: Option>, + sk: Option>, + th: Option>, + tr: Option>, + us: Option>, + vn: Option>, + za: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductRegistrationsResourceCountryOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + ae: self.ae?, + at: self.at?, + au: self.au?, + be: self.be?, + bg: self.bg?, + ca: self.ca.take()?, + ch: self.ch?, + cl: self.cl?, + co: self.co?, + cy: self.cy?, + cz: self.cz?, + de: self.de?, + dk: self.dk?, + ee: self.ee?, + es: self.es?, + fi: self.fi?, + fr: self.fr?, + gb: self.gb?, + gr: self.gr?, + hr: self.hr?, + hu: self.hu?, + id: self.id?, + ie: self.ie?, + is: self.is?, + it: self.it?, + jp: self.jp?, + kr: self.kr?, + lt: self.lt?, + lu: self.lu?, + lv: self.lv?, + mt: self.mt?, + mx: self.mx?, + my: self.my?, + nl: self.nl?, + no: self.no?, + nz: self.nz?, + pl: self.pl?, + pt: self.pt?, + ro: self.ro?, + sa: self.sa?, + se: self.se?, + sg: self.sg?, + si: self.si?, + sk: self.sk?, + th: self.th?, + tr: self.tr?, + us: self.us.take()?, + vn: self.vn?, + za: self.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 { + 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..e595d268f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductRegistrationsResourceCountryOptionsCaProvinceStandard { /// Two-letter CA province code ([ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2)). pub province: String, } +#[doc(hidden)] +pub struct TaxProductRegistrationsResourceCountryOptionsCaProvinceStandardBuilder { + province: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductRegistrationsResourceCountryOptionsCaProvinceStandardBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { province: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { province: self.province.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..353fc90d1 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,108 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductRegistrationsResourceCountryOptionsCanada { - #[serde(skip_serializing_if = "Option::is_none")] pub province_standard: Option, /// Type of registration in Canada. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: TaxProductRegistrationsResourceCountryOptionsCanadaType, } +#[doc(hidden)] +pub struct TaxProductRegistrationsResourceCountryOptionsCanadaBuilder { + province_standard: Option< + Option, + >, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductRegistrationsResourceCountryOptionsCanadaBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { province_standard: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + province_standard: self.province_standard.take()?, + type_: self.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 { + 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 { @@ -48,6 +144,7 @@ impl std::fmt::Debug for TaxProductRegistrationsResourceCountryOptionsCanadaType f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxProductRegistrationsResourceCountryOptionsCanadaType { fn serialize(&self, serializer: S) -> Result where @@ -56,6 +153,27 @@ impl serde::Serialize for TaxProductRegistrationsResourceCountryOptionsCanadaTyp serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxProductRegistrationsResourceCountryOptionsCanadaType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TaxProductRegistrationsResourceCountryOptionsCanadaType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxProductRegistrationsResourceCountryOptionsCanadaType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxProductRegistrationsResourceCountryOptionsCanadaType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..116c79a3c 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,99 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductRegistrationsResourceCountryOptionsDefault { /// Type of registration in `country`. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: TaxProductRegistrationsResourceCountryOptionsDefaultType, } +#[doc(hidden)] +pub struct TaxProductRegistrationsResourceCountryOptionsDefaultBuilder { + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductRegistrationsResourceCountryOptionsDefaultBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { type_: self.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 { + 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 { @@ -39,6 +129,7 @@ impl std::fmt::Debug for TaxProductRegistrationsResourceCountryOptionsDefaultTyp f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxProductRegistrationsResourceCountryOptionsDefaultType { fn serialize(&self, serializer: S) -> Result where @@ -47,6 +138,29 @@ impl serde::Serialize for TaxProductRegistrationsResourceCountryOptionsDefaultTy serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxProductRegistrationsResourceCountryOptionsDefaultType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TaxProductRegistrationsResourceCountryOptionsDefaultType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + TaxProductRegistrationsResourceCountryOptionsDefaultType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxProductRegistrationsResourceCountryOptionsDefaultType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..45d3efbf1 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,102 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductRegistrationsResourceCountryOptionsEuStandard { /// Place of supply scheme used in an EU standard registration. pub place_of_supply_scheme: TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme, } +#[doc(hidden)] +pub struct TaxProductRegistrationsResourceCountryOptionsEuStandardBuilder { + place_of_supply_scheme: + Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductRegistrationsResourceCountryOptionsEuStandardBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { place_of_supply_scheme: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { place_of_supply_scheme: self.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 { + 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 { @@ -48,6 +141,7 @@ impl std::fmt::Debug f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme { @@ -58,6 +152,31 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + TaxProductRegistrationsResourceCountryOptionsEuStandardPlaceOfSupplyScheme +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for 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..836f22459 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductRegistrationsResourceCountryOptionsEurope { - #[serde(skip_serializing_if = "Option::is_none")] pub standard: Option, /// Type of registration in an EU country. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: TaxProductRegistrationsResourceCountryOptionsEuropeType, } +#[doc(hidden)] +pub struct TaxProductRegistrationsResourceCountryOptionsEuropeBuilder { + standard: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductRegistrationsResourceCountryOptionsEuropeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { standard: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { standard: self.standard?, type_: self.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 { + 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 { @@ -50,6 +141,7 @@ impl std::fmt::Debug for TaxProductRegistrationsResourceCountryOptionsEuropeType f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxProductRegistrationsResourceCountryOptionsEuropeType { fn serialize(&self, serializer: S) -> Result where @@ -58,6 +150,27 @@ impl serde::Serialize for TaxProductRegistrationsResourceCountryOptionsEuropeTyp serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxProductRegistrationsResourceCountryOptionsEuropeType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TaxProductRegistrationsResourceCountryOptionsEuropeType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxProductRegistrationsResourceCountryOptionsEuropeType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxProductRegistrationsResourceCountryOptionsEuropeType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..1d326e9f2 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,99 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductRegistrationsResourceCountryOptionsSimplified { /// Type of registration in `country`. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: TaxProductRegistrationsResourceCountryOptionsSimplifiedType, } +#[doc(hidden)] +pub struct TaxProductRegistrationsResourceCountryOptionsSimplifiedBuilder { + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductRegistrationsResourceCountryOptionsSimplifiedBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { type_: self.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 { + 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 { @@ -39,6 +129,7 @@ impl std::fmt::Debug for TaxProductRegistrationsResourceCountryOptionsSimplified f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxProductRegistrationsResourceCountryOptionsSimplifiedType { fn serialize(&self, serializer: S) -> Result where @@ -47,6 +138,29 @@ impl serde::Serialize for TaxProductRegistrationsResourceCountryOptionsSimplifie serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxProductRegistrationsResourceCountryOptionsSimplifiedType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TaxProductRegistrationsResourceCountryOptionsSimplifiedType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + TaxProductRegistrationsResourceCountryOptionsSimplifiedType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxProductRegistrationsResourceCountryOptionsSimplifiedType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..90c9f676e 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,130 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductRegistrationsResourceCountryOptionsUnitedStates { - #[serde(skip_serializing_if = "Option::is_none")] pub local_amusement_tax: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub local_lease_tax: Option, /// 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(feature = "serde", serde(rename = "type"))] pub type_: TaxProductRegistrationsResourceCountryOptionsUnitedStatesType, } +#[doc(hidden)] +pub struct TaxProductRegistrationsResourceCountryOptionsUnitedStatesBuilder { + local_amusement_tax: Option< + Option, + >, + local_lease_tax: + Option>, + state: Option, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductRegistrationsResourceCountryOptionsUnitedStatesBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + local_amusement_tax: self.local_amusement_tax.take()?, + local_lease_tax: self.local_lease_tax.take()?, + state: self.state.take()?, + type_: self.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 { + 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 { @@ -56,6 +169,7 @@ impl std::fmt::Debug for TaxProductRegistrationsResourceCountryOptionsUnitedStat f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxProductRegistrationsResourceCountryOptionsUnitedStatesType { fn serialize(&self, serializer: S) -> Result where @@ -64,6 +178,29 @@ impl serde::Serialize for TaxProductRegistrationsResourceCountryOptionsUnitedSta serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxProductRegistrationsResourceCountryOptionsUnitedStatesType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TaxProductRegistrationsResourceCountryOptionsUnitedStatesType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + TaxProductRegistrationsResourceCountryOptionsUnitedStatesType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for 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..74940766c 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTax { /// A [FIPS code](https://www.census.gov/library/reference/code-lists/ansi.html) representing the local jurisdiction. pub jurisdiction: String, } +#[doc(hidden)] +pub struct TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTaxBuilder { + jurisdiction: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductRegistrationsResourceCountryOptionsUsLocalAmusementTaxBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { jurisdiction: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { jurisdiction: self.jurisdiction.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..f203dec6c 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,95 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTax { /// A [FIPS code](https://www.census.gov/library/reference/code-lists/ansi.html) representing the local jurisdiction. pub jurisdiction: String, } +#[doc(hidden)] +pub struct TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTaxBuilder { + jurisdiction: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductRegistrationsResourceCountryOptionsUsLocalLeaseTaxBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { jurisdiction: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { jurisdiction: self.jurisdiction.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..f5e6ecd3f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductResourceCustomerDetails { /// The customer's postal address (for example, home or business location). pub address: Option, @@ -11,6 +13,118 @@ pub struct TaxProductResourceCustomerDetails { /// The taxability override used for taxation. pub taxability_override: TaxProductResourceCustomerDetailsTaxabilityOverride, } +#[doc(hidden)] +pub struct TaxProductResourceCustomerDetailsBuilder { + address: Option>, + address_source: Option>, + ip_address: Option>, + tax_ids: Option>, + taxability_override: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductResourceCustomerDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + address: self.address.take()?, + address_source: self.address_source?, + ip_address: self.ip_address.take()?, + tax_ids: self.tax_ids.take()?, + taxability_override: self.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 { + 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 { @@ -49,6 +163,7 @@ impl std::fmt::Debug for TaxProductResourceCustomerDetailsAddressSource { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxProductResourceCustomerDetailsAddressSource { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +172,25 @@ impl serde::Serialize for TaxProductResourceCustomerDetailsAddressSource { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxProductResourceCustomerDetailsAddressSource { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TaxProductResourceCustomerDetailsAddressSource::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxProductResourceCustomerDetailsAddressSource); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxProductResourceCustomerDetailsAddressSource { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -109,6 +243,7 @@ impl std::fmt::Debug for TaxProductResourceCustomerDetailsTaxabilityOverride { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxProductResourceCustomerDetailsTaxabilityOverride { fn serialize(&self, serializer: S) -> Result where @@ -117,6 +252,25 @@ impl serde::Serialize for TaxProductResourceCustomerDetailsTaxabilityOverride { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxProductResourceCustomerDetailsTaxabilityOverride { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TaxProductResourceCustomerDetailsTaxabilityOverride::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxProductResourceCustomerDetailsTaxabilityOverride); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxProductResourceCustomerDetailsTaxabilityOverride { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..4ecd2546f 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,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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(feature = "serde", serde(rename = "type"))] pub type_: TaxProductResourceCustomerDetailsResourceTaxIdType, /// The value of the tax ID. pub value: String, } +#[doc(hidden)] +pub struct TaxProductResourceCustomerDetailsResourceTaxIdBuilder { + type_: Option, + value: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductResourceCustomerDetailsResourceTaxIdBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { type_: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { type_: self.type_?, value: self.value.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -239,6 +330,7 @@ impl std::fmt::Debug for TaxProductResourceCustomerDetailsResourceTaxIdType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxProductResourceCustomerDetailsResourceTaxIdType { fn serialize(&self, serializer: S) -> Result where @@ -247,6 +339,25 @@ impl serde::Serialize for TaxProductResourceCustomerDetailsResourceTaxIdType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxProductResourceCustomerDetailsResourceTaxIdType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TaxProductResourceCustomerDetailsResourceTaxIdType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxProductResourceCustomerDetailsResourceTaxIdType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxProductResourceCustomerDetailsResourceTaxIdType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/tax_product_resource_jurisdiction.rs b/generated/stripe_misc/src/tax_product_resource_jurisdiction.rs index 47fd98460..d201b4f8a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,111 @@ pub struct TaxProductResourceJurisdiction { /// For example, "NY" for New York, United States. pub state: Option, } +#[doc(hidden)] +pub struct TaxProductResourceJurisdictionBuilder { + country: Option, + display_name: Option, + level: Option, + state: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductResourceJurisdictionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + country: self.country.take()?, + display_name: self.display_name.take()?, + level: self.level?, + state: self.state.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -57,6 +164,7 @@ impl std::fmt::Debug for TaxProductResourceJurisdictionLevel { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxProductResourceJurisdictionLevel { fn serialize(&self, serializer: S) -> Result where @@ -65,6 +173,23 @@ impl serde::Serialize for TaxProductResourceJurisdictionLevel { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxProductResourceJurisdictionLevel { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(TaxProductResourceJurisdictionLevel::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxProductResourceJurisdictionLevel); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxProductResourceJurisdictionLevel { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..f850384b0 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,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductResourceLineItemTaxBreakdown { /// The amount of tax, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). pub amount: i64, @@ -14,6 +16,121 @@ pub struct TaxProductResourceLineItemTaxBreakdown { /// The amount on which tax is calculated, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). pub taxable_amount: i64, } +#[doc(hidden)] +pub struct TaxProductResourceLineItemTaxBreakdownBuilder { + amount: Option, + jurisdiction: Option, + sourcing: Option, + tax_rate_details: Option>, + taxability_reason: Option, + taxable_amount: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductResourceLineItemTaxBreakdownBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount: self.amount?, + jurisdiction: self.jurisdiction.take()?, + sourcing: self.sourcing?, + tax_rate_details: self.tax_rate_details.take()?, + taxability_reason: self.taxability_reason?, + taxable_amount: self.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 { + 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 { @@ -52,6 +169,7 @@ impl std::fmt::Debug for TaxProductResourceLineItemTaxBreakdownSourcing { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxProductResourceLineItemTaxBreakdownSourcing { fn serialize(&self, serializer: S) -> Result where @@ -60,6 +178,25 @@ impl serde::Serialize for TaxProductResourceLineItemTaxBreakdownSourcing { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxProductResourceLineItemTaxBreakdownSourcing { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TaxProductResourceLineItemTaxBreakdownSourcing::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxProductResourceLineItemTaxBreakdownSourcing); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxProductResourceLineItemTaxBreakdownSourcing { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -153,6 +290,7 @@ impl std::fmt::Debug for TaxProductResourceLineItemTaxBreakdownTaxabilityReason f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxProductResourceLineItemTaxBreakdownTaxabilityReason { fn serialize(&self, serializer: S) -> Result where @@ -161,11 +299,31 @@ impl serde::Serialize for TaxProductResourceLineItemTaxBreakdownTaxabilityReason serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxProductResourceLineItemTaxBreakdownTaxabilityReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TaxProductResourceLineItemTaxBreakdownTaxabilityReason::from_str(s) + .unwrap_or(TaxProductResourceLineItemTaxBreakdownTaxabilityReason::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxProductResourceLineItemTaxBreakdownTaxabilityReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxProductResourceLineItemTaxBreakdownTaxabilityReason { fn deserialize>(deserializer: D) -> Result { 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)) } } 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..5e257e067 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,108 @@ pub struct TaxProductResourceLineItemTaxRateDetails { /// The tax type, such as `vat` or `sales_tax`. pub tax_type: TaxProductResourceLineItemTaxRateDetailsTaxType, } +#[doc(hidden)] +pub struct TaxProductResourceLineItemTaxRateDetailsBuilder { + display_name: Option, + percentage_decimal: Option, + tax_type: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductResourceLineItemTaxRateDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + display_name: Deserialize::default(), + percentage_decimal: Deserialize::default(), + tax_type: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + display_name: self.display_name.take()?, + percentage_decimal: self.percentage_decimal.take()?, + tax_type: self.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 { + 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 { @@ -76,6 +180,7 @@ impl std::fmt::Debug for TaxProductResourceLineItemTaxRateDetailsTaxType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxProductResourceLineItemTaxRateDetailsTaxType { fn serialize(&self, serializer: S) -> Result where @@ -84,6 +189,25 @@ impl serde::Serialize for TaxProductResourceLineItemTaxRateDetailsTaxType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxProductResourceLineItemTaxRateDetailsTaxType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TaxProductResourceLineItemTaxRateDetailsTaxType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxProductResourceLineItemTaxRateDetailsTaxType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxProductResourceLineItemTaxRateDetailsTaxType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..5eb0ab99c 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductResourcePostalAddress { /// City, district, suburb, town, or village. pub city: Option, @@ -14,3 +16,118 @@ pub struct TaxProductResourcePostalAddress { /// Example: "NY" or "TX". pub state: Option, } +#[doc(hidden)] +pub struct TaxProductResourcePostalAddressBuilder { + city: Option>, + country: Option, + line1: Option>, + line2: Option>, + postal_code: Option>, + state: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductResourcePostalAddressBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + city: self.city.take()?, + country: self.country.take()?, + line1: self.line1.take()?, + line2: self.line2.take()?, + postal_code: self.postal_code.take()?, + state: self.state.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..81097bf60 100644 --- a/generated/stripe_misc/src/tax_product_resource_tax_breakdown.rs +++ b/generated/stripe_misc/src/tax_product_resource_tax_breakdown.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductResourceTaxBreakdown { /// The amount of tax, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). pub amount: i64, @@ -11,6 +13,116 @@ pub struct TaxProductResourceTaxBreakdown { /// The amount on which tax is calculated, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). pub taxable_amount: i64, } +#[doc(hidden)] +pub struct TaxProductResourceTaxBreakdownBuilder { + amount: Option, + inclusive: Option, + tax_rate_details: Option, + taxability_reason: Option, + taxable_amount: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductResourceTaxBreakdownBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount: self.amount?, + inclusive: self.inclusive?, + tax_rate_details: self.tax_rate_details.take()?, + taxability_reason: self.taxability_reason?, + taxable_amount: self.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 { + 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)] @@ -93,6 +205,7 @@ impl std::fmt::Debug for TaxProductResourceTaxBreakdownTaxabilityReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxProductResourceTaxBreakdownTaxabilityReason { fn serialize(&self, serializer: S) -> Result where @@ -101,10 +214,29 @@ impl serde::Serialize for TaxProductResourceTaxBreakdownTaxabilityReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxProductResourceTaxBreakdownTaxabilityReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TaxProductResourceTaxBreakdownTaxabilityReason::from_str(s) + .unwrap_or(TaxProductResourceTaxBreakdownTaxabilityReason::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxProductResourceTaxBreakdownTaxabilityReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxProductResourceTaxBreakdownTaxabilityReason { fn deserialize>(deserializer: D) -> Result { 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)) } } 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..00825a8d4 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,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductResourceTaxCalculationShippingCost { /// The shipping amount in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). /// If `tax_behavior=inclusive`, then this amount includes taxes. @@ -7,17 +9,130 @@ pub struct TaxProductResourceTaxCalculationShippingCost { /// The amount of tax calculated for shipping, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). 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, /// 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>, /// The [tax code](https://stripe.com/docs/tax/tax-categories) ID used for shipping. pub tax_code: String, } +#[doc(hidden)] +pub struct TaxProductResourceTaxCalculationShippingCostBuilder { + amount: Option, + amount_tax: Option, + shipping_rate: Option>, + tax_behavior: Option, + tax_breakdown: Option>>, + tax_code: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductResourceTaxCalculationShippingCostBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount: self.amount?, + amount_tax: self.amount_tax?, + shipping_rate: self.shipping_rate.take()?, + tax_behavior: self.tax_behavior?, + tax_breakdown: self.tax_breakdown.take()?, + tax_code: self.tax_code.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)] @@ -57,6 +172,7 @@ impl std::fmt::Debug for TaxProductResourceTaxCalculationShippingCostTaxBehavior f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxProductResourceTaxCalculationShippingCostTaxBehavior { fn serialize(&self, serializer: S) -> Result where @@ -65,6 +181,27 @@ impl serde::Serialize for TaxProductResourceTaxCalculationShippingCostTaxBehavio serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxProductResourceTaxCalculationShippingCostTaxBehavior { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TaxProductResourceTaxCalculationShippingCostTaxBehavior::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxProductResourceTaxCalculationShippingCostTaxBehavior); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxProductResourceTaxCalculationShippingCostTaxBehavior { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..f5f402fcd 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -9,6 +11,113 @@ pub struct TaxProductResourceTaxRateDetails { /// The tax type, such as `vat` or `sales_tax`. pub tax_type: Option, } +#[doc(hidden)] +pub struct TaxProductResourceTaxRateDetailsBuilder { + country: Option>, + percentage_decimal: Option, + state: Option>, + tax_type: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductResourceTaxRateDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + country: self.country.take()?, + percentage_decimal: self.percentage_decimal.take()?, + state: self.state.take()?, + tax_type: self.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 { + 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 { @@ -77,6 +186,7 @@ impl std::fmt::Debug for TaxProductResourceTaxRateDetailsTaxType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxProductResourceTaxRateDetailsTaxType { fn serialize(&self, serializer: S) -> Result where @@ -85,6 +195,24 @@ impl serde::Serialize for TaxProductResourceTaxRateDetailsTaxType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxProductResourceTaxRateDetailsTaxType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TaxProductResourceTaxRateDetailsTaxType::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxProductResourceTaxRateDetailsTaxType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxProductResourceTaxRateDetailsTaxType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..1e240480f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,95 @@ pub struct TaxProductResourceTaxSettingsDefaults { /// Default [tax code](https://stripe.com/docs/tax/tax-categories) used to classify your products and prices. pub tax_code: Option, } +#[doc(hidden)] +pub struct TaxProductResourceTaxSettingsDefaultsBuilder { + tax_behavior: Option>, + tax_code: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductResourceTaxSettingsDefaultsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { tax_behavior: Deserialize::default(), tax_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { tax_behavior: self.tax_behavior?, tax_code: self.tax_code.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)] @@ -48,6 +139,7 @@ impl std::fmt::Debug for TaxProductResourceTaxSettingsDefaultsTaxBehavior { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxProductResourceTaxSettingsDefaultsTaxBehavior { fn serialize(&self, serializer: S) -> Result where @@ -56,6 +148,25 @@ impl serde::Serialize for TaxProductResourceTaxSettingsDefaultsTaxBehavior { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxProductResourceTaxSettingsDefaultsTaxBehavior { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TaxProductResourceTaxSettingsDefaultsTaxBehavior::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxProductResourceTaxSettingsDefaultsTaxBehavior); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxProductResourceTaxSettingsDefaultsTaxBehavior { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..dac218482 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductResourceTaxSettingsHeadOffice { pub address: stripe_shared::Address, } +#[doc(hidden)] +pub struct TaxProductResourceTaxSettingsHeadOfficeBuilder { + address: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductResourceTaxSettingsHeadOfficeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { address: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { address: self.address.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..c9708b413 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,96 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductResourceTaxSettingsStatusDetails { - #[serde(skip_serializing_if = "Option::is_none")] pub active: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pending: Option, } +#[doc(hidden)] +pub struct TaxProductResourceTaxSettingsStatusDetailsBuilder { + active: Option>, + pending: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductResourceTaxSettingsStatusDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { active: Deserialize::default(), pending: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { active: self.active?, pending: self.pending.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..de2005450 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,86 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductResourceTaxSettingsStatusDetailsResourceActive {} +#[doc(hidden)] +pub struct TaxProductResourceTaxSettingsStatusDetailsResourceActiveBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductResourceTaxSettingsStatusDetailsResourceActiveBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..bf50c9dbb 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,92 @@ pub struct TaxProductResourceTaxSettingsStatusDetailsResourcePending { /// Calculations can fail if missing fields aren't explicitly provided on every call. pub missing_fields: Option>, } +#[doc(hidden)] +pub struct TaxProductResourceTaxSettingsStatusDetailsResourcePendingBuilder { + missing_fields: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductResourceTaxSettingsStatusDetailsResourcePendingBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { missing_fields: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { missing_fields: self.missing_fields.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..5feee3779 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,97 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductResourceTaxTransactionLineItemResourceReversal { /// The `id` of the line item to reverse in the original transaction. pub original_line_item: String, } +#[doc(hidden)] +pub struct TaxProductResourceTaxTransactionLineItemResourceReversalBuilder { + original_line_item: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductResourceTaxTransactionLineItemResourceReversalBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { original_line_item: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { original_line_item: self.original_line_item.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..397bb7dd9 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,95 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductResourceTaxTransactionResourceReversal { /// The `id` of the reversed `Transaction` object. pub original_transaction: Option, } +#[doc(hidden)] +pub struct TaxProductResourceTaxTransactionResourceReversalBuilder { + original_transaction: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductResourceTaxTransactionResourceReversalBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { original_transaction: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { original_transaction: self.original_transaction.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..6b069d46c 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,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxProductResourceTaxTransactionShippingCost { /// The shipping amount in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). /// If `tax_behavior=inclusive`, then this amount includes taxes. @@ -7,18 +9,131 @@ pub struct TaxProductResourceTaxTransactionShippingCost { /// The amount of tax calculated for shipping, in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). 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, /// 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>, /// The [tax code](https://stripe.com/docs/tax/tax-categories) ID used for shipping. pub tax_code: String, } +#[doc(hidden)] +pub struct TaxProductResourceTaxTransactionShippingCostBuilder { + amount: Option, + amount_tax: Option, + shipping_rate: Option>, + tax_behavior: Option, + tax_breakdown: Option>>, + tax_code: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxProductResourceTaxTransactionShippingCostBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount: self.amount?, + amount_tax: self.amount_tax?, + shipping_rate: self.shipping_rate.take()?, + tax_behavior: self.tax_behavior?, + tax_breakdown: self.tax_breakdown.take()?, + tax_code: self.tax_code.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)] @@ -58,6 +173,7 @@ impl std::fmt::Debug for TaxProductResourceTaxTransactionShippingCostTaxBehavior f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxProductResourceTaxTransactionShippingCostTaxBehavior { fn serialize(&self, serializer: S) -> Result where @@ -66,6 +182,27 @@ impl serde::Serialize for TaxProductResourceTaxTransactionShippingCostTaxBehavio serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxProductResourceTaxTransactionShippingCostTaxBehavior { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TaxProductResourceTaxTransactionShippingCostTaxBehavior::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxProductResourceTaxTransactionShippingCostTaxBehavior); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxProductResourceTaxTransactionShippingCostTaxBehavior { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/tax_registration/requests.rs b/generated/stripe_misc/src/tax_registration/requests.rs index a64b8d749..586ab8fe0 100644 --- a/generated/stripe_misc/src/tax_registration/requests.rs +++ b/generated/stripe_misc/src/tax_registration/requests.rs @@ -78,6 +78,15 @@ impl serde::Serialize for ListTaxRegistrationStatus { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ListTaxRegistrationStatus { + fn deserialize>(deserializer: D) -> 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 ListTaxRegistrationStatus")) + } +} impl<'a> ListTaxRegistration<'a> { /// Returns a list of Tax `Registration` objects. pub fn send( @@ -359,6 +368,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsAeType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsAeType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsAeType") + }) + } +} /// Options for the registration in AT. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsAt { @@ -433,6 +452,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsAtStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsAtStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsAtStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsAtType { @@ -485,6 +514,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsAtType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsAtType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsAtType") + }) + } +} /// Options for the registration in AU. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsAu { @@ -540,6 +579,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsAuType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsAuType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsAuType") + }) + } +} /// Options for the registration in BE. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsBe { @@ -614,6 +663,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsBeStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsBeStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsBeStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsBeType { @@ -666,6 +725,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsBeType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsBeType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsBeType") + }) + } +} /// Options for the registration in BG. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsBg { @@ -740,6 +809,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsBgStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsBgStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsBgStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsBgType { @@ -792,6 +871,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsBgType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsBgType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsBgType") + }) + } +} /// Options for the registration in CA. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsCa<'a> { @@ -867,6 +956,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsCaType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsCaType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsCaType") + }) + } +} /// Options for the registration in CH. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsCh { @@ -922,6 +1021,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsChType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsChType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsChType") + }) + } +} /// Options for the registration in CL. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsCl { @@ -977,6 +1086,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsClType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsClType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsClType") + }) + } +} /// Options for the registration in CO. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsCo { @@ -1032,6 +1151,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsCoType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsCoType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsCoType") + }) + } +} /// Options for the registration in CY. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsCy { @@ -1106,6 +1235,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsCyStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsCyStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsCyStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsCyType { @@ -1158,6 +1297,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsCyType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsCyType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsCyType") + }) + } +} /// Options for the registration in CZ. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsCz { @@ -1232,6 +1381,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsCzStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsCzStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsCzStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsCzType { @@ -1284,6 +1443,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsCzType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsCzType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsCzType") + }) + } +} /// Options for the registration in DE. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsDe { @@ -1358,6 +1527,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsDeStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsDeStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsDeStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsDeType { @@ -1410,6 +1589,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsDeType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsDeType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsDeType") + }) + } +} /// Options for the registration in DK. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsDk { @@ -1484,6 +1673,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsDkStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsDkStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsDkStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsDkType { @@ -1536,6 +1735,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsDkType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsDkType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsDkType") + }) + } +} /// Options for the registration in EE. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsEe { @@ -1610,6 +1819,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsEeStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsEeStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsEeStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsEeType { @@ -1662,6 +1881,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsEeType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsEeType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsEeType") + }) + } +} /// Options for the registration in ES. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsEs { @@ -1736,6 +1965,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsEsStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsEsStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsEsStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsEsType { @@ -1788,6 +2027,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsEsType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsEsType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsEsType") + }) + } +} /// Options for the registration in FI. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsFi { @@ -1862,6 +2111,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsFiStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsFiStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsFiStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsFiType { @@ -1914,6 +2173,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsFiType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsFiType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsFiType") + }) + } +} /// Options for the registration in FR. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsFr { @@ -1988,6 +2257,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsFrStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsFrStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsFrStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsFrType { @@ -2040,6 +2319,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsFrType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsFrType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsFrType") + }) + } +} /// Options for the registration in GB. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsGb { @@ -2095,6 +2384,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsGbType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsGbType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsGbType") + }) + } +} /// Options for the registration in GR. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsGr { @@ -2169,6 +2468,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsGrStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsGrStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsGrStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsGrType { @@ -2221,6 +2530,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsGrType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsGrType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsGrType") + }) + } +} /// Options for the registration in HR. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsHr { @@ -2295,6 +2614,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsHrStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsHrStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsHrStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsHrType { @@ -2347,6 +2676,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsHrType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsHrType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsHrType") + }) + } +} /// Options for the registration in HU. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsHu { @@ -2421,6 +2760,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsHuStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsHuStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsHuStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsHuType { @@ -2473,6 +2822,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsHuType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsHuType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsHuType") + }) + } +} /// Options for the registration in ID. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsId { @@ -2528,6 +2887,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsIdType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsIdType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsIdType") + }) + } +} /// Options for the registration in IE. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsIe { @@ -2602,6 +2971,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsIeStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsIeStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsIeStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsIeType { @@ -2654,6 +3033,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsIeType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsIeType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsIeType") + }) + } +} /// Options for the registration in IS. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsIs { @@ -2709,6 +3098,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsIsType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsIsType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsIsType") + }) + } +} /// Options for the registration in IT. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsIt { @@ -2783,6 +3182,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsItStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsItStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsItStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsItType { @@ -2835,6 +3244,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsItType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsItType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsItType") + }) + } +} /// Options for the registration in JP. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsJp { @@ -2890,6 +3309,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsJpType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsJpType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsJpType") + }) + } +} /// Options for the registration in KR. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsKr { @@ -2945,6 +3374,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsKrType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsKrType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsKrType") + }) + } +} /// Options for the registration in LT. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsLt { @@ -3019,6 +3458,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsLtStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsLtStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsLtStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsLtType { @@ -3071,6 +3520,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsLtType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsLtType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsLtType") + }) + } +} /// Options for the registration in LU. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsLu { @@ -3145,6 +3604,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsLuStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsLuStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsLuStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsLuType { @@ -3197,6 +3666,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsLuType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsLuType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsLuType") + }) + } +} /// Options for the registration in LV. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsLv { @@ -3271,6 +3750,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsLvStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsLvStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsLvStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsLvType { @@ -3323,6 +3812,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsLvType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsLvType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsLvType") + }) + } +} /// Options for the registration in MT. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsMt { @@ -3397,6 +3896,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsMtStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsMtStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsMtStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsMtType { @@ -3449,6 +3958,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsMtType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsMtType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsMtType") + }) + } +} /// Options for the registration in MX. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsMx { @@ -3504,6 +4023,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsMxType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsMxType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsMxType") + }) + } +} /// Options for the registration in MY. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsMy { @@ -3559,6 +4088,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsMyType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsMyType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsMyType") + }) + } +} /// Options for the registration in NL. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsNl { @@ -3633,6 +4172,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsNlStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsNlStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsNlStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsNlType { @@ -3685,6 +4234,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsNlType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsNlType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsNlType") + }) + } +} /// Options for the registration in NO. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsNo { @@ -3740,6 +4299,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsNoType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsNoType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsNoType") + }) + } +} /// Options for the registration in NZ. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsNz { @@ -3795,6 +4364,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsNzType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsNzType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsNzType") + }) + } +} /// Options for the registration in PL. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsPl { @@ -3869,6 +4448,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsPlStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsPlStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsPlStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsPlType { @@ -3921,6 +4510,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsPlType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsPlType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsPlType") + }) + } +} /// Options for the registration in PT. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsPt { @@ -3995,6 +4594,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsPtStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsPtStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsPtStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsPtType { @@ -4047,6 +4656,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsPtType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsPtType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsPtType") + }) + } +} /// Options for the registration in RO. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsRo { @@ -4121,6 +4740,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsRoStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsRoStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsRoStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsRoType { @@ -4173,6 +4802,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsRoType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsRoType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsRoType") + }) + } +} /// Options for the registration in SA. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsSa { @@ -4228,6 +4867,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsSaType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsSaType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsSaType") + }) + } +} /// Options for the registration in SE. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsSe { @@ -4302,6 +4951,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsSeStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsSeStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsSeStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsSeType { @@ -4354,6 +5013,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsSeType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsSeType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsSeType") + }) + } +} /// Options for the registration in SG. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsSg { @@ -4409,6 +5078,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsSgType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsSgType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsSgType") + }) + } +} /// Options for the registration in SI. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsSi { @@ -4483,6 +5162,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsSiStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsSiStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsSiStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsSiType { @@ -4535,6 +5224,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsSiType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsSiType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsSiType") + }) + } +} /// Options for the registration in SK. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsSk { @@ -4609,6 +5308,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsSkStandardPlaceOfSu serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTaxRegistrationCountryOptionsSkStandardPlaceOfSupplyScheme +{ + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsSkStandardPlaceOfSupplyScheme")) + } +} /// Type of registration to be created in an EU country. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTaxRegistrationCountryOptionsSkType { @@ -4661,6 +5370,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsSkType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsSkType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsSkType") + }) + } +} /// Options for the registration in TH. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsTh { @@ -4716,6 +5435,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsThType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsThType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsThType") + }) + } +} /// Options for the registration in TR. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsTr { @@ -4771,6 +5500,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsTrType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsTrType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsTrType") + }) + } +} /// Options for the registration in US. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsUs<'a> { @@ -4867,6 +5606,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsUsType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsUsType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsUsType") + }) + } +} /// Options for the registration in VN. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsVn { @@ -4922,6 +5671,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsVnType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsVnType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsVnType") + }) + } +} /// Options for the registration in ZA. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTaxRegistrationCountryOptionsZa { @@ -4977,6 +5736,16 @@ impl serde::Serialize for CreateTaxRegistrationCountryOptionsZaType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTaxRegistrationCountryOptionsZaType { + fn deserialize>(deserializer: D) -> 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 CreateTaxRegistrationCountryOptionsZaType") + }) + } +} impl<'a> CreateTaxRegistration<'a> { /// Creates a new Tax `Registration` object. pub fn send(&self, client: &stripe::Client) -> stripe::Response { diff --git a/generated/stripe_misc/src/tax_registration/types.rs b/generated/stripe_misc/src/tax_registration/types.rs index 74cb67139..358ec28a4 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxRegistration { /// Time at which the registration becomes active. Measured in seconds since the Unix epoch. pub active_from: stripe_types::Timestamp, @@ -21,10 +23,210 @@ pub struct TaxRegistration { pub id: stripe_misc::TaxRegistrationId, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: TaxRegistrationObject, /// The status of the registration. /// This field is present for convenience and can be deduced from `active_from` and `expires_at`. pub status: TaxRegistrationStatus, } +#[doc(hidden)] +pub struct TaxRegistrationBuilder { + active_from: Option, + country: Option, + country_options: Option, + created: Option, + expires_at: Option>, + id: Option, + livemode: Option, + object: Option, + status: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxRegistrationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "status" => Deserialize::begin(&mut self.status), + + _ => ::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(), + object: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + active_from: self.active_from?, + country: self.country.take()?, + country_options: self.country_options.take()?, + created: self.created?, + expires_at: self.expires_at?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + status: self.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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TaxRegistrationObject { + TaxRegistration, +} +impl TaxRegistrationObject { + pub fn as_str(self) -> &'static str { + use TaxRegistrationObject::*; + match self { + TaxRegistration => "tax.registration", + } + } +} + +impl std::str::FromStr for TaxRegistrationObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TaxRegistrationObject::*; + match s { + "tax.registration" => Ok(TaxRegistration), + _ => Err(()), + } + } +} +impl std::fmt::Display for TaxRegistrationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TaxRegistrationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TaxRegistrationObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TaxRegistrationObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxRegistrationObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxRegistrationObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TaxRegistrationObject { + fn deserialize>(deserializer: D) -> 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 TaxRegistrationObject")) + } +} /// 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)] @@ -67,6 +269,7 @@ impl std::fmt::Debug for TaxRegistrationStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxRegistrationStatus { fn serialize(&self, serializer: S) -> Result where @@ -75,6 +278,22 @@ impl serde::Serialize for TaxRegistrationStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxRegistrationStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxRegistrationStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxRegistrationStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxRegistrationStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/tax_settings/requests.rs b/generated/stripe_misc/src/tax_settings/requests.rs index a92c564ba..334c4112a 100644 --- a/generated/stripe_misc/src/tax_settings/requests.rs +++ b/generated/stripe_misc/src/tax_settings/requests.rs @@ -100,6 +100,16 @@ impl serde::Serialize for UpdateTaxSettingsDefaultsTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateTaxSettingsDefaultsTaxBehavior { + fn deserialize>(deserializer: D) -> 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 UpdateTaxSettingsDefaultsTaxBehavior") + }) + } +} /// The place where your business is located. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdateTaxSettingsHeadOffice<'a> { diff --git a/generated/stripe_misc/src/tax_settings/types.rs b/generated/stripe_misc/src/tax_settings/types.rs index 66d271a9b..0937d6552 100644 --- a/generated/stripe_misc/src/tax_settings/types.rs +++ b/generated/stripe_misc/src/tax_settings/types.rs @@ -3,18 +3,205 @@ /// Related guide: [Using the Settings API](https://stripe.com/docs/tax/settings-api) /// /// For more details see <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxSettings { pub defaults: stripe_misc::TaxProductResourceTaxSettingsDefaults, /// The place where your business is located. pub head_office: Option, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: TaxSettingsObject, /// 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. pub status: TaxSettingsStatus, pub status_details: stripe_misc::TaxProductResourceTaxSettingsStatusDetails, } +#[doc(hidden)] +pub struct TaxSettingsBuilder { + defaults: Option, + head_office: Option>, + livemode: Option, + object: Option, + status: Option, + status_details: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "status" => Deserialize::begin(&mut self.status), + "status_details" => Deserialize::begin(&mut self.status_details), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + defaults: Deserialize::default(), + head_office: Deserialize::default(), + livemode: Deserialize::default(), + object: Deserialize::default(), + status: Deserialize::default(), + status_details: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + defaults: self.defaults.take()?, + head_office: self.head_office.take()?, + livemode: self.livemode?, + object: self.object?, + status: self.status?, + status_details: self.status_details.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TaxSettingsObject { + TaxSettings, +} +impl TaxSettingsObject { + pub fn as_str(self) -> &'static str { + use TaxSettingsObject::*; + match self { + TaxSettings => "tax.settings", + } + } +} + +impl std::str::FromStr for TaxSettingsObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TaxSettingsObject::*; + match s { + "tax.settings" => Ok(TaxSettings), + _ => Err(()), + } + } +} +impl std::fmt::Display for TaxSettingsObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TaxSettingsObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TaxSettingsObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TaxSettingsObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxSettingsObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxSettingsObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TaxSettingsObject { + fn deserialize>(deserializer: D) -> 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 TaxSettingsObject")) + } +} /// 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)] @@ -54,6 +241,7 @@ impl std::fmt::Debug for TaxSettingsStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxSettingsStatus { fn serialize(&self, serializer: S) -> Result where @@ -62,6 +250,22 @@ impl serde::Serialize for TaxSettingsStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxSettingsStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxSettingsStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxSettingsStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxSettingsStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/tax_transaction/requests.rs b/generated/stripe_misc/src/tax_transaction/requests.rs index f53c5a9c6..9bceca334 100644 --- a/generated/stripe_misc/src/tax_transaction/requests.rs +++ b/generated/stripe_misc/src/tax_transaction/requests.rs @@ -220,6 +220,16 @@ impl serde::Serialize for CreateReversalTaxTransactionMode { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateReversalTaxTransactionMode { + fn deserialize>(deserializer: D) -> 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 CreateReversalTaxTransactionMode") + }) + } +} /// The shipping cost to reverse. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateReversalTaxTransactionShippingCost { diff --git a/generated/stripe_misc/src/tax_transaction/types.rs b/generated/stripe_misc/src/tax_transaction/types.rs index dcabfd75e..6d8ff39f6 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxTransaction { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -22,6 +24,8 @@ pub struct TaxTransaction { /// 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>, + /// String representing the object's type. Objects of the same type share the same value. + pub object: TaxTransactionObject, /// A custom unique identifier, such as 'myOrder_123'. pub reference: String, /// If `type=reversal`, contains information about what was reversed. @@ -31,9 +35,232 @@ 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(feature = "serde", serde(rename = "type"))] pub type_: TaxTransactionType, } +#[doc(hidden)] +pub struct TaxTransactionBuilder { + created: Option, + currency: Option, + customer: Option>, + customer_details: Option, + id: Option, + line_items: Option>>, + livemode: Option, + metadata: Option>>, + object: Option, + reference: Option, + reversal: Option>, + shipping_cost: Option>, + tax_date: Option, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxTransactionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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_), + + _ => ::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(), + object: 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 { + Some(Self::Out { + created: self.created?, + currency: self.currency?, + customer: self.customer.take()?, + customer_details: self.customer_details.take()?, + id: self.id.take()?, + line_items: self.line_items.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + reference: self.reference.take()?, + reversal: self.reversal.take()?, + shipping_cost: self.shipping_cost.take()?, + tax_date: self.tax_date?, + type_: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TaxTransactionObject { + TaxTransaction, +} +impl TaxTransactionObject { + pub fn as_str(self) -> &'static str { + use TaxTransactionObject::*; + match self { + TaxTransaction => "tax.transaction", + } + } +} + +impl std::str::FromStr for TaxTransactionObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TaxTransactionObject::*; + match s { + "tax.transaction" => Ok(TaxTransaction), + _ => Err(()), + } + } +} +impl std::fmt::Display for TaxTransactionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TaxTransactionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TaxTransactionObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TaxTransactionObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxTransactionObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxTransactionObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TaxTransactionObject { + fn deserialize>(deserializer: D) -> 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 TaxTransactionObject")) + } +} /// If `reversal`, this transaction reverses an earlier transaction. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TaxTransactionType { @@ -72,6 +299,7 @@ impl std::fmt::Debug for TaxTransactionType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxTransactionType { fn serialize(&self, serializer: S) -> Result where @@ -80,6 +308,22 @@ impl serde::Serialize for TaxTransactionType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxTransactionType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxTransactionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxTransactionType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxTransactionType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/tax_transaction_line_item.rs b/generated/stripe_misc/src/tax_transaction_line_item.rs index 06dd5f86f..e6d4fde9c 100644 --- a/generated/stripe_misc/src/tax_transaction_line_item.rs +++ b/generated/stripe_misc/src/tax_transaction_line_item.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxTransactionLineItem { /// The line item amount in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). /// If `tax_behavior=inclusive`, then this amount includes taxes. @@ -13,6 +15,8 @@ pub struct TaxTransactionLineItem { /// 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>, + /// String representing the object's type. Objects of the same type share the same value. + pub object: TaxTransactionLineItemObject, /// The ID of an existing [Product](https://stripe.com/docs/api/products/object). pub product: Option, /// The number of units of the item being purchased. For reversals, this is the quantity reversed. @@ -27,9 +31,227 @@ 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(feature = "serde", serde(rename = "type"))] pub type_: TaxTransactionLineItemType, } +#[doc(hidden)] +pub struct TaxTransactionLineItemBuilder { + amount: Option, + amount_tax: Option, + id: Option, + livemode: Option, + metadata: Option>>, + object: Option, + product: Option>, + quantity: Option, + reference: Option, + reversal: Option>, + tax_behavior: Option, + tax_code: Option, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxTransactionLineItemBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_tax: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + object: 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 { + Some(Self::Out { + amount: self.amount?, + amount_tax: self.amount_tax?, + id: self.id.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + product: self.product.take()?, + quantity: self.quantity?, + reference: self.reference.take()?, + reversal: self.reversal.take()?, + tax_behavior: self.tax_behavior?, + tax_code: self.tax_code.take()?, + type_: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TaxTransactionLineItemObject { + TaxTransactionLineItem, +} +impl TaxTransactionLineItemObject { + pub fn as_str(self) -> &'static str { + use TaxTransactionLineItemObject::*; + match self { + TaxTransactionLineItem => "tax.transaction_line_item", + } + } +} + +impl std::str::FromStr for TaxTransactionLineItemObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TaxTransactionLineItemObject::*; + match s { + "tax.transaction_line_item" => Ok(TaxTransactionLineItem), + _ => Err(()), + } + } +} +impl std::fmt::Display for TaxTransactionLineItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TaxTransactionLineItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TaxTransactionLineItemObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TaxTransactionLineItemObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxTransactionLineItemObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxTransactionLineItemObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TaxTransactionLineItemObject { + fn deserialize>(deserializer: D) -> 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 TaxTransactionLineItemObject")) + } +} /// Specifies whether the `amount` includes taxes. /// If `tax_behavior=inclusive`, then the amount includes taxes. #[derive(Copy, Clone, Eq, PartialEq)] @@ -69,6 +291,7 @@ impl std::fmt::Debug for TaxTransactionLineItemTaxBehavior { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxTransactionLineItemTaxBehavior { fn serialize(&self, serializer: S) -> Result where @@ -77,6 +300,23 @@ impl serde::Serialize for TaxTransactionLineItemTaxBehavior { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxTransactionLineItemTaxBehavior { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(TaxTransactionLineItemTaxBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxTransactionLineItemTaxBehavior); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxTransactionLineItemTaxBehavior { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -124,6 +364,7 @@ impl std::fmt::Debug for TaxTransactionLineItemType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxTransactionLineItemType { fn serialize(&self, serializer: S) -> Result where @@ -132,6 +373,22 @@ impl serde::Serialize for TaxTransactionLineItemType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxTransactionLineItemType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxTransactionLineItemType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxTransactionLineItemType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxTransactionLineItemType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/verification_session_redaction.rs b/generated/stripe_misc/src/verification_session_redaction.rs index c0264d6c4..7c2fa52bd 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct VerificationSessionRedaction { /// Indicates whether this object and its related objects have been redacted or not. pub status: VerificationSessionRedactionStatus, } +#[doc(hidden)] +pub struct VerificationSessionRedactionBuilder { + status: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: VerificationSessionRedactionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { status: self.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 { + 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 { @@ -41,6 +129,7 @@ impl std::fmt::Debug for VerificationSessionRedactionStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for VerificationSessionRedactionStatus { fn serialize(&self, serializer: S) -> Result where @@ -49,6 +138,23 @@ impl serde::Serialize for VerificationSessionRedactionStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for VerificationSessionRedactionStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(VerificationSessionRedactionStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(VerificationSessionRedactionStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for VerificationSessionRedactionStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_misc/src/webhook_endpoint/requests.rs b/generated/stripe_misc/src/webhook_endpoint/requests.rs index f02bee507..aba528949 100644 --- a/generated/stripe_misc/src/webhook_endpoint/requests.rs +++ b/generated/stripe_misc/src/webhook_endpoint/requests.rs @@ -886,6 +886,14 @@ impl serde::Serialize for CreateWebhookEndpointEnabledEvents { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateWebhookEndpointEnabledEvents { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} impl<'a> CreateWebhookEndpoint<'a> { /// A webhook endpoint must have a `url` and a list of `enabled_events`. /// You may optionally specify the Boolean `connect` parameter. @@ -1692,6 +1700,14 @@ impl serde::Serialize for UpdateWebhookEndpointEnabledEvents { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateWebhookEndpointEnabledEvents { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} impl<'a> UpdateWebhookEndpoint<'a> { /// Updates the webhook endpoint. /// You may edit the `url`, the list of `enabled_events`, and the status of your endpoint. diff --git a/generated/stripe_misc/src/webhook_endpoint/types.rs b/generated/stripe_misc/src/webhook_endpoint/types.rs index 9eae76e71..c00b383c2 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct WebhookEndpoint { /// The API version events are rendered as for this webhook endpoint. pub api_version: Option, @@ -27,15 +29,229 @@ pub struct WebhookEndpoint { /// 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 representing the object's type. Objects of the same type share the same value. + pub object: WebhookEndpointObject, /// 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, /// The status of the webhook. It can be `enabled` or `disabled`. pub status: String, /// The URL of the webhook endpoint. pub url: String, } +#[doc(hidden)] +pub struct WebhookEndpointBuilder { + api_version: Option>, + application: Option>, + created: Option, + description: Option>, + enabled_events: Option>, + id: Option, + livemode: Option, + metadata: Option>, + object: Option, + secret: Option>, + status: Option, + url: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: WebhookEndpointBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "secret" => Deserialize::begin(&mut self.secret), + "status" => Deserialize::begin(&mut self.status), + "url" => Deserialize::begin(&mut self.url), + + _ => ::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(), + object: Deserialize::default(), + secret: Deserialize::default(), + status: Deserialize::default(), + url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + api_version: self.api_version.take()?, + application: self.application.take()?, + created: self.created?, + description: self.description.take()?, + enabled_events: self.enabled_events.take()?, + id: self.id.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + secret: self.secret.take()?, + status: self.status.take()?, + url: self.url.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum WebhookEndpointObject { + WebhookEndpoint, +} +impl WebhookEndpointObject { + pub fn as_str(self) -> &'static str { + use WebhookEndpointObject::*; + match self { + WebhookEndpoint => "webhook_endpoint", + } + } +} + +impl std::str::FromStr for WebhookEndpointObject { + type Err = (); + fn from_str(s: &str) -> Result { + use WebhookEndpointObject::*; + match s { + "webhook_endpoint" => Ok(WebhookEndpoint), + _ => Err(()), + } + } +} +impl std::fmt::Display for WebhookEndpointObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for WebhookEndpointObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for WebhookEndpointObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for WebhookEndpointObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(WebhookEndpointObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(WebhookEndpointObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for WebhookEndpointObject { + fn deserialize>(deserializer: D) -> 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 WebhookEndpointObject")) + } +} impl stripe_types::Object for WebhookEndpoint { type Id = stripe_misc::WebhookEndpointId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_payment/Cargo.toml b/generated/stripe_payment/Cargo.toml index 5776be916..e684d7bd3 100644 --- a/generated/stripe_payment/Cargo.toml +++ b/generated/stripe_payment/Cargo.toml @@ -16,8 +16,9 @@ path = "src/mod.rs" [dependencies] serde.workspace = true -smol_str.workspace = true serde_json.workspace = true +smol_str.workspace = true +miniserde.workspace = true stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +serde = ["stripe_types/serde","stripe_shared/serde"] 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..35a78ce05 100644 --- a/generated/stripe_payment/src/bank_account/requests.rs +++ b/generated/stripe_payment/src/bank_account/requests.rs @@ -46,12 +46,88 @@ impl<'a> DeleteCustomerBankAccount<'a> { ) } } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(untagged))] pub enum DeleteCustomerBankAccountReturned { PaymentSource(stripe_shared::PaymentSource), DeletedPaymentSource(stripe_shared::DeletedPaymentSource), } + +#[derive(Default)] +pub struct DeleteCustomerBankAccountReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +const _: () = { + use 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, + builder: DeleteCustomerBankAccountReturnedBuilder, + } + + impl Deserialize for DeleteCustomerBankAccountReturned { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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 UpdateAccountBankAccount<'a> { /// The name of the person or business that owns the bank account. @@ -159,6 +235,16 @@ impl serde::Serialize for UpdateAccountBankAccountAccountHolderType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateAccountBankAccountAccountHolderType { + fn deserialize>(deserializer: D) -> 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 UpdateAccountBankAccountAccountHolderType") + }) + } +} /// The bank account type. /// This can only be `checking` or `savings` in most countries. /// In Japan, this can only be `futsu` or `toza`. @@ -213,6 +299,16 @@ impl serde::Serialize for UpdateAccountBankAccountAccountType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateAccountBankAccountAccountType { + fn deserialize>(deserializer: D) -> 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 UpdateAccountBankAccountAccountType") + }) + } +} /// Documents that may be submitted to satisfy various informational requests. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateAccountBankAccountDocuments<'a> { @@ -356,6 +452,16 @@ impl serde::Serialize for UpdateCustomerBankAccountAccountHolderType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateCustomerBankAccountAccountHolderType { + fn deserialize>(deserializer: D) -> 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 UpdateCustomerBankAccountAccountHolderType") + }) + } +} #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateCustomerBankAccountOwner<'a> { /// Owner's address. @@ -418,16 +524,102 @@ impl<'a> UpdateCustomerBankAccount<'a> { ) } } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(tag = "object"))] pub enum UpdateCustomerBankAccountReturned { - #[serde(rename = "card")] + #[cfg_attr(feature = "serde", serde(rename = "card"))] Card(stripe_shared::Card), - #[serde(rename = "bank_account")] + #[cfg_attr(feature = "serde", serde(rename = "bank_account"))] BankAccount(stripe_shared::BankAccount), - #[serde(rename = "source")] + #[cfg_attr(feature = "serde", serde(rename = "source"))] Source(stripe_shared::Source), } + +#[derive(Default)] +pub struct UpdateCustomerBankAccountReturnedBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +const _: () = { + use 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, + builder: UpdateCustomerBankAccountReturnedBuilder, + } + + impl Deserialize for UpdateCustomerBankAccountReturned { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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 { + 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 { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + #[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. diff --git a/generated/stripe_payment/src/card/requests.rs b/generated/stripe_payment/src/card/requests.rs index 37fe3124b..fca0ef7d4 100644 --- a/generated/stripe_payment/src/card/requests.rs +++ b/generated/stripe_payment/src/card/requests.rs @@ -46,12 +46,88 @@ impl<'a> DeleteCustomerCard<'a> { ) } } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(untagged))] pub enum DeleteCustomerCardReturned { PaymentSource(stripe_shared::PaymentSource), DeletedPaymentSource(stripe_shared::DeletedPaymentSource), } + +#[derive(Default)] +pub struct DeleteCustomerCardReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +const _: () = { + use 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, + builder: DeleteCustomerCardReturnedBuilder, + } + + impl Deserialize for DeleteCustomerCardReturned { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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. @@ -159,6 +235,16 @@ impl serde::Serialize for UpdateAccountCardAccountHolderType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateAccountCardAccountHolderType { + fn deserialize>(deserializer: D) -> 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 UpdateAccountCardAccountHolderType") + }) + } +} /// The bank account type. /// This can only be `checking` or `savings` in most countries. /// In Japan, this can only be `futsu` or `toza`. @@ -213,6 +299,15 @@ impl serde::Serialize for UpdateAccountCardAccountType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateAccountCardAccountType { + fn deserialize>(deserializer: D) -> 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 UpdateAccountCardAccountType")) + } +} /// Documents that may be submitted to satisfy various informational requests. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateAccountCardDocuments<'a> { @@ -356,6 +451,16 @@ impl serde::Serialize for UpdateCustomerCardAccountHolderType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateCustomerCardAccountHolderType { + fn deserialize>(deserializer: D) -> 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 UpdateCustomerCardAccountHolderType") + }) + } +} #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdateCustomerCardOwner<'a> { /// Owner's address. @@ -418,13 +523,98 @@ impl<'a> UpdateCustomerCard<'a> { ) } } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(tag = "object"))] pub enum UpdateCustomerCardReturned { - #[serde(rename = "card")] + #[cfg_attr(feature = "serde", serde(rename = "card"))] Card(stripe_shared::Card), - #[serde(rename = "bank_account")] + #[cfg_attr(feature = "serde", serde(rename = "bank_account"))] BankAccount(stripe_shared::BankAccount), - #[serde(rename = "source")] + #[cfg_attr(feature = "serde", serde(rename = "source"))] Source(stripe_shared::Source), } + +#[derive(Default)] +pub struct UpdateCustomerCardReturnedBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +const _: () = { + use 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, + builder: UpdateCustomerCardReturnedBuilder, + } + + impl Deserialize for UpdateCustomerCardReturned { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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 { + 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 { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; diff --git a/generated/stripe_payment/src/mod.rs b/generated/stripe_payment/src/mod.rs index 523419582..11dbee75a 100644 --- a/generated/stripe_payment/src/mod.rs +++ b/generated/stripe_payment/src/mod.rs @@ -8,6 +8,8 @@ //! of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_payment; + +miniserde::make_place!(Place); pub mod bank_account; pub use stripe_shared::bank_account::*; pub mod card; diff --git a/generated/stripe_payment/src/payment_link/requests.rs b/generated/stripe_payment/src/payment_link/requests.rs index 14fde7ad6..c83d49681 100644 --- a/generated/stripe_payment/src/payment_link/requests.rs +++ b/generated/stripe_payment/src/payment_link/requests.rs @@ -309,6 +309,16 @@ impl serde::Serialize for CreatePaymentLinkAfterCompletionType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentLinkAfterCompletionType { + fn deserialize>(deserializer: D) -> 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 CreatePaymentLinkAfterCompletionType") + }) + } +} /// Configuration for automatic tax collection. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreatePaymentLinkAutomaticTax<'a> { @@ -388,6 +398,16 @@ impl serde::Serialize for CreatePaymentLinkAutomaticTaxLiabilityType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentLinkAutomaticTaxLiabilityType { + fn deserialize>(deserializer: D) -> 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 CreatePaymentLinkAutomaticTaxLiabilityType") + }) + } +} /// Configure fields to gather active consent from customers. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentLinkConsentCollection { @@ -478,6 +498,16 @@ impl serde::Serialize for CreatePaymentLinkConsentCollectionPaymentMethodReuseAg serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentLinkConsentCollectionPaymentMethodReuseAgreementPosition +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentLinkConsentCollectionPaymentMethodReuseAgreementPosition")) + } +} /// 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 @@ -527,6 +557,18 @@ impl serde::Serialize for CreatePaymentLinkConsentCollectionPromotions { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentLinkConsentCollectionPromotions { + fn deserialize>(deserializer: D) -> 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 CreatePaymentLinkConsentCollectionPromotions", + ) + }) + } +} /// If set to `required`, it requires customers to check a terms of service checkbox before being able to pay. /// There must be a valid terms of service URL set in your [Dashboard settings](https://dashboard.stripe.com/settings/public). #[derive(Copy, Clone, Eq, PartialEq)] @@ -574,6 +616,18 @@ impl serde::Serialize for CreatePaymentLinkConsentCollectionTermsOfService { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentLinkConsentCollectionTermsOfService { + fn deserialize>(deserializer: D) -> 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 CreatePaymentLinkConsentCollectionTermsOfService", + ) + }) + } +} /// Collect additional information from your customer using custom fields. /// Up to 3 fields are supported. #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -666,6 +720,16 @@ impl serde::Serialize for CreatePaymentLinkCustomFieldsLabelType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentLinkCustomFieldsLabelType { + fn deserialize>(deserializer: D) -> 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 CreatePaymentLinkCustomFieldsLabelType") + }) + } +} /// Configuration for `type=numeric` fields. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentLinkCustomFieldsNumeric { @@ -745,6 +809,16 @@ impl serde::Serialize for CreatePaymentLinkCustomFieldsType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentLinkCustomFieldsType { + fn deserialize>(deserializer: D) -> 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 CreatePaymentLinkCustomFieldsType") + }) + } +} /// Configures whether [checkout sessions](https://stripe.com/docs/api/checkout/sessions) created by this payment link create a [Customer](https://stripe.com/docs/api/customers). #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentLinkCustomerCreation { @@ -791,6 +865,16 @@ impl serde::Serialize for CreatePaymentLinkCustomerCreation { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentLinkCustomerCreation { + fn deserialize>(deserializer: D) -> 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 CreatePaymentLinkCustomerCreation") + }) + } +} /// Generate a post-purchase Invoice for one-time payments. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreatePaymentLinkInvoiceCreation<'a> { @@ -901,6 +985,18 @@ impl serde::Serialize for CreatePaymentLinkInvoiceCreationInvoiceDataIssuerType serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentLinkInvoiceCreationInvoiceDataIssuerType { + fn deserialize>(deserializer: D) -> 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 CreatePaymentLinkInvoiceCreationInvoiceDataIssuerType", + ) + }) + } +} /// Default options for invoice PDF rendering for this customer. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentLinkInvoiceCreationInvoiceDataRenderingOptions { @@ -974,6 +1070,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay")) + } +} /// The line items representing what is being sold. /// Each line item represents an item being sold. /// Up to 20 line items are supported. @@ -1088,6 +1194,18 @@ impl serde::Serialize for CreatePaymentLinkPaymentIntentDataCaptureMethod { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentLinkPaymentIntentDataCaptureMethod { + fn deserialize>(deserializer: D) -> 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 CreatePaymentLinkPaymentIntentDataCaptureMethod", + ) + }) + } +} /// Indicates that you intend to [make future payments](https://stripe.com/docs/payments/payment-intents#future-usage) with the payment method collected by this Checkout Session. /// /// When setting this to `on_session`, Checkout will show a notice to the customer that their payment details will be saved. @@ -1145,6 +1263,18 @@ impl serde::Serialize for CreatePaymentLinkPaymentIntentDataSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentLinkPaymentIntentDataSetupFutureUsage { + fn deserialize>(deserializer: D) -> 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 CreatePaymentLinkPaymentIntentDataSetupFutureUsage", + ) + }) + } +} /// Specify whether Checkout should collect a payment method. /// When set to `if_required`, Checkout will not collect a payment method when the total due for the session is 0.This may occur if the Checkout Session includes a free trial or a discount. /// @@ -1196,6 +1326,16 @@ impl serde::Serialize for CreatePaymentLinkPaymentMethodCollection { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentLinkPaymentMethodCollection { + fn deserialize>(deserializer: D) -> 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 CreatePaymentLinkPaymentMethodCollection") + }) + } +} /// Controls phone number collection settings during checkout. /// /// We recommend that you review your privacy policy and check with your legal contacts. @@ -1981,6 +2121,14 @@ impl serde::Serialize for CreatePaymentLinkShippingAddressCollectionAllowedCount serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentLinkShippingAddressCollectionAllowedCountries { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// The shipping rate options to apply to [checkout sessions](https://stripe.com/docs/api/checkout/sessions) created by this payment link. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentLinkShippingOptions<'a> { @@ -2097,6 +2245,18 @@ impl serde::Serialize for CreatePaymentLinkSubscriptionDataInvoiceSettingsIssuer serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType { + fn deserialize>(deserializer: D) -> 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 CreatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType", + ) + }) + } +} /// Settings related to subscription trials. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreatePaymentLinkSubscriptionDataTrialSettings { @@ -2179,6 +2339,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod")) + } +} /// Controls tax ID collection during checkout. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreatePaymentLinkTaxIdCollection { @@ -2357,6 +2527,16 @@ impl serde::Serialize for UpdatePaymentLinkAfterCompletionType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentLinkAfterCompletionType { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentLinkAfterCompletionType") + }) + } +} /// Configuration for automatic tax collection. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdatePaymentLinkAutomaticTax<'a> { @@ -2436,6 +2616,16 @@ impl serde::Serialize for UpdatePaymentLinkAutomaticTaxLiabilityType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentLinkAutomaticTaxLiabilityType { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentLinkAutomaticTaxLiabilityType") + }) + } +} /// Collect additional information from your customer using custom fields. /// Up to 3 fields are supported. #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -2528,6 +2718,16 @@ impl serde::Serialize for UpdatePaymentLinkCustomFieldsLabelType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentLinkCustomFieldsLabelType { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentLinkCustomFieldsLabelType") + }) + } +} /// Configuration for `type=numeric` fields. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentLinkCustomFieldsNumeric { @@ -2607,6 +2807,16 @@ impl serde::Serialize for UpdatePaymentLinkCustomFieldsType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentLinkCustomFieldsType { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentLinkCustomFieldsType") + }) + } +} /// Configures whether [checkout sessions](https://stripe.com/docs/api/checkout/sessions) created by this payment link create a [Customer](https://stripe.com/docs/api/customers). #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentLinkCustomerCreation { @@ -2653,6 +2863,16 @@ impl serde::Serialize for UpdatePaymentLinkCustomerCreation { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentLinkCustomerCreation { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentLinkCustomerCreation") + }) + } +} /// Generate a post-purchase Invoice for one-time payments. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdatePaymentLinkInvoiceCreation<'a> { @@ -2763,6 +2983,18 @@ impl serde::Serialize for UpdatePaymentLinkInvoiceCreationInvoiceDataIssuerType serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentLinkInvoiceCreationInvoiceDataIssuerType { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentLinkInvoiceCreationInvoiceDataIssuerType", + ) + }) + } +} /// Default options for invoice PDF rendering for this customer. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct UpdatePaymentLinkInvoiceCreationInvoiceDataRenderingOptions { @@ -2836,6 +3068,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentLinkInvoiceCreationInvoiceDataRenderingOptionsAmountTaxDisplay")) + } +} /// The line items representing what is being sold. /// Each line item represents an item being sold. /// Up to 20 line items are supported. @@ -2936,6 +3178,16 @@ impl serde::Serialize for UpdatePaymentLinkPaymentMethodCollection { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentLinkPaymentMethodCollection { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentLinkPaymentMethodCollection") + }) + } +} /// Configuration for collecting the customer's shipping address. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdatePaymentLinkShippingAddressCollection<'a> { @@ -3708,6 +3960,14 @@ impl serde::Serialize for UpdatePaymentLinkShippingAddressCollectionAllowedCount serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentLinkShippingAddressCollectionAllowedCountries { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// When creating a subscription, the specified configuration data will be used. /// There must be at least one line item with a recurring price to use `subscription_data`. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -3804,6 +4064,18 @@ impl serde::Serialize for UpdatePaymentLinkSubscriptionDataInvoiceSettingsIssuer serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentLinkSubscriptionDataInvoiceSettingsIssuerType", + ) + }) + } +} /// Settings related to subscription trials. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct UpdatePaymentLinkSubscriptionDataTrialSettings { @@ -3886,6 +4158,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentLinkSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod")) + } +} impl<'a> UpdatePaymentLink<'a> { /// Updates a payment link. pub fn send( diff --git a/generated/stripe_payment/src/payment_method/requests.rs b/generated/stripe_payment/src/payment_method/requests.rs index 9e1f1f17b..c59cf73bc 100644 --- a/generated/stripe_payment/src/payment_method/requests.rs +++ b/generated/stripe_payment/src/payment_method/requests.rs @@ -177,6 +177,14 @@ impl serde::Serialize for ListPaymentMethodType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ListPaymentMethodType { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} 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. @@ -214,20 +222,23 @@ impl<'a> RetrievePaymentMethod<'a> { client.get_query(&format!("/payment_methods/{payment_method}"), self) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(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")] pub acss_debit: Option>, /// If this is an `affirm` PaymentMethod, this hash contains details about the Affirm payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub affirm: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub affirm: Option, /// If this is an `AfterpayClearpay` PaymentMethod, this hash contains details about the AfterpayClearpay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub afterpay_clearpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub afterpay_clearpay: Option, /// If this is an `Alipay` PaymentMethod, this hash contains details about the Alipay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub alipay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub alipay: Option, /// If this is an `au_becs_debit` PaymentMethod, this hash contains details about the bank account. #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option>, @@ -236,13 +247,15 @@ pub struct CreatePaymentMethod<'a> { pub bacs_debit: Option>, /// If this is a `bancontact` PaymentMethod, this hash contains details about the Bancontact payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub bancontact: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub bancontact: Option, /// 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>, /// If this is a `blik` PaymentMethod, this hash contains details about the BLIK payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub blik: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub blik: Option, /// If this is a `boleto` PaymentMethod, this hash contains details about the Boleto payment method. #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option>, @@ -254,13 +267,15 @@ pub struct CreatePaymentMethod<'a> { pub card: Option>, /// If this is a `cashapp` PaymentMethod, this hash contains details about the Cash App Pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub cashapp: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub cashapp: Option, /// The `Customer` to whom the original PaymentMethod is attached. #[serde(skip_serializing_if = "Option::is_none")] pub customer: Option<&'a str>, /// If this is a `customer_balance` PaymentMethod, this hash contains details about the CustomerBalance payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub customer_balance: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub customer_balance: Option, /// If this is an `eps` PaymentMethod, this hash contains details about the EPS payment method. #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option, @@ -272,25 +287,30 @@ pub struct CreatePaymentMethod<'a> { pub fpx: Option, /// If this is a `giropay` PaymentMethod, this hash contains details about the Giropay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub giropay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub giropay: Option, /// If this is a `grabpay` PaymentMethod, this hash contains details about the GrabPay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub grabpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub grabpay: Option, /// If this is an `ideal` PaymentMethod, this hash contains details about the iDEAL payment method. #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option, /// If this is an `interac_present` PaymentMethod, this hash contains details about the Interac Present payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub interac_present: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub interac_present: Option, /// If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method. #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option, /// If this is a `konbini` PaymentMethod, this hash contains details about the Konbini payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub konbini: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub konbini: Option, /// If this is an `Link` PaymentMethod, this hash contains details about the Link payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub link: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub link: Option, /// 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. @@ -299,7 +319,8 @@ pub struct CreatePaymentMethod<'a> { pub metadata: Option<&'a std::collections::HashMap>, /// If this is an `oxxo` PaymentMethod, this hash contains details about the OXXO payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub oxxo: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub oxxo: Option, /// If this is a `p24` PaymentMethod, this hash contains details about the P24 payment method. #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option, @@ -308,23 +329,28 @@ pub struct CreatePaymentMethod<'a> { pub payment_method: Option<&'a str>, /// If this is a `paynow` PaymentMethod, this hash contains details about the PayNow payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub paynow: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub paynow: Option, /// If this is a `paypal` PaymentMethod, this hash contains details about the PayPal payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub paypal: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub paypal: Option, /// If this is a `pix` PaymentMethod, this hash contains details about the Pix payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub pix: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub pix: Option, /// If this is a `promptpay` PaymentMethod, this hash contains details about the PromptPay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub promptpay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub promptpay: Option, /// Options to configure Radar. /// See [Radar Session](https://stripe.com/docs/radar/radar-session) for more information. #[serde(skip_serializing_if = "Option::is_none")] pub radar_options: Option>, /// If this is a `Revolut Pay` PaymentMethod, this hash contains details about the Revolut Pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub revolut_pay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub revolut_pay: Option, /// If this is a `sepa_debit` PaymentMethod, this hash contains details about the SEPA debit bank account. #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option>, @@ -333,7 +359,8 @@ pub struct CreatePaymentMethod<'a> { pub sofort: Option, /// 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>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub swish: Option, /// 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. @@ -345,10 +372,12 @@ pub struct CreatePaymentMethod<'a> { pub us_bank_account: Option>, /// If this is an `wechat_pay` PaymentMethod, this hash contains details about the wechat_pay payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub wechat_pay: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub wechat_pay: Option, /// If this is a `zip` PaymentMethod, this hash contains details about the Zip payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub zip: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub zip: Option, } impl<'a> CreatePaymentMethod<'a> { pub fn new() -> Self { @@ -598,6 +627,14 @@ impl serde::Serialize for CreatePaymentMethodEpsBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentMethodEpsBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is an `fpx` PaymentMethod, this hash contains details about the FPX payment method. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreatePaymentMethodFpx { @@ -658,6 +695,16 @@ impl serde::Serialize for CreatePaymentMethodFpxAccountHolderType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentMethodFpxAccountHolderType { + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodFpxAccountHolderType") + }) + } +} /// The customer's bank. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -768,6 +815,14 @@ impl serde::Serialize for CreatePaymentMethodFpxBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentMethodFpxBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is an `ideal` PaymentMethod, this hash contains details about the iDEAL payment method. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentMethodIdeal { @@ -872,6 +927,14 @@ impl serde::Serialize for CreatePaymentMethodIdealBank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentMethodIdealBank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// If this is a `klarna` PaymentMethod, this hash contains details about the Klarna payment method. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreatePaymentMethodKlarna { @@ -1033,6 +1096,14 @@ impl serde::Serialize for CreatePaymentMethodP24Bank { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentMethodP24Bank { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// Options to configure Radar. /// See [Radar Session](https://stripe.com/docs/radar/radar-session) for more information. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -1126,6 +1197,16 @@ impl serde::Serialize for CreatePaymentMethodSofortCountry { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentMethodSofortCountry { + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodSofortCountry") + }) + } +} /// 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. @@ -1271,6 +1352,14 @@ impl serde::Serialize for CreatePaymentMethodType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentMethodType { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} /// 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 CreatePaymentMethodUsBankAccount<'a> { @@ -1341,6 +1430,18 @@ impl serde::Serialize for CreatePaymentMethodUsBankAccountAccountHolderType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentMethodUsBankAccountAccountHolderType { + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodUsBankAccountAccountHolderType", + ) + }) + } +} /// Account type: checkings or savings. Defaults to checking if omitted. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePaymentMethodUsBankAccountAccountType { @@ -1387,6 +1488,18 @@ impl serde::Serialize for CreatePaymentMethodUsBankAccountAccountType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePaymentMethodUsBankAccountAccountType { + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodUsBankAccountAccountType", + ) + }) + } +} impl<'a> CreatePaymentMethod<'a> { /// Creates a PaymentMethod object. /// Read the [Stripe.js reference](https://stripe.com/docs/stripe-js/reference#stripe-create-payment-method) to learn how to create PaymentMethods via Stripe.js. @@ -1396,7 +1509,7 @@ impl<'a> CreatePaymentMethod<'a> { client.send_form("/payment_methods", self, http_types::Method::Post) } } -#[derive(Copy, Clone, Debug, Default, serde::Serialize)] +#[derive(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")] @@ -1409,7 +1522,8 @@ pub struct UpdatePaymentMethod<'a> { pub expand: Option<&'a [&'a str]>, /// If this is an `Link` PaymentMethod, this hash contains details about the Link payment method. #[serde(skip_serializing_if = "Option::is_none")] - pub link: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub link: Option, /// 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. @@ -1501,6 +1615,18 @@ impl serde::Serialize for UpdatePaymentMethodUsBankAccountAccountHolderType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentMethodUsBankAccountAccountHolderType { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodUsBankAccountAccountHolderType", + ) + }) + } +} /// Bank account type. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdatePaymentMethodUsBankAccountAccountType { @@ -1547,6 +1673,18 @@ impl serde::Serialize for UpdatePaymentMethodUsBankAccountAccountType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdatePaymentMethodUsBankAccountAccountType { + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodUsBankAccountAccountType", + ) + }) + } +} impl<'a> UpdatePaymentMethod<'a> { /// Updates a PaymentMethod object. A PaymentMethod must be attached a customer to be updated. pub fn send( 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..0f9451060 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,106 @@ pub struct PaymentMethodConfigResourceDisplayPreference { /// The effective display preference value. pub value: PaymentMethodConfigResourceDisplayPreferenceValue, } +#[doc(hidden)] +pub struct PaymentMethodConfigResourceDisplayPreferenceBuilder { + overridable: Option>, + preference: Option, + value: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodConfigResourceDisplayPreferenceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + overridable: Deserialize::default(), + preference: Deserialize::default(), + value: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + overridable: self.overridable?, + preference: self.preference?, + value: self.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 { + 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 { @@ -49,6 +151,7 @@ impl std::fmt::Debug for PaymentMethodConfigResourceDisplayPreferencePreference f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodConfigResourceDisplayPreferencePreference { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +160,27 @@ impl serde::Serialize for PaymentMethodConfigResourceDisplayPreferencePreference serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodConfigResourceDisplayPreferencePreference { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodConfigResourceDisplayPreferencePreference::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodConfigResourceDisplayPreferencePreference); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodConfigResourceDisplayPreferencePreference { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -106,6 +230,7 @@ impl std::fmt::Debug for PaymentMethodConfigResourceDisplayPreferenceValue { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodConfigResourceDisplayPreferenceValue { fn serialize(&self, serializer: S) -> Result where @@ -114,6 +239,25 @@ impl serde::Serialize for PaymentMethodConfigResourceDisplayPreferenceValue { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodConfigResourceDisplayPreferenceValue { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodConfigResourceDisplayPreferenceValue::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodConfigResourceDisplayPreferenceValue); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodConfigResourceDisplayPreferenceValue { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..49f09703a 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,103 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct PaymentMethodConfigResourcePaymentMethodPropertiesBuilder { + available: Option, + display_preference: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodConfigResourcePaymentMethodPropertiesBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { available: Deserialize::default(), display_preference: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + available: self.available?, + display_preference: self.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 { + 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..154c9882a 100644 --- a/generated/stripe_payment/src/payment_method_configuration/requests.rs +++ b/generated/stripe_payment/src/payment_method_configuration/requests.rs @@ -298,6 +298,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationAcssDebitDisplayPrefer serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference")) + } +} /// [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. @@ -373,6 +383,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationAffirmDisplayPreferenc serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationAffirmDisplayPreferencePreference")) + } +} /// 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)] @@ -457,6 +477,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference")) + } +} /// 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. @@ -533,6 +563,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationAlipayDisplayPreferenc serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationAlipayDisplayPreferencePreference")) + } +} /// 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. @@ -608,6 +648,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationApplePayDisplayPrefere serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationApplePayDisplayPreferencePreference")) + } +} /// 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 { @@ -686,6 +736,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationApplePayLaterDisplayPr serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference")) + } +} /// 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)] @@ -760,6 +820,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationAuBecsDebitDisplayPref serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference")) + } +} /// 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 { @@ -833,6 +903,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationBacsDebitDisplayPrefer serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference")) + } +} /// 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. @@ -908,6 +988,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationBancontactDisplayPrefe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationBancontactDisplayPreferencePreference")) + } +} /// 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. @@ -983,6 +1073,20 @@ impl serde::Serialize for CreatePaymentMethodConfigurationBlikDisplayPreferenceP serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationBlikDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationBlikDisplayPreferencePreference", + ) + }) + } +} /// 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)] @@ -1057,6 +1161,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationBoletoDisplayPreferenc serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationBoletoDisplayPreferencePreference")) + } +} /// 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)] @@ -1131,6 +1245,20 @@ impl serde::Serialize for CreatePaymentMethodConfigurationCardDisplayPreferenceP serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationCardDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationCardDisplayPreferencePreference", + ) + }) + } +} /// 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. @@ -1216,6 +1344,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference")) + } +} /// 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)] @@ -1290,6 +1428,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationCashappDisplayPreferen serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationCashappDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationCashappDisplayPreferencePreference")) + } +} /// 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. @@ -1375,6 +1523,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference")) + } +} /// 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. @@ -1450,6 +1608,20 @@ impl serde::Serialize for CreatePaymentMethodConfigurationEpsDisplayPreferencePr serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationEpsDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationEpsDisplayPreferencePreference", + ) + }) + } +} /// 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. @@ -1526,6 +1698,20 @@ impl serde::Serialize for CreatePaymentMethodConfigurationFpxDisplayPreferencePr serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationFpxDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationFpxDisplayPreferencePreference", + ) + }) + } +} /// 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. @@ -1603,6 +1789,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationGiropayDisplayPreferen serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationGiropayDisplayPreferencePreference")) + } +} /// 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. @@ -1678,6 +1874,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationGooglePayDisplayPrefer serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationGooglePayDisplayPreferencePreference")) + } +} /// 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. @@ -1753,6 +1959,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationGrabpayDisplayPreferen serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationGrabpayDisplayPreferencePreference")) + } +} /// 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. @@ -1828,6 +2044,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationIdealDisplayPreference serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationIdealDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationIdealDisplayPreferencePreference")) + } +} /// 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. @@ -1903,6 +2129,20 @@ impl serde::Serialize for CreatePaymentMethodConfigurationJcbDisplayPreferencePr serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationJcbDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationJcbDisplayPreferencePreference", + ) + }) + } +} /// 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. @@ -1979,6 +2219,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationKlarnaDisplayPreferenc serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationKlarnaDisplayPreferencePreference")) + } +} /// 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)] @@ -2053,6 +2303,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationKonbiniDisplayPreferen serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationKonbiniDisplayPreferencePreference")) + } +} /// [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)] @@ -2127,6 +2387,20 @@ impl serde::Serialize for CreatePaymentMethodConfigurationLinkDisplayPreferenceP serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationLinkDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationLinkDisplayPreferencePreference", + ) + }) + } +} /// 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. @@ -2202,6 +2476,20 @@ impl serde::Serialize for CreatePaymentMethodConfigurationOxxoDisplayPreferenceP serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationOxxoDisplayPreferencePreference", + ) + }) + } +} /// 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. @@ -2277,6 +2565,20 @@ impl serde::Serialize for CreatePaymentMethodConfigurationP24DisplayPreferencePr serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationP24DisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationP24DisplayPreferencePreference", + ) + }) + } +} /// 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)] @@ -2351,6 +2653,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationPaynowDisplayPreferenc serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationPaynowDisplayPreferencePreference")) + } +} /// 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)] @@ -2425,6 +2737,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationPaypalDisplayPreferenc serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationPaypalDisplayPreferencePreference")) + } +} /// 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)] @@ -2499,6 +2821,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationPromptpayDisplayPrefer serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationPromptpayDisplayPreferencePreference")) + } +} /// 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. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -2573,6 +2905,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationRevolutPayDisplayPrefe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference")) + } +} /// 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)] @@ -2647,6 +2989,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationSepaDebitDisplayPrefer serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference")) + } +} /// 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)] @@ -2721,6 +3073,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationSofortDisplayPreferenc serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationSofortDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationSofortDisplayPreferencePreference")) + } +} /// 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)] @@ -2800,6 +3162,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationUsBankAccountDisplayPr serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference")) + } +} /// 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. @@ -2876,6 +3248,16 @@ impl serde::Serialize for CreatePaymentMethodConfigurationWechatPayDisplayPrefer serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 CreatePaymentMethodConfigurationWechatPayDisplayPreferencePreference")) + } +} impl<'a> CreatePaymentMethodConfiguration<'a> { /// Creates a payment method configuration pub fn send( @@ -3136,6 +3518,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationAcssDebitDisplayPrefer serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationAcssDebitDisplayPreferencePreference")) + } +} /// [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. @@ -3211,6 +3603,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationAffirmDisplayPreferenc serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationAffirmDisplayPreferencePreference")) + } +} /// 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)] @@ -3295,6 +3697,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationAfterpayClearpayDisplayPreferencePreference")) + } +} /// 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. @@ -3371,6 +3783,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationAlipayDisplayPreferenc serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationAlipayDisplayPreferencePreference")) + } +} /// 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. @@ -3446,6 +3868,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationApplePayDisplayPrefere serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationApplePayDisplayPreferencePreference")) + } +} /// 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 UpdatePaymentMethodConfigurationApplePayLater { @@ -3524,6 +3956,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationApplePayLaterDisplayPr serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationApplePayLaterDisplayPreferencePreference")) + } +} /// 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)] @@ -3598,6 +4040,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationAuBecsDebitDisplayPref serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationAuBecsDebitDisplayPreferencePreference")) + } +} /// 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 UpdatePaymentMethodConfigurationBacsDebit { @@ -3671,6 +4123,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationBacsDebitDisplayPrefer serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationBacsDebitDisplayPreferencePreference")) + } +} /// 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. @@ -3746,6 +4208,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationBancontactDisplayPrefe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationBancontactDisplayPreferencePreference")) + } +} /// 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. @@ -3821,6 +4293,20 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationBlikDisplayPreferenceP serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationBlikDisplayPreferencePreference", + ) + }) + } +} /// 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)] @@ -3895,6 +4381,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationBoletoDisplayPreferenc serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationBoletoDisplayPreferencePreference")) + } +} /// 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)] @@ -3969,6 +4465,20 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationCardDisplayPreferenceP serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationCardDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationCardDisplayPreferencePreference", + ) + }) + } +} /// 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. @@ -4054,6 +4564,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationCartesBancairesDisplayPreferencePreference")) + } +} /// 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)] @@ -4128,6 +4648,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationCashappDisplayPreferen serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationCashappDisplayPreferencePreference")) + } +} /// 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. @@ -4213,6 +4743,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationCustomerBalanceDisplayPreferencePreference")) + } +} /// 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. @@ -4288,6 +4828,20 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationEpsDisplayPreferencePr serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationEpsDisplayPreferencePreference", + ) + }) + } +} /// 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. @@ -4364,6 +4918,20 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationFpxDisplayPreferencePr serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationFpxDisplayPreferencePreference", + ) + }) + } +} /// 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. @@ -4441,6 +5009,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationGiropayDisplayPreferen serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationGiropayDisplayPreferencePreference")) + } +} /// 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. @@ -4516,6 +5094,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationGooglePayDisplayPrefer serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationGooglePayDisplayPreferencePreference")) + } +} /// 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. @@ -4591,6 +5179,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationGrabpayDisplayPreferen serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationGrabpayDisplayPreferencePreference")) + } +} /// 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. @@ -4666,6 +5264,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationIdealDisplayPreference serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationIdealDisplayPreferencePreference")) + } +} /// 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. @@ -4741,6 +5349,20 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationJcbDisplayPreferencePr serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationJcbDisplayPreferencePreference", + ) + }) + } +} /// 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. @@ -4817,6 +5439,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationKlarnaDisplayPreferenc serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationKlarnaDisplayPreferencePreference")) + } +} /// 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)] @@ -4891,6 +5523,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationKonbiniDisplayPreferen serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationKonbiniDisplayPreferencePreference")) + } +} /// [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)] @@ -4965,6 +5607,20 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationLinkDisplayPreferenceP serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationLinkDisplayPreferencePreference", + ) + }) + } +} /// 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. @@ -5040,6 +5696,20 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationOxxoDisplayPreferenceP serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationOxxoDisplayPreferencePreference", + ) + }) + } +} /// 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. @@ -5115,6 +5785,20 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationP24DisplayPreferencePr serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationP24DisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationP24DisplayPreferencePreference", + ) + }) + } +} /// 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)] @@ -5189,6 +5873,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationPaynowDisplayPreferenc serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationPaynowDisplayPreferencePreference")) + } +} /// 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)] @@ -5263,6 +5957,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationPaypalDisplayPreferenc serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationPaypalDisplayPreferencePreference")) + } +} /// 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)] @@ -5337,6 +6041,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationPromptpayDisplayPrefer serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationPromptpayDisplayPreferencePreference")) + } +} /// 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. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -5411,6 +6125,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationRevolutPayDisplayPrefe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationRevolutPayDisplayPreferencePreference")) + } +} /// 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)] @@ -5485,6 +6209,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationSepaDebitDisplayPrefer serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationSepaDebitDisplayPreferencePreference")) + } +} /// 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)] @@ -5559,6 +6293,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationSofortDisplayPreferenc serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationSofortDisplayPreferencePreference")) + } +} /// 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)] @@ -5638,6 +6382,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationUsBankAccountDisplayPr serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationUsBankAccountDisplayPreferencePreference")) + } +} /// 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. @@ -5714,6 +6468,16 @@ impl serde::Serialize for UpdatePaymentMethodConfigurationWechatPayDisplayPrefer serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference +{ + fn deserialize>(deserializer: D) -> 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 UpdatePaymentMethodConfigurationWechatPayDisplayPreferencePreference")) + } +} impl<'a> UpdatePaymentMethodConfiguration<'a> { /// Update payment method configuration pub fn send( diff --git a/generated/stripe_payment/src/payment_method_configuration/types.rs b/generated/stripe_payment/src/payment_method_configuration/types.rs index 2dd733767..848097d39 100644 --- a/generated/stripe_payment/src/payment_method_configuration/types.rs +++ b/generated/stripe_payment/src/payment_method_configuration/types.rs @@ -18,94 +18,434 @@ /// - [Multiple configurations for your Connect accounts](https://stripe.com/docs/connect/multiple-payment-method-configurations). /// /// For more details see <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodConfiguration { - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option, /// Whether the configuration can be used for new payments. pub active: bool, - #[serde(skip_serializing_if = "Option::is_none")] pub affirm: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub afterpay_clearpay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub alipay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub apple_pay: Option, /// For child configs, the Connect application associated with the configuration. pub application: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bancontact: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub blik: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cartes_bancaires: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cashapp: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub customer_balance: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub fpx: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub giropay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub google_pay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub grabpay: Option, /// Unique identifier for the object. pub id: stripe_payment::PaymentMethodConfigurationId, - #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option, /// 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, - #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub konbini: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option, /// 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 configuration's name. pub name: String, - #[serde(skip_serializing_if = "Option::is_none")] + /// String representing the object's type. Objects of the same type share the same value. + pub object: PaymentMethodConfigurationObject, pub oxxo: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option, /// For child configs, the configuration's parent configuration. pub parent: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub paynow: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub paypal: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub promptpay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub revolut_pay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub wechat_pay: Option, } +#[doc(hidden)] +pub struct PaymentMethodConfigurationBuilder { + acss_debit: Option>, + active: Option, + affirm: Option>, + afterpay_clearpay: + Option>, + alipay: Option>, + apple_pay: Option>, + application: Option>, + au_becs_debit: + Option>, + bacs_debit: Option>, + bancontact: Option>, + blik: Option>, + boleto: Option>, + card: Option>, + cartes_bancaires: + Option>, + cashapp: Option>, + customer_balance: + Option>, + eps: Option>, + fpx: Option>, + giropay: Option>, + google_pay: Option>, + grabpay: Option>, + id: Option, + ideal: Option>, + is_default: Option, + jcb: Option>, + klarna: Option>, + konbini: Option>, + link: Option>, + livemode: Option, + name: Option, + object: Option, + oxxo: Option>, + p24: Option>, + parent: Option>, + paynow: Option>, + paypal: Option>, + promptpay: Option>, + revolut_pay: Option>, + sepa_debit: Option>, + sofort: Option>, + us_bank_account: + Option>, + wechat_pay: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodConfigurationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "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), + "google_pay" => Deserialize::begin(&mut self.google_pay), + "grabpay" => Deserialize::begin(&mut self.grabpay), + "id" => Deserialize::begin(&mut self.id), + "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), + "name" => Deserialize::begin(&mut self.name), + "object" => Deserialize::begin(&mut self.object), + "oxxo" => Deserialize::begin(&mut self.oxxo), + "p24" => Deserialize::begin(&mut self.p24), + "parent" => Deserialize::begin(&mut self.parent), + "paynow" => Deserialize::begin(&mut self.paynow), + "paypal" => Deserialize::begin(&mut self.paypal), + "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), + + _ => ::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(), + customer_balance: Deserialize::default(), + eps: Deserialize::default(), + fpx: Deserialize::default(), + giropay: Deserialize::default(), + google_pay: Deserialize::default(), + grabpay: Deserialize::default(), + id: Deserialize::default(), + ideal: Deserialize::default(), + is_default: Deserialize::default(), + jcb: Deserialize::default(), + klarna: Deserialize::default(), + konbini: Deserialize::default(), + link: Deserialize::default(), + livemode: Deserialize::default(), + name: Deserialize::default(), + object: Deserialize::default(), + oxxo: Deserialize::default(), + p24: Deserialize::default(), + parent: Deserialize::default(), + paynow: Deserialize::default(), + paypal: 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(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + acss_debit: self.acss_debit?, + active: self.active?, + affirm: self.affirm?, + afterpay_clearpay: self.afterpay_clearpay?, + alipay: self.alipay?, + apple_pay: self.apple_pay?, + application: self.application.take()?, + au_becs_debit: self.au_becs_debit?, + bacs_debit: self.bacs_debit?, + bancontact: self.bancontact?, + blik: self.blik?, + boleto: self.boleto?, + card: self.card?, + cartes_bancaires: self.cartes_bancaires?, + cashapp: self.cashapp?, + customer_balance: self.customer_balance?, + eps: self.eps?, + fpx: self.fpx?, + giropay: self.giropay?, + google_pay: self.google_pay?, + grabpay: self.grabpay?, + id: self.id.take()?, + ideal: self.ideal?, + is_default: self.is_default?, + jcb: self.jcb?, + klarna: self.klarna?, + konbini: self.konbini?, + link: self.link?, + livemode: self.livemode?, + name: self.name.take()?, + object: self.object?, + oxxo: self.oxxo?, + p24: self.p24?, + parent: self.parent.take()?, + paynow: self.paynow?, + paypal: self.paypal?, + promptpay: self.promptpay?, + revolut_pay: self.revolut_pay?, + sepa_debit: self.sepa_debit?, + sofort: self.sofort?, + us_bank_account: self.us_bank_account?, + wechat_pay: self.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 { + 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)?), + "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)?), + "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)?), + "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)?), + "name" => b.name = Some(FromValueOpt::from_value(v)?), + "object" => b.object = 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)?), + "paynow" => b.paynow = Some(FromValueOpt::from_value(v)?), + "paypal" => b.paypal = 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)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum PaymentMethodConfigurationObject { + PaymentMethodConfiguration, +} +impl PaymentMethodConfigurationObject { + pub fn as_str(self) -> &'static str { + use PaymentMethodConfigurationObject::*; + match self { + PaymentMethodConfiguration => "payment_method_configuration", + } + } +} + +impl std::str::FromStr for PaymentMethodConfigurationObject { + type Err = (); + fn from_str(s: &str) -> Result { + use PaymentMethodConfigurationObject::*; + match s { + "payment_method_configuration" => Ok(PaymentMethodConfiguration), + _ => Err(()), + } + } +} +impl std::fmt::Display for PaymentMethodConfigurationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for PaymentMethodConfigurationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for PaymentMethodConfigurationObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for PaymentMethodConfigurationObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(PaymentMethodConfigurationObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodConfigurationObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for PaymentMethodConfigurationObject { + fn deserialize>(deserializer: D) -> 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 PaymentMethodConfigurationObject") + }) + } +} 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/types.rs b/generated/stripe_payment/src/payment_method_domain/types.rs index 432a94292..241e31aa3 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDomain { pub apple_pay: stripe_payment::PaymentMethodDomainResourcePaymentMethodStatus, /// Time at which the object was created. Measured in seconds since the Unix epoch. @@ -20,8 +22,213 @@ pub struct PaymentMethodDomain { pub link: stripe_payment::PaymentMethodDomainResourcePaymentMethodStatus, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: PaymentMethodDomainObject, pub paypal: stripe_payment::PaymentMethodDomainResourcePaymentMethodStatus, } +#[doc(hidden)] +pub struct PaymentMethodDomainBuilder { + apple_pay: Option, + created: Option, + domain_name: Option, + enabled: Option, + google_pay: Option, + id: Option, + link: Option, + livemode: Option, + object: Option, + paypal: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDomainBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "paypal" => Deserialize::begin(&mut self.paypal), + + _ => ::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(), + object: Deserialize::default(), + paypal: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + apple_pay: self.apple_pay.take()?, + created: self.created?, + domain_name: self.domain_name.take()?, + enabled: self.enabled?, + google_pay: self.google_pay.take()?, + id: self.id.take()?, + link: self.link.take()?, + livemode: self.livemode?, + object: self.object?, + paypal: self.paypal.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "paypal" => b.paypal = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum PaymentMethodDomainObject { + PaymentMethodDomain, +} +impl PaymentMethodDomainObject { + pub fn as_str(self) -> &'static str { + use PaymentMethodDomainObject::*; + match self { + PaymentMethodDomain => "payment_method_domain", + } + } +} + +impl std::str::FromStr for PaymentMethodDomainObject { + type Err = (); + fn from_str(s: &str) -> Result { + use PaymentMethodDomainObject::*; + match s { + "payment_method_domain" => Ok(PaymentMethodDomain), + _ => Err(()), + } + } +} +impl std::fmt::Display for PaymentMethodDomainObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for PaymentMethodDomainObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for PaymentMethodDomainObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for PaymentMethodDomainObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodDomainObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDomainObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for PaymentMethodDomainObject { + fn deserialize>(deserializer: D) -> 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 PaymentMethodDomainObject")) + } +} 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..b00ae10d0 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,103 @@ /// 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct PaymentMethodDomainResourcePaymentMethodStatusBuilder { + status: Option, + status_details: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDomainResourcePaymentMethodStatusBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { status: Deserialize::default(), status_details: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { status: self.status?, status_details: self.status_details.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -45,6 +136,7 @@ impl std::fmt::Debug for PaymentMethodDomainResourcePaymentMethodStatusStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDomainResourcePaymentMethodStatusStatus { fn serialize(&self, serializer: S) -> Result where @@ -53,6 +145,25 @@ impl serde::Serialize for PaymentMethodDomainResourcePaymentMethodStatusStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDomainResourcePaymentMethodStatusStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodDomainResourcePaymentMethodStatusStatus::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDomainResourcePaymentMethodStatusStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDomainResourcePaymentMethodStatusStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..02a8c39b9 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,96 @@ /// 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDomainResourcePaymentMethodStatusDetails { /// The error message associated with the status of the payment method on the domain. pub error_message: String, } +#[doc(hidden)] +pub struct PaymentMethodDomainResourcePaymentMethodStatusDetailsBuilder { + error_message: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDomainResourcePaymentMethodStatusDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { error_message: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { error_message: self.error_message.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..8403f0c54 100644 --- a/generated/stripe_payment/src/source/requests.rs +++ b/generated/stripe_payment/src/source/requests.rs @@ -24,12 +24,86 @@ impl<'a> DetachSource<'a> { ) } } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(untagged))] pub enum DetachSourceReturned { PaymentSource(stripe_shared::PaymentSource), DeletedPaymentSource(stripe_shared::DeletedPaymentSource), } + +#[derive(Default)] +pub struct DetachSourceReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +const _: () = { + use 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, + builder: DetachSourceReturnedBuilder, + } + + impl Deserialize for DetachSourceReturned { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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. @@ -221,6 +295,15 @@ impl serde::Serialize for CreateSourceFlow { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSourceFlow { + fn deserialize>(deserializer: D) -> 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 CreateSourceFlow")) + } +} /// Information about a mandate possibility attached to a source object (generally for bank debits) as well as its acceptance status. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateSourceMandate<'a> { @@ -341,6 +424,16 @@ impl serde::Serialize for CreateSourceMandateAcceptanceStatus { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSourceMandateAcceptanceStatus { + fn deserialize>(deserializer: D) -> 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 CreateSourceMandateAcceptanceStatus") + }) + } +} /// The type of acceptance information included with the mandate. Either `online` or `offline` #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateSourceMandateAcceptanceType { @@ -387,6 +480,16 @@ impl serde::Serialize for CreateSourceMandateAcceptanceType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSourceMandateAcceptanceType { + fn deserialize>(deserializer: D) -> 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 CreateSourceMandateAcceptanceType") + }) + } +} /// The interval of debits permitted by the mandate. /// Either `one_time` (just permitting a single debit), `scheduled` (with debits on an agreed schedule or for clearly-defined events), or `variable`(for debits with any frequency). #[derive(Copy, Clone, Eq, PartialEq)] @@ -437,6 +540,15 @@ impl serde::Serialize for CreateSourceMandateInterval { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSourceMandateInterval { + fn deserialize>(deserializer: D) -> 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 CreateSourceMandateInterval")) + } +} /// The method Stripe should use to notify the customer of upcoming debit instructions and/or mandate confirmation as required by the underlying debit network. /// Either `email` (an email is sent directly to the customer), `manual` (a `source.mandate_notification` event is sent to your webhooks endpoint and you should handle the notification) or `none` (the underlying debit network does not require any notification). #[derive(Copy, Clone, Eq, PartialEq)] @@ -493,6 +605,16 @@ impl serde::Serialize for CreateSourceMandateNotificationMethod { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSourceMandateNotificationMethod { + fn deserialize>(deserializer: D) -> 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 CreateSourceMandateNotificationMethod") + }) + } +} /// Optional parameters for the receiver flow. /// Can be set only if the source is a receiver (`flow` is `receiver`). #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -559,6 +681,16 @@ impl serde::Serialize for CreateSourceReceiverRefundAttributesMethod { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSourceReceiverRefundAttributesMethod { + fn deserialize>(deserializer: D) -> 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 CreateSourceReceiverRefundAttributesMethod") + }) + } +} /// Parameters required for the redirect flow. /// Required if the source is authenticated by a redirect (`flow` is `redirect`). #[derive(Copy, Clone, Debug, serde::Serialize)] @@ -665,6 +797,16 @@ impl serde::Serialize for CreateSourceSourceOrderItemsType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSourceSourceOrderItemsType { + fn deserialize>(deserializer: D) -> 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 CreateSourceSourceOrderItemsType") + }) + } +} #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateSourceUsage { Reusable, @@ -710,6 +852,15 @@ impl serde::Serialize for CreateSourceUsage { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateSourceUsage { + fn deserialize>(deserializer: D) -> 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 CreateSourceUsage")) + } +} impl<'a> CreateSource<'a> { /// Creates a new source object. pub fn send(&self, client: &stripe::Client) -> stripe::Response { @@ -866,6 +1017,16 @@ impl serde::Serialize for UpdateSourceMandateAcceptanceStatus { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSourceMandateAcceptanceStatus { + fn deserialize>(deserializer: D) -> 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 UpdateSourceMandateAcceptanceStatus") + }) + } +} /// The type of acceptance information included with the mandate. Either `online` or `offline` #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateSourceMandateAcceptanceType { @@ -912,6 +1073,16 @@ impl serde::Serialize for UpdateSourceMandateAcceptanceType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSourceMandateAcceptanceType { + fn deserialize>(deserializer: D) -> 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 UpdateSourceMandateAcceptanceType") + }) + } +} /// The interval of debits permitted by the mandate. /// Either `one_time` (just permitting a single debit), `scheduled` (with debits on an agreed schedule or for clearly-defined events), or `variable`(for debits with any frequency). #[derive(Copy, Clone, Eq, PartialEq)] @@ -962,6 +1133,15 @@ impl serde::Serialize for UpdateSourceMandateInterval { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSourceMandateInterval { + fn deserialize>(deserializer: D) -> 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 UpdateSourceMandateInterval")) + } +} /// The method Stripe should use to notify the customer of upcoming debit instructions and/or mandate confirmation as required by the underlying debit network. /// Either `email` (an email is sent directly to the customer), `manual` (a `source.mandate_notification` event is sent to your webhooks endpoint and you should handle the notification) or `none` (the underlying debit network does not require any notification). #[derive(Copy, Clone, Eq, PartialEq)] @@ -1018,6 +1198,16 @@ impl serde::Serialize for UpdateSourceMandateNotificationMethod { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSourceMandateNotificationMethod { + fn deserialize>(deserializer: D) -> 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 UpdateSourceMandateNotificationMethod") + }) + } +} /// Information about the items and shipping associated with the source. /// Required for transactional credit (for example Klarna) sources before you can charge it. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] @@ -1111,6 +1301,16 @@ impl serde::Serialize for UpdateSourceSourceOrderItemsType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UpdateSourceSourceOrderItemsType { + fn deserialize>(deserializer: D) -> 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 UpdateSourceSourceOrderItemsType") + }) + } +} impl<'a> UpdateSource<'a> { /// Updates the specified source by setting the values of the parameters passed. /// Any parameters not provided will be left unchanged. diff --git a/generated/stripe_payment/src/source_mandate_notification.rs b/generated/stripe_payment/src/source_mandate_notification.rs index 66ecbc19c..ffb234fbe 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceMandateNotification { - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option, /// 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, - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit: Option, /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -17,18 +17,234 @@ pub struct SourceMandateNotification { pub id: stripe_payment::SourceMandateNotificationId, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: SourceMandateNotificationObject, /// 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, 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(feature = "serde", serde(rename = "type"))] pub type_: String, } +#[doc(hidden)] +pub struct SourceMandateNotificationBuilder { + acss_debit: Option>, + amount: Option>, + bacs_debit: Option>, + created: Option, + id: Option, + livemode: Option, + object: Option, + reason: Option, + sepa_debit: Option>, + source: Option, + status: Option, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceMandateNotificationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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_), + + _ => ::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(), + object: Deserialize::default(), + reason: Deserialize::default(), + sepa_debit: Deserialize::default(), + source: Deserialize::default(), + status: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + acss_debit: self.acss_debit.take()?, + amount: self.amount?, + bacs_debit: self.bacs_debit.take()?, + created: self.created?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + reason: self.reason.take()?, + sepa_debit: self.sepa_debit.take()?, + source: self.source.take()?, + status: self.status.take()?, + type_: self.type_.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum SourceMandateNotificationObject { + SourceMandateNotification, +} +impl SourceMandateNotificationObject { + pub fn as_str(self) -> &'static str { + use SourceMandateNotificationObject::*; + match self { + SourceMandateNotification => "source_mandate_notification", + } + } +} + +impl std::str::FromStr for SourceMandateNotificationObject { + type Err = (); + fn from_str(s: &str) -> Result { + use SourceMandateNotificationObject::*; + match s { + "source_mandate_notification" => Ok(SourceMandateNotification), + _ => Err(()), + } + } +} +impl std::fmt::Display for SourceMandateNotificationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for SourceMandateNotificationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for SourceMandateNotificationObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for SourceMandateNotificationObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(SourceMandateNotificationObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SourceMandateNotificationObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for SourceMandateNotificationObject { + fn deserialize>(deserializer: D) -> 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 SourceMandateNotificationObject") + }) + } +} 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..4003d53d5 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,95 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceMandateNotificationAcssDebitData { /// The statement descriptor associate with the debit. - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option, } +#[doc(hidden)] +pub struct SourceMandateNotificationAcssDebitDataBuilder { + statement_descriptor: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceMandateNotificationAcssDebitDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { statement_descriptor: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { statement_descriptor: self.statement_descriptor.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..495a6f861 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceMandateNotificationBacsDebitData { /// Last 4 digits of the account number associated with the debit. - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option, } +#[doc(hidden)] +pub struct SourceMandateNotificationBacsDebitDataBuilder { + last4: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceMandateNotificationBacsDebitDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { last4: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { last4: self.last4.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..920d3e702 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,113 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceMandateNotificationSepaDebitData { /// SEPA creditor ID. - #[serde(skip_serializing_if = "Option::is_none")] pub creditor_identifier: Option, /// Last 4 digits of the account number associated with the debit. - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option, /// Mandate reference associated with the debit. - #[serde(skip_serializing_if = "Option::is_none")] pub mandate_reference: Option, } +#[doc(hidden)] +pub struct SourceMandateNotificationSepaDebitDataBuilder { + creditor_identifier: Option>, + last4: Option>, + mandate_reference: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceMandateNotificationSepaDebitDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + creditor_identifier: Deserialize::default(), + last4: Deserialize::default(), + mandate_reference: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + creditor_identifier: self.creditor_identifier.take()?, + last4: self.last4.take()?, + mandate_reference: self.mandate_reference.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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/Cargo.toml b/generated/stripe_product/Cargo.toml index 8dd73d620..e1c332d44 100644 --- a/generated/stripe_product/Cargo.toml +++ b/generated/stripe_product/Cargo.toml @@ -16,8 +16,9 @@ path = "src/mod.rs" [dependencies] serde.workspace = true -smol_str.workspace = true serde_json.workspace = true +smol_str.workspace = true +miniserde.workspace = true stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +serde = ["stripe_types/serde","stripe_shared/serde"] 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/mod.rs b/generated/stripe_product/src/mod.rs index 544a4bd74..9f45305c8 100644 --- a/generated/stripe_product/src/mod.rs +++ b/generated/stripe_product/src/mod.rs @@ -7,6 +7,8 @@ //! for requests mentioned in the `Products` section of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_product; + +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..ab027be79 100644 --- a/generated/stripe_product/src/price/requests.rs +++ b/generated/stripe_product/src/price/requests.rs @@ -113,6 +113,15 @@ impl serde::Serialize for ListPriceRecurringInterval { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ListPriceRecurringInterval { + fn deserialize>(deserializer: D) -> 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 ListPriceRecurringInterval")) + } +} /// Filter by the usage type for this price. Can be either `metered` or `licensed`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ListPriceRecurringUsageType { @@ -159,6 +168,15 @@ impl serde::Serialize for ListPriceRecurringUsageType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ListPriceRecurringUsageType { + fn deserialize>(deserializer: D) -> 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 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. @@ -546,6 +564,16 @@ impl serde::Serialize for CreatePriceRecurringAggregateUsage { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePriceRecurringAggregateUsage { + fn deserialize>(deserializer: D) -> 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 CreatePriceRecurringAggregateUsage") + }) + } +} /// Specifies billing frequency. Either `day`, `week`, `month` or `year`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreatePriceRecurringInterval { @@ -598,6 +626,15 @@ impl serde::Serialize for CreatePriceRecurringInterval { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePriceRecurringInterval { + fn deserialize>(deserializer: D) -> 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 CreatePriceRecurringInterval")) + } +} /// 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. @@ -648,6 +685,16 @@ impl serde::Serialize for CreatePriceRecurringUsageType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePriceRecurringUsageType { + fn deserialize>(deserializer: D) -> 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 CreatePriceRecurringUsageType") + }) + } +} /// Each element represents a pricing tier. /// This parameter requires `billing_scheme` to be set to `tiered`. /// See also the documentation for `billing_scheme`. @@ -752,6 +799,16 @@ impl serde::Serialize for CreatePriceTransformQuantityRound { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreatePriceTransformQuantityRound { + fn deserialize>(deserializer: D) -> 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 CreatePriceTransformQuantityRound") + }) + } +} impl<'a> CreatePrice<'a> { /// Creates a new price for an existing product. The price can be recurring or one-time. pub fn send(&self, client: &stripe::Client) -> stripe::Response { diff --git a/generated/stripe_product/src/product/requests.rs b/generated/stripe_product/src/product/requests.rs index 4fc865adb..923650064 100644 --- a/generated/stripe_product/src/product/requests.rs +++ b/generated/stripe_product/src/product/requests.rs @@ -379,6 +379,18 @@ impl serde::Serialize for CreateProductDefaultPriceDataCurrencyOptionsTaxBehavio serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior { + fn deserialize>(deserializer: D) -> 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 CreateProductDefaultPriceDataCurrencyOptionsTaxBehavior", + ) + }) + } +} /// Each element represents a pricing tier. /// This parameter requires `billing_scheme` to be set to `tiered`. /// See also the documentation for `billing_scheme`. @@ -491,6 +503,18 @@ impl serde::Serialize for CreateProductDefaultPriceDataRecurringInterval { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateProductDefaultPriceDataRecurringInterval { + fn deserialize>(deserializer: D) -> 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 CreateProductDefaultPriceDataRecurringInterval", + ) + }) + } +} /// 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`. @@ -543,6 +567,16 @@ impl serde::Serialize for CreateProductDefaultPriceDataTaxBehavior { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateProductDefaultPriceDataTaxBehavior { + fn deserialize>(deserializer: D) -> 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 CreateProductDefaultPriceDataTaxBehavior") + }) + } +} impl<'a> CreateProduct<'a> { /// Creates a new product object. pub fn send(&self, client: &stripe::Client) -> stripe::Response { diff --git a/generated/stripe_product/src/shipping_rate/requests.rs b/generated/stripe_product/src/shipping_rate/requests.rs index c785de5c1..ac50c45c2 100644 --- a/generated/stripe_product/src/shipping_rate/requests.rs +++ b/generated/stripe_product/src/shipping_rate/requests.rs @@ -200,6 +200,18 @@ impl serde::Serialize for CreateShippingRateDeliveryEstimateMaximumUnit { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateShippingRateDeliveryEstimateMaximumUnit { + fn deserialize>(deserializer: D) -> 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 CreateShippingRateDeliveryEstimateMaximumUnit", + ) + }) + } +} /// The lower bound of the estimated range. If empty, represents no lower bound. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateShippingRateDeliveryEstimateMinimum { @@ -268,6 +280,18 @@ impl serde::Serialize for CreateShippingRateDeliveryEstimateMinimumUnit { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateShippingRateDeliveryEstimateMinimumUnit { + fn deserialize>(deserializer: D) -> 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 CreateShippingRateDeliveryEstimateMinimumUnit", + ) + }) + } +} /// Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateShippingRateFixedAmount<'a> { diff --git a/generated/stripe_shared/Cargo.toml b/generated/stripe_shared/Cargo.toml index abaa68367..3fe55b36d 100644 --- a/generated/stripe_shared/Cargo.toml +++ b/generated/stripe_shared/Cargo.toml @@ -16,12 +16,15 @@ path = "src/mod.rs" [dependencies] serde.workspace = true -smol_str.workspace = true serde_json.workspace = true +smol_str.workspace = true +miniserde.workspace = true stripe_types = {path = "../../stripe_types"} +[features] +serde = ["stripe_types/serde"] diff --git a/generated/stripe_shared/src/account.rs b/generated/stripe_shared/src/account.rs index c34d82a4d..bebe1f2be 100644 --- a/generated/stripe_shared/src/account.rs +++ b/generated/stripe_shared/src/account.rs @@ -10,71 +10,316 @@ /// Learn about the differences [between accounts](https://stripe.com/docs/connect/accounts). /// /// For more details see <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Account { /// Business information about the account. - #[serde(skip_serializing_if = "Option::is_none")] pub business_profile: Option, /// 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, - #[serde(skip_serializing_if = "Option::is_none")] pub capabilities: Option, /// Whether the account can create live charges. - #[serde(skip_serializing_if = "Option::is_none")] pub charges_enabled: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub company: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub controller: Option, /// The account's country. - #[serde(skip_serializing_if = "Option::is_none")] pub country: Option, /// Time at which the account was connected. Measured in seconds since the Unix epoch. - #[serde(skip_serializing_if = "Option::is_none")] pub created: Option, /// 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, /// 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, /// 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, /// 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")] pub external_accounts: Option>, - #[serde(skip_serializing_if = "Option::is_none")] pub future_requirements: Option, /// Unique identifier for the object. pub id: stripe_shared::AccountId, - #[serde(skip_serializing_if = "Option::is_none")] pub individual: Option, /// 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>, + /// String representing the object's type. Objects of the same type share the same value. + pub object: AccountObject, /// Whether Stripe can send payouts to this account. - #[serde(skip_serializing_if = "Option::is_none")] pub payouts_enabled: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub requirements: Option, /// Options for customizing how the account functions within Stripe. - #[serde(skip_serializing_if = "Option::is_none")] pub settings: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub tos_acceptance: Option, /// The Stripe account type. Can be `standard`, `express`, or `custom`. - #[serde(rename = "type")] - #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: Option, } +#[doc(hidden)] +pub struct AccountBuilder { + business_profile: Option>, + business_type: Option>, + capabilities: Option>, + charges_enabled: Option>, + company: Option>, + controller: Option>, + country: Option>, + created: Option>, + default_currency: Option>, + details_submitted: Option>, + email: Option>, + external_accounts: Option>>, + future_requirements: Option>, + id: Option, + individual: Option>, + metadata: Option>>, + object: Option, + payouts_enabled: Option>, + requirements: Option>, + settings: Option>, + tos_acceptance: Option>, + type_: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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_), + + _ => ::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(), + object: 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 { + Some(Self::Out { + business_profile: self.business_profile.take()?, + business_type: self.business_type?, + capabilities: self.capabilities?, + charges_enabled: self.charges_enabled?, + company: self.company.take()?, + controller: self.controller?, + country: self.country.take()?, + created: self.created?, + default_currency: self.default_currency?, + details_submitted: self.details_submitted?, + email: self.email.take()?, + external_accounts: self.external_accounts.take()?, + future_requirements: self.future_requirements.take()?, + id: self.id.take()?, + individual: self.individual.take()?, + metadata: self.metadata.take()?, + object: self.object?, + payouts_enabled: self.payouts_enabled?, + requirements: self.requirements.take()?, + settings: self.settings.take()?, + tos_acceptance: self.tos_acceptance.take()?, + type_: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum AccountObject { + Account, +} +impl AccountObject { + pub fn as_str(self) -> &'static str { + use AccountObject::*; + match self { + Account => "account", + } + } +} + +impl std::str::FromStr for AccountObject { + type Err = (); + fn from_str(s: &str) -> Result { + use AccountObject::*; + match s { + "account" => Ok(Account), + _ => Err(()), + } + } +} +impl std::fmt::Display for AccountObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for AccountObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for AccountObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for AccountObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(AccountObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(AccountObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for AccountObject { + fn deserialize>(deserializer: D) -> 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 AccountObject")) + } +} impl stripe_types::Object for Account { type Id = stripe_shared::AccountId; fn id(&self) -> &Self::Id { @@ -133,6 +378,22 @@ impl serde::Serialize for AccountBusinessType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for AccountBusinessType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(AccountBusinessType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(AccountBusinessType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for AccountBusinessType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -189,6 +450,22 @@ impl serde::Serialize for AccountType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for AccountType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(AccountType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(AccountType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for AccountType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/account_annual_revenue.rs b/generated/stripe_shared/src/account_annual_revenue.rs index 7f3366455..fc60d4784 100644 --- a/generated/stripe_shared/src/account_annual_revenue.rs +++ b/generated/stripe_shared/src/account_annual_revenue.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -10,3 +12,103 @@ pub struct AccountAnnualRevenue { /// 2023-12-31 for the 31st of December, 2023. pub fiscal_year_end: Option, } +#[doc(hidden)] +pub struct AccountAnnualRevenueBuilder { + amount: Option>, + currency: Option>, + fiscal_year_end: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountAnnualRevenue { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountAnnualRevenueBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: AccountAnnualRevenueBuilder::deser_default(), + })) + } + } + + impl MapBuilder for AccountAnnualRevenueBuilder { + type Out = AccountAnnualRevenue; + 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), + "fiscal_year_end" => Deserialize::begin(&mut self.fiscal_year_end), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + currency: Deserialize::default(), + fiscal_year_end: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + currency: self.currency?, + fiscal_year_end: self.fiscal_year_end.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountAnnualRevenue { + type Builder = AccountAnnualRevenueBuilder; + } + + impl FromValueOpt for AccountAnnualRevenue { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountAnnualRevenueBuilder::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)?), + "fiscal_year_end" => b.fiscal_year_end = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; 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..7aa9963eb 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,100 @@ 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, } +#[doc(hidden)] +pub struct AccountBacsDebitPaymentsSettingsBuilder { + display_name: Option>, + service_user_number: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountBacsDebitPaymentsSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + display_name: Deserialize::default(), + service_user_number: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + display_name: self.display_name.take()?, + service_user_number: self.service_user_number.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..c47d356ea 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,108 @@ pub struct AccountBrandingSettings { /// A CSS hex color value representing the secondary branding color for this account pub secondary_color: Option, } +#[doc(hidden)] +pub struct AccountBrandingSettingsBuilder { + icon: Option>>, + logo: Option>>, + primary_color: Option>, + secondary_color: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountBrandingSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + icon: self.icon.take()?, + logo: self.logo.take()?, + primary_color: self.primary_color.take()?, + secondary_color: self.secondary_color.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..91b918ab7 100644 --- a/generated/stripe_shared/src/account_business_profile.rs +++ b/generated/stripe_shared/src/account_business_profile.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct AccountBusinessProfile { /// The applicant's gross annual revenue for its preceding fiscal year. pub annual_revenue: Option, @@ -8,13 +10,11 @@ pub struct AccountBusinessProfile { /// [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, - #[serde(skip_serializing_if = "Option::is_none")] pub monthly_estimated_revenue: Option, /// The customer-facing business name. pub name: Option, /// 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, /// A publicly available mailing address for sending support issues to. pub support_address: Option, @@ -27,3 +27,151 @@ pub struct AccountBusinessProfile { /// The business's publicly available website. pub url: Option, } +#[doc(hidden)] +pub struct AccountBusinessProfileBuilder { + annual_revenue: Option>, + estimated_worker_count: Option>, + mcc: Option>, + monthly_estimated_revenue: Option>, + name: Option>, + product_description: Option>, + support_address: Option>, + support_email: Option>, + support_phone: Option>, + support_url: Option>, + url: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountBusinessProfileBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + "annual_revenue" => Deserialize::begin(&mut self.annual_revenue), + "estimated_worker_count" => Deserialize::begin(&mut self.estimated_worker_count), + "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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + annual_revenue: Deserialize::default(), + estimated_worker_count: Deserialize::default(), + 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 { + Some(Self::Out { + annual_revenue: self.annual_revenue.take()?, + estimated_worker_count: self.estimated_worker_count?, + mcc: self.mcc.take()?, + monthly_estimated_revenue: self.monthly_estimated_revenue?, + name: self.name.take()?, + product_description: self.product_description.take()?, + support_address: self.support_address.take()?, + support_email: self.support_email.take()?, + support_phone: self.support_phone.take()?, + support_url: self.support_url.take()?, + url: self.url.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountBusinessProfileBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "annual_revenue" => b.annual_revenue = Some(FromValueOpt::from_value(v)?), + "estimated_worker_count" => { + b.estimated_worker_count = Some(FromValueOpt::from_value(v)?) + } + "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..eb2211029 100644 --- a/generated/stripe_shared/src/account_capabilities.rs +++ b/generated/stripe_shared/src/account_capabilities.rs @@ -1,120 +1,397 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// The status of the legacy payments capability of the account. - #[serde(skip_serializing_if = "Option::is_none")] pub legacy_payments: Option, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// The status of the banking capability, or whether the account can have bank accounts. - #[serde(skip_serializing_if = "Option::is_none")] pub treasury: Option, /// 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, /// 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, } +#[doc(hidden)] +pub struct AccountCapabilitiesBuilder { + acss_debit_payments: Option>, + affirm_payments: Option>, + afterpay_clearpay_payments: Option>, + au_becs_debit_payments: Option>, + bacs_debit_payments: Option>, + bancontact_payments: Option>, + bank_transfer_payments: Option>, + blik_payments: Option>, + boleto_payments: Option>, + card_issuing: Option>, + card_payments: Option>, + cartes_bancaires_payments: Option>, + cashapp_payments: Option>, + eps_payments: Option>, + fpx_payments: Option>, + giropay_payments: Option>, + grabpay_payments: Option>, + ideal_payments: Option>, + india_international_payments: Option>, + jcb_payments: Option>, + klarna_payments: Option>, + konbini_payments: Option>, + legacy_payments: Option>, + link_payments: Option>, + oxxo_payments: Option>, + p24_payments: Option>, + paynow_payments: Option>, + promptpay_payments: Option>, + revolut_pay_payments: Option>, + sepa_debit_payments: Option>, + sofort_payments: Option>, + swish_payments: Option>, + tax_reporting_us_1099_k: Option>, + tax_reporting_us_1099_misc: Option>, + transfers: Option>, + treasury: Option>, + us_bank_account_ach_payments: Option>, + zip_payments: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountCapabilitiesBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "swish_payments" => Deserialize::begin(&mut self.swish_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), + + _ => ::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(), + swish_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 { + Some(Self::Out { + acss_debit_payments: self.acss_debit_payments?, + affirm_payments: self.affirm_payments?, + afterpay_clearpay_payments: self.afterpay_clearpay_payments?, + au_becs_debit_payments: self.au_becs_debit_payments?, + bacs_debit_payments: self.bacs_debit_payments?, + bancontact_payments: self.bancontact_payments?, + bank_transfer_payments: self.bank_transfer_payments?, + blik_payments: self.blik_payments?, + boleto_payments: self.boleto_payments?, + card_issuing: self.card_issuing?, + card_payments: self.card_payments?, + cartes_bancaires_payments: self.cartes_bancaires_payments?, + cashapp_payments: self.cashapp_payments?, + eps_payments: self.eps_payments?, + fpx_payments: self.fpx_payments?, + giropay_payments: self.giropay_payments?, + grabpay_payments: self.grabpay_payments?, + ideal_payments: self.ideal_payments?, + india_international_payments: self.india_international_payments?, + jcb_payments: self.jcb_payments?, + klarna_payments: self.klarna_payments?, + konbini_payments: self.konbini_payments?, + legacy_payments: self.legacy_payments?, + link_payments: self.link_payments?, + oxxo_payments: self.oxxo_payments?, + p24_payments: self.p24_payments?, + paynow_payments: self.paynow_payments?, + promptpay_payments: self.promptpay_payments?, + revolut_pay_payments: self.revolut_pay_payments?, + sepa_debit_payments: self.sepa_debit_payments?, + sofort_payments: self.sofort_payments?, + swish_payments: self.swish_payments?, + tax_reporting_us_1099_k: self.tax_reporting_us_1099_k?, + tax_reporting_us_1099_misc: self.tax_reporting_us_1099_misc?, + transfers: self.transfers?, + treasury: self.treasury?, + us_bank_account_ach_payments: self.us_bank_account_ach_payments?, + zip_payments: self.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 { + 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)?), + "swish_payments" => b.swish_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, @@ -155,6 +432,7 @@ impl std::fmt::Debug for AccountCapabilitiesStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for AccountCapabilitiesStatus { fn serialize(&self, serializer: S) -> Result where @@ -163,6 +441,22 @@ impl serde::Serialize for AccountCapabilitiesStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for AccountCapabilitiesStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(AccountCapabilitiesStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(AccountCapabilitiesStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for AccountCapabilitiesStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/account_capability_future_requirements.rs b/generated/stripe_shared/src/account_capability_future_requirements.rs index ece1afa90..dbf46106a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct AccountCapabilityFutureRequirements { /// Fields that are due and can be satisfied by providing the corresponding alternative fields instead. pub alternatives: Option>, @@ -24,3 +26,130 @@ pub struct AccountCapabilityFutureRequirements { /// If verification fails, these fields move to `eventually_due` or `currently_due`. pub pending_verification: Vec, } +#[doc(hidden)] +pub struct AccountCapabilityFutureRequirementsBuilder { + alternatives: Option>>, + current_deadline: Option>, + currently_due: Option>, + disabled_reason: Option>, + errors: Option>, + eventually_due: Option>, + past_due: Option>, + pending_verification: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountCapabilityFutureRequirementsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + alternatives: self.alternatives.take()?, + current_deadline: self.current_deadline?, + currently_due: self.currently_due.take()?, + disabled_reason: self.disabled_reason.take()?, + errors: self.errors.take()?, + eventually_due: self.eventually_due.take()?, + past_due: self.past_due.take()?, + pending_verification: self.pending_verification.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..8764d6831 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct AccountCapabilityRequirements { /// Fields that are due and can be satisfied by providing the corresponding alternative fields instead. pub alternatives: Option>, @@ -31,3 +33,130 @@ pub struct AccountCapabilityRequirements { /// If verification fails, these fields move to `eventually_due`, `currently_due`, or `past_due`. pub pending_verification: Vec, } +#[doc(hidden)] +pub struct AccountCapabilityRequirementsBuilder { + alternatives: Option>>, + current_deadline: Option>, + currently_due: Option>, + disabled_reason: Option>, + errors: Option>, + eventually_due: Option>, + past_due: Option>, + pending_verification: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountCapabilityRequirementsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + alternatives: self.alternatives.take()?, + current_deadline: self.current_deadline?, + currently_due: self.currently_due.take()?, + disabled_reason: self.disabled_reason.take()?, + errors: self.errors.take()?, + eventually_due: self.eventually_due.take()?, + past_due: self.past_due.take()?, + pending_verification: self.pending_verification.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..e064cbae7 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct AccountCardIssuingSettings { - #[serde(skip_serializing_if = "Option::is_none")] pub tos_acceptance: Option, } +#[doc(hidden)] +pub struct AccountCardIssuingSettingsBuilder { + tos_acceptance: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountCardIssuingSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { tos_acceptance: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { tos_acceptance: self.tos_acceptance.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..48292debe 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct AccountCardPaymentsSettings { - #[serde(skip_serializing_if = "Option::is_none")] pub decline_on: Option, /// 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,120 @@ pub struct AccountCardPaymentsSettings { /// `statement_descriptor_prefix_kanji` is useful for maximizing descriptor space for the dynamic portion. pub statement_descriptor_prefix_kanji: Option, } +#[doc(hidden)] +pub struct AccountCardPaymentsSettingsBuilder { + decline_on: Option>, + statement_descriptor_prefix: Option>, + statement_descriptor_prefix_kana: Option>, + statement_descriptor_prefix_kanji: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountCardPaymentsSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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) + } + + _ => ::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 { + Some(Self::Out { + decline_on: self.decline_on?, + statement_descriptor_prefix: self.statement_descriptor_prefix.take()?, + statement_descriptor_prefix_kana: self.statement_descriptor_prefix_kana.take()?, + statement_descriptor_prefix_kanji: self.statement_descriptor_prefix_kanji.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..1ffc0bf34 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct AccountDashboardSettings { /// The display name for this account. /// This is used on the Stripe Dashboard to differentiate between accounts. @@ -7,3 +9,95 @@ 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, } +#[doc(hidden)] +pub struct AccountDashboardSettingsBuilder { + display_name: Option>, + timezone: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountDashboardSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { display_name: Deserialize::default(), timezone: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + display_name: self.display_name.take()?, + timezone: self.timezone.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..10e6bc4cb 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,92 @@ pub struct AccountDeclineChargeOn { /// This setting only applies when a CVC is provided and it fails bank verification. pub cvc_failure: bool, } +#[doc(hidden)] +pub struct AccountDeclineChargeOnBuilder { + avs_failure: Option, + cvc_failure: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountDeclineChargeOnBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { avs_failure: Deserialize::default(), cvc_failure: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { avs_failure: self.avs_failure?, cvc_failure: self.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 { + 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..d846ce625 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct AccountFutureRequirements { /// Fields that are due and can be satisfied by providing the corresponding alternative fields instead. pub alternatives: Option>, @@ -24,3 +26,130 @@ pub struct AccountFutureRequirements { /// If verification fails, these fields move to `eventually_due` or `currently_due`. pub pending_verification: Option>, } +#[doc(hidden)] +pub struct AccountFutureRequirementsBuilder { + alternatives: Option>>, + current_deadline: Option>, + currently_due: Option>>, + disabled_reason: Option>, + errors: Option>>, + eventually_due: Option>>, + past_due: Option>>, + pending_verification: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountFutureRequirementsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + alternatives: self.alternatives.take()?, + current_deadline: self.current_deadline?, + currently_due: self.currently_due.take()?, + disabled_reason: self.disabled_reason.take()?, + errors: self.errors.take()?, + eventually_due: self.eventually_due.take()?, + past_due: self.past_due.take()?, + pending_verification: self.pending_verification.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 index f493594a8..448be062a 100644 --- a/generated/stripe_shared/src/account_invoices_settings.rs +++ b/generated/stripe_shared/src/account_invoices_settings.rs @@ -1,6 +1,96 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>>, } +#[doc(hidden)] +pub struct AccountInvoicesSettingsBuilder { + default_account_tax_ids: Option>>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for AccountInvoicesSettings { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountInvoicesSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: AccountInvoicesSettingsBuilder::deser_default(), + })) + } + } + + impl MapBuilder for AccountInvoicesSettingsBuilder { + type Out = AccountInvoicesSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "default_account_tax_ids" => Deserialize::begin(&mut self.default_account_tax_ids), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { default_account_tax_ids: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { default_account_tax_ids: self.default_account_tax_ids.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for AccountInvoicesSettings { + type Builder = AccountInvoicesSettingsBuilder; + } + + impl FromValueOpt for AccountInvoicesSettings { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = AccountInvoicesSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "default_account_tax_ids" => { + b.default_account_tax_ids = Some(FromValueOpt::from_value(v)?) + } + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/account_monthly_estimated_revenue.rs b/generated/stripe_shared/src/account_monthly_estimated_revenue.rs index 276f7ec27..d247ce9cf 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,92 @@ pub struct AccountMonthlyEstimatedRevenue { /// Must be a [supported currency](https://stripe.com/docs/currencies). pub currency: stripe_types::Currency, } +#[doc(hidden)] +pub struct AccountMonthlyEstimatedRevenueBuilder { + amount: Option, + currency: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountMonthlyEstimatedRevenueBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), currency: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { amount: self.amount?, currency: self.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 { + 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..101f3b1d0 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,131 @@ pub struct AccountPaymentsSettings { /// `statement_descriptor_prefix_kanji` is useful for maximizing descriptor space for the dynamic portion. pub statement_descriptor_prefix_kanji: Option, } +#[doc(hidden)] +pub struct AccountPaymentsSettingsBuilder { + statement_descriptor: Option>, + statement_descriptor_kana: Option>, + statement_descriptor_kanji: Option>, + statement_descriptor_prefix_kana: Option>, + statement_descriptor_prefix_kanji: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountPaymentsSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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) + } + + _ => ::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 { + Some(Self::Out { + statement_descriptor: self.statement_descriptor.take()?, + statement_descriptor_kana: self.statement_descriptor_kana.take()?, + statement_descriptor_kanji: self.statement_descriptor_kanji.take()?, + statement_descriptor_prefix_kana: self.statement_descriptor_prefix_kana.take()?, + statement_descriptor_prefix_kanji: self.statement_descriptor_prefix_kanji.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..e6bcac6b5 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,107 @@ pub struct AccountPayoutSettings { /// If not set, this defaults to the platform's bank descriptor as set in the Dashboard. pub statement_descriptor: Option, } +#[doc(hidden)] +pub struct AccountPayoutSettingsBuilder { + debit_negative_balances: Option, + schedule: Option, + statement_descriptor: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountPayoutSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + debit_negative_balances: Deserialize::default(), + schedule: Deserialize::default(), + statement_descriptor: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + debit_negative_balances: self.debit_negative_balances?, + schedule: self.schedule.take()?, + statement_descriptor: self.statement_descriptor.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..91cc7a83a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct AccountRequirements { /// Fields that are due and can be satisfied by providing the corresponding alternative fields instead. pub alternatives: Option>, @@ -25,3 +27,130 @@ pub struct AccountRequirements { /// If verification fails, these fields move to `eventually_due`, `currently_due`, or `past_due`. pub pending_verification: Option>, } +#[doc(hidden)] +pub struct AccountRequirementsBuilder { + alternatives: Option>>, + current_deadline: Option>, + currently_due: Option>>, + disabled_reason: Option>, + errors: Option>>, + eventually_due: Option>>, + past_due: Option>>, + pending_verification: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountRequirementsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + alternatives: self.alternatives.take()?, + current_deadline: self.current_deadline?, + currently_due: self.currently_due.take()?, + disabled_reason: self.disabled_reason.take()?, + errors: self.errors.take()?, + eventually_due: self.eventually_due.take()?, + past_due: self.past_due.take()?, + pending_verification: self.pending_verification.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..a13b1c8ee 100644 --- a/generated/stripe_shared/src/account_requirements_alternative.rs +++ b/generated/stripe_shared/src/account_requirements_alternative.rs @@ -1,7 +1,108 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct AccountRequirementsAlternative { /// Fields that can be provided to satisfy all fields in `original_fields_due`. pub alternative_fields_due: Vec, /// Fields that are due and can be satisfied by providing all fields in `alternative_fields_due`. pub original_fields_due: Vec, } +#[doc(hidden)] +pub struct AccountRequirementsAlternativeBuilder { + alternative_fields_due: Option>, + original_fields_due: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountRequirementsAlternativeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + alternative_fields_due: Deserialize::default(), + original_fields_due: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + alternative_fields_due: self.alternative_fields_due.take()?, + original_fields_due: self.original_fields_due.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..aa0cf16ae 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct AccountRequirementsError { /// The code for the type of error. pub code: AccountRequirementsErrorCode, @@ -7,6 +9,106 @@ pub struct AccountRequirementsError { /// The specific user onboarding requirement field (in the requirements hash) that needs to be resolved. pub requirement: String, } +#[doc(hidden)] +pub struct AccountRequirementsErrorBuilder { + code: Option, + reason: Option, + requirement: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountRequirementsErrorBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + code: Deserialize::default(), + reason: Deserialize::default(), + requirement: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + code: self.code?, + reason: self.reason.take()?, + requirement: self.requirement.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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] @@ -370,6 +472,7 @@ impl std::fmt::Debug for AccountRequirementsErrorCode { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for AccountRequirementsErrorCode { fn serialize(&self, serializer: S) -> Result where @@ -378,10 +481,29 @@ impl serde::Serialize for AccountRequirementsErrorCode { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for AccountRequirementsErrorCode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + AccountRequirementsErrorCode::from_str(s) + .unwrap_or(AccountRequirementsErrorCode::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(AccountRequirementsErrorCode); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for AccountRequirementsErrorCode { fn deserialize>(deserializer: D) -> Result { 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)) } } 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..e57de0376 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct AccountSepaDebitPaymentsSettings { /// SEPA creditor identifier that identifies the company making the payment. - #[serde(skip_serializing_if = "Option::is_none")] pub creditor_id: Option, } +#[doc(hidden)] +pub struct AccountSepaDebitPaymentsSettingsBuilder { + creditor_id: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountSepaDebitPaymentsSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { creditor_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { creditor_id: self.creditor_id.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..7056df55a 100644 --- a/generated/stripe_shared/src/account_settings.rs +++ b/generated/stripe_shared/src/account_settings.rs @@ -1,19 +1,154 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct AccountSettings { - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit_payments: Option, pub branding: stripe_shared::AccountBrandingSettings, - #[serde(skip_serializing_if = "Option::is_none")] pub card_issuing: Option, pub card_payments: stripe_shared::AccountCardPaymentsSettings, pub dashboard: stripe_shared::AccountDashboardSettings, - #[serde(skip_serializing_if = "Option::is_none")] pub invoices: Option, pub payments: stripe_shared::AccountPaymentsSettings, - #[serde(skip_serializing_if = "Option::is_none")] pub payouts: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit_payments: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub treasury: Option, } +#[doc(hidden)] +pub struct AccountSettingsBuilder { + bacs_debit_payments: Option>, + branding: Option, + card_issuing: Option>, + card_payments: Option, + dashboard: Option, + invoices: Option>, + payments: Option, + payouts: Option>, + sepa_debit_payments: Option>, + treasury: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "invoices" => Deserialize::begin(&mut self.invoices), + "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), + + _ => ::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(), + invoices: Deserialize::default(), + payments: Deserialize::default(), + payouts: Deserialize::default(), + sepa_debit_payments: Deserialize::default(), + treasury: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + bacs_debit_payments: self.bacs_debit_payments.take()?, + branding: self.branding.take()?, + card_issuing: self.card_issuing.take()?, + card_payments: self.card_payments.take()?, + dashboard: self.dashboard.take()?, + invoices: self.invoices.take()?, + payments: self.payments.take()?, + payouts: self.payouts.take()?, + sepa_debit_payments: self.sepa_debit_payments.take()?, + treasury: self.treasury.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "invoices" => b.invoices = 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..375b3ca78 100644 --- a/generated/stripe_shared/src/account_terms_of_service.rs +++ b/generated/stripe_shared/src/account_terms_of_service.rs @@ -1,10 +1,111 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct AccountTermsOfService { /// The Unix timestamp marking when the account representative accepted the service agreement. pub date: Option, /// The IP address from which the account representative accepted the service agreement. pub ip: Option, /// 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, } +#[doc(hidden)] +pub struct AccountTermsOfServiceBuilder { + date: Option>, + ip: Option>, + user_agent: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountTermsOfServiceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + date: Deserialize::default(), + ip: Deserialize::default(), + user_agent: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + date: self.date?, + ip: self.ip.take()?, + user_agent: self.user_agent.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..4d2474c10 100644 --- a/generated/stripe_shared/src/account_tos_acceptance.rs +++ b/generated/stripe_shared/src/account_tos_acceptance.rs @@ -1,15 +1,118 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// The IP address from which the account representative accepted their service agreement - #[serde(skip_serializing_if = "Option::is_none")] pub ip: Option, /// The user's service agreement type - #[serde(skip_serializing_if = "Option::is_none")] pub service_agreement: Option, /// 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, } +#[doc(hidden)] +pub struct AccountTosAcceptanceBuilder { + date: Option>, + ip: Option>, + service_agreement: Option>, + user_agent: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountTosAcceptanceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + date: self.date?, + ip: self.ip.take()?, + service_agreement: self.service_agreement.take()?, + user_agent: self.user_agent.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..6f23952ef 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct AccountTreasurySettings { - #[serde(skip_serializing_if = "Option::is_none")] pub tos_acceptance: Option, } +#[doc(hidden)] +pub struct AccountTreasurySettingsBuilder { + tos_acceptance: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountTreasurySettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { tos_acceptance: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { tos_acceptance: self.tos_acceptance.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..fbb05b28a 100644 --- a/generated/stripe_shared/src/account_unification_account_controller.rs +++ b/generated/stripe_shared/src/account_unification_account_controller.rs @@ -1,14 +1,104 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// 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(feature = "serde", serde(rename = "type"))] pub type_: AccountUnificationAccountControllerType, } +#[doc(hidden)] +pub struct AccountUnificationAccountControllerBuilder { + is_controller: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AccountUnificationAccountControllerBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { is_controller: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { is_controller: self.is_controller?, type_: self.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 { + 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)] @@ -48,6 +138,7 @@ impl std::fmt::Debug for AccountUnificationAccountControllerType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for AccountUnificationAccountControllerType { fn serialize(&self, serializer: S) -> Result where @@ -56,6 +147,24 @@ impl serde::Serialize for AccountUnificationAccountControllerType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for AccountUnificationAccountControllerType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + AccountUnificationAccountControllerType::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(AccountUnificationAccountControllerType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for AccountUnificationAccountControllerType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/address.rs b/generated/stripe_shared/src/address.rs index 9aaf337bf..0742b95db 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Address { /// City, district, suburb, town, or village. pub city: Option, @@ -13,3 +15,115 @@ pub struct Address { /// State, county, province, or region. pub state: Option, } +#[doc(hidden)] +pub struct AddressBuilder { + city: Option>, + country: Option>, + line1: Option>, + line2: Option>, + postal_code: Option>, + state: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option
, + builder: AddressBuilder, + } + + impl Visitor for Place
{ + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + city: self.city.take()?, + country: self.country.take()?, + line1: self.line1.take()?, + line2: self.line2.take()?, + postal_code: self.postal_code.take()?, + state: self.state.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..fb87eadcb 100644 --- a/generated/stripe_shared/src/api_errors.rs +++ b/generated/stripe_shared/src/api_errors.rs @@ -1,45 +1,184 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ApiErrors { /// For card errors, the ID of the failed charge. - #[serde(skip_serializing_if = "Option::is_none")] pub charge: Option, /// 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, /// 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, /// 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, /// 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, /// 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, - #[serde(skip_serializing_if = "Option::is_none")] pub payment_intent: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub payment_method: Option, /// 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, /// A URL to the request log entry in your dashboard. - #[serde(skip_serializing_if = "Option::is_none")] pub request_log_url: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub setup_intent: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub source: Option, /// The type of error returned. /// One of `api_error`, `card_error`, `idempotency_error`, or `invalid_request_error`. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: ApiErrorsType, } +#[doc(hidden)] +pub struct ApiErrorsBuilder { + charge: Option>, + code: Option>, + decline_code: Option>, + doc_url: Option>, + message: Option>, + param: Option>, + payment_intent: Option>, + payment_method: Option>, + payment_method_type: Option>, + request_log_url: Option>, + setup_intent: Option>, + source: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ApiErrorsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + charge: self.charge.take()?, + code: self.code?, + decline_code: self.decline_code.take()?, + doc_url: self.doc_url.take()?, + message: self.message.take()?, + param: self.param.take()?, + payment_intent: self.payment_intent.take()?, + payment_method: self.payment_method.take()?, + payment_method_type: self.payment_method_type.take()?, + request_log_url: self.request_log_url.take()?, + setup_intent: self.setup_intent.take()?, + source: self.source.take()?, + type_: self.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 { + 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] @@ -613,6 +752,7 @@ impl std::fmt::Debug for ApiErrorsCode { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ApiErrorsCode { fn serialize(&self, serializer: S) -> Result where @@ -621,11 +761,27 @@ impl serde::Serialize for ApiErrorsCode { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ApiErrorsCode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ApiErrorsCode::from_str(s).unwrap_or(ApiErrorsCode::Unknown)); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ApiErrorsCode); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ApiErrorsCode { fn deserialize>(deserializer: D) -> Result { 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)) } } /// The type of error returned. @@ -673,6 +829,7 @@ impl std::fmt::Debug for ApiErrorsType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ApiErrorsType { fn serialize(&self, serializer: S) -> Result where @@ -681,6 +838,22 @@ impl serde::Serialize for ApiErrorsType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ApiErrorsType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ApiErrorsType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ApiErrorsType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ApiErrorsType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/api_version.rs b/generated/stripe_shared/src/api_version.rs index 7dfe978ab..cf2b86bb5 100644 --- a/generated/stripe_shared/src/api_version.rs +++ b/generated/stripe_shared/src/api_version.rs @@ -341,10 +341,26 @@ impl serde::Serialize for ApiVersion { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ApiVersion { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ApiVersion::from_str(s).unwrap_or(ApiVersion::Unknown)); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ApiVersion); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ApiVersion { fn deserialize>(deserializer: D) -> Result { 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)) } } diff --git a/generated/stripe_shared/src/application.rs b/generated/stripe_shared/src/application.rs index 4f671ae0e..7510221d1 100644 --- a/generated/stripe_shared/src/application.rs +++ b/generated/stripe_shared/src/application.rs @@ -1,9 +1,177 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Application { /// Unique identifier for the object. pub id: stripe_shared::ApplicationId, /// The name of the application. pub name: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: ApplicationObject, +} +#[doc(hidden)] +pub struct ApplicationBuilder { + id: Option, + name: Option>, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ApplicationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + id: Deserialize::default(), + name: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { id: self.id.take()?, name: self.name.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ApplicationObject { + Application, +} +impl ApplicationObject { + pub fn as_str(self) -> &'static str { + use ApplicationObject::*; + match self { + Application => "application", + } + } +} + +impl std::str::FromStr for ApplicationObject { + type Err = (); + fn from_str(s: &str) -> Result { + use ApplicationObject::*; + match s { + "application" => Ok(Application), + _ => Err(()), + } + } +} +impl std::fmt::Display for ApplicationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ApplicationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for ApplicationObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for ApplicationObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ApplicationObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ApplicationObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ApplicationObject { + fn deserialize>(deserializer: D) -> 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 ApplicationObject")) + } } impl stripe_types::Object for Application { type Id = stripe_shared::ApplicationId; diff --git a/generated/stripe_shared/src/application_fee.rs b/generated/stripe_shared/src/application_fee.rs index ebc801ef6..52120356a 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ApplicationFee { /// ID of the Stripe account this fee was taken from. pub account: stripe_types::Expandable, @@ -22,6 +24,8 @@ pub struct ApplicationFee { pub id: stripe_shared::ApplicationFeeId, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: ApplicationFeeObject, /// ID of the corresponding charge on the platform account, if this fee was the result of a charge using the `destination` parameter. pub originating_transaction: Option>, /// Whether the fee has been fully refunded. @@ -30,6 +34,234 @@ pub struct ApplicationFee { /// A list of refunds that have been applied to the fee. pub refunds: stripe_types::List, } +#[doc(hidden)] +pub struct ApplicationFeeBuilder { + account: Option>, + amount: Option, + amount_refunded: Option, + application: Option>, + balance_transaction: + Option>>, + charge: Option>, + created: Option, + currency: Option, + id: Option, + livemode: Option, + object: Option, + originating_transaction: Option>>, + refunded: Option, + refunds: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ApplicationFeeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "originating_transaction" => Deserialize::begin(&mut self.originating_transaction), + "refunded" => Deserialize::begin(&mut self.refunded), + "refunds" => Deserialize::begin(&mut self.refunds), + + _ => ::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(), + object: Deserialize::default(), + originating_transaction: Deserialize::default(), + refunded: Deserialize::default(), + refunds: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account: self.account.take()?, + amount: self.amount?, + amount_refunded: self.amount_refunded?, + application: self.application.take()?, + balance_transaction: self.balance_transaction.take()?, + charge: self.charge.take()?, + created: self.created?, + currency: self.currency?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + originating_transaction: self.originating_transaction.take()?, + refunded: self.refunded?, + refunds: self.refunds.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ApplicationFeeObject { + ApplicationFee, +} +impl ApplicationFeeObject { + pub fn as_str(self) -> &'static str { + use ApplicationFeeObject::*; + match self { + ApplicationFee => "application_fee", + } + } +} + +impl std::str::FromStr for ApplicationFeeObject { + type Err = (); + fn from_str(s: &str) -> Result { + use ApplicationFeeObject::*; + match s { + "application_fee" => Ok(ApplicationFee), + _ => Err(()), + } + } +} +impl std::fmt::Display for ApplicationFeeObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ApplicationFeeObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for ApplicationFeeObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for ApplicationFeeObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ApplicationFeeObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ApplicationFeeObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ApplicationFeeObject { + fn deserialize>(deserializer: D) -> 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 ApplicationFeeObject")) + } +} 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..89c2c9215 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ApplicationFeeRefund { /// Amount, in cents (or local equivalent). pub amount: i64, @@ -23,6 +25,204 @@ pub struct ApplicationFeeRefund { /// 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>, + /// String representing the object's type. Objects of the same type share the same value. + pub object: ApplicationFeeRefundObject, +} +#[doc(hidden)] +pub struct ApplicationFeeRefundBuilder { + amount: Option, + balance_transaction: + Option>>, + created: Option, + currency: Option, + fee: Option>, + id: Option, + metadata: Option>>, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ApplicationFeeRefundBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::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(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + balance_transaction: self.balance_transaction.take()?, + created: self.created?, + currency: self.currency?, + fee: self.fee.take()?, + id: self.id.take()?, + metadata: self.metadata.take()?, + object: self.object?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ApplicationFeeRefundObject { + FeeRefund, +} +impl ApplicationFeeRefundObject { + pub fn as_str(self) -> &'static str { + use ApplicationFeeRefundObject::*; + match self { + FeeRefund => "fee_refund", + } + } +} + +impl std::str::FromStr for ApplicationFeeRefundObject { + type Err = (); + fn from_str(s: &str) -> Result { + use ApplicationFeeRefundObject::*; + match s { + "fee_refund" => Ok(FeeRefund), + _ => Err(()), + } + } +} +impl std::fmt::Display for ApplicationFeeRefundObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ApplicationFeeRefundObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for ApplicationFeeRefundObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for ApplicationFeeRefundObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ApplicationFeeRefundObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ApplicationFeeRefundObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ApplicationFeeRefundObject { + fn deserialize>(deserializer: D) -> 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 ApplicationFeeRefundObject")) + } } impl stripe_types::Object for ApplicationFeeRefund { type Id = stripe_shared::ApplicationFeeRefundId; diff --git a/generated/stripe_shared/src/automatic_tax.rs b/generated/stripe_shared/src/automatic_tax.rs index 8afb53aba..04872fd57 100644 --- a/generated/stripe_shared/src/automatic_tax.rs +++ b/generated/stripe_shared/src/automatic_tax.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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. @@ -10,6 +12,106 @@ pub struct AutomaticTax { /// The status of the most recent automated tax calculation for this invoice. pub status: Option, } +#[doc(hidden)] +pub struct AutomaticTaxBuilder { + enabled: Option, + liability: Option>, + status: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: AutomaticTaxBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "liability" => Deserialize::begin(&mut self.liability), + "status" => Deserialize::begin(&mut self.status), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + enabled: Deserialize::default(), + liability: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + enabled: self.enabled?, + liability: self.liability.take()?, + status: self.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 { + 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)?), + "liability" => b.liability = 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 { @@ -51,6 +153,7 @@ impl std::fmt::Debug for AutomaticTaxStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for AutomaticTaxStatus { fn serialize(&self, serializer: S) -> Result where @@ -59,6 +162,22 @@ impl serde::Serialize for AutomaticTaxStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for AutomaticTaxStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(AutomaticTaxStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(AutomaticTaxStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for AutomaticTaxStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/balance_transaction.rs b/generated/stripe_shared/src/balance_transaction.rs index ad8b77726..8039960f7 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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. @@ -34,6 +36,8 @@ pub struct BalanceTransaction { /// A positive value represents incrementing a Stripe balance, and a negative value decrementing a Stripe balance. /// You can calculate the net impact of a transaction on a balance by `amount` - `fee`. pub net: i64, + /// String representing the object's type. Objects of the same type share the same value. + pub object: BalanceTransactionObject, /// Learn more about how [reporting categories](https://stripe.com/docs/reports/reporting-categories) can help you understand balance transactions from an accounting perspective. pub reporting_category: String, /// This transaction relates to the Stripe object. @@ -43,9 +47,239 @@ pub struct BalanceTransaction { /// 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`. /// 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(feature = "serde", serde(rename = "type"))] pub type_: BalanceTransactionType, } +#[doc(hidden)] +pub struct BalanceTransactionBuilder { + amount: Option, + available_on: Option, + created: Option, + currency: Option, + description: Option>, + exchange_rate: Option>, + fee: Option, + fee_details: Option>, + id: Option, + net: Option, + object: Option, + reporting_category: Option, + source: Option>>, + status: Option, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BalanceTransactionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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_), + + _ => ::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(), + object: Deserialize::default(), + reporting_category: Deserialize::default(), + source: Deserialize::default(), + status: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + available_on: self.available_on?, + created: self.created?, + currency: self.currency?, + description: self.description.take()?, + exchange_rate: self.exchange_rate?, + fee: self.fee?, + fee_details: self.fee_details.take()?, + id: self.id.take()?, + net: self.net?, + object: self.object?, + reporting_category: self.reporting_category.take()?, + source: self.source.take()?, + status: self.status.take()?, + type_: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum BalanceTransactionObject { + BalanceTransaction, +} +impl BalanceTransactionObject { + pub fn as_str(self) -> &'static str { + use BalanceTransactionObject::*; + match self { + BalanceTransaction => "balance_transaction", + } + } +} + +impl std::str::FromStr for BalanceTransactionObject { + type Err = (); + fn from_str(s: &str) -> Result { + use BalanceTransactionObject::*; + match s { + "balance_transaction" => Ok(BalanceTransaction), + _ => Err(()), + } + } +} +impl std::fmt::Display for BalanceTransactionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for BalanceTransactionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for BalanceTransactionObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for BalanceTransactionObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(BalanceTransactionObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(BalanceTransactionObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for BalanceTransactionObject { + fn deserialize>(deserializer: D) -> 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 BalanceTransactionObject")) + } +} /// 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`. /// 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. @@ -204,6 +438,7 @@ impl std::fmt::Debug for BalanceTransactionType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for BalanceTransactionType { fn serialize(&self, serializer: S) -> Result where @@ -212,11 +447,28 @@ impl serde::Serialize for BalanceTransactionType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for BalanceTransactionType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(BalanceTransactionType::from_str(s).unwrap_or(BalanceTransactionType::Unknown)); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(BalanceTransactionType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for BalanceTransactionType { fn deserialize>(deserializer: D) -> Result { 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)) } } impl stripe_types::Object for BalanceTransaction { diff --git a/generated/stripe_shared/src/balance_transaction_source.rs b/generated/stripe_shared/src/balance_transaction_source.rs index 5ca060b07..3e94a4630 100644 --- a/generated/stripe_shared/src/balance_transaction_source.rs +++ b/generated/stripe_shared/src/balance_transaction_source.rs @@ -1,42 +1,164 @@ /// The resource representing a Stripe Polymorphic -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(tag = "object"))] pub enum BalanceTransactionSource { - #[serde(rename = "application_fee")] + #[cfg_attr(feature = "serde", serde(rename = "application_fee"))] ApplicationFee(stripe_shared::ApplicationFee), - #[serde(rename = "charge")] + #[cfg_attr(feature = "serde", serde(rename = "charge"))] Charge(stripe_shared::Charge), - #[serde(rename = "connect_collection_transfer")] + #[cfg_attr(feature = "serde", serde(rename = "connect_collection_transfer"))] ConnectCollectionTransfer(stripe_shared::ConnectCollectionTransfer), - #[serde(rename = "customer_cash_balance_transaction")] + #[cfg_attr(feature = "serde", serde(rename = "customer_cash_balance_transaction"))] CustomerCashBalanceTransaction(stripe_shared::CustomerCashBalanceTransaction), - #[serde(rename = "dispute")] + #[cfg_attr(feature = "serde", serde(rename = "dispute"))] Dispute(stripe_shared::Dispute), - #[serde(rename = "fee_refund")] + #[cfg_attr(feature = "serde", serde(rename = "fee_refund"))] ApplicationFeeRefund(stripe_shared::ApplicationFeeRefund), - #[serde(rename = "issuing.authorization")] + #[cfg_attr(feature = "serde", serde(rename = "issuing.authorization"))] IssuingAuthorization(stripe_shared::IssuingAuthorization), - #[serde(rename = "issuing.dispute")] + #[cfg_attr(feature = "serde", serde(rename = "issuing.dispute"))] IssuingDispute(stripe_shared::IssuingDispute), - #[serde(rename = "issuing.transaction")] + #[cfg_attr(feature = "serde", serde(rename = "issuing.transaction"))] IssuingTransaction(stripe_shared::IssuingTransaction), - #[serde(rename = "payout")] + #[cfg_attr(feature = "serde", serde(rename = "payout"))] Payout(stripe_shared::Payout), - #[serde(rename = "platform_tax_fee")] + #[cfg_attr(feature = "serde", serde(rename = "platform_tax_fee"))] PlatformTaxFee(stripe_shared::PlatformTaxFee), - #[serde(rename = "refund")] + #[cfg_attr(feature = "serde", serde(rename = "refund"))] Refund(stripe_shared::Refund), - #[serde(rename = "reserve_transaction")] + #[cfg_attr(feature = "serde", serde(rename = "reserve_transaction"))] ReserveTransaction(stripe_shared::ReserveTransaction), - #[serde(rename = "tax_deducted_at_source")] + #[cfg_attr(feature = "serde", serde(rename = "tax_deducted_at_source"))] TaxDeductedAtSource(stripe_shared::TaxDeductedAtSource), - #[serde(rename = "topup")] + #[cfg_attr(feature = "serde", serde(rename = "topup"))] Topup(stripe_shared::Topup), - #[serde(rename = "transfer")] + #[cfg_attr(feature = "serde", serde(rename = "transfer"))] Transfer(stripe_shared::Transfer), - #[serde(rename = "transfer_reversal")] + #[cfg_attr(feature = "serde", serde(rename = "transfer_reversal"))] TransferReversal(stripe_shared::TransferReversal), } + +#[derive(Default)] +pub struct BalanceTransactionSourceBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +const _: () = { + use 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, + builder: BalanceTransactionSourceBuilder, + } + + impl Deserialize for BalanceTransactionSource { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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 { + 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 { + 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..8859f5a0b 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, /// The name of the person or business that owns the bank account. pub account_holder_name: Option, @@ -20,7 +21,6 @@ pub struct BankAccount { pub account_type: Option, /// 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>, /// Name of the bank associated with the routing number (e.g., `WELLS FARGO`). pub bank_name: Option, @@ -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>, /// Whether this bank account is the default external account for its currency. - #[serde(skip_serializing_if = "Option::is_none")] pub default_for_currency: Option, /// Uniquely identifies this particular bank account. /// You can use this attribute to check whether two bank accounts are the same. pub fingerprint: Option, /// 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, /// Unique identifier for the object. pub id: stripe_shared::BankAccountId, @@ -46,10 +43,10 @@ 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>, + /// String representing the object's type. Objects of the same type share the same value. + pub object: BankAccountObject, /// 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, /// The routing transit number for the bank account. pub routing_number: Option, @@ -68,6 +65,198 @@ pub struct BankAccount { /// This means the other statuses don't apply. pub status: String, } +#[doc(hidden)] +pub struct BankAccountBuilder { + account: Option>>, + account_holder_name: Option>, + account_holder_type: Option>, + account_type: Option>, + available_payout_methods: Option>>, + bank_name: Option>, + country: Option, + currency: Option, + customer: Option>>, + default_for_currency: Option>, + fingerprint: Option>, + future_requirements: Option>, + id: Option, + last4: Option, + metadata: Option>>, + object: Option, + requirements: Option>, + routing_number: Option>, + status: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BankAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "requirements" => Deserialize::begin(&mut self.requirements), + "routing_number" => Deserialize::begin(&mut self.routing_number), + "status" => Deserialize::begin(&mut self.status), + + _ => ::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(), + object: Deserialize::default(), + requirements: Deserialize::default(), + routing_number: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account: self.account.take()?, + account_holder_name: self.account_holder_name.take()?, + account_holder_type: self.account_holder_type.take()?, + account_type: self.account_type.take()?, + available_payout_methods: self.available_payout_methods.take()?, + bank_name: self.bank_name.take()?, + country: self.country.take()?, + currency: self.currency?, + customer: self.customer.take()?, + default_for_currency: self.default_for_currency?, + fingerprint: self.fingerprint.take()?, + future_requirements: self.future_requirements.take()?, + id: self.id.take()?, + last4: self.last4.take()?, + metadata: self.metadata.take()?, + object: self.object?, + requirements: self.requirements.take()?, + routing_number: self.routing_number.take()?, + status: self.status.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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)] @@ -107,6 +296,7 @@ impl std::fmt::Debug for BankAccountAvailablePayoutMethods { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for BankAccountAvailablePayoutMethods { fn serialize(&self, serializer: S) -> Result where @@ -115,6 +305,23 @@ impl serde::Serialize for BankAccountAvailablePayoutMethods { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for BankAccountAvailablePayoutMethods { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(BankAccountAvailablePayoutMethods::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(BankAccountAvailablePayoutMethods); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for BankAccountAvailablePayoutMethods { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -124,6 +331,74 @@ impl<'de> serde::Deserialize<'de> for BankAccountAvailablePayoutMethods { }) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum BankAccountObject { + BankAccount, +} +impl BankAccountObject { + pub fn as_str(self) -> &'static str { + use BankAccountObject::*; + match self { + BankAccount => "bank_account", + } + } +} + +impl std::str::FromStr for BankAccountObject { + type Err = (); + fn from_str(s: &str) -> Result { + use BankAccountObject::*; + match s { + "bank_account" => Ok(BankAccount), + _ => Err(()), + } + } +} +impl std::fmt::Display for BankAccountObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for BankAccountObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for BankAccountObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for BankAccountObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(BankAccountObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(BankAccountObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for BankAccountObject { + fn deserialize>(deserializer: D) -> 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 BankAccountObject")) + } +} 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..f6144c481 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct BillingDetails { /// Billing address. pub address: Option, @@ -9,3 +11,108 @@ pub struct BillingDetails { /// Billing phone number (including extension). pub phone: Option, } +#[doc(hidden)] +pub struct BillingDetailsBuilder { + address: Option>, + email: Option>, + name: Option>, + phone: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: BillingDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + address: Deserialize::default(), + email: Deserialize::default(), + name: Deserialize::default(), + phone: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + address: self.address.take()?, + email: self.email.take()?, + name: self.name.take()?, + phone: self.phone.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..5ff33e6c9 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CancellationDetails { /// Additional comments about why the user canceled the subscription, if the subscription was canceled explicitly by the user. pub comment: Option, @@ -7,6 +9,106 @@ pub struct CancellationDetails { /// Why this subscription was canceled. pub reason: Option, } +#[doc(hidden)] +pub struct CancellationDetailsBuilder { + comment: Option>, + feedback: Option>, + reason: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CancellationDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + comment: Deserialize::default(), + feedback: Deserialize::default(), + reason: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + comment: self.comment.take()?, + feedback: self.feedback?, + reason: self.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 { + 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 { @@ -63,6 +165,7 @@ impl std::fmt::Debug for CancellationDetailsFeedback { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CancellationDetailsFeedback { fn serialize(&self, serializer: S) -> Result where @@ -71,6 +174,22 @@ impl serde::Serialize for CancellationDetailsFeedback { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CancellationDetailsFeedback { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CancellationDetailsFeedback::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CancellationDetailsFeedback); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CancellationDetailsFeedback { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -120,6 +239,7 @@ impl std::fmt::Debug for CancellationDetailsReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CancellationDetailsReason { fn serialize(&self, serializer: S) -> Result where @@ -128,6 +248,22 @@ impl serde::Serialize for CancellationDetailsReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CancellationDetailsReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CancellationDetailsReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CancellationDetailsReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CancellationDetailsReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/capability.rs b/generated/stripe_shared/src/capability.rs index 4876b8912..8291f0b02 100644 --- a/generated/stripe_shared/src/capability.rs +++ b/generated/stripe_shared/src/capability.rs @@ -3,23 +3,220 @@ /// Related guide: [Account capabilities](https://stripe.com/docs/connect/account-capabilities) /// /// For more details see <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Capability { /// The account for which the capability enables functionality. pub account: stripe_types::Expandable, - #[serde(skip_serializing_if = "Option::is_none")] pub future_requirements: Option, /// The identifier for the capability. pub id: stripe_shared::CapabilityId, + /// String representing the object's type. Objects of the same type share the same value. + pub object: CapabilityObject, /// Whether the capability has been requested. pub requested: bool, /// Time at which the capability was requested. Measured in seconds since the Unix epoch. pub requested_at: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub requirements: Option, /// The status of the capability. Can be `active`, `inactive`, `pending`, or `unrequested`. pub status: CapabilityStatus, } +#[doc(hidden)] +pub struct CapabilityBuilder { + account: Option>, + future_requirements: Option>, + id: Option, + object: Option, + requested: Option, + requested_at: Option>, + requirements: Option>, + status: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CapabilityBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account: Deserialize::default(), + future_requirements: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + requested: Deserialize::default(), + requested_at: Deserialize::default(), + requirements: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account: self.account.take()?, + future_requirements: self.future_requirements.take()?, + id: self.id.take()?, + object: self.object?, + requested: self.requested?, + requested_at: self.requested_at?, + requirements: self.requirements.take()?, + status: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum CapabilityObject { + Capability, +} +impl CapabilityObject { + pub fn as_str(self) -> &'static str { + use CapabilityObject::*; + match self { + Capability => "capability", + } + } +} + +impl std::str::FromStr for CapabilityObject { + type Err = (); + fn from_str(s: &str) -> Result { + use CapabilityObject::*; + match s { + "capability" => Ok(Capability), + _ => Err(()), + } + } +} +impl std::fmt::Display for CapabilityObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for CapabilityObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for CapabilityObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for CapabilityObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CapabilityObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CapabilityObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CapabilityObject { + fn deserialize>(deserializer: D) -> 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 CapabilityObject")) + } +} /// The status of the capability. Can be `active`, `inactive`, `pending`, or `unrequested`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CapabilityStatus { @@ -67,6 +264,7 @@ impl std::fmt::Debug for CapabilityStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CapabilityStatus { fn serialize(&self, serializer: S) -> Result where @@ -75,6 +273,22 @@ impl serde::Serialize for CapabilityStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CapabilityStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CapabilityStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CapabilityStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CapabilityStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/card.rs b/generated/stripe_shared/src/card.rs index 1200b690d..72ecf3b03 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, /// City/District/Suburb/Town/Village. pub address_city: Option, @@ -29,7 +30,6 @@ pub struct Card { pub address_zip_check: Option, /// 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>, /// 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, /// 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>, /// 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, /// Whether this card is the default external account for its currency. - #[serde(skip_serializing_if = "Option::is_none")] pub default_for_currency: Option, /// 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, /// (For tokenized numbers only.) The last four digits of the device account number. pub dynamic_last4: Option, @@ -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, /// 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, /// 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, /// The last four digits of the card. pub last4: String, @@ -90,14 +83,262 @@ pub struct Card { pub metadata: Option>, /// Cardholder name. pub name: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: CardObject, /// 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, /// 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, } +#[doc(hidden)] +pub struct CardBuilder { + account: Option>>, + address_city: Option>, + address_country: Option>, + address_line1: Option>, + address_line1_check: Option>, + address_line2: Option>, + address_state: Option>, + address_zip: Option>, + address_zip_check: Option>, + available_payout_methods: Option>>, + brand: Option, + country: Option>, + currency: Option>, + customer: Option>>, + cvc_check: Option>, + default_for_currency: Option>, + description: Option>, + dynamic_last4: Option>, + exp_month: Option, + exp_year: Option, + fingerprint: Option>, + funding: Option, + id: Option, + iin: Option>, + issuer: Option>, + last4: Option, + metadata: Option>>, + name: Option>, + object: Option, + status: Option>, + tokenization_method: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CardBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "status" => Deserialize::begin(&mut self.status), + "tokenization_method" => Deserialize::begin(&mut self.tokenization_method), + + _ => ::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(), + object: Deserialize::default(), + status: Deserialize::default(), + tokenization_method: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account: self.account.take()?, + address_city: self.address_city.take()?, + address_country: self.address_country.take()?, + address_line1: self.address_line1.take()?, + address_line1_check: self.address_line1_check.take()?, + address_line2: self.address_line2.take()?, + address_state: self.address_state.take()?, + address_zip: self.address_zip.take()?, + address_zip_check: self.address_zip_check.take()?, + available_payout_methods: self.available_payout_methods.take()?, + brand: self.brand.take()?, + country: self.country.take()?, + currency: self.currency?, + customer: self.customer.take()?, + cvc_check: self.cvc_check.take()?, + default_for_currency: self.default_for_currency?, + description: self.description.take()?, + dynamic_last4: self.dynamic_last4.take()?, + exp_month: self.exp_month?, + exp_year: self.exp_year?, + fingerprint: self.fingerprint.take()?, + funding: self.funding.take()?, + id: self.id.take()?, + iin: self.iin.take()?, + issuer: self.issuer.take()?, + last4: self.last4.take()?, + metadata: self.metadata.take()?, + name: self.name.take()?, + object: self.object?, + status: self.status.take()?, + tokenization_method: self.tokenization_method.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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)] @@ -137,6 +378,7 @@ impl std::fmt::Debug for CardAvailablePayoutMethods { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CardAvailablePayoutMethods { fn serialize(&self, serializer: S) -> Result where @@ -145,6 +387,22 @@ impl serde::Serialize for CardAvailablePayoutMethods { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CardAvailablePayoutMethods { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CardAvailablePayoutMethods::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CardAvailablePayoutMethods); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CardAvailablePayoutMethods { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -153,6 +411,73 @@ impl<'de> serde::Deserialize<'de> for CardAvailablePayoutMethods { .map_err(|_| serde::de::Error::custom("Unknown value for CardAvailablePayoutMethods")) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum CardObject { + Card, +} +impl CardObject { + pub fn as_str(self) -> &'static str { + use CardObject::*; + match self { + Card => "card", + } + } +} + +impl std::str::FromStr for CardObject { + type Err = (); + fn from_str(s: &str) -> Result { + use CardObject::*; + match s { + "card" => Ok(Card), + _ => Err(()), + } + } +} +impl std::fmt::Display for CardObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for CardObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for CardObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for CardObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CardObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CardObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CardObject { + fn deserialize>(deserializer: D) -> 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 CardObject")) + } +} 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..3c865116c 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,111 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CardIssuingAccountTermsOfService { /// The Unix timestamp marking when the account representative accepted the service agreement. pub date: Option, /// The IP address from which the account representative accepted the service agreement. pub ip: Option, /// 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, } +#[doc(hidden)] +pub struct CardIssuingAccountTermsOfServiceBuilder { + date: Option>, + ip: Option>, + user_agent: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CardIssuingAccountTermsOfServiceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + date: Deserialize::default(), + ip: Deserialize::default(), + user_agent: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + date: self.date?, + ip: self.ip.take()?, + user_agent: self.user_agent.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..15f6f0472 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CardMandatePaymentMethodDetails {} +#[doc(hidden)] +pub struct CardMandatePaymentMethodDetailsBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CardMandatePaymentMethodDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..dc4059ce7 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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. @@ -13,5 +15,185 @@ pub struct CashBalance { pub customer: 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: CashBalanceObject, pub settings: stripe_shared::CustomerBalanceCustomerBalanceSettings, } +#[doc(hidden)] +pub struct CashBalanceBuilder { + available: Option>>, + customer: Option, + livemode: Option, + object: Option, + settings: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CashBalanceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "settings" => Deserialize::begin(&mut self.settings), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + available: Deserialize::default(), + customer: Deserialize::default(), + livemode: Deserialize::default(), + object: Deserialize::default(), + settings: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + available: self.available.take()?, + customer: self.customer.take()?, + livemode: self.livemode?, + object: self.object?, + settings: self.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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "settings" => b.settings = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum CashBalanceObject { + CashBalance, +} +impl CashBalanceObject { + pub fn as_str(self) -> &'static str { + use CashBalanceObject::*; + match self { + CashBalance => "cash_balance", + } + } +} + +impl std::str::FromStr for CashBalanceObject { + type Err = (); + fn from_str(s: &str) -> Result { + use CashBalanceObject::*; + match s { + "cash_balance" => Ok(CashBalance), + _ => Err(()), + } + } +} +impl std::fmt::Display for CashBalanceObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for CashBalanceObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for CashBalanceObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for CashBalanceObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CashBalanceObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CashBalanceObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CashBalanceObject { + fn deserialize>(deserializer: D) -> 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 CashBalanceObject")) + } +} diff --git a/generated/stripe_shared/src/charge.rs b/generated/stripe_shared/src/charge.rs index d4bc526f1..be774c1e7 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// Authorization code on the charge. - #[serde(skip_serializing_if = "Option::is_none")] pub authorization_code: Option, /// 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>, @@ -58,13 +59,14 @@ pub struct Charge { pub id: stripe_shared::ChargeId, /// ID of the invoice this charge is for if one exists. pub invoice: Option>, - #[serde(skip_serializing_if = "Option::is_none")] pub level3: Option, /// 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 representing the object's type. Objects of the same type share the same value. + pub object: ChargeObject, /// The account (if any) the charge was made on behalf of without triggering an automatic transfer. /// See the [Connect documentation](https://stripe.com/docs/connect/separate-charges-and-transfers) for details. pub on_behalf_of: Option>, @@ -79,7 +81,6 @@ pub struct Charge { pub payment_method: Option, /// Details about the payment method at the time of the transaction. pub payment_method_details: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub radar_options: Option, /// This is the email address that the receipt for this charge was sent to. pub receipt_email: Option, @@ -118,7 +119,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>, /// 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 +127,419 @@ pub struct Charge { /// See the [Connect documentation](https://stripe.com/docs/connect/separate-charges-and-transfers#transfer-options) for details. pub transfer_group: Option, } +#[doc(hidden)] +pub struct ChargeBuilder { + amount: Option, + amount_captured: Option, + amount_refunded: Option, + application: Option>>, + application_fee: Option>>, + application_fee_amount: Option>, + authorization_code: Option>, + balance_transaction: + Option>>, + billing_details: Option, + calculated_statement_descriptor: Option>, + captured: Option, + created: Option, + currency: Option, + customer: Option>>, + description: Option>, + disputed: Option, + failure_balance_transaction: + Option>>, + failure_code: Option>, + failure_message: Option>, + fraud_details: Option>, + id: Option, + invoice: Option>>, + level3: Option>, + livemode: Option, + metadata: Option>, + object: Option, + on_behalf_of: Option>>, + outcome: Option>, + paid: Option, + payment_intent: Option>>, + payment_method: Option>, + payment_method_details: Option>, + radar_options: Option>, + receipt_email: Option>, + receipt_number: Option>, + receipt_url: Option>, + refunded: Option, + refunds: Option>>, + review: Option>>, + shipping: Option>, + source: Option>, + source_transfer: Option>>, + statement_descriptor: Option>, + statement_descriptor_suffix: Option>, + status: Option, + transfer: Option>>, + transfer_data: Option>, + transfer_group: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ChargeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + amount: self.amount?, + amount_captured: self.amount_captured?, + amount_refunded: self.amount_refunded?, + application: self.application.take()?, + application_fee: self.application_fee.take()?, + application_fee_amount: self.application_fee_amount?, + authorization_code: self.authorization_code.take()?, + balance_transaction: self.balance_transaction.take()?, + billing_details: self.billing_details.take()?, + calculated_statement_descriptor: self.calculated_statement_descriptor.take()?, + captured: self.captured?, + created: self.created?, + currency: self.currency?, + customer: self.customer.take()?, + description: self.description.take()?, + disputed: self.disputed?, + failure_balance_transaction: self.failure_balance_transaction.take()?, + failure_code: self.failure_code.take()?, + failure_message: self.failure_message.take()?, + fraud_details: self.fraud_details.take()?, + id: self.id.take()?, + invoice: self.invoice.take()?, + level3: self.level3.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + on_behalf_of: self.on_behalf_of.take()?, + outcome: self.outcome.take()?, + paid: self.paid?, + payment_intent: self.payment_intent.take()?, + payment_method: self.payment_method.take()?, + payment_method_details: self.payment_method_details.take()?, + radar_options: self.radar_options.take()?, + receipt_email: self.receipt_email.take()?, + receipt_number: self.receipt_number.take()?, + receipt_url: self.receipt_url.take()?, + refunded: self.refunded?, + refunds: self.refunds.take()?, + review: self.review.take()?, + shipping: self.shipping.take()?, + source: self.source.take()?, + source_transfer: self.source_transfer.take()?, + statement_descriptor: self.statement_descriptor.take()?, + statement_descriptor_suffix: self.statement_descriptor_suffix.take()?, + status: self.status?, + transfer: self.transfer.take()?, + transfer_data: self.transfer_data.take()?, + transfer_group: self.transfer_group.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ChargeObject { + Charge, +} +impl ChargeObject { + pub fn as_str(self) -> &'static str { + use ChargeObject::*; + match self { + Charge => "charge", + } + } +} + +impl std::str::FromStr for ChargeObject { + type Err = (); + fn from_str(s: &str) -> Result { + use ChargeObject::*; + match s { + "charge" => Ok(Charge), + _ => Err(()), + } + } +} +impl std::fmt::Display for ChargeObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ChargeObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for ChargeObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for ChargeObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ChargeObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ChargeObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ChargeObject { + fn deserialize>(deserializer: D) -> 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 ChargeObject")) + } +} /// The status of the payment is either `succeeded`, `pending`, or `failed`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ChargeStatus { @@ -168,6 +581,7 @@ impl std::fmt::Debug for ChargeStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ChargeStatus { fn serialize(&self, serializer: S) -> Result where @@ -176,6 +590,22 @@ impl serde::Serialize for ChargeStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ChargeStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ChargeStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ChargeStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ChargeStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/charge_fraud_details.rs b/generated/stripe_shared/src/charge_fraud_details.rs index e1de5731d..c4ab575e2 100644 --- a/generated/stripe_shared/src/charge_fraud_details.rs +++ b/generated/stripe_shared/src/charge_fraud_details.rs @@ -1,9 +1,101 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ChargeFraudDetails { /// Assessments from Stripe. If set, the value is `fraudulent`. - #[serde(skip_serializing_if = "Option::is_none")] pub stripe_report: Option, /// Assessments reported by you. If set, possible values of are `safe` and `fraudulent`. - #[serde(skip_serializing_if = "Option::is_none")] pub user_report: Option, } +#[doc(hidden)] +pub struct ChargeFraudDetailsBuilder { + stripe_report: Option>, + user_report: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ChargeFraudDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { stripe_report: Deserialize::default(), user_report: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + stripe_report: self.stripe_report.take()?, + user_report: self.user_report.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..f05a275d3 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,138 @@ 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, /// 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, /// The ID of the Radar rule that matched the payment, if applicable. - #[serde(skip_serializing_if = "Option::is_none")] pub rule: Option>, /// 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, /// 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(feature = "serde", serde(rename = "type"))] pub type_: String, } +#[doc(hidden)] +pub struct ChargeOutcomeBuilder { + network_status: Option>, + reason: Option>, + risk_level: Option>, + risk_score: Option>, + rule: Option>>, + seller_message: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ChargeOutcomeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + network_status: self.network_status.take()?, + reason: self.reason.take()?, + risk_level: self.risk_level.take()?, + risk_score: self.risk_score?, + rule: self.rule.take()?, + seller_message: self.seller_message.take()?, + type_: self.type_.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..3e7bebf6c 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,92 @@ 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, } +#[doc(hidden)] +pub struct ChargeTransferDataBuilder { + amount: Option>, + destination: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ChargeTransferDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), destination: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { amount: self.amount?, destination: self.destination.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..511f5c0ba 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CheckoutSessionItem { /// Total discount amount applied. If no discounts were applied, defaults to 0. pub amount_discount: i64, @@ -17,18 +19,231 @@ 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>, /// Unique identifier for the object. pub id: stripe_shared::CheckoutSessionItemId, + /// String representing the object's type. Objects of the same type share the same value. + pub object: CheckoutSessionItemObject, /// The price used to generate the line item. pub price: Option, /// The quantity of products being purchased. pub quantity: Option, /// The taxes applied to the line item. - #[serde(skip_serializing_if = "Option::is_none")] pub taxes: Option>, } +#[doc(hidden)] +pub struct CheckoutSessionItemBuilder { + amount_discount: Option, + amount_subtotal: Option, + amount_tax: Option, + amount_total: Option, + currency: Option, + description: Option, + discounts: Option>>, + id: Option, + object: Option, + price: Option>, + quantity: Option>, + taxes: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CheckoutSessionItemBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "price" => Deserialize::begin(&mut self.price), + "quantity" => Deserialize::begin(&mut self.quantity), + "taxes" => Deserialize::begin(&mut self.taxes), + + _ => ::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(), + object: Deserialize::default(), + price: Deserialize::default(), + quantity: Deserialize::default(), + taxes: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount_discount: self.amount_discount?, + amount_subtotal: self.amount_subtotal?, + amount_tax: self.amount_tax?, + amount_total: self.amount_total?, + currency: self.currency?, + description: self.description.take()?, + discounts: self.discounts.take()?, + id: self.id.take()?, + object: self.object?, + price: self.price.take()?, + quantity: self.quantity?, + taxes: self.taxes.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum CheckoutSessionItemObject { + Item, +} +impl CheckoutSessionItemObject { + pub fn as_str(self) -> &'static str { + use CheckoutSessionItemObject::*; + match self { + Item => "item", + } + } +} + +impl std::str::FromStr for CheckoutSessionItemObject { + type Err = (); + fn from_str(s: &str) -> Result { + use CheckoutSessionItemObject::*; + match s { + "item" => Ok(Item), + _ => Err(()), + } + } +} +impl std::fmt::Display for CheckoutSessionItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for CheckoutSessionItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for CheckoutSessionItemObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for CheckoutSessionItemObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CheckoutSessionItemObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CheckoutSessionItemObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CheckoutSessionItemObject { + fn deserialize>(deserializer: D) -> 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 CheckoutSessionItemObject")) + } +} 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 index 672d07b2c..15297b178 100644 --- a/generated/stripe_shared/src/connect_account_reference.rs +++ b/generated/stripe_shared/src/connect_account_reference.rs @@ -1,12 +1,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ConnectAccountReference { /// The connected account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] pub account: Option>, /// Type of the account referenced. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: ConnectAccountReferenceType, } +#[doc(hidden)] +pub struct ConnectAccountReferenceBuilder { + account: Option>>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for ConnectAccountReference { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ConnectAccountReferenceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: ConnectAccountReferenceBuilder::deser_default(), + })) + } + } + + impl MapBuilder for ConnectAccountReferenceBuilder { + type Out = ConnectAccountReference; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account" => Deserialize::begin(&mut self.account), + "type" => Deserialize::begin(&mut self.type_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { account: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { account: self.account.take()?, type_: self.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 ConnectAccountReference { + type Builder = ConnectAccountReferenceBuilder; + } + + impl FromValueOpt for ConnectAccountReference { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = ConnectAccountReferenceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account" => b.account = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Type of the account referenced. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConnectAccountReferenceType { @@ -45,6 +135,7 @@ impl std::fmt::Debug for ConnectAccountReferenceType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ConnectAccountReferenceType { fn serialize(&self, serializer: S) -> Result where @@ -53,6 +144,22 @@ impl serde::Serialize for ConnectAccountReferenceType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ConnectAccountReferenceType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ConnectAccountReferenceType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ConnectAccountReferenceType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ConnectAccountReferenceType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/connect_collection_transfer.rs b/generated/stripe_shared/src/connect_collection_transfer.rs index 9aafd6e1b..158e965e6 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ConnectCollectionTransfer { /// Amount transferred, in cents (or local equivalent). pub amount: i64, @@ -11,6 +13,193 @@ pub struct ConnectCollectionTransfer { pub id: stripe_shared::ConnectCollectionTransferId, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: ConnectCollectionTransferObject, +} +#[doc(hidden)] +pub struct ConnectCollectionTransferBuilder { + amount: Option, + currency: Option, + destination: Option>, + id: Option, + livemode: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ConnectCollectionTransferBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + currency: Deserialize::default(), + destination: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + currency: self.currency?, + destination: self.destination.take()?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ConnectCollectionTransferObject { + ConnectCollectionTransfer, +} +impl ConnectCollectionTransferObject { + pub fn as_str(self) -> &'static str { + use ConnectCollectionTransferObject::*; + match self { + ConnectCollectionTransfer => "connect_collection_transfer", + } + } +} + +impl std::str::FromStr for ConnectCollectionTransferObject { + type Err = (); + fn from_str(s: &str) -> Result { + use ConnectCollectionTransferObject::*; + match s { + "connect_collection_transfer" => Ok(ConnectCollectionTransfer), + _ => Err(()), + } + } +} +impl std::fmt::Display for ConnectCollectionTransferObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ConnectCollectionTransferObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for ConnectCollectionTransferObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for ConnectCollectionTransferObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(ConnectCollectionTransferObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ConnectCollectionTransferObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ConnectCollectionTransferObject { + fn deserialize>(deserializer: D) -> 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 ConnectCollectionTransferObject") + }) + } } impl stripe_types::Object for ConnectCollectionTransfer { type Id = stripe_shared::ConnectCollectionTransferId; diff --git a/generated/stripe_shared/src/coupon.rs b/generated/stripe_shared/src/coupon.rs index bde2892a3..721a0ce47 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, - #[serde(skip_serializing_if = "Option::is_none")] pub applies_to: Option, /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -17,7 +18,6 @@ pub struct Coupon { pub currency: Option, /// 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, >, @@ -38,6 +38,8 @@ pub struct Coupon { pub metadata: Option>, /// Name of the coupon displayed to customers on for instance invoices or receipts. pub name: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: CouponObject, /// Percent that will be taken off the subtotal of any invoices for this customer for the duration of the coupon. /// For example, a coupon with percent_off of 50 will make a $ (or local equivalent)100 invoice $ (or local equivalent)50 instead. pub percent_off: Option, @@ -48,6 +50,246 @@ pub struct Coupon { /// Taking account of the above properties, whether this coupon can still be applied to a customer. pub valid: bool, } +#[doc(hidden)] +pub struct CouponBuilder { + amount_off: Option>, + applies_to: Option>, + created: Option, + currency: Option>, + currency_options: Option< + Option< + std::collections::HashMap, + >, + >, + duration: Option, + duration_in_months: Option>, + id: Option, + livemode: Option, + max_redemptions: Option>, + metadata: Option>>, + name: Option>, + object: Option, + percent_off: Option>, + redeem_by: Option>, + times_redeemed: Option, + valid: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CouponBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: Deserialize::default(), + percent_off: Deserialize::default(), + redeem_by: Deserialize::default(), + times_redeemed: Deserialize::default(), + valid: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount_off: self.amount_off?, + applies_to: self.applies_to.take()?, + created: self.created?, + currency: self.currency?, + currency_options: self.currency_options.take()?, + duration: self.duration?, + duration_in_months: self.duration_in_months?, + id: self.id.take()?, + livemode: self.livemode?, + max_redemptions: self.max_redemptions?, + metadata: self.metadata.take()?, + name: self.name.take()?, + object: self.object?, + percent_off: self.percent_off?, + redeem_by: self.redeem_by?, + times_redeemed: self.times_redeemed?, + valid: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum CouponObject { + Coupon, +} +impl CouponObject { + pub fn as_str(self) -> &'static str { + use CouponObject::*; + match self { + Coupon => "coupon", + } + } +} + +impl std::str::FromStr for CouponObject { + type Err = (); + fn from_str(s: &str) -> Result { + use CouponObject::*; + match s { + "coupon" => Ok(Coupon), + _ => Err(()), + } + } +} +impl std::fmt::Display for CouponObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for CouponObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for CouponObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for CouponObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CouponObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CouponObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CouponObject { + fn deserialize>(deserializer: D) -> 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 CouponObject")) + } +} impl stripe_types::Object for Coupon { type Id = stripe_shared::CouponId; fn id(&self) -> &Self::Id { @@ -103,6 +345,22 @@ impl serde::Serialize for CouponDuration { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CouponDuration { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CouponDuration::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CouponDuration); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CouponDuration { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/coupon_applies_to.rs b/generated/stripe_shared/src/coupon_applies_to.rs index ca45f409b..1db817a6f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CouponAppliesTo { /// A list of product IDs this coupon applies to pub products: Vec, } +#[doc(hidden)] +pub struct CouponAppliesToBuilder { + products: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CouponAppliesToBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { products: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { products: self.products.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..37b0c1b70 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct CouponCurrencyOptionBuilder { + amount_off: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CouponCurrencyOptionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount_off: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { amount_off: self.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 { + 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..26a5d757b 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CreditNote { /// The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax. pub amount: i64, @@ -42,6 +44,8 @@ pub struct CreditNote { pub metadata: Option>, /// A unique number that identifies this particular credit note and appears on the PDF of the credit note and its associated invoice. pub number: String, + /// String representing the object's type. Objects of the same type share the same value. + pub object: CreditNoteObject, /// Amount that was credited outside of Stripe. pub out_of_band_amount: Option, /// The link to download the PDF of the credit note. @@ -68,11 +72,325 @@ 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(feature = "serde", serde(rename = "type"))] pub type_: CreditNoteType, /// The time that the credit note was voided. pub voided_at: Option, } +#[doc(hidden)] +pub struct CreditNoteBuilder { + amount: Option, + amount_shipping: Option, + created: Option, + currency: Option, + customer: Option>, + customer_balance_transaction: + Option>>, + discount_amount: Option, + discount_amounts: Option>, + effective_at: Option>, + id: Option, + invoice: Option>, + lines: Option>, + livemode: Option, + memo: Option>, + metadata: Option>>, + number: Option, + object: Option, + out_of_band_amount: Option>, + pdf: Option, + reason: Option>, + refund: Option>>, + shipping_cost: Option>, + status: Option, + subtotal: Option, + subtotal_excluding_tax: Option>, + tax_amounts: Option>, + total: Option, + total_excluding_tax: Option>, + type_: Option, + voided_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CreditNoteBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + amount: self.amount?, + amount_shipping: self.amount_shipping?, + created: self.created?, + currency: self.currency?, + customer: self.customer.take()?, + customer_balance_transaction: self.customer_balance_transaction.take()?, + discount_amount: self.discount_amount?, + discount_amounts: self.discount_amounts.take()?, + effective_at: self.effective_at?, + id: self.id.take()?, + invoice: self.invoice.take()?, + lines: self.lines.take()?, + livemode: self.livemode?, + memo: self.memo.take()?, + metadata: self.metadata.take()?, + number: self.number.take()?, + object: self.object?, + out_of_band_amount: self.out_of_band_amount?, + pdf: self.pdf.take()?, + reason: self.reason?, + refund: self.refund.take()?, + shipping_cost: self.shipping_cost.take()?, + status: self.status?, + subtotal: self.subtotal?, + subtotal_excluding_tax: self.subtotal_excluding_tax?, + tax_amounts: self.tax_amounts.take()?, + total: self.total?, + total_excluding_tax: self.total_excluding_tax?, + type_: self.type_?, + voided_at: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum CreditNoteObject { + CreditNote, +} +impl CreditNoteObject { + pub fn as_str(self) -> &'static str { + use CreditNoteObject::*; + match self { + CreditNote => "credit_note", + } + } +} + +impl std::str::FromStr for CreditNoteObject { + type Err = (); + fn from_str(s: &str) -> Result { + use CreditNoteObject::*; + match s { + "credit_note" => Ok(CreditNote), + _ => Err(()), + } + } +} +impl std::fmt::Display for CreditNoteObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for CreditNoteObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for CreditNoteObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for CreditNoteObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CreditNoteObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CreditNoteObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreditNoteObject { + fn deserialize>(deserializer: D) -> 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 CreditNoteObject")) + } +} /// 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)] @@ -112,6 +430,7 @@ impl std::fmt::Debug for CreditNoteStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CreditNoteStatus { fn serialize(&self, serializer: S) -> Result where @@ -120,6 +439,22 @@ impl serde::Serialize for CreditNoteStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CreditNoteStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CreditNoteStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CreditNoteStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CreditNoteStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -168,6 +503,7 @@ impl std::fmt::Debug for CreditNoteType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CreditNoteType { fn serialize(&self, serializer: S) -> Result where @@ -176,6 +512,22 @@ impl serde::Serialize for CreditNoteType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CreditNoteType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CreditNoteType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CreditNoteType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CreditNoteType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -241,6 +593,22 @@ impl serde::Serialize for CreditNoteReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CreditNoteReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CreditNoteReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CreditNoteReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CreditNoteReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/credit_note_line_item.rs b/generated/stripe_shared/src/credit_note_line_item.rs index b35f9e106..c68697bc6 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,10 +18,11 @@ 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, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: CreditNoteLineItemObject, /// The number of units of product being credited. pub quantity: Option, /// The amount of tax calculated per tax rate for this line item @@ -28,7 +31,7 @@ pub struct CreditNoteLineItem { pub tax_rates: Vec, /// 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(feature = "serde", serde(rename = "type"))] pub type_: CreditNoteLineItemType, /// The cost of each unit of product being credited. pub unit_amount: Option, @@ -37,6 +40,247 @@ 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, } +#[doc(hidden)] +pub struct CreditNoteLineItemBuilder { + amount: Option, + amount_excluding_tax: Option>, + description: Option>, + discount_amount: Option, + discount_amounts: Option>, + id: Option, + invoice_line_item: Option>, + livemode: Option, + object: Option, + quantity: Option>, + tax_amounts: Option>, + tax_rates: Option>, + type_: Option, + unit_amount: Option>, + unit_amount_decimal: Option>, + unit_amount_excluding_tax: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CreditNoteLineItemBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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) + } + + _ => ::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(), + object: 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 { + Some(Self::Out { + amount: self.amount?, + amount_excluding_tax: self.amount_excluding_tax?, + description: self.description.take()?, + discount_amount: self.discount_amount?, + discount_amounts: self.discount_amounts.take()?, + id: self.id.take()?, + invoice_line_item: self.invoice_line_item.take()?, + livemode: self.livemode?, + object: self.object?, + quantity: self.quantity?, + tax_amounts: self.tax_amounts.take()?, + tax_rates: self.tax_rates.take()?, + type_: self.type_?, + unit_amount: self.unit_amount?, + unit_amount_decimal: self.unit_amount_decimal.take()?, + unit_amount_excluding_tax: self.unit_amount_excluding_tax.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum CreditNoteLineItemObject { + CreditNoteLineItem, +} +impl CreditNoteLineItemObject { + pub fn as_str(self) -> &'static str { + use CreditNoteLineItemObject::*; + match self { + CreditNoteLineItem => "credit_note_line_item", + } + } +} + +impl std::str::FromStr for CreditNoteLineItemObject { + type Err = (); + fn from_str(s: &str) -> Result { + use CreditNoteLineItemObject::*; + match s { + "credit_note_line_item" => Ok(CreditNoteLineItem), + _ => Err(()), + } + } +} +impl std::fmt::Display for CreditNoteLineItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for CreditNoteLineItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for CreditNoteLineItemObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for CreditNoteLineItemObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CreditNoteLineItemObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CreditNoteLineItemObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreditNoteLineItemObject { + fn deserialize>(deserializer: D) -> 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 CreditNoteLineItemObject")) + } +} /// 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)] @@ -76,6 +320,7 @@ impl std::fmt::Debug for CreditNoteLineItemType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CreditNoteLineItemType { fn serialize(&self, serializer: S) -> Result where @@ -84,6 +329,22 @@ impl serde::Serialize for CreditNoteLineItemType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CreditNoteLineItemType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CreditNoteLineItemType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CreditNoteLineItemType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CreditNoteLineItemType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/credit_note_tax_amount.rs b/generated/stripe_shared/src/credit_note_tax_amount.rs index 6a78ae397..8e0f3344c 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CreditNoteTaxAmount { /// The amount, in cents (or local equivalent), of the tax. pub amount: i64, @@ -12,6 +14,116 @@ pub struct CreditNoteTaxAmount { /// The amount on which tax is calculated, in cents (or local equivalent). pub taxable_amount: Option, } +#[doc(hidden)] +pub struct CreditNoteTaxAmountBuilder { + amount: Option, + inclusive: Option, + tax_rate: Option>, + taxability_reason: Option>, + taxable_amount: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CreditNoteTaxAmountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount: self.amount?, + inclusive: self.inclusive?, + tax_rate: self.tax_rate.take()?, + taxability_reason: self.taxability_reason?, + taxable_amount: self.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 { + 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)] @@ -94,6 +206,7 @@ impl std::fmt::Debug for CreditNoteTaxAmountTaxabilityReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CreditNoteTaxAmountTaxabilityReason { fn serialize(&self, serializer: S) -> Result where @@ -102,10 +215,29 @@ impl serde::Serialize for CreditNoteTaxAmountTaxabilityReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CreditNoteTaxAmountTaxabilityReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CreditNoteTaxAmountTaxabilityReason::from_str(s) + .unwrap_or(CreditNoteTaxAmountTaxabilityReason::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CreditNoteTaxAmountTaxabilityReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CreditNoteTaxAmountTaxabilityReason { fn deserialize>(deserializer: D) -> Result { 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)) } } diff --git a/generated/stripe_shared/src/currency_option.rs b/generated/stripe_shared/src/currency_option.rs index cee2cd55b..0691c05c4 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -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>, /// 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,120 @@ pub struct CurrencyOption { /// Only set if `billing_scheme=per_unit`. pub unit_amount_decimal: Option, } +#[doc(hidden)] +pub struct CurrencyOptionBuilder { + custom_unit_amount: Option>, + tax_behavior: Option>, + tiers: Option>>, + unit_amount: Option>, + unit_amount_decimal: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CurrencyOptionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + custom_unit_amount: self.custom_unit_amount?, + tax_behavior: self.tax_behavior?, + tiers: self.tiers.take()?, + unit_amount: self.unit_amount?, + unit_amount_decimal: self.unit_amount_decimal.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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`. @@ -63,6 +178,7 @@ impl std::fmt::Debug for CurrencyOptionTaxBehavior { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CurrencyOptionTaxBehavior { fn serialize(&self, serializer: S) -> Result where @@ -71,6 +187,22 @@ impl serde::Serialize for CurrencyOptionTaxBehavior { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CurrencyOptionTaxBehavior { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CurrencyOptionTaxBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CurrencyOptionTaxBehavior); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CurrencyOptionTaxBehavior { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/custom_unit_amount.rs b/generated/stripe_shared/src/custom_unit_amount.rs index 6fd2c00df..4b1c1ee8e 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CustomUnitAmount { /// The maximum unit amount the customer can specify for this item. pub maximum: Option, @@ -8,3 +10,99 @@ pub struct CustomUnitAmount { /// The starting unit amount which can be updated by the customer. pub preset: Option, } +#[doc(hidden)] +pub struct CustomUnitAmountBuilder { + maximum: Option>, + minimum: Option>, + preset: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomUnitAmountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + maximum: Deserialize::default(), + minimum: Deserialize::default(), + preset: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { maximum: self.maximum?, minimum: self.minimum?, preset: self.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 { + 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..8d124c294 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Customer { /// The customer's address. - #[serde(skip_serializing_if = "Option::is_none")] pub address: Option, /// 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, /// 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, /// 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, /// 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, /// An arbitrary string attached to the object. Often useful for displaying to users. pub description: Option, /// Describes the current discount active on the customer, if there is one. - #[serde(skip_serializing_if = "Option::is_none")] pub discount: Option, /// The customer's email address. pub email: Option, @@ -56,52 +52,333 @@ 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>, /// The prefix for the customer used to generate unique invoice numbers. - #[serde(skip_serializing_if = "Option::is_none")] pub invoice_prefix: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub invoice_settings: Option, /// 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>, /// The customer's full name or business name. - #[serde(skip_serializing_if = "Option::is_none")] pub name: Option, /// The suffix of the customer's next invoice number (for example, 0001). - #[serde(skip_serializing_if = "Option::is_none")] pub next_invoice_sequence: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: CustomerObject, /// The customer's phone number. - #[serde(skip_serializing_if = "Option::is_none")] pub phone: Option, /// The customer's preferred locales (languages), ordered by preference. - #[serde(skip_serializing_if = "Option::is_none")] pub preferred_locales: Option>, /// Mailing and shipping address for the customer. Appears on invoices emailed to this customer. pub shipping: Option, /// The customer's payment sources, if any. - #[serde(skip_serializing_if = "Option::is_none")] pub sources: Option>, /// The customer's current subscriptions, if any. - #[serde(skip_serializing_if = "Option::is_none")] pub subscriptions: Option>, - #[serde(skip_serializing_if = "Option::is_none")] pub tax: Option, /// 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, /// The customer's tax IDs. - #[serde(skip_serializing_if = "Option::is_none")] pub tax_ids: Option>, /// ID of the test clock that this customer belongs to. - #[serde(skip_serializing_if = "Option::is_none")] pub test_clock: Option>, } +#[doc(hidden)] +pub struct CustomerBuilder { + address: Option>, + balance: Option>, + cash_balance: Option>, + created: Option, + currency: Option>, + default_source: Option>>, + delinquent: Option>, + description: Option>, + discount: Option>, + email: Option>, + id: Option, + invoice_credit_balance: Option>>, + invoice_prefix: Option>, + invoice_settings: Option>, + livemode: Option, + metadata: Option>>, + name: Option>, + next_invoice_sequence: Option>, + object: Option, + phone: Option>, + preferred_locales: Option>>, + shipping: Option>, + sources: Option>>, + subscriptions: Option>>, + tax: Option>, + tax_exempt: Option>, + tax_ids: Option>>, + test_clock: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + address: self.address.take()?, + balance: self.balance?, + cash_balance: self.cash_balance.take()?, + created: self.created?, + currency: self.currency?, + default_source: self.default_source.take()?, + delinquent: self.delinquent?, + description: self.description.take()?, + discount: self.discount.take()?, + email: self.email.take()?, + id: self.id.take()?, + invoice_credit_balance: self.invoice_credit_balance.take()?, + invoice_prefix: self.invoice_prefix.take()?, + invoice_settings: self.invoice_settings.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + name: self.name.take()?, + next_invoice_sequence: self.next_invoice_sequence?, + object: self.object?, + phone: self.phone.take()?, + preferred_locales: self.preferred_locales.take()?, + shipping: self.shipping.take()?, + sources: self.sources.take()?, + subscriptions: self.subscriptions.take()?, + tax: self.tax.take()?, + tax_exempt: self.tax_exempt?, + tax_ids: self.tax_ids.take()?, + test_clock: self.test_clock.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?) + } + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum CustomerObject { + Customer, +} +impl CustomerObject { + pub fn as_str(self) -> &'static str { + use CustomerObject::*; + match self { + Customer => "customer", + } + } +} + +impl std::str::FromStr for CustomerObject { + type Err = (); + fn from_str(s: &str) -> Result { + use CustomerObject::*; + match s { + "customer" => Ok(Customer), + _ => Err(()), + } + } +} +impl std::fmt::Display for CustomerObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for CustomerObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for CustomerObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for CustomerObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CustomerObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CustomerObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CustomerObject { + fn deserialize>(deserializer: D) -> 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 CustomerObject")) + } +} impl stripe_types::Object for Customer { type Id = stripe_shared::CustomerId; fn id(&self) -> &Self::Id { @@ -157,6 +434,22 @@ impl serde::Serialize for CustomerTaxExempt { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CustomerTaxExempt { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CustomerTaxExempt::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CustomerTaxExempt); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CustomerTaxExempt { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/customer_acceptance.rs b/generated/stripe_shared/src/customer_acceptance.rs index 237725fe6..e4371ad42 100644 --- a/generated/stripe_shared/src/customer_acceptance.rs +++ b/generated/stripe_shared/src/customer_acceptance.rs @@ -1,15 +1,120 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CustomerAcceptance { /// The time that the customer accepts the mandate. pub accepted_at: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub offline: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub online: Option, /// The mandate includes the type of customer acceptance information, such as: `online` or `offline`. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: CustomerAcceptanceType, } +#[doc(hidden)] +pub struct CustomerAcceptanceBuilder { + accepted_at: Option>, + offline: Option>, + online: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerAcceptanceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + accepted_at: self.accepted_at?, + offline: self.offline?, + online: self.online.take()?, + type_: self.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 { + 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 { @@ -48,6 +153,7 @@ impl std::fmt::Debug for CustomerAcceptanceType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CustomerAcceptanceType { fn serialize(&self, serializer: S) -> Result where @@ -56,6 +162,22 @@ impl serde::Serialize for CustomerAcceptanceType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CustomerAcceptanceType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CustomerAcceptanceType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CustomerAcceptanceType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CustomerAcceptanceType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..4e510ea21 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,111 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct CustomerBalanceCustomerBalanceSettingsBuilder { + reconciliation_mode: Option, + using_merchant_default: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerBalanceCustomerBalanceSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + reconciliation_mode: Deserialize::default(), + using_merchant_default: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + reconciliation_mode: self.reconciliation_mode?, + using_merchant_default: self.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 { + 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 { @@ -43,6 +144,7 @@ impl std::fmt::Debug for CustomerBalanceCustomerBalanceSettingsReconciliationMod f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CustomerBalanceCustomerBalanceSettingsReconciliationMode { fn serialize(&self, serializer: S) -> Result where @@ -51,6 +153,29 @@ impl serde::Serialize for CustomerBalanceCustomerBalanceSettingsReconciliationMo serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CustomerBalanceCustomerBalanceSettingsReconciliationMode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + CustomerBalanceCustomerBalanceSettingsReconciliationMode::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + CustomerBalanceCustomerBalanceSettingsReconciliationMode +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CustomerBalanceCustomerBalanceSettingsReconciliationMode { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..e26fbdf1a 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,114 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// 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, } +#[doc(hidden)] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraftBuilder { + balance_transaction: Option>, + linked_transaction: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option< + CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraft, + >, + builder: CustomerBalanceResourceCashBalanceTransactionResourceAdjustedForOverdraftBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + balance_transaction: Deserialize::default(), + linked_transaction: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + balance_transaction: self.balance_transaction.take()?, + linked_transaction: self.linked_transaction.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..e91ac31a4 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,107 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransactionBuilder { + payment_intent: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option< + CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransaction, + >, + builder: + CustomerBalanceResourceCashBalanceTransactionResourceAppliedToPaymentTransactionBuilder, + } + + impl Visitor + for Place + { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { payment_intent: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { payment_intent: self.payment_intent.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..69050765b 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,95 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransaction { pub bank_transfer: stripe_shared::CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransfer, } +#[doc(hidden)] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionBuilder { + bank_transfer: Option, + +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank_transfer: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { bank_transfer: self.bank_transfer.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..cfa11fc00 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,21 +1,135 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransfer { -#[serde(skip_serializing_if = "Option::is_none")] pub eu_bank_transfer: Option, -#[serde(skip_serializing_if = "Option::is_none")] pub gb_bank_transfer: Option, -#[serde(skip_serializing_if = "Option::is_none")] pub jp_bank_transfer: Option, /// The user-supplied reference field on the bank transfer. pub reference: Option, /// 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")] +#[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType, -#[serde(skip_serializing_if = "Option::is_none")] pub us_bank_transfer: Option, } +#[doc(hidden)] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferBuilder { + eu_bank_transfer: Option>, +gb_bank_transfer: Option>, +jp_bank_transfer: Option>, +reference: Option>, +type_: Option, +us_bank_transfer: Option>, + +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } +} + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferBuilder, +} + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { eu_bank_transfer: self.eu_bank_transfer.take()?, +gb_bank_transfer: self.gb_bank_transfer.take()?, +jp_bank_transfer: self.jp_bank_transfer.take()?, +reference: self.reference.take()?, +type_: self.type_?, +us_bank_transfer: self.us_bank_transfer.take()?, + }) + } +} + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)] @@ -68,11 +182,30 @@ impl std::fmt::Debug for CustomerBalanceResourceCashBalanceTransactionResourceFu f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..41e6059e8 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,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransfer { /// The BIC of the bank of the sender of the funding. @@ -8,3 +10,104 @@ pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactio /// The full name of the sender, as supplied by the sending bank. pub sender_name: Option, } +#[doc(hidden)] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransferBuilder +{ + bic: Option>, + iban_last4: Option>, + sender_name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } +} + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceEuBankTransferBuilder, +} + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bic: Deserialize::default(), +iban_last4: Deserialize::default(), +sender_name: Deserialize::default(), + + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { bic: self.bic.take()?, +iban_last4: self.iban_last4.take()?, +sender_name: self.sender_name.take()?, + }) + } +} + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..764d1a96b 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,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransfer { /// The last 4 digits of the account number of the sender of the funding. @@ -8,3 +10,104 @@ pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactio /// The sort code of the bank of the sender of the funding pub sort_code: Option, } +#[doc(hidden)] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransferBuilder +{ + account_number_last4: Option>, + sender_name: Option>, + sort_code: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } +} + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceGbBankTransferBuilder, +} + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { account_number_last4: self.account_number_last4.take()?, +sender_name: self.sender_name.take()?, +sort_code: self.sort_code.take()?, + }) + } +} + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..26e322fd1 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,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransfer { /// The name of the bank of the sender of the funding. @@ -8,3 +10,104 @@ pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactio /// The full name of the sender, as supplied by the sending bank. pub sender_name: Option, } +#[doc(hidden)] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransferBuilder +{ + sender_bank: Option>, + sender_branch: Option>, + sender_name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } +} + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceJpBankTransferBuilder, +} + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + sender_bank: Deserialize::default(), +sender_branch: Deserialize::default(), +sender_name: Deserialize::default(), + + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { sender_bank: self.sender_bank.take()?, +sender_branch: self.sender_branch.take()?, +sender_name: self.sender_name.take()?, + }) + } +} + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..c7e4e27d0 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,12 +1,109 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransfer { /// The banking network used for this funding. -#[serde(skip_serializing_if = "Option::is_none")] pub network: Option, /// The full name of the sender, as supplied by the sending bank. pub sender_name: Option, } +#[doc(hidden)] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferBuilder { + network: Option>, +sender_name: Option>, + +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } +} + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferBuilder, +} + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + network: Deserialize::default(), +sender_name: Deserialize::default(), + + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { network: self.network?, +sender_name: self.sender_name.take()?, + }) + } +} + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 @@ -51,11 +148,28 @@ impl std::fmt::Debug for CustomerBalanceResourceCashBalanceTransactionResourceFu f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CustomerBalanceResourceCashBalanceTransactionResourceFundedTransactionResourceBankTransferResourceUsBankTransferNetwork { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..22f76b4e3 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,108 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransactionBuilder +{ + refund: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransactionBuilder, +} + + impl Visitor + for Place< + CustomerBalanceResourceCashBalanceTransactionResourceRefundedFromPaymentTransaction, + > + { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + refund: Deserialize::default(), + + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { refund: self.refund.take()?, + }) + } +} + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 index e18d761cb..c58291c36 100644 --- 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 @@ -1,5 +1,100 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceTransferredToBalanceBuilder { + balance_transaction: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for CustomerBalanceResourceCashBalanceTransactionResourceTransferredToBalance { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option< + CustomerBalanceResourceCashBalanceTransactionResourceTransferredToBalance, + >, + builder: CustomerBalanceResourceCashBalanceTransactionResourceTransferredToBalanceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: CustomerBalanceResourceCashBalanceTransactionResourceTransferredToBalanceBuilder::deser_default(), + })) + } + } + + impl MapBuilder + for CustomerBalanceResourceCashBalanceTransactionResourceTransferredToBalanceBuilder + { + type Out = CustomerBalanceResourceCashBalanceTransactionResourceTransferredToBalance; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "balance_transaction" => Deserialize::begin(&mut self.balance_transaction), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { balance_transaction: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { balance_transaction: self.balance_transaction.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for CustomerBalanceResourceCashBalanceTransactionResourceTransferredToBalance { + type Builder = + CustomerBalanceResourceCashBalanceTransactionResourceTransferredToBalanceBuilder; + } + + impl FromValueOpt for CustomerBalanceResourceCashBalanceTransactionResourceTransferredToBalance { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = CustomerBalanceResourceCashBalanceTransactionResourceTransferredToBalanceBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "balance_transaction" => { + b.balance_transaction = Some(FromValueOpt::from_value(v)?) + } + + _ => {} + } + } + b.take_out() + } + } +}; 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..e6d9052b5 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,108 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransactionBuilder +{ + payment_intent: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransactionBuilder, +} + + impl Visitor + for Place< + CustomerBalanceResourceCashBalanceTransactionResourceUnappliedFromPaymentTransaction, + > + { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + payment_intent: Deserialize::default(), + + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { payment_intent: self.payment_intent.take()?, + }) + } +} + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..36619b6ae 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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`. @@ -35,11 +37,233 @@ pub struct CustomerBalanceTransaction { /// 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>, + /// String representing the object's type. Objects of the same type share the same value. + pub object: CustomerBalanceTransactionObject, /// 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(feature = "serde", serde(rename = "type"))] pub type_: CustomerBalanceTransactionType, } +#[doc(hidden)] +pub struct CustomerBalanceTransactionBuilder { + amount: Option, + created: Option, + credit_note: Option>>, + currency: Option, + customer: Option>, + description: Option>, + ending_balance: Option, + id: Option, + invoice: Option>>, + livemode: Option, + metadata: Option>>, + object: Option, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerBalanceTransactionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "type" => Deserialize::begin(&mut self.type_), + + _ => ::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(), + object: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + created: self.created?, + credit_note: self.credit_note.take()?, + currency: self.currency?, + customer: self.customer.take()?, + description: self.description.take()?, + ending_balance: self.ending_balance?, + id: self.id.take()?, + invoice: self.invoice.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + type_: self.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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum CustomerBalanceTransactionObject { + CustomerBalanceTransaction, +} +impl CustomerBalanceTransactionObject { + pub fn as_str(self) -> &'static str { + use CustomerBalanceTransactionObject::*; + match self { + CustomerBalanceTransaction => "customer_balance_transaction", + } + } +} + +impl std::str::FromStr for CustomerBalanceTransactionObject { + type Err = (); + fn from_str(s: &str) -> Result { + use CustomerBalanceTransactionObject::*; + match s { + "customer_balance_transaction" => Ok(CustomerBalanceTransaction), + _ => Err(()), + } + } +} +impl std::fmt::Display for CustomerBalanceTransactionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for CustomerBalanceTransactionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for CustomerBalanceTransactionObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for CustomerBalanceTransactionObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(CustomerBalanceTransactionObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CustomerBalanceTransactionObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CustomerBalanceTransactionObject { + fn deserialize>(deserializer: D) -> 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 CustomerBalanceTransactionObject") + }) + } +} /// 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)] @@ -103,6 +327,7 @@ impl std::fmt::Debug for CustomerBalanceTransactionType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CustomerBalanceTransactionType { fn serialize(&self, serializer: S) -> Result where @@ -111,6 +336,22 @@ impl serde::Serialize for CustomerBalanceTransactionType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CustomerBalanceTransactionType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CustomerBalanceTransactionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CustomerBalanceTransactionType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CustomerBalanceTransactionType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/customer_cash_balance_transaction.rs b/generated/stripe_shared/src/customer_cash_balance_transaction.rs index e65cf7add..0582e1eea 100644 --- a/generated/stripe_shared/src/customer_cash_balance_transaction.rs +++ b/generated/stripe_shared/src/customer_cash_balance_transaction.rs @@ -6,11 +6,11 @@ /// to payments, and refunds to the customer. /// /// For more details see <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CustomerCashBalanceTransaction { -#[serde(skip_serializing_if = "Option::is_none")] pub adjusted_for_overdraft: Option, -#[serde(skip_serializing_if = "Option::is_none")] pub applied_to_payment: Option, /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -22,7 +22,6 @@ pub customer: stripe_types::Expandable, /// 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, /// Unique identifier for the object. pub id: stripe_shared::CustomerCashBalanceTransactionId, @@ -31,18 +30,258 @@ 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")] + /// String representing the object's type. Objects of the same type share the same value. +pub object: CustomerCashBalanceTransactionObject, pub refunded_from_payment: Option, -#[serde(skip_serializing_if = "Option::is_none")] pub transferred_to_balance: Option, /// 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")] +#[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: CustomerCashBalanceTransactionType, -#[serde(skip_serializing_if = "Option::is_none")] pub unapplied_from_payment: Option, +} +#[doc(hidden)] +pub struct CustomerCashBalanceTransactionBuilder { + adjusted_for_overdraft: Option>, +applied_to_payment: Option>, +created: Option, +currency: Option, +customer: Option>, +ending_balance: Option, +funded: Option>, +id: Option, +livemode: Option, +net_amount: Option, +object: Option, +refunded_from_payment: Option>, +transferred_to_balance: Option>, +type_: Option, +unapplied_from_payment: Option>, + +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerCashBalanceTransactionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "refunded_from_payment" => Deserialize::begin(&mut self.refunded_from_payment), + "transferred_to_balance" => Deserialize::begin(&mut self.transferred_to_balance), + "type" => Deserialize::begin(&mut self.type_), + "unapplied_from_payment" => Deserialize::begin(&mut self.unapplied_from_payment), + + _ => ::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(), + object: Deserialize::default(), + refunded_from_payment: Deserialize::default(), + transferred_to_balance: Deserialize::default(), + type_: Deserialize::default(), + unapplied_from_payment: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + adjusted_for_overdraft: self.adjusted_for_overdraft.take()?, + applied_to_payment: self.applied_to_payment.take()?, + created: self.created?, + currency: self.currency?, + customer: self.customer.take()?, + ending_balance: self.ending_balance?, + funded: self.funded.take()?, + id: self.id.take()?, + livemode: self.livemode?, + net_amount: self.net_amount?, + object: self.object?, + refunded_from_payment: self.refunded_from_payment.take()?, + transferred_to_balance: self.transferred_to_balance.take()?, + type_: self.type_?, + unapplied_from_payment: self.unapplied_from_payment.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "refunded_from_payment" => { + b.refunded_from_payment = Some(FromValueOpt::from_value(v)?) + } + "transferred_to_balance" => { + b.transferred_to_balance = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum CustomerCashBalanceTransactionObject { + CustomerCashBalanceTransaction, +} +impl CustomerCashBalanceTransactionObject { + pub fn as_str(self) -> &'static str { + use CustomerCashBalanceTransactionObject::*; + match self { + CustomerCashBalanceTransaction => "customer_cash_balance_transaction", + } + } +} + +impl std::str::FromStr for CustomerCashBalanceTransactionObject { + type Err = (); + fn from_str(s: &str) -> Result { + use CustomerCashBalanceTransactionObject::*; + match s { + "customer_cash_balance_transaction" => Ok(CustomerCashBalanceTransaction), + _ => Err(()), + } + } +} +impl std::fmt::Display for CustomerCashBalanceTransactionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for CustomerCashBalanceTransactionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for CustomerCashBalanceTransactionObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for CustomerCashBalanceTransactionObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(CustomerCashBalanceTransactionObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CustomerCashBalanceTransactionObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CustomerCashBalanceTransactionObject { + fn deserialize>(deserializer: D) -> 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 CustomerCashBalanceTransactionObject") + }) + } } /// The type of the cash balance transaction. /// New types may be added in future. @@ -105,6 +344,7 @@ impl std::fmt::Debug for CustomerCashBalanceTransactionType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CustomerCashBalanceTransactionType { fn serialize(&self, serializer: S) -> Result where @@ -113,6 +353,23 @@ impl serde::Serialize for CustomerCashBalanceTransactionType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CustomerCashBalanceTransactionType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(CustomerCashBalanceTransactionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CustomerCashBalanceTransactionType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CustomerCashBalanceTransactionType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/customer_tax.rs b/generated/stripe_shared/src/customer_tax.rs index a4698f5dd..c1f61157e 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CustomerTax { /// Surfaces if automatic tax computation is possible given the current customer location information. pub automatic_tax: CustomerTaxAutomaticTax, @@ -7,6 +9,106 @@ pub struct CustomerTax { /// The customer's location as identified by Stripe Tax. pub location: Option, } +#[doc(hidden)] +pub struct CustomerTaxBuilder { + automatic_tax: Option, + ip_address: Option>, + location: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerTaxBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + automatic_tax: Deserialize::default(), + ip_address: Deserialize::default(), + location: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + automatic_tax: self.automatic_tax?, + ip_address: self.ip_address.take()?, + location: self.location.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -51,6 +153,7 @@ impl std::fmt::Debug for CustomerTaxAutomaticTax { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CustomerTaxAutomaticTax { fn serialize(&self, serializer: S) -> Result where @@ -59,6 +162,22 @@ impl serde::Serialize for CustomerTaxAutomaticTax { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CustomerTaxAutomaticTax { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CustomerTaxAutomaticTax::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CustomerTaxAutomaticTax); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CustomerTaxAutomaticTax { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/customer_tax_location.rs b/generated/stripe_shared/src/customer_tax_location.rs index b99613984..51d53fbf2 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct CustomerTaxLocation { /// The customer's country as identified by Stripe Tax. pub country: String, @@ -7,6 +9,106 @@ pub struct CustomerTaxLocation { /// The customer's state, county, province, or region as identified by Stripe Tax. pub state: Option, } +#[doc(hidden)] +pub struct CustomerTaxLocationBuilder { + country: Option, + source: Option, + state: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: CustomerTaxLocationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + country: Deserialize::default(), + source: Deserialize::default(), + state: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + country: self.country.take()?, + source: self.source?, + state: self.state.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -51,6 +153,7 @@ impl std::fmt::Debug for CustomerTaxLocationSource { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for CustomerTaxLocationSource { fn serialize(&self, serializer: S) -> Result where @@ -59,6 +162,22 @@ impl serde::Serialize for CustomerTaxLocationSource { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for CustomerTaxLocationSource { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(CustomerTaxLocationSource::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(CustomerTaxLocationSource); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for CustomerTaxLocationSource { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/deleted_account.rs b/generated/stripe_shared/src/deleted_account.rs index 7f3c8435a..5f0087a92 100644 --- a/generated/stripe_shared/src/deleted_account.rs +++ b/generated/stripe_shared/src/deleted_account.rs @@ -1,9 +1,178 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedAccountObject, +} +#[doc(hidden)] +pub struct DeletedAccountBuilder { + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deleted: self.deleted?, id: self.id.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedAccountObject { + Account, +} +impl DeletedAccountObject { + pub fn as_str(self) -> &'static str { + use DeletedAccountObject::*; + match self { + Account => "account", + } + } +} + +impl std::str::FromStr for DeletedAccountObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedAccountObject::*; + match s { + "account" => Ok(Account), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedAccountObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedAccountObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedAccountObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedAccountObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DeletedAccountObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedAccountObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedAccountObject { + fn deserialize>(deserializer: D) -> 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 DeletedAccountObject")) + } } impl stripe_types::Object for DeletedAccount { type Id = stripe_shared::AccountId; diff --git a/generated/stripe_shared/src/deleted_bank_account.rs b/generated/stripe_shared/src/deleted_bank_account.rs index 2c8093965..cc63aee20 100644 --- a/generated/stripe_shared/src/deleted_bank_account.rs +++ b/generated/stripe_shared/src/deleted_bank_account.rs @@ -1,12 +1,189 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_shared::BankAccountId, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedBankAccountObject, +} +#[doc(hidden)] +pub struct DeletedBankAccountBuilder { + currency: Option>, + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedBankAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + currency: Deserialize::default(), + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + currency: self.currency?, + deleted: self.deleted?, + id: self.id.take()?, + object: self.object?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedBankAccountObject { + BankAccount, +} +impl DeletedBankAccountObject { + pub fn as_str(self) -> &'static str { + use DeletedBankAccountObject::*; + match self { + BankAccount => "bank_account", + } + } +} + +impl std::str::FromStr for DeletedBankAccountObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedBankAccountObject::*; + match s { + "bank_account" => Ok(BankAccount), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedBankAccountObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedBankAccountObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedBankAccountObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedBankAccountObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DeletedBankAccountObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedBankAccountObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedBankAccountObject { + fn deserialize>(deserializer: D) -> 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 DeletedBankAccountObject")) + } } impl stripe_types::Object for DeletedBankAccount { type Id = stripe_shared::BankAccountId; diff --git a/generated/stripe_shared/src/deleted_card.rs b/generated/stripe_shared/src/deleted_card.rs index e430a17aa..1b1ca118c 100644 --- a/generated/stripe_shared/src/deleted_card.rs +++ b/generated/stripe_shared/src/deleted_card.rs @@ -1,12 +1,189 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// Always true for a deleted object + #[allow(dead_code)] deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. pub id: stripe_shared::CardId, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedCardObject, +} +#[doc(hidden)] +pub struct DeletedCardBuilder { + currency: Option>, + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedCardBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + currency: Deserialize::default(), + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + currency: self.currency?, + deleted: self.deleted?, + id: self.id.take()?, + object: self.object?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedCardObject { + Card, +} +impl DeletedCardObject { + pub fn as_str(self) -> &'static str { + use DeletedCardObject::*; + match self { + Card => "card", + } + } +} + +impl std::str::FromStr for DeletedCardObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedCardObject::*; + match s { + "card" => Ok(Card), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedCardObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedCardObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedCardObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedCardObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DeletedCardObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedCardObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedCardObject { + fn deserialize>(deserializer: D) -> 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 DeletedCardObject")) + } } impl stripe_types::Object for DeletedCard { type Id = stripe_shared::CardId; diff --git a/generated/stripe_shared/src/deleted_coupon.rs b/generated/stripe_shared/src/deleted_coupon.rs index f179913b1..41a001f12 100644 --- a/generated/stripe_shared/src/deleted_coupon.rs +++ b/generated/stripe_shared/src/deleted_coupon.rs @@ -1,9 +1,178 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedCouponObject, +} +#[doc(hidden)] +pub struct DeletedCouponBuilder { + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedCouponBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deleted: self.deleted?, id: self.id.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedCouponObject { + Coupon, +} +impl DeletedCouponObject { + pub fn as_str(self) -> &'static str { + use DeletedCouponObject::*; + match self { + Coupon => "coupon", + } + } +} + +impl std::str::FromStr for DeletedCouponObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedCouponObject::*; + match s { + "coupon" => Ok(Coupon), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedCouponObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedCouponObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedCouponObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedCouponObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DeletedCouponObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedCouponObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedCouponObject { + fn deserialize>(deserializer: D) -> 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 DeletedCouponObject")) + } } impl stripe_types::Object for DeletedCoupon { type Id = stripe_shared::CouponId; diff --git a/generated/stripe_shared/src/deleted_customer.rs b/generated/stripe_shared/src/deleted_customer.rs index 96058aab1..b006c142c 100644 --- a/generated/stripe_shared/src/deleted_customer.rs +++ b/generated/stripe_shared/src/deleted_customer.rs @@ -1,9 +1,178 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedCustomerObject, +} +#[doc(hidden)] +pub struct DeletedCustomerBuilder { + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedCustomerBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deleted: self.deleted?, id: self.id.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedCustomerObject { + Customer, +} +impl DeletedCustomerObject { + pub fn as_str(self) -> &'static str { + use DeletedCustomerObject::*; + match self { + Customer => "customer", + } + } +} + +impl std::str::FromStr for DeletedCustomerObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedCustomerObject::*; + match s { + "customer" => Ok(Customer), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedCustomerObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedCustomerObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedCustomerObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedCustomerObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DeletedCustomerObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedCustomerObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedCustomerObject { + fn deserialize>(deserializer: D) -> 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 DeletedCustomerObject")) + } } impl stripe_types::Object for DeletedCustomer { type Id = stripe_shared::CustomerId; diff --git a/generated/stripe_shared/src/deleted_discount.rs b/generated/stripe_shared/src/deleted_discount.rs index a3027a163..40ef3f87b 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, /// 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. @@ -16,6 +19,8 @@ pub struct DeletedDiscount { pub invoice: Option, /// The invoice item `id` (or invoice line item `id` for invoice line items of type='subscription') that the discount's coupon was applied to, if it was applied directly to a particular invoice item or invoice line item. pub invoice_item: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedDiscountObject, /// The promotion code applied to create this discount. pub promotion_code: Option>, /// Date that the coupon was applied. @@ -23,6 +28,214 @@ pub struct DeletedDiscount { /// The subscription that this coupon is applied to, if it is applied to a particular subscription. pub subscription: Option, } +#[doc(hidden)] +pub struct DeletedDiscountBuilder { + checkout_session: Option>, + coupon: Option, + customer: Option>>, + deleted: Option, + id: Option, + invoice: Option>, + invoice_item: Option>, + object: Option, + promotion_code: Option>>, + start: Option, + subscription: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedDiscountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "promotion_code" => Deserialize::begin(&mut self.promotion_code), + "start" => Deserialize::begin(&mut self.start), + "subscription" => Deserialize::begin(&mut self.subscription), + + _ => ::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(), + object: Deserialize::default(), + promotion_code: Deserialize::default(), + start: Deserialize::default(), + subscription: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + checkout_session: self.checkout_session.take()?, + coupon: self.coupon.take()?, + customer: self.customer.take()?, + deleted: self.deleted?, + id: self.id.take()?, + invoice: self.invoice.take()?, + invoice_item: self.invoice_item.take()?, + object: self.object?, + promotion_code: self.promotion_code.take()?, + start: self.start?, + subscription: self.subscription.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedDiscountObject { + Discount, +} +impl DeletedDiscountObject { + pub fn as_str(self) -> &'static str { + use DeletedDiscountObject::*; + match self { + Discount => "discount", + } + } +} + +impl std::str::FromStr for DeletedDiscountObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedDiscountObject::*; + match s { + "discount" => Ok(Discount), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedDiscountObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedDiscountObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedDiscountObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedDiscountObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DeletedDiscountObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedDiscountObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedDiscountObject { + fn deserialize>(deserializer: D) -> 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 DeletedDiscountObject")) + } +} 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..cafeb061d 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(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(tag = "object"))] pub enum DeletedExternalAccount { - #[serde(rename = "bank_account")] + #[cfg_attr(feature = "serde", serde(rename = "bank_account"))] DeletedBankAccount(stripe_shared::DeletedBankAccount), - #[serde(rename = "card")] + #[cfg_attr(feature = "serde", serde(rename = "card"))] DeletedCard(stripe_shared::DeletedCard), } + +#[derive(Default)] +pub struct DeletedExternalAccountBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +const _: () = { + use 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, + builder: DeletedExternalAccountBuilder, + } + + impl Deserialize for DeletedExternalAccount { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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 { + 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 { + 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..42a162707 100644 --- a/generated/stripe_shared/src/deleted_invoice.rs +++ b/generated/stripe_shared/src/deleted_invoice.rs @@ -1,9 +1,178 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedInvoiceObject, +} +#[doc(hidden)] +pub struct DeletedInvoiceBuilder { + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedInvoiceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deleted: self.deleted?, id: self.id.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedInvoiceObject { + Invoice, +} +impl DeletedInvoiceObject { + pub fn as_str(self) -> &'static str { + use DeletedInvoiceObject::*; + match self { + Invoice => "invoice", + } + } +} + +impl std::str::FromStr for DeletedInvoiceObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedInvoiceObject::*; + match s { + "invoice" => Ok(Invoice), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedInvoiceObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedInvoiceObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedInvoiceObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedInvoiceObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DeletedInvoiceObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedInvoiceObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedInvoiceObject { + fn deserialize>(deserializer: D) -> 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 DeletedInvoiceObject")) + } } impl stripe_types::Object for DeletedInvoice { type Id = stripe_shared::InvoiceId; diff --git a/generated/stripe_shared/src/deleted_invoiceitem.rs b/generated/stripe_shared/src/deleted_invoiceitem.rs index bcaf0face..655fde9da 100644 --- a/generated/stripe_shared/src/deleted_invoiceitem.rs +++ b/generated/stripe_shared/src/deleted_invoiceitem.rs @@ -1,9 +1,178 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedInvoiceitemObject, +} +#[doc(hidden)] +pub struct DeletedInvoiceitemBuilder { + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedInvoiceitemBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deleted: self.deleted?, id: self.id.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedInvoiceitemObject { + Invoiceitem, +} +impl DeletedInvoiceitemObject { + pub fn as_str(self) -> &'static str { + use DeletedInvoiceitemObject::*; + match self { + Invoiceitem => "invoiceitem", + } + } +} + +impl std::str::FromStr for DeletedInvoiceitemObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedInvoiceitemObject::*; + match s { + "invoiceitem" => Ok(Invoiceitem), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedInvoiceitemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedInvoiceitemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedInvoiceitemObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedInvoiceitemObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DeletedInvoiceitemObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedInvoiceitemObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedInvoiceitemObject { + fn deserialize>(deserializer: D) -> 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 DeletedInvoiceitemObject")) + } } impl stripe_types::Object for DeletedInvoiceitem { type Id = stripe_shared::InvoiceItemId; diff --git a/generated/stripe_shared/src/deleted_payment_source.rs b/generated/stripe_shared/src/deleted_payment_source.rs index a7e02870f..bf1c931a8 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(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(tag = "object"))] pub enum DeletedPaymentSource { - #[serde(rename = "bank_account")] + #[cfg_attr(feature = "serde", serde(rename = "bank_account"))] DeletedBankAccount(stripe_shared::DeletedBankAccount), - #[serde(rename = "card")] + #[cfg_attr(feature = "serde", serde(rename = "card"))] DeletedCard(stripe_shared::DeletedCard), } + +#[derive(Default)] +pub struct DeletedPaymentSourceBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +const _: () = { + use 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, + builder: DeletedPaymentSourceBuilder, + } + + impl Deserialize for DeletedPaymentSource { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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 { + 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 { + 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..d842a1058 100644 --- a/generated/stripe_shared/src/deleted_person.rs +++ b/generated/stripe_shared/src/deleted_person.rs @@ -1,9 +1,178 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedPersonObject, +} +#[doc(hidden)] +pub struct DeletedPersonBuilder { + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedPersonBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deleted: self.deleted?, id: self.id.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedPersonObject { + Person, +} +impl DeletedPersonObject { + pub fn as_str(self) -> &'static str { + use DeletedPersonObject::*; + match self { + Person => "person", + } + } +} + +impl std::str::FromStr for DeletedPersonObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedPersonObject::*; + match s { + "person" => Ok(Person), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedPersonObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedPersonObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedPersonObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedPersonObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DeletedPersonObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedPersonObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedPersonObject { + fn deserialize>(deserializer: D) -> 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 DeletedPersonObject")) + } } impl stripe_types::Object for DeletedPerson { type Id = stripe_shared::PersonId; diff --git a/generated/stripe_shared/src/deleted_plan.rs b/generated/stripe_shared/src/deleted_plan.rs index 0d749aff2..4e7458e40 100644 --- a/generated/stripe_shared/src/deleted_plan.rs +++ b/generated/stripe_shared/src/deleted_plan.rs @@ -1,9 +1,178 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedPlanObject, +} +#[doc(hidden)] +pub struct DeletedPlanBuilder { + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedPlanBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deleted: self.deleted?, id: self.id.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedPlanObject { + Plan, +} +impl DeletedPlanObject { + pub fn as_str(self) -> &'static str { + use DeletedPlanObject::*; + match self { + Plan => "plan", + } + } +} + +impl std::str::FromStr for DeletedPlanObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedPlanObject::*; + match s { + "plan" => Ok(Plan), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedPlanObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedPlanObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedPlanObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedPlanObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DeletedPlanObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedPlanObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedPlanObject { + fn deserialize>(deserializer: D) -> 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 DeletedPlanObject")) + } } impl stripe_types::Object for DeletedPlan { type Id = stripe_shared::PlanId; diff --git a/generated/stripe_shared/src/deleted_product.rs b/generated/stripe_shared/src/deleted_product.rs index 754490d5c..9381b9ddf 100644 --- a/generated/stripe_shared/src/deleted_product.rs +++ b/generated/stripe_shared/src/deleted_product.rs @@ -1,9 +1,178 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedProductObject, +} +#[doc(hidden)] +pub struct DeletedProductBuilder { + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedProductBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deleted: self.deleted?, id: self.id.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedProductObject { + Product, +} +impl DeletedProductObject { + pub fn as_str(self) -> &'static str { + use DeletedProductObject::*; + match self { + Product => "product", + } + } +} + +impl std::str::FromStr for DeletedProductObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedProductObject::*; + match s { + "product" => Ok(Product), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedProductObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedProductObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedProductObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedProductObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DeletedProductObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedProductObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedProductObject { + fn deserialize>(deserializer: D) -> 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 DeletedProductObject")) + } } impl stripe_types::Object for DeletedProduct { type Id = stripe_shared::ProductId; diff --git a/generated/stripe_shared/src/deleted_subscription_item.rs b/generated/stripe_shared/src/deleted_subscription_item.rs index 1fe5b43dd..cb164af42 100644 --- a/generated/stripe_shared/src/deleted_subscription_item.rs +++ b/generated/stripe_shared/src/deleted_subscription_item.rs @@ -1,9 +1,179 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedSubscriptionItemObject, +} +#[doc(hidden)] +pub struct DeletedSubscriptionItemBuilder { + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedSubscriptionItemBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deleted: self.deleted?, id: self.id.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedSubscriptionItemObject { + SubscriptionItem, +} +impl DeletedSubscriptionItemObject { + pub fn as_str(self) -> &'static str { + use DeletedSubscriptionItemObject::*; + match self { + SubscriptionItem => "subscription_item", + } + } +} + +impl std::str::FromStr for DeletedSubscriptionItemObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedSubscriptionItemObject::*; + match s { + "subscription_item" => Ok(SubscriptionItem), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedSubscriptionItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedSubscriptionItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedSubscriptionItemObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedSubscriptionItemObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DeletedSubscriptionItemObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedSubscriptionItemObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedSubscriptionItemObject { + fn deserialize>(deserializer: D) -> 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 DeletedSubscriptionItemObject") + }) + } } impl stripe_types::Object for DeletedSubscriptionItem { type Id = stripe_shared::SubscriptionItemId; diff --git a/generated/stripe_shared/src/deleted_tax_id.rs b/generated/stripe_shared/src/deleted_tax_id.rs index 79bdb8882..c30470c48 100644 --- a/generated/stripe_shared/src/deleted_tax_id.rs +++ b/generated/stripe_shared/src/deleted_tax_id.rs @@ -1,9 +1,178 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedTaxIdObject, +} +#[doc(hidden)] +pub struct DeletedTaxIdBuilder { + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedTaxIdBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deleted: self.deleted?, id: self.id.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedTaxIdObject { + TaxId, +} +impl DeletedTaxIdObject { + pub fn as_str(self) -> &'static str { + use DeletedTaxIdObject::*; + match self { + TaxId => "tax_id", + } + } +} + +impl std::str::FromStr for DeletedTaxIdObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedTaxIdObject::*; + match s { + "tax_id" => Ok(TaxId), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedTaxIdObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedTaxIdObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedTaxIdObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedTaxIdObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DeletedTaxIdObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedTaxIdObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedTaxIdObject { + fn deserialize>(deserializer: D) -> 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 DeletedTaxIdObject")) + } } impl stripe_types::Object for DeletedTaxId { type Id = stripe_shared::TaxIdId; 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..56741cd69 100644 --- a/generated/stripe_shared/src/deleted_test_helpers_test_clock.rs +++ b/generated/stripe_shared/src/deleted_test_helpers_test_clock.rs @@ -1,9 +1,180 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedTestHelpersTestClockObject, +} +#[doc(hidden)] +pub struct DeletedTestHelpersTestClockBuilder { + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedTestHelpersTestClockBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deleted: self.deleted?, id: self.id.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedTestHelpersTestClockObject { + TestHelpersTestClock, +} +impl DeletedTestHelpersTestClockObject { + pub fn as_str(self) -> &'static str { + use DeletedTestHelpersTestClockObject::*; + match self { + TestHelpersTestClock => "test_helpers.test_clock", + } + } +} + +impl std::str::FromStr for DeletedTestHelpersTestClockObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedTestHelpersTestClockObject::*; + match s { + "test_helpers.test_clock" => Ok(TestHelpersTestClock), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedTestHelpersTestClockObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedTestHelpersTestClockObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedTestHelpersTestClockObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedTestHelpersTestClockObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(DeletedTestHelpersTestClockObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedTestHelpersTestClockObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedTestHelpersTestClockObject { + fn deserialize>(deserializer: D) -> 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 DeletedTestHelpersTestClockObject") + }) + } } impl stripe_types::Object for DeletedTestHelpersTestClock { type Id = stripe_shared::TestHelpersTestClockId; diff --git a/generated/stripe_shared/src/destination_details_unimplemented.rs b/generated/stripe_shared/src/destination_details_unimplemented.rs index 0c49c86d1..4af3db77d 100644 --- a/generated/stripe_shared/src/destination_details_unimplemented.rs +++ b/generated/stripe_shared/src/destination_details_unimplemented.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct DestinationDetailsUnimplemented {} +#[doc(hidden)] +pub struct DestinationDetailsUnimplementedBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for DestinationDetailsUnimplemented { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DestinationDetailsUnimplementedBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: DestinationDetailsUnimplementedBuilder::deser_default(), + })) + } + } + + impl MapBuilder for DestinationDetailsUnimplementedBuilder { + type Out = DestinationDetailsUnimplemented; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 DestinationDetailsUnimplemented { + type Builder = DestinationDetailsUnimplementedBuilder; + } + + impl FromValueOpt for DestinationDetailsUnimplemented { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = DestinationDetailsUnimplementedBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/discount.rs b/generated/stripe_shared/src/discount.rs index 09db8a753..f6ddb3a01 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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. @@ -23,6 +25,8 @@ pub struct Discount { pub invoice: Option, /// The invoice item `id` (or invoice line item `id` for invoice line items of type='subscription') that the discount's coupon was applied to, if it was applied directly to a particular invoice item or invoice line item. pub invoice_item: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DiscountObject, /// The promotion code applied to create this discount. pub promotion_code: Option>, /// Date that the coupon was applied. @@ -30,6 +34,210 @@ pub struct Discount { /// The subscription that this coupon is applied to, if it is applied to a particular subscription. pub subscription: Option, } +#[doc(hidden)] +pub struct DiscountBuilder { + checkout_session: Option>, + coupon: Option, + customer: Option>>, + end: Option>, + id: Option, + invoice: Option>, + invoice_item: Option>, + object: Option, + promotion_code: Option>>, + start: Option, + subscription: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DiscountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "promotion_code" => Deserialize::begin(&mut self.promotion_code), + "start" => Deserialize::begin(&mut self.start), + "subscription" => Deserialize::begin(&mut self.subscription), + + _ => ::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(), + object: Deserialize::default(), + promotion_code: Deserialize::default(), + start: Deserialize::default(), + subscription: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + checkout_session: self.checkout_session.take()?, + coupon: self.coupon.take()?, + customer: self.customer.take()?, + end: self.end?, + id: self.id.take()?, + invoice: self.invoice.take()?, + invoice_item: self.invoice_item.take()?, + object: self.object?, + promotion_code: self.promotion_code.take()?, + start: self.start?, + subscription: self.subscription.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DiscountObject { + Discount, +} +impl DiscountObject { + pub fn as_str(self) -> &'static str { + use DiscountObject::*; + match self { + Discount => "discount", + } + } +} + +impl std::str::FromStr for DiscountObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DiscountObject::*; + match s { + "discount" => Ok(Discount), + _ => Err(()), + } + } +} +impl std::fmt::Display for DiscountObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DiscountObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DiscountObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DiscountObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DiscountObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DiscountObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DiscountObject { + fn deserialize>(deserializer: D) -> 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 DiscountObject")) + } +} 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..b1f5a8de6 100644 --- a/generated/stripe_shared/src/discounts_resource_discount_amount.rs +++ b/generated/stripe_shared/src/discounts_resource_discount_amount.rs @@ -1,7 +1,98 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct DiscountsResourceDiscountAmountBuilder { + amount: Option, + discount: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DiscountsResourceDiscountAmountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), discount: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { amount: self.amount?, discount: self.discount.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..d9d7fc40e 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,11 @@ pub struct Dispute { /// This can be useful for storing additional information about the object in a structured format. pub metadata: std::collections::HashMap, /// Network-dependent reason code for the dispute. - #[serde(skip_serializing_if = "Option::is_none")] pub network_reason_code: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DisputeObject, /// ID of the PaymentIntent that's disputed. pub payment_intent: Option>, - #[serde(skip_serializing_if = "Option::is_none")] pub payment_method_details: Option, /// 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 +48,248 @@ pub struct Dispute { /// Possible values are `warning_needs_response`, `warning_under_review`, `warning_closed`, `needs_response`, `under_review`, `won`, or `lost`. pub status: DisputeStatus, } +#[doc(hidden)] +pub struct DisputeBuilder { + amount: Option, + balance_transactions: Option>, + charge: Option>, + created: Option, + currency: Option, + evidence: Option, + evidence_details: Option, + id: Option, + is_charge_refundable: Option, + livemode: Option, + metadata: Option>, + network_reason_code: Option>, + object: Option, + payment_intent: Option>>, + payment_method_details: Option>, + reason: Option, + status: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DisputeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: Deserialize::default(), + payment_intent: Deserialize::default(), + payment_method_details: Deserialize::default(), + reason: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + balance_transactions: self.balance_transactions.take()?, + charge: self.charge.take()?, + created: self.created?, + currency: self.currency?, + evidence: self.evidence.take()?, + evidence_details: self.evidence_details?, + id: self.id.take()?, + is_charge_refundable: self.is_charge_refundable?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + network_reason_code: self.network_reason_code.take()?, + object: self.object?, + payment_intent: self.payment_intent.take()?, + payment_method_details: self.payment_method_details.take()?, + reason: self.reason.take()?, + status: self.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 { + 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)?) + } + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DisputeObject { + Dispute, +} +impl DisputeObject { + pub fn as_str(self) -> &'static str { + use DisputeObject::*; + match self { + Dispute => "dispute", + } + } +} + +impl std::str::FromStr for DisputeObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DisputeObject::*; + match s { + "dispute" => Ok(Dispute), + _ => Err(()), + } + } +} +impl std::fmt::Display for DisputeObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DisputeObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DisputeObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DisputeObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DisputeObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DisputeObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DisputeObject { + fn deserialize>(deserializer: D) -> 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 DisputeObject")) + } +} /// 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)] @@ -100,6 +344,7 @@ impl std::fmt::Debug for DisputeStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for DisputeStatus { fn serialize(&self, serializer: S) -> Result where @@ -108,6 +353,22 @@ impl serde::Serialize for DisputeStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for DisputeStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DisputeStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DisputeStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for DisputeStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/dispute_evidence.rs b/generated/stripe_shared/src/dispute_evidence.rs index 9437e4a8f..f7fe16f0a 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 <>. -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,273 @@ pub struct DisputeEvidence { /// Any additional evidence or statements. pub uncategorized_text: Option, } +#[doc(hidden)] +pub struct DisputeEvidenceBuilder { + access_activity_log: Option>, + billing_address: Option>, + cancellation_policy: Option>>, + cancellation_policy_disclosure: Option>, + cancellation_rebuttal: Option>, + customer_communication: Option>>, + customer_email_address: Option>, + customer_name: Option>, + customer_purchase_ip: Option>, + customer_signature: Option>>, + duplicate_charge_documentation: Option>>, + duplicate_charge_explanation: Option>, + duplicate_charge_id: Option>, + product_description: Option>, + receipt: Option>>, + refund_policy: Option>>, + refund_policy_disclosure: Option>, + refund_refusal_explanation: Option>, + service_date: Option>, + service_documentation: Option>>, + shipping_address: Option>, + shipping_carrier: Option>, + shipping_date: Option>, + shipping_documentation: Option>>, + shipping_tracking_number: Option>, + uncategorized_file: Option>>, + uncategorized_text: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DisputeEvidenceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + access_activity_log: self.access_activity_log.take()?, + billing_address: self.billing_address.take()?, + cancellation_policy: self.cancellation_policy.take()?, + cancellation_policy_disclosure: self.cancellation_policy_disclosure.take()?, + cancellation_rebuttal: self.cancellation_rebuttal.take()?, + customer_communication: self.customer_communication.take()?, + customer_email_address: self.customer_email_address.take()?, + customer_name: self.customer_name.take()?, + customer_purchase_ip: self.customer_purchase_ip.take()?, + customer_signature: self.customer_signature.take()?, + duplicate_charge_documentation: self.duplicate_charge_documentation.take()?, + duplicate_charge_explanation: self.duplicate_charge_explanation.take()?, + duplicate_charge_id: self.duplicate_charge_id.take()?, + product_description: self.product_description.take()?, + receipt: self.receipt.take()?, + refund_policy: self.refund_policy.take()?, + refund_policy_disclosure: self.refund_policy_disclosure.take()?, + refund_refusal_explanation: self.refund_refusal_explanation.take()?, + service_date: self.service_date.take()?, + service_documentation: self.service_documentation.take()?, + shipping_address: self.shipping_address.take()?, + shipping_carrier: self.shipping_carrier.take()?, + shipping_date: self.shipping_date.take()?, + shipping_documentation: self.shipping_documentation.take()?, + shipping_tracking_number: self.shipping_tracking_number.take()?, + uncategorized_file: self.uncategorized_file.take()?, + uncategorized_text: self.uncategorized_text.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..77fabb7b7 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,108 @@ pub struct DisputeEvidenceDetails { /// The number of times evidence has been submitted. Typically, you may only submit evidence once. pub submission_count: u64, } +#[doc(hidden)] +pub struct DisputeEvidenceDetailsBuilder { + due_by: Option>, + has_evidence: Option, + past_due: Option, + submission_count: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DisputeEvidenceDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + due_by: self.due_by?, + has_evidence: self.has_evidence?, + past_due: self.past_due?, + submission_count: self.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 { + 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..8a46fca1a 100644 --- a/generated/stripe_shared/src/dispute_payment_method_details.rs +++ b/generated/stripe_shared/src/dispute_payment_method_details.rs @@ -1,11 +1,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct DisputePaymentMethodDetails { /// Card specific dispute details. pub card: Option, /// Payment method type. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: DisputePaymentMethodDetailsType, } +#[doc(hidden)] +pub struct DisputePaymentMethodDetailsBuilder { + card: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DisputePaymentMethodDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { card: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { card: self.card.take()?, type_: self.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 { + 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 { @@ -41,6 +132,7 @@ impl std::fmt::Debug for DisputePaymentMethodDetailsType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for DisputePaymentMethodDetailsType { fn serialize(&self, serializer: S) -> Result where @@ -49,6 +141,23 @@ impl serde::Serialize for DisputePaymentMethodDetailsType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for DisputePaymentMethodDetailsType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(DisputePaymentMethodDetailsType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DisputePaymentMethodDetailsType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for DisputePaymentMethodDetailsType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..ed7a63e61 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct DisputePaymentMethodDetailsCard { /// Card brand. /// Can be `amex`, `diners`, `discover`, `eftpos_au`, `jcb`, `mastercard`, `unionpay`, `visa`, or `unknown`. @@ -7,3 +9,97 @@ 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, } +#[doc(hidden)] +pub struct DisputePaymentMethodDetailsCardBuilder { + brand: Option, + network_reason_code: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DisputePaymentMethodDetailsCardBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { brand: Deserialize::default(), network_reason_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + brand: self.brand.take()?, + network_reason_code: self.network_reason_code.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..1e64322d9 100644 --- a/generated/stripe_shared/src/email_sent.rs +++ b/generated/stripe_shared/src/email_sent.rs @@ -1,7 +1,98 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct EmailSentBuilder { + email_sent_at: Option, + email_sent_to: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: EmailSentBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { email_sent_at: Deserialize::default(), email_sent_to: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + email_sent_at: self.email_sent_at?, + email_sent_to: self.email_sent_to.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..529d7019c 100644 --- a/generated/stripe_shared/src/error.rs +++ b/generated/stripe_shared/src/error.rs @@ -1,5 +1,90 @@ /// An error response from the Stripe API -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Error { pub error: Box, } +#[doc(hidden)] +pub struct ErrorBuilder { + error: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ErrorBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { error: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { error: self.error.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..ed4be633b 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Event { /// The connected account that originates the event. - #[serde(skip_serializing_if = "Option::is_none")] pub account: Option, /// The Stripe API version used to render `data`. /// This property is populated only for events on or after October 31, 2014. @@ -45,14 +46,215 @@ pub struct Event { pub id: stripe_shared::EventId, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: EventObject, /// Number of webhooks that haven't been successfully delivered (for example, to return a 20x response) to the URLs you specify. pub pending_webhooks: i64, /// Information on the API request that triggers the event. pub request: Option, /// Description of the event (for example, `invoice.created` or `charge.refunded`). - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: EventType, } +#[doc(hidden)] +pub struct EventBuilder { + account: Option>, + api_version: Option>, + created: Option, + data: Option, + id: Option, + livemode: Option, + object: Option, + pending_webhooks: Option, + request: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: EventBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "pending_webhooks" => Deserialize::begin(&mut self.pending_webhooks), + "request" => Deserialize::begin(&mut self.request), + "type" => Deserialize::begin(&mut self.type_), + + _ => ::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(), + object: Deserialize::default(), + pending_webhooks: Deserialize::default(), + request: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account: self.account.take()?, + api_version: self.api_version.take()?, + created: self.created?, + data: self.data.take()?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + pending_webhooks: self.pending_webhooks?, + request: self.request.take()?, + type_: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum EventObject { + Event, +} +impl EventObject { + pub fn as_str(self) -> &'static str { + use EventObject::*; + match self { + Event => "event", + } + } +} + +impl std::str::FromStr for EventObject { + type Err = (); + fn from_str(s: &str) -> Result { + use EventObject::*; + match s { + "event" => Ok(Event), + _ => Err(()), + } + } +} +impl std::fmt::Display for EventObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for EventObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for EventObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for EventObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(EventObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(EventObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for EventObject { + fn deserialize>(deserializer: D) -> 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 EventObject")) + } +} /// Description of the event (for example, `invoice.created` or `charge.refunded`). #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -808,6 +1010,7 @@ impl std::fmt::Debug for EventType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for EventType { fn serialize(&self, serializer: S) -> Result where @@ -816,11 +1019,27 @@ impl serde::Serialize for EventType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for EventType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(EventType::from_str(s).unwrap_or(EventType::Unknown)); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(EventType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for EventType { fn deserialize>(deserializer: D) -> Result { 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)) } } impl stripe_types::Object for Event { diff --git a/generated/stripe_shared/src/external_account.rs b/generated/stripe_shared/src/external_account.rs index 60ea6a327..61ef6eadb 100644 --- a/generated/stripe_shared/src/external_account.rs +++ b/generated/stripe_shared/src/external_account.rs @@ -1,12 +1,97 @@ /// The resource representing a Stripe Polymorphic -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(tag = "object"))] pub enum ExternalAccount { - #[serde(rename = "bank_account")] + #[cfg_attr(feature = "serde", serde(rename = "bank_account"))] BankAccount(stripe_shared::BankAccount), - #[serde(rename = "card")] + #[cfg_attr(feature = "serde", serde(rename = "card"))] Card(stripe_shared::Card), } + +#[derive(Default)] +pub struct ExternalAccountBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +const _: () = { + use 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, + builder: ExternalAccountBuilder, + } + + impl Deserialize for ExternalAccount { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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 { + 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 { + 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..2413df1da 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,110 @@ pub struct ExternalAccountRequirements { /// If verification fails, these fields move to `eventually_due`, `currently_due`, or `past_due`. pub pending_verification: Option>, } +#[doc(hidden)] +pub struct ExternalAccountRequirementsBuilder { + currently_due: Option>>, + errors: Option>>, + past_due: Option>>, + pending_verification: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ExternalAccountRequirementsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + currently_due: self.currently_due.take()?, + errors: self.errors.take()?, + past_due: self.past_due.take()?, + pending_verification: self.pending_verification.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..cbff78d9b 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Fee { /// Amount of the fee, in cents. pub amount: i64, @@ -10,6 +12,113 @@ pub struct Fee { /// An arbitrary string attached to the object. Often useful for displaying to users. pub description: Option, /// Type of the fee, one of: `application_fee`, `stripe_fee` or `tax`. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: String, } +#[doc(hidden)] +pub struct FeeBuilder { + amount: Option, + application: Option>, + currency: Option, + description: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: FeeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + amount: self.amount?, + application: self.application.take()?, + currency: self.currency?, + description: self.description.take()?, + type_: self.type_.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..b5948162c 100644 --- a/generated/stripe_shared/src/file.rs +++ b/generated/stripe_shared/src/file.rs @@ -7,7 +7,9 @@ /// Related guide: [File upload guide](https://stripe.com/docs/file-upload) /// /// For more details see <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct File { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -18,8 +20,9 @@ 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>, + /// String representing the object's type. Objects of the same type share the same value. + pub object: FileObject, /// The [purpose](https://stripe.com/docs/file-upload#uploading-a-file) of the uploaded file. pub purpose: stripe_shared::FilePurpose, /// The size of the file object in bytes. @@ -27,11 +30,215 @@ pub struct File { /// A suitable title for the document. pub title: Option, /// The returned file type (for example, `csv`, `pdf`, `jpg`, or `png`). - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: Option, /// Use your live secret API key to download the file from this URL. pub url: Option, } +#[doc(hidden)] +pub struct FileBuilder { + created: Option, + expires_at: Option>, + filename: Option>, + id: Option, + links: Option>>, + object: Option, + purpose: Option, + size: Option, + title: Option>, + type_: Option>, + url: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: FileBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + created: Deserialize::default(), + expires_at: Deserialize::default(), + filename: Deserialize::default(), + id: Deserialize::default(), + links: Deserialize::default(), + object: Deserialize::default(), + purpose: Deserialize::default(), + size: Deserialize::default(), + title: Deserialize::default(), + type_: Deserialize::default(), + url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + created: self.created?, + expires_at: self.expires_at?, + filename: self.filename.take()?, + id: self.id.take()?, + links: self.links.take()?, + object: self.object?, + purpose: self.purpose?, + size: self.size?, + title: self.title.take()?, + type_: self.type_.take()?, + url: self.url.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum FileObject { + File, +} +impl FileObject { + pub fn as_str(self) -> &'static str { + use FileObject::*; + match self { + File => "file", + } + } +} + +impl std::str::FromStr for FileObject { + type Err = (); + fn from_str(s: &str) -> Result { + use FileObject::*; + match s { + "file" => Ok(File), + _ => Err(()), + } + } +} +impl std::fmt::Display for FileObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for FileObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for FileObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for FileObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(FileObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FileObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for FileObject { + fn deserialize>(deserializer: D) -> 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 FileObject")) + } +} impl stripe_types::Object for File { type Id = stripe_shared::FileId; fn id(&self) -> &Self::Id { @@ -127,10 +334,26 @@ impl serde::Serialize for FilePurpose { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for FilePurpose { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(FilePurpose::from_str(s).unwrap_or(FilePurpose::Unknown)); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FilePurpose); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for FilePurpose { fn deserialize>(deserializer: D) -> Result { 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)) } } diff --git a/generated/stripe_shared/src/file_link.rs b/generated/stripe_shared/src/file_link.rs index 79c569794..a6bd7a00f 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct FileLink { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -20,9 +22,205 @@ pub struct FileLink { /// 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 representing the object's type. Objects of the same type share the same value. + pub object: FileLinkObject, /// The publicly accessible URL to download the file. pub url: Option, } +#[doc(hidden)] +pub struct FileLinkBuilder { + created: Option, + expired: Option, + expires_at: Option>, + file: Option>, + id: Option, + livemode: Option, + metadata: Option>, + object: Option, + url: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: FileLinkBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "url" => Deserialize::begin(&mut self.url), + + _ => ::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(), + object: Deserialize::default(), + url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + created: self.created?, + expired: self.expired?, + expires_at: self.expires_at?, + file: self.file.take()?, + id: self.id.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + url: self.url.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "url" => b.url = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum FileLinkObject { + FileLink, +} +impl FileLinkObject { + pub fn as_str(self) -> &'static str { + use FileLinkObject::*; + match self { + FileLink => "file_link", + } + } +} + +impl std::str::FromStr for FileLinkObject { + type Err = (); + fn from_str(s: &str) -> Result { + use FileLinkObject::*; + match s { + "file_link" => Ok(FileLink), + _ => Err(()), + } + } +} +impl std::fmt::Display for FileLinkObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for FileLinkObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for FileLinkObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for FileLinkObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(FileLinkObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FileLinkObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for FileLinkObject { + fn deserialize>(deserializer: D) -> 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 FileLinkObject")) + } +} 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..1dee71b89 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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. @@ -13,7 +15,119 @@ pub struct FundingInstructions { pub funding_type: FundingInstructionsFundingType, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: FundingInstructionsObject, } +#[doc(hidden)] +pub struct FundingInstructionsBuilder { + bank_transfer: Option, + currency: Option, + funding_type: Option, + livemode: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: FundingInstructionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_transfer: Deserialize::default(), + currency: Deserialize::default(), + funding_type: Deserialize::default(), + livemode: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + bank_transfer: self.bank_transfer.take()?, + currency: self.currency?, + funding_type: self.funding_type?, + livemode: self.livemode?, + object: self.object?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The `funding_type` of the returned instructions #[derive(Copy, Clone, Eq, PartialEq)] pub enum FundingInstructionsFundingType { @@ -49,6 +163,7 @@ impl std::fmt::Debug for FundingInstructionsFundingType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for FundingInstructionsFundingType { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +172,22 @@ impl serde::Serialize for FundingInstructionsFundingType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for FundingInstructionsFundingType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(FundingInstructionsFundingType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FundingInstructionsFundingType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for FundingInstructionsFundingType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -66,3 +197,71 @@ impl<'de> serde::Deserialize<'de> for FundingInstructionsFundingType { }) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum FundingInstructionsObject { + FundingInstructions, +} +impl FundingInstructionsObject { + pub fn as_str(self) -> &'static str { + use FundingInstructionsObject::*; + match self { + FundingInstructions => "funding_instructions", + } + } +} + +impl std::str::FromStr for FundingInstructionsObject { + type Err = (); + fn from_str(s: &str) -> Result { + use FundingInstructionsObject::*; + match s { + "funding_instructions" => Ok(FundingInstructions), + _ => Err(()), + } + } +} +impl std::fmt::Display for FundingInstructionsObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for FundingInstructionsObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for FundingInstructionsObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for FundingInstructionsObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(FundingInstructionsObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FundingInstructionsObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for FundingInstructionsObject { + fn deserialize>(deserializer: D) -> 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 FundingInstructionsObject")) + } +} diff --git a/generated/stripe_shared/src/funding_instructions_bank_transfer.rs b/generated/stripe_shared/src/funding_instructions_bank_transfer.rs index 3556b6569..e9e44661a 100644 --- a/generated/stripe_shared/src/funding_instructions_bank_transfer.rs +++ b/generated/stripe_shared/src/funding_instructions_bank_transfer.rs @@ -1,13 +1,118 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// The bank_transfer type - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: FundingInstructionsBankTransferType, } +#[doc(hidden)] +pub struct FundingInstructionsBankTransferBuilder { + country: Option, + financial_addresses: + Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: FundingInstructionsBankTransferBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + country: Deserialize::default(), + financial_addresses: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + country: self.country.take()?, + financial_addresses: self.financial_addresses.take()?, + type_: self.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 { + 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 { @@ -46,6 +151,7 @@ impl std::fmt::Debug for FundingInstructionsBankTransferType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for FundingInstructionsBankTransferType { fn serialize(&self, serializer: S) -> Result where @@ -54,6 +160,23 @@ impl serde::Serialize for FundingInstructionsBankTransferType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for FundingInstructionsBankTransferType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(FundingInstructionsBankTransferType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FundingInstructionsBankTransferType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for FundingInstructionsBankTransferType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..e879e04a8 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct FundingInstructionsBankTransferAbaRecord { /// The ABA account number pub account_number: String, @@ -8,3 +10,103 @@ pub struct FundingInstructionsBankTransferAbaRecord { /// The ABA routing number pub routing_number: String, } +#[doc(hidden)] +pub struct FundingInstructionsBankTransferAbaRecordBuilder { + account_number: Option, + bank_name: Option, + routing_number: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: FundingInstructionsBankTransferAbaRecordBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_number: Deserialize::default(), + bank_name: Deserialize::default(), + routing_number: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account_number: self.account_number.take()?, + bank_name: self.bank_name.take()?, + routing_number: self.routing_number.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..c4041fab5 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,149 @@ /// FinancialAddresses contain identifying information that resolves to a FinancialAccount. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct FundingInstructionsBankTransferFinancialAddress { - #[serde(skip_serializing_if = "Option::is_none")] pub aba: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub iban: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sort_code: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub spei: Option, /// The payment networks supported by this FinancialAddress - #[serde(skip_serializing_if = "Option::is_none")] pub supported_networks: Option>, - #[serde(skip_serializing_if = "Option::is_none")] pub swift: Option, /// The type of financial address - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: FundingInstructionsBankTransferFinancialAddressType, - #[serde(skip_serializing_if = "Option::is_none")] pub zengin: Option, } +#[doc(hidden)] +pub struct FundingInstructionsBankTransferFinancialAddressBuilder { + aba: Option>, + iban: Option>, + sort_code: Option>, + spei: Option>, + supported_networks: + Option>>, + swift: Option>, + type_: Option, + zengin: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: FundingInstructionsBankTransferFinancialAddressBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + aba: self.aba.take()?, + iban: self.iban.take()?, + sort_code: self.sort_code.take()?, + spei: self.spei.take()?, + supported_networks: self.supported_networks.take()?, + swift: self.swift.take()?, + type_: self.type_?, + zengin: self.zengin.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -77,6 +200,7 @@ impl std::fmt::Debug for FundingInstructionsBankTransferFinancialAddressSupporte f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for FundingInstructionsBankTransferFinancialAddressSupportedNetworks { fn serialize(&self, serializer: S) -> Result where @@ -85,6 +209,29 @@ impl serde::Serialize for FundingInstructionsBankTransferFinancialAddressSupport serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for FundingInstructionsBankTransferFinancialAddressSupportedNetworks { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + FundingInstructionsBankTransferFinancialAddressSupportedNetworks::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + FundingInstructionsBankTransferFinancialAddressSupportedNetworks +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for FundingInstructionsBankTransferFinancialAddressSupportedNetworks { @@ -144,6 +291,7 @@ impl std::fmt::Debug for FundingInstructionsBankTransferFinancialAddressType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for FundingInstructionsBankTransferFinancialAddressType { fn serialize(&self, serializer: S) -> Result where @@ -152,6 +300,25 @@ impl serde::Serialize for FundingInstructionsBankTransferFinancialAddressType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for FundingInstructionsBankTransferFinancialAddressType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + FundingInstructionsBankTransferFinancialAddressType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(FundingInstructionsBankTransferFinancialAddressType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for FundingInstructionsBankTransferFinancialAddressType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..b9deea383 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct FundingInstructionsBankTransferIbanRecord { /// The name of the person or business that owns the bank account pub account_holder_name: String, @@ -10,3 +12,110 @@ pub struct FundingInstructionsBankTransferIbanRecord { /// The IBAN of the account. pub iban: String, } +#[doc(hidden)] +pub struct FundingInstructionsBankTransferIbanRecordBuilder { + account_holder_name: Option, + bic: Option, + country: Option, + iban: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: FundingInstructionsBankTransferIbanRecordBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + account_holder_name: self.account_holder_name.take()?, + bic: self.bic.take()?, + country: self.country.take()?, + iban: self.iban.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..19a4a068c 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct FundingInstructionsBankTransferSortCodeRecord { /// The name of the person or business that owns the bank account pub account_holder_name: String, @@ -8,3 +10,105 @@ pub struct FundingInstructionsBankTransferSortCodeRecord { /// The six-digit sort code pub sort_code: String, } +#[doc(hidden)] +pub struct FundingInstructionsBankTransferSortCodeRecordBuilder { + account_holder_name: Option, + account_number: Option, + sort_code: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: FundingInstructionsBankTransferSortCodeRecordBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + account_holder_name: self.account_holder_name.take()?, + account_number: self.account_number.take()?, + sort_code: self.sort_code.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..b2645ef36 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct FundingInstructionsBankTransferSpeiRecord { /// The three-digit bank code pub bank_code: String, @@ -8,3 +10,103 @@ pub struct FundingInstructionsBankTransferSpeiRecord { /// The CLABE number pub clabe: String, } +#[doc(hidden)] +pub struct FundingInstructionsBankTransferSpeiRecordBuilder { + bank_code: Option, + bank_name: Option, + clabe: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: FundingInstructionsBankTransferSpeiRecordBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_code: Deserialize::default(), + bank_name: Deserialize::default(), + clabe: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + bank_code: self.bank_code.take()?, + bank_name: self.bank_name.take()?, + clabe: self.clabe.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..bee556d13 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct FundingInstructionsBankTransferSwiftRecord { /// The account number pub account_number: String, @@ -8,3 +10,103 @@ pub struct FundingInstructionsBankTransferSwiftRecord { /// The SWIFT code pub swift_code: String, } +#[doc(hidden)] +pub struct FundingInstructionsBankTransferSwiftRecordBuilder { + account_number: Option, + bank_name: Option, + swift_code: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: FundingInstructionsBankTransferSwiftRecordBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_number: Deserialize::default(), + bank_name: Deserialize::default(), + swift_code: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account_number: self.account_number.take()?, + bank_name: self.bank_name.take()?, + swift_code: self.swift_code.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..c9c70bde2 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct FundingInstructionsBankTransferZenginRecord { /// The account holder name pub account_holder_name: Option, @@ -16,3 +18,125 @@ pub struct FundingInstructionsBankTransferZenginRecord { /// The branch name of the account pub branch_name: Option, } +#[doc(hidden)] +pub struct FundingInstructionsBankTransferZenginRecordBuilder { + account_holder_name: Option>, + account_number: Option>, + account_type: Option>, + bank_code: Option>, + bank_name: Option>, + branch_code: Option>, + branch_name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: FundingInstructionsBankTransferZenginRecordBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + account_holder_name: self.account_holder_name.take()?, + account_number: self.account_number.take()?, + account_type: self.account_type.take()?, + bank_code: self.bank_code.take()?, + bank_name: self.bank_name.take()?, + branch_code: self.branch_code.take()?, + branch_name: self.branch_name.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..13f275e99 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Invoice { /// The country of the business associated with this invoice, most often the business creating the invoice. pub account_country: Option, @@ -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, 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>, /// ID of the default payment method for the invoice. /// It must belong to the customer associated with the invoice. @@ -161,16 +161,13 @@ pub struct Invoice { pub from_invoice: Option, /// 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, /// 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, /// 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, pub issuer: stripe_shared::ConnectAccountReference, /// The error encountered during the previous attempt to finalize the invoice. @@ -192,6 +189,8 @@ pub struct Invoice { /// A unique, identifying string that appears on emails sent to the customer for this invoice. /// This starts with the customer's unique invoice_prefix if it is specified. pub number: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: InvoiceObject, /// 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. @@ -244,7 +243,6 @@ pub struct Invoice { /// Details about the subscription that created this invoice. pub subscription_details: Option, /// 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, /// 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 +254,6 @@ pub struct Invoice { pub tax: Option, /// ID of the test clock this invoice belongs to. pub test_clock: Option>, - #[serde(skip_serializing_if = "Option::is_none")] pub threshold_reason: Option, /// Total after discounts and taxes. pub total: i64, @@ -273,6 +270,541 @@ 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, } +#[doc(hidden)] +pub struct InvoiceBuilder { + account_country: Option>, + account_name: Option>, + account_tax_ids: Option>>>, + amount_due: Option, + amount_paid: Option, + amount_remaining: Option, + amount_shipping: Option, + application: Option>>, + application_fee_amount: Option>, + attempt_count: Option, + attempted: Option, + auto_advance: Option>, + automatic_tax: Option, + billing_reason: Option>, + charge: Option>>, + collection_method: Option, + created: Option, + currency: Option, + custom_fields: Option>>, + customer: Option>>, + customer_address: Option>, + customer_email: Option>, + customer_name: Option>, + customer_phone: Option>, + customer_shipping: Option>, + customer_tax_exempt: Option>, + customer_tax_ids: Option>>, + default_payment_method: Option>>, + default_source: Option>>, + default_tax_rates: Option>, + description: Option>, + discount: Option>, + discounts: Option>>>, + due_date: Option>, + effective_at: Option>, + ending_balance: Option>, + footer: Option>, + from_invoice: Option>, + hosted_invoice_url: Option>, + id: Option>, + invoice_pdf: Option>, + issuer: Option, + last_finalization_error: Option>>, + latest_revision: Option>>, + lines: Option>, + livemode: Option, + metadata: Option>>, + next_payment_attempt: Option>, + number: Option>, + object: Option, + on_behalf_of: Option>>, + paid: Option, + paid_out_of_band: Option, + payment_intent: Option>>, + payment_settings: Option, + period_end: Option, + period_start: Option, + post_payment_credit_notes_amount: Option, + pre_payment_credit_notes_amount: Option, + quote: Option>>, + receipt_number: Option>, + rendering: Option>, + rendering_options: Option>, + shipping_cost: Option>, + shipping_details: Option>, + starting_balance: Option, + statement_descriptor: Option>, + status: Option>, + status_transitions: Option, + subscription: Option>>, + subscription_details: Option>, + subscription_proration_date: Option>, + subtotal: Option, + subtotal_excluding_tax: Option>, + tax: Option>, + test_clock: Option>>, + threshold_reason: Option>, + total: Option, + total_discount_amounts: Option>>, + total_excluding_tax: Option>, + total_tax_amounts: Option>, + transfer_data: Option>, + webhooks_delivered_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoiceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "issuer" => Deserialize::begin(&mut self.issuer), + "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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + issuer: 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(), + object: 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 { + Some(Self::Out { + account_country: self.account_country.take()?, + account_name: self.account_name.take()?, + account_tax_ids: self.account_tax_ids.take()?, + amount_due: self.amount_due?, + amount_paid: self.amount_paid?, + amount_remaining: self.amount_remaining?, + amount_shipping: self.amount_shipping?, + application: self.application.take()?, + application_fee_amount: self.application_fee_amount?, + attempt_count: self.attempt_count?, + attempted: self.attempted?, + auto_advance: self.auto_advance?, + automatic_tax: self.automatic_tax.take()?, + billing_reason: self.billing_reason?, + charge: self.charge.take()?, + collection_method: self.collection_method?, + created: self.created?, + currency: self.currency?, + custom_fields: self.custom_fields.take()?, + customer: self.customer.take()?, + customer_address: self.customer_address.take()?, + customer_email: self.customer_email.take()?, + customer_name: self.customer_name.take()?, + customer_phone: self.customer_phone.take()?, + customer_shipping: self.customer_shipping.take()?, + customer_tax_exempt: self.customer_tax_exempt?, + customer_tax_ids: self.customer_tax_ids.take()?, + default_payment_method: self.default_payment_method.take()?, + default_source: self.default_source.take()?, + default_tax_rates: self.default_tax_rates.take()?, + description: self.description.take()?, + discount: self.discount.take()?, + discounts: self.discounts.take()?, + due_date: self.due_date?, + effective_at: self.effective_at?, + ending_balance: self.ending_balance?, + footer: self.footer.take()?, + from_invoice: self.from_invoice.take()?, + hosted_invoice_url: self.hosted_invoice_url.take()?, + id: self.id.take()?, + invoice_pdf: self.invoice_pdf.take()?, + issuer: self.issuer.take()?, + last_finalization_error: self.last_finalization_error.take()?, + latest_revision: self.latest_revision.take()?, + lines: self.lines.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + next_payment_attempt: self.next_payment_attempt?, + number: self.number.take()?, + object: self.object?, + on_behalf_of: self.on_behalf_of.take()?, + paid: self.paid?, + paid_out_of_band: self.paid_out_of_band?, + payment_intent: self.payment_intent.take()?, + payment_settings: self.payment_settings.take()?, + period_end: self.period_end?, + period_start: self.period_start?, + post_payment_credit_notes_amount: self.post_payment_credit_notes_amount?, + pre_payment_credit_notes_amount: self.pre_payment_credit_notes_amount?, + quote: self.quote.take()?, + receipt_number: self.receipt_number.take()?, + rendering: self.rendering.take()?, + rendering_options: self.rendering_options.take()?, + shipping_cost: self.shipping_cost.take()?, + shipping_details: self.shipping_details.take()?, + starting_balance: self.starting_balance?, + statement_descriptor: self.statement_descriptor.take()?, + status: self.status?, + status_transitions: self.status_transitions?, + subscription: self.subscription.take()?, + subscription_details: self.subscription_details.take()?, + subscription_proration_date: self.subscription_proration_date?, + subtotal: self.subtotal?, + subtotal_excluding_tax: self.subtotal_excluding_tax?, + tax: self.tax?, + test_clock: self.test_clock.take()?, + threshold_reason: self.threshold_reason.take()?, + total: self.total?, + total_discount_amounts: self.total_discount_amounts.take()?, + total_excluding_tax: self.total_excluding_tax?, + total_tax_amounts: self.total_tax_amounts.take()?, + transfer_data: self.transfer_data.take()?, + webhooks_delivered_at: self.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 { + 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)?), + "issuer" => b.issuer = 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)?), + "object" => b.object = 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. @@ -341,6 +873,7 @@ impl std::fmt::Debug for InvoiceBillingReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InvoiceBillingReason { fn serialize(&self, serializer: S) -> Result where @@ -349,6 +882,22 @@ impl serde::Serialize for InvoiceBillingReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InvoiceBillingReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoiceBillingReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(InvoiceBillingReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InvoiceBillingReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -400,6 +949,7 @@ impl std::fmt::Debug for InvoiceCustomerTaxExempt { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InvoiceCustomerTaxExempt { fn serialize(&self, serializer: S) -> Result where @@ -408,6 +958,22 @@ impl serde::Serialize for InvoiceCustomerTaxExempt { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InvoiceCustomerTaxExempt { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoiceCustomerTaxExempt::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(InvoiceCustomerTaxExempt); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InvoiceCustomerTaxExempt { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -416,6 +982,73 @@ impl<'de> serde::Deserialize<'de> for InvoiceCustomerTaxExempt { .map_err(|_| serde::de::Error::custom("Unknown value for InvoiceCustomerTaxExempt")) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum InvoiceObject { + Invoice, +} +impl InvoiceObject { + pub fn as_str(self) -> &'static str { + use InvoiceObject::*; + match self { + Invoice => "invoice", + } + } +} + +impl std::str::FromStr for InvoiceObject { + type Err = (); + fn from_str(s: &str) -> Result { + use InvoiceObject::*; + match s { + "invoice" => Ok(Invoice), + _ => Err(()), + } + } +} +impl std::fmt::Display for InvoiceObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for InvoiceObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for InvoiceObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for InvoiceObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoiceObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(InvoiceObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for InvoiceObject { + fn deserialize>(deserializer: D) -> 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 InvoiceObject")) + } +} impl stripe_types::Object for Invoice { type Id = Option; fn id(&self) -> &Self::Id { @@ -468,6 +1101,22 @@ impl serde::Serialize for InvoiceCollectionMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InvoiceCollectionMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoiceCollectionMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(InvoiceCollectionMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InvoiceCollectionMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -530,6 +1179,22 @@ impl serde::Serialize for InvoiceStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InvoiceStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoiceStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(InvoiceStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InvoiceStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/invoice_installments_card.rs b/generated/stripe_shared/src/invoice_installments_card.rs index eb15116d7..55b99a231 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoiceInstallmentsCard { /// Whether Installments are enabled for this Invoice. pub enabled: Option, } +#[doc(hidden)] +pub struct InvoiceInstallmentsCardBuilder { + enabled: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoiceInstallmentsCardBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.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 { + 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..dafb70368 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoiceItem { /// Amount (in the `currency` specified) of the invoice item. /// This should always be equal to `unit_amount * quantity`. @@ -44,6 +46,8 @@ pub struct InvoiceItem { /// 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>, + /// String representing the object's type. Objects of the same type share the same value. + pub object: InvoiceItemObject, pub period: stripe_shared::InvoiceLineItemPeriod, /// If the invoice item is a proration, the plan of the subscription that the proration was computed for. pub plan: Option, @@ -57,7 +61,6 @@ pub struct InvoiceItem { /// The subscription that this invoice item has been created for, if any. pub subscription: Option>, /// The subscription item that this invoice item has been created for, if any. - #[serde(skip_serializing_if = "Option::is_none")] pub subscription_item: Option, /// 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 +72,276 @@ pub struct InvoiceItem { /// Same as `unit_amount`, but contains a decimal value with at most 12 decimal places. pub unit_amount_decimal: Option, } +#[doc(hidden)] +pub struct InvoiceItemBuilder { + amount: Option, + currency: Option, + customer: Option>, + date: Option, + description: Option>, + discountable: Option, + discounts: Option>>>, + id: Option, + invoice: Option>>, + livemode: Option, + metadata: Option>>, + object: Option, + period: Option, + plan: Option>, + price: Option>, + proration: Option, + quantity: Option, + subscription: Option>>, + subscription_item: Option>, + tax_rates: Option>>, + test_clock: Option>>, + unit_amount: Option>, + unit_amount_decimal: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoiceItemBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + amount: self.amount?, + currency: self.currency?, + customer: self.customer.take()?, + date: self.date?, + description: self.description.take()?, + discountable: self.discountable?, + discounts: self.discounts.take()?, + id: self.id.take()?, + invoice: self.invoice.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + period: self.period?, + plan: self.plan.take()?, + price: self.price.take()?, + proration: self.proration?, + quantity: self.quantity?, + subscription: self.subscription.take()?, + subscription_item: self.subscription_item.take()?, + tax_rates: self.tax_rates.take()?, + test_clock: self.test_clock.take()?, + unit_amount: self.unit_amount?, + unit_amount_decimal: self.unit_amount_decimal.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum InvoiceItemObject { + Invoiceitem, +} +impl InvoiceItemObject { + pub fn as_str(self) -> &'static str { + use InvoiceItemObject::*; + match self { + Invoiceitem => "invoiceitem", + } + } +} + +impl std::str::FromStr for InvoiceItemObject { + type Err = (); + fn from_str(s: &str) -> Result { + use InvoiceItemObject::*; + match s { + "invoiceitem" => Ok(Invoiceitem), + _ => Err(()), + } + } +} +impl std::fmt::Display for InvoiceItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for InvoiceItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for InvoiceItemObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for InvoiceItemObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoiceItemObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(InvoiceItemObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for InvoiceItemObject { + fn deserialize>(deserializer: D) -> 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 InvoiceItemObject")) + } +} 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..8eaf04ada 100644 --- a/generated/stripe_shared/src/invoice_item_threshold_reason.rs +++ b/generated/stripe_shared/src/invoice_item_threshold_reason.rs @@ -1,7 +1,101 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoiceItemThresholdReason { /// The IDs of the line items that triggered the threshold invoice. pub line_item_ids: Vec, /// The quantity threshold boundary that applied to the given line item. pub usage_gte: i64, } +#[doc(hidden)] +pub struct InvoiceItemThresholdReasonBuilder { + line_item_ids: Option>, + usage_gte: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoiceItemThresholdReasonBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { line_item_ids: Deserialize::default(), usage_gte: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + line_item_ids: self.line_item_ids.take()?, + usage_gte: self.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 { + 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..066e1e979 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, /// 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,6 +29,8 @@ pub struct InvoiceLineItem { /// This can be useful for storing additional information about the object in a structured format. /// Note that for line items with `type=subscription` this will reflect the metadata of the subscription that caused the line item to be created. pub metadata: std::collections::HashMap, + /// String representing the object's type. Objects of the same type share the same value. + pub object: InvoiceLineItemObject, pub period: stripe_shared::InvoiceLineItemPeriod, /// The plan of the subscription, if the line item is a subscription or a proration. pub plan: Option, @@ -43,20 +46,296 @@ pub struct InvoiceLineItem { pub subscription: Option>, /// 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>, /// The amount of tax calculated per tax rate for this line item - #[serde(skip_serializing_if = "Option::is_none")] pub tax_amounts: Option>, /// The tax rates which apply to the line item. - #[serde(skip_serializing_if = "Option::is_none")] pub tax_rates: Option>, /// A string identifying the type of the source of this line item, either an `invoiceitem` or a `subscription`. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", 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, } +#[doc(hidden)] +pub struct InvoiceLineItemBuilder { + amount: Option, + amount_excluding_tax: Option>, + currency: Option, + description: Option>, + discount_amounts: Option>>, + discountable: Option, + discounts: Option>>>, + id: Option, + invoice_item: Option>>, + livemode: Option, + metadata: Option>, + object: Option, + period: Option, + plan: Option>, + price: Option>, + proration: Option, + proration_details: Option>, + quantity: Option>, + subscription: Option>>, + subscription_item: Option>>, + tax_amounts: Option>>, + tax_rates: Option>>, + type_: Option, + unit_amount_excluding_tax: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoiceLineItemBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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) + } + + _ => ::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(), + object: 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 { + Some(Self::Out { + amount: self.amount?, + amount_excluding_tax: self.amount_excluding_tax?, + currency: self.currency?, + description: self.description.take()?, + discount_amounts: self.discount_amounts.take()?, + discountable: self.discountable?, + discounts: self.discounts.take()?, + id: self.id.take()?, + invoice_item: self.invoice_item.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + period: self.period?, + plan: self.plan.take()?, + price: self.price.take()?, + proration: self.proration?, + proration_details: self.proration_details.take()?, + quantity: self.quantity?, + subscription: self.subscription.take()?, + subscription_item: self.subscription_item.take()?, + tax_amounts: self.tax_amounts.take()?, + tax_rates: self.tax_rates.take()?, + type_: self.type_?, + unit_amount_excluding_tax: self.unit_amount_excluding_tax.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum InvoiceLineItemObject { + LineItem, +} +impl InvoiceLineItemObject { + pub fn as_str(self) -> &'static str { + use InvoiceLineItemObject::*; + match self { + LineItem => "line_item", + } + } +} + +impl std::str::FromStr for InvoiceLineItemObject { + type Err = (); + fn from_str(s: &str) -> Result { + use InvoiceLineItemObject::*; + match s { + "line_item" => Ok(LineItem), + _ => Err(()), + } + } +} +impl std::fmt::Display for InvoiceLineItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for InvoiceLineItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for InvoiceLineItemObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for InvoiceLineItemObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoiceLineItemObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(InvoiceLineItemObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for InvoiceLineItemObject { + fn deserialize>(deserializer: D) -> 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 InvoiceLineItemObject")) + } +} /// 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 { @@ -95,6 +374,7 @@ impl std::fmt::Debug for InvoiceLineItemType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InvoiceLineItemType { fn serialize(&self, serializer: S) -> Result where @@ -103,6 +383,22 @@ impl serde::Serialize for InvoiceLineItemType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InvoiceLineItemType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoiceLineItemType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(InvoiceLineItemType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InvoiceLineItemType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/invoice_line_item_period.rs b/generated/stripe_shared/src/invoice_line_item_period.rs index 19b7fe0ba..ebba62f37 100644 --- a/generated/stripe_shared/src/invoice_line_item_period.rs +++ b/generated/stripe_shared/src/invoice_line_item_period.rs @@ -1,7 +1,98 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct InvoiceLineItemPeriodBuilder { + end: Option, + start: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoiceLineItemPeriodBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { end: Deserialize::default(), start: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { end: self.end?, start: self.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 { + 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..9eb9c7b35 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoiceMandateOptionsCard { /// Amount to be charged for future payments. pub amount: Option, @@ -9,6 +11,106 @@ pub struct InvoiceMandateOptionsCard { /// A description of the mandate or subscription that is meant to be displayed to the customer. pub description: Option, } +#[doc(hidden)] +pub struct InvoiceMandateOptionsCardBuilder { + amount: Option>, + amount_type: Option>, + description: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoiceMandateOptionsCardBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_type: Deserialize::default(), + description: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + amount_type: self.amount_type?, + description: self.description.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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. @@ -49,6 +151,7 @@ impl std::fmt::Debug for InvoiceMandateOptionsCardAmountType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InvoiceMandateOptionsCardAmountType { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +160,23 @@ impl serde::Serialize for InvoiceMandateOptionsCardAmountType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InvoiceMandateOptionsCardAmountType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(InvoiceMandateOptionsCardAmountType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(InvoiceMandateOptionsCardAmountType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InvoiceMandateOptionsCardAmountType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..acf5f7860 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,109 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoicePaymentMethodOptionsAcssDebit { - #[serde(skip_serializing_if = "Option::is_none")] pub mandate_options: Option, /// Bank account verification method. - #[serde(skip_serializing_if = "Option::is_none")] pub verification_method: Option, } +#[doc(hidden)] +pub struct InvoicePaymentMethodOptionsAcssDebitBuilder { + mandate_options: + Option>, + verification_method: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicePaymentMethodOptionsAcssDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + mandate_options: Deserialize::default(), + verification_method: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + mandate_options: self.mandate_options?, + verification_method: self.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 { + 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 { @@ -47,6 +145,7 @@ impl std::fmt::Debug for InvoicePaymentMethodOptionsAcssDebitVerificationMethod f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InvoicePaymentMethodOptionsAcssDebitVerificationMethod { fn serialize(&self, serializer: S) -> Result where @@ -55,6 +154,27 @@ impl serde::Serialize for InvoicePaymentMethodOptionsAcssDebitVerificationMethod serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InvoicePaymentMethodOptionsAcssDebitVerificationMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + InvoicePaymentMethodOptionsAcssDebitVerificationMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(InvoicePaymentMethodOptionsAcssDebitVerificationMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InvoicePaymentMethodOptionsAcssDebitVerificationMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..ced7c1d98 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,97 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoicePaymentMethodOptionsAcssDebitMandateOptions { /// Transaction type of the mandate. pub transaction_type: Option, } +#[doc(hidden)] +pub struct InvoicePaymentMethodOptionsAcssDebitMandateOptionsBuilder { + transaction_type: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicePaymentMethodOptionsAcssDebitMandateOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { transaction_type: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { transaction_type: self.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 { + 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 { @@ -41,6 +130,7 @@ impl std::fmt::Debug for InvoicePaymentMethodOptionsAcssDebitMandateOptionsTrans f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InvoicePaymentMethodOptionsAcssDebitMandateOptionsTransactionType { fn serialize(&self, serializer: S) -> Result where @@ -49,6 +139,29 @@ impl serde::Serialize for InvoicePaymentMethodOptionsAcssDebitMandateOptionsTran serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InvoicePaymentMethodOptionsAcssDebitMandateOptionsTransactionType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + InvoicePaymentMethodOptionsAcssDebitMandateOptionsTransactionType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + InvoicePaymentMethodOptionsAcssDebitMandateOptionsTransactionType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for 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..abcdd5f13 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,98 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoicePaymentMethodOptionsBancontact { /// Preferred language of the Bancontact authorization page that the customer is redirected to. pub preferred_language: InvoicePaymentMethodOptionsBancontactPreferredLanguage, } +#[doc(hidden)] +pub struct InvoicePaymentMethodOptionsBancontactBuilder { + preferred_language: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicePaymentMethodOptionsBancontactBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { preferred_language: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { preferred_language: self.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 { + 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 { @@ -47,6 +137,7 @@ impl std::fmt::Debug for InvoicePaymentMethodOptionsBancontactPreferredLanguage f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InvoicePaymentMethodOptionsBancontactPreferredLanguage { fn serialize(&self, serializer: S) -> Result where @@ -55,6 +146,27 @@ impl serde::Serialize for InvoicePaymentMethodOptionsBancontactPreferredLanguage serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InvoicePaymentMethodOptionsBancontactPreferredLanguage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + InvoicePaymentMethodOptionsBancontactPreferredLanguage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(InvoicePaymentMethodOptionsBancontactPreferredLanguage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InvoicePaymentMethodOptionsBancontactPreferredLanguage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..0c2d04295 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,110 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoicePaymentMethodOptionsCard { - #[serde(skip_serializing_if = "Option::is_none")] pub installments: Option, /// 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, } +#[doc(hidden)] +pub struct InvoicePaymentMethodOptionsCardBuilder { + installments: Option>, + request_three_d_secure: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicePaymentMethodOptionsCardBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + installments: Deserialize::default(), + request_three_d_secure: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + installments: self.installments?, + request_three_d_secure: self.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 { + 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. @@ -50,6 +148,7 @@ impl std::fmt::Debug for InvoicePaymentMethodOptionsCardRequestThreeDSecure { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InvoicePaymentMethodOptionsCardRequestThreeDSecure { fn serialize(&self, serializer: S) -> Result where @@ -58,6 +157,25 @@ impl serde::Serialize for InvoicePaymentMethodOptionsCardRequestThreeDSecure { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InvoicePaymentMethodOptionsCardRequestThreeDSecure { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + InvoicePaymentMethodOptionsCardRequestThreeDSecure::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(InvoicePaymentMethodOptionsCardRequestThreeDSecure); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InvoicePaymentMethodOptionsCardRequestThreeDSecure { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..7b9ddbfad 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,106 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoicePaymentMethodOptionsCustomerBalance { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_transfer: Option, /// 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, } +#[doc(hidden)] +pub struct InvoicePaymentMethodOptionsCustomerBalanceBuilder { + bank_transfer: + Option>, + funding_type: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicePaymentMethodOptionsCustomerBalanceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank_transfer: Deserialize::default(), funding_type: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + bank_transfer: self.bank_transfer.take()?, + funding_type: self.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 { + 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)] @@ -43,6 +137,7 @@ impl std::fmt::Debug for InvoicePaymentMethodOptionsCustomerBalanceFundingType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InvoicePaymentMethodOptionsCustomerBalanceFundingType { fn serialize(&self, serializer: S) -> Result where @@ -51,6 +146,27 @@ impl serde::Serialize for InvoicePaymentMethodOptionsCustomerBalanceFundingType serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InvoicePaymentMethodOptionsCustomerBalanceFundingType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + InvoicePaymentMethodOptionsCustomerBalanceFundingType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(InvoicePaymentMethodOptionsCustomerBalanceFundingType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InvoicePaymentMethodOptionsCustomerBalanceFundingType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..0f1290080 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,104 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoicePaymentMethodOptionsCustomerBalanceBankTransfer { - #[serde(skip_serializing_if = "Option::is_none")] pub eu_bank_transfer: Option, /// 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(feature = "serde", serde(rename = "type"))] pub type_: Option, } +#[doc(hidden)] +pub struct InvoicePaymentMethodOptionsCustomerBalanceBankTransferBuilder { + eu_bank_transfer: Option< + Option, + >, + type_: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicePaymentMethodOptionsCustomerBalanceBankTransferBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { eu_bank_transfer: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { eu_bank_transfer: self.eu_bank_transfer?, type_: self.type_.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..b8563f694 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferBuilder { + country: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { country: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { country: self.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 { + 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)] @@ -61,6 +149,7 @@ impl std::fmt::Debug f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry { @@ -71,6 +160,33 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry::from_str( + s, + ) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + InvoicePaymentMethodOptionsCustomerBalanceBankTransferEuBankTransferCountry +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for 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..b904b12fb 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoicePaymentMethodOptionsKonbini {} +#[doc(hidden)] +pub struct InvoicePaymentMethodOptionsKonbiniBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicePaymentMethodOptionsKonbiniBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..a1d2d4bd7 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,112 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoicePaymentMethodOptionsUsBankAccount { - #[serde(skip_serializing_if = "Option::is_none")] pub financial_connections: Option, /// Bank account verification method. - #[serde(skip_serializing_if = "Option::is_none")] pub verification_method: Option, } +#[doc(hidden)] +pub struct InvoicePaymentMethodOptionsUsBankAccountBuilder { + financial_connections: + Option>, + verification_method: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicePaymentMethodOptionsUsBankAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + financial_connections: Deserialize::default(), + verification_method: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + financial_connections: self.financial_connections.take()?, + verification_method: self.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 { + 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 { @@ -48,6 +148,7 @@ impl std::fmt::Debug for InvoicePaymentMethodOptionsUsBankAccountVerificationMet f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InvoicePaymentMethodOptionsUsBankAccountVerificationMethod { fn serialize(&self, serializer: S) -> Result where @@ -56,6 +157,29 @@ impl serde::Serialize for InvoicePaymentMethodOptionsUsBankAccountVerificationMe serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InvoicePaymentMethodOptionsUsBankAccountVerificationMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + InvoicePaymentMethodOptionsUsBankAccountVerificationMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + InvoicePaymentMethodOptionsUsBankAccountVerificationMethod +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InvoicePaymentMethodOptionsUsBankAccountVerificationMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..973d1ecef 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,110 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, /// Data features requested to be retrieved upon account creation. pub prefetch: Option>, } +#[doc(hidden)] +pub struct InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsBuilder { + permissions: Option< + Option>, + >, + prefetch: + Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { permissions: Deserialize::default(), prefetch: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + permissions: self.permissions.take()?, + prefetch: self.prefetch.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -48,6 +146,7 @@ impl std::fmt::Debug for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOp f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPermissions { fn serialize(&self, serializer: S) -> Result where @@ -56,6 +155,31 @@ impl serde::Serialize for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountO serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPermissions +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPermissions::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPermissions +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPermissions { @@ -103,6 +227,7 @@ impl std::fmt::Debug for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOp f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPrefetch { fn serialize(&self, serializer: S) -> Result where @@ -111,6 +236,31 @@ impl serde::Serialize for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountO serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPrefetch +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPrefetch::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPrefetch +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InvoicePaymentMethodOptionsUsBankAccountLinkedAccountOptionsPrefetch { diff --git a/generated/stripe_shared/src/invoice_rendering_pdf.rs b/generated/stripe_shared/src/invoice_rendering_pdf.rs index 5ede36ef1..d2cd3db7e 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct InvoiceRenderingPdfBuilder { + page_size: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoiceRenderingPdfBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { page_size: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { page_size: self.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 { + 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. @@ -48,6 +136,7 @@ impl std::fmt::Debug for InvoiceRenderingPdfPageSize { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InvoiceRenderingPdfPageSize { fn serialize(&self, serializer: S) -> Result where @@ -56,6 +145,22 @@ impl serde::Serialize for InvoiceRenderingPdfPageSize { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InvoiceRenderingPdfPageSize { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InvoiceRenderingPdfPageSize::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(InvoiceRenderingPdfPageSize); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InvoiceRenderingPdfPageSize { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/invoice_setting_custom_field.rs b/generated/stripe_shared/src/invoice_setting_custom_field.rs index 6a3c97ccc..79bb643b1 100644 --- a/generated/stripe_shared/src/invoice_setting_custom_field.rs +++ b/generated/stripe_shared/src/invoice_setting_custom_field.rs @@ -1,7 +1,98 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoiceSettingCustomField { /// The name of the custom field. pub name: String, /// The value of the custom field. pub value: String, } +#[doc(hidden)] +pub struct InvoiceSettingCustomFieldBuilder { + name: Option, + value: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoiceSettingCustomFieldBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { name: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { name: self.name.take()?, value: self.value.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..aaa83d490 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoiceSettingCustomerSetting { /// Default custom fields to be displayed on invoices for this customer. pub custom_fields: Option>, @@ -9,3 +11,110 @@ pub struct InvoiceSettingCustomerSetting { /// Default options for invoice PDF rendering for this customer. pub rendering_options: Option, } +#[doc(hidden)] +pub struct InvoiceSettingCustomerSettingBuilder { + custom_fields: Option>>, + default_payment_method: Option>>, + footer: Option>, + rendering_options: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoiceSettingCustomerSettingBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + custom_fields: self.custom_fields.take()?, + default_payment_method: self.default_payment_method.take()?, + footer: self.footer.take()?, + rendering_options: self.rendering_options.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..43b929a1c 100644 --- a/generated/stripe_shared/src/invoice_setting_quote_setting.rs +++ b/generated/stripe_shared/src/invoice_setting_quote_setting.rs @@ -1,7 +1,98 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, pub issuer: stripe_shared::ConnectAccountReference, } +#[doc(hidden)] +pub struct InvoiceSettingQuoteSettingBuilder { + days_until_due: Option>, + issuer: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoiceSettingQuoteSettingBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "issuer" => Deserialize::begin(&mut self.issuer), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { days_until_due: Deserialize::default(), issuer: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { days_until_due: self.days_until_due?, issuer: self.issuer.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "issuer" => b.issuer = 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..506015c63 100644 --- a/generated/stripe_shared/src/invoice_setting_rendering_options.rs +++ b/generated/stripe_shared/src/invoice_setting_rendering_options.rs @@ -1,5 +1,95 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoiceSettingRenderingOptions { /// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. pub amount_tax_display: Option, } +#[doc(hidden)] +pub struct InvoiceSettingRenderingOptionsBuilder { + amount_tax_display: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoiceSettingRenderingOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount_tax_display: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { amount_tax_display: self.amount_tax_display.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..7938c86bc 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,8 +1,9 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>>, /// 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`. @@ -11,3 +12,103 @@ pub struct InvoiceSettingSubscriptionSchedulePhaseSetting { /// The invoice is presented with the branding and support information of the specified account. pub issuer: Option, } +#[doc(hidden)] +pub struct InvoiceSettingSubscriptionSchedulePhaseSettingBuilder { + account_tax_ids: Option>>>, + days_until_due: Option>, + issuer: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoiceSettingSubscriptionSchedulePhaseSettingBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + "account_tax_ids" => Deserialize::begin(&mut self.account_tax_ids), + "days_until_due" => Deserialize::begin(&mut self.days_until_due), + "issuer" => Deserialize::begin(&mut self.issuer), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_tax_ids: Deserialize::default(), + days_until_due: Deserialize::default(), + issuer: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account_tax_ids: self.account_tax_ids.take()?, + days_until_due: self.days_until_due?, + issuer: self.issuer.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceSettingSubscriptionSchedulePhaseSettingBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_tax_ids" => b.account_tax_ids = Some(FromValueOpt::from_value(v)?), + "days_until_due" => b.days_until_due = Some(FromValueOpt::from_value(v)?), + "issuer" => b.issuer = 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..ed709f75f 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,112 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>>, /// 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, pub issuer: stripe_shared::ConnectAccountReference, } +#[doc(hidden)] +pub struct InvoiceSettingSubscriptionScheduleSettingBuilder { + account_tax_ids: Option>>>, + days_until_due: Option>, + issuer: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoiceSettingSubscriptionScheduleSettingBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + "account_tax_ids" => Deserialize::begin(&mut self.account_tax_ids), + "days_until_due" => Deserialize::begin(&mut self.days_until_due), + "issuer" => Deserialize::begin(&mut self.issuer), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_tax_ids: Deserialize::default(), + days_until_due: Deserialize::default(), + issuer: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account_tax_ids: self.account_tax_ids.take()?, + days_until_due: self.days_until_due?, + issuer: self.issuer.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + let Value::Object(obj) = v else { + return None; + }; + let mut b = InvoiceSettingSubscriptionScheduleSettingBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account_tax_ids" => b.account_tax_ids = Some(FromValueOpt::from_value(v)?), + "days_until_due" => b.days_until_due = Some(FromValueOpt::from_value(v)?), + "issuer" => b.issuer = 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..d5be5c554 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoiceTaxAmount { /// The amount, in cents (or local equivalent), of the tax. pub amount: i64, @@ -12,6 +14,116 @@ pub struct InvoiceTaxAmount { /// The amount on which tax is calculated, in cents (or local equivalent). pub taxable_amount: Option, } +#[doc(hidden)] +pub struct InvoiceTaxAmountBuilder { + amount: Option, + inclusive: Option, + tax_rate: Option>, + taxability_reason: Option>, + taxable_amount: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoiceTaxAmountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount: self.amount?, + inclusive: self.inclusive?, + tax_rate: self.tax_rate.take()?, + taxability_reason: self.taxability_reason?, + taxable_amount: self.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 { + 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)] @@ -94,6 +206,7 @@ impl std::fmt::Debug for InvoiceTaxAmountTaxabilityReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InvoiceTaxAmountTaxabilityReason { fn serialize(&self, serializer: S) -> Result where @@ -102,10 +215,29 @@ impl serde::Serialize for InvoiceTaxAmountTaxabilityReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InvoiceTaxAmountTaxabilityReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + InvoiceTaxAmountTaxabilityReason::from_str(s) + .unwrap_or(InvoiceTaxAmountTaxabilityReason::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(InvoiceTaxAmountTaxabilityReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InvoiceTaxAmountTaxabilityReason { fn deserialize>(deserializer: D) -> Result { 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)) } } diff --git a/generated/stripe_shared/src/invoice_threshold_reason.rs b/generated/stripe_shared/src/invoice_threshold_reason.rs index fdf1ccc36..d9e74da42 100644 --- a/generated/stripe_shared/src/invoice_threshold_reason.rs +++ b/generated/stripe_shared/src/invoice_threshold_reason.rs @@ -1,7 +1,101 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoiceThresholdReason { /// The total invoice amount threshold boundary if it triggered the threshold invoice. pub amount_gte: Option, /// Indicates which line items triggered a threshold invoice. pub item_reasons: Vec, } +#[doc(hidden)] +pub struct InvoiceThresholdReasonBuilder { + amount_gte: Option>, + item_reasons: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoiceThresholdReasonBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount_gte: Deserialize::default(), item_reasons: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount_gte: self.amount_gte?, + item_reasons: self.item_reasons.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..3ece8d04c 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,92 @@ pub struct InvoiceTransferData { /// The account where funds from the payment will be transferred to upon payment success. pub destination: stripe_types::Expandable, } +#[doc(hidden)] +pub struct InvoiceTransferDataBuilder { + amount: Option>, + destination: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoiceTransferDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), destination: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { amount: self.amount?, destination: self.destination.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..8403304c8 100644 --- a/generated/stripe_shared/src/invoices_from_invoice.rs +++ b/generated/stripe_shared/src/invoices_from_invoice.rs @@ -1,7 +1,98 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct InvoicesFromInvoiceBuilder { + action: Option, + invoice: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicesFromInvoiceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { action: Deserialize::default(), invoice: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { action: self.action.take()?, invoice: self.invoice.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..8e3300c26 100644 --- a/generated/stripe_shared/src/invoices_invoice_rendering.rs +++ b/generated/stripe_shared/src/invoices_invoice_rendering.rs @@ -1,7 +1,100 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoicesInvoiceRendering { /// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs. pub amount_tax_display: Option, /// Invoice pdf rendering options pub pdf: Option, } +#[doc(hidden)] +pub struct InvoicesInvoiceRenderingBuilder { + amount_tax_display: Option>, + pdf: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicesInvoiceRenderingBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount_tax_display: Deserialize::default(), pdf: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { amount_tax_display: self.amount_tax_display.take()?, pdf: self.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 { + 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..abbe24747 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -13,3 +15,118 @@ 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, } +#[doc(hidden)] +pub struct InvoicesPaymentMethodOptionsBuilder { + acss_debit: Option>, + bancontact: Option>, + card: Option>, + customer_balance: Option>, + konbini: Option>, + us_bank_account: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicesPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + acss_debit: self.acss_debit?, + bancontact: self.bancontact?, + card: self.card?, + customer_balance: self.customer_balance.take()?, + konbini: self.konbini?, + us_bank_account: self.us_bank_account.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..3f8a668eb 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,110 @@ 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>, } +#[doc(hidden)] +pub struct InvoicesPaymentSettingsBuilder { + default_mandate: Option>, + payment_method_options: Option>, + payment_method_types: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicesPaymentSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + default_mandate: self.default_mandate.take()?, + payment_method_options: self.payment_method_options.take()?, + payment_method_types: self.payment_method_types.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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). @@ -126,6 +232,7 @@ impl std::fmt::Debug for InvoicesPaymentSettingsPaymentMethodTypes { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InvoicesPaymentSettingsPaymentMethodTypes { fn serialize(&self, serializer: S) -> Result where @@ -134,10 +241,29 @@ impl serde::Serialize for InvoicesPaymentSettingsPaymentMethodTypes { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InvoicesPaymentSettingsPaymentMethodTypes { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + InvoicesPaymentSettingsPaymentMethodTypes::from_str(s) + .unwrap_or(InvoicesPaymentSettingsPaymentMethodTypes::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(InvoicesPaymentSettingsPaymentMethodTypes); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InvoicesPaymentSettingsPaymentMethodTypes { fn deserialize>(deserializer: D) -> Result { 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)) } } 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..c9ae9f6ed 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,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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(feature = "serde", serde(rename = "type"))] pub type_: InvoicesResourceInvoiceTaxIdType, /// The value of the tax ID. pub value: Option, } +#[doc(hidden)] +pub struct InvoicesResourceInvoiceTaxIdBuilder { + type_: Option, + value: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicesResourceInvoiceTaxIdBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { type_: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { type_: self.type_?, value: self.value.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -239,6 +330,7 @@ impl std::fmt::Debug for InvoicesResourceInvoiceTaxIdType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InvoicesResourceInvoiceTaxIdType { fn serialize(&self, serializer: S) -> Result where @@ -247,6 +339,23 @@ impl serde::Serialize for InvoicesResourceInvoiceTaxIdType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InvoicesResourceInvoiceTaxIdType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(InvoicesResourceInvoiceTaxIdType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(InvoicesResourceInvoiceTaxIdType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InvoicesResourceInvoiceTaxIdType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..12bc3bedf 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,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoicesResourceLineItemsCreditedItems { /// Invoice containing the credited invoice line items pub invoice: String, /// Credited invoice line items pub invoice_line_items: Vec, } +#[doc(hidden)] +pub struct InvoicesResourceLineItemsCreditedItemsBuilder { + invoice: Option, + invoice_line_items: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicesResourceLineItemsCreditedItemsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { invoice: Deserialize::default(), invoice_line_items: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + invoice: self.invoice.take()?, + invoice_line_items: self.invoice_line_items.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..cfe85fe60 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoicesResourceLineItemsProrationDetails { /// For a credit proration `line_item`, the original debit line_items to which the credit proration applies. pub credited_items: Option, } +#[doc(hidden)] +pub struct InvoicesResourceLineItemsProrationDetailsBuilder { + credited_items: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicesResourceLineItemsProrationDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { credited_items: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { credited_items: self.credited_items.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..64230f0c8 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoicesShippingCost { /// Total shipping cost before any taxes are applied. pub amount_subtotal: i64, @@ -9,6 +11,115 @@ pub struct InvoicesShippingCost { /// The ID of the ShippingRate for this invoice. pub shipping_rate: Option>, /// The taxes applied to the shipping rate. - #[serde(skip_serializing_if = "Option::is_none")] pub taxes: Option>, } +#[doc(hidden)] +pub struct InvoicesShippingCostBuilder { + amount_subtotal: Option, + amount_tax: Option, + amount_total: Option, + shipping_rate: Option>>, + taxes: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicesShippingCostBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount_subtotal: self.amount_subtotal?, + amount_tax: self.amount_tax?, + amount_total: self.amount_total?, + shipping_rate: self.shipping_rate.take()?, + taxes: self.taxes.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..fad6b2ca6 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InvoicesStatusTransitions { /// The time that the invoice draft was finalized. pub finalized_at: Option, @@ -9,3 +11,110 @@ pub struct InvoicesStatusTransitions { /// The time that the invoice was voided. pub voided_at: Option, } +#[doc(hidden)] +pub struct InvoicesStatusTransitionsBuilder { + finalized_at: Option>, + marked_uncollectible_at: Option>, + paid_at: Option>, + voided_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InvoicesStatusTransitionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + finalized_at: self.finalized_at?, + marked_uncollectible_at: self.marked_uncollectible_at?, + paid_at: self.paid_at?, + voided_at: self.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 { + 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..c20848988 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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). @@ -50,6 +52,8 @@ pub struct IssuingAuthorization { pub metadata: std::collections::HashMap, /// Details about the authorization, such as identifiers, set by the card network. pub network_data: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: IssuingAuthorizationObject, /// The pending authorization request. /// This field will only be non-null during an `issuing_authorization.request` webhook. pub pending_request: Option, @@ -62,12 +66,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>, /// List of [transactions](https://stripe.com/docs/api/issuing/transactions) associated with this authorization. pub transactions: Vec, /// [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, pub verification_data: stripe_shared::IssuingAuthorizationVerificationData, /// The digital wallet used for this transaction. @@ -75,6 +77,288 @@ pub struct IssuingAuthorization { /// Will populate as `null` when no digital wallet was utilized. pub wallet: Option, } +#[doc(hidden)] +pub struct IssuingAuthorizationBuilder { + amount: Option, + amount_details: Option>, + approved: Option, + authorization_method: Option, + balance_transactions: Option>, + card: Option, + cardholder: Option>>, + created: Option, + currency: Option, + id: Option, + livemode: Option, + merchant_amount: Option, + merchant_currency: Option, + merchant_data: Option, + metadata: Option>, + network_data: Option>, + object: Option, + pending_request: Option>, + request_history: Option>, + status: Option, + token: Option>>, + transactions: Option>, + treasury: Option>, + verification_data: Option, + wallet: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingAuthorizationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + amount: self.amount?, + amount_details: self.amount_details?, + approved: self.approved?, + authorization_method: self.authorization_method?, + balance_transactions: self.balance_transactions.take()?, + card: self.card.take()?, + cardholder: self.cardholder.take()?, + created: self.created?, + currency: self.currency?, + id: self.id.take()?, + livemode: self.livemode?, + merchant_amount: self.merchant_amount?, + merchant_currency: self.merchant_currency?, + merchant_data: self.merchant_data.take()?, + metadata: self.metadata.take()?, + network_data: self.network_data.take()?, + object: self.object?, + pending_request: self.pending_request?, + request_history: self.request_history.take()?, + status: self.status?, + token: self.token.take()?, + transactions: self.transactions.take()?, + treasury: self.treasury.take()?, + verification_data: self.verification_data.take()?, + wallet: self.wallet.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum IssuingAuthorizationObject { + IssuingAuthorization, +} +impl IssuingAuthorizationObject { + pub fn as_str(self) -> &'static str { + use IssuingAuthorizationObject::*; + match self { + IssuingAuthorization => "issuing.authorization", + } + } +} + +impl std::str::FromStr for IssuingAuthorizationObject { + type Err = (); + fn from_str(s: &str) -> Result { + use IssuingAuthorizationObject::*; + match s { + "issuing.authorization" => Ok(IssuingAuthorization), + _ => Err(()), + } + } +} +impl std::fmt::Display for IssuingAuthorizationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for IssuingAuthorizationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for IssuingAuthorizationObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for IssuingAuthorizationObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingAuthorizationObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for IssuingAuthorizationObject { + fn deserialize>(deserializer: D) -> 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 IssuingAuthorizationObject")) + } +} impl stripe_types::Object for IssuingAuthorization { type Id = stripe_shared::IssuingAuthorizationId; fn id(&self) -> &Self::Id { @@ -136,6 +420,24 @@ impl serde::Serialize for IssuingAuthorizationAuthorizationMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingAuthorizationAuthorizationMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingAuthorizationAuthorizationMethod::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationAuthorizationMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingAuthorizationAuthorizationMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -193,6 +495,22 @@ impl serde::Serialize for IssuingAuthorizationStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingAuthorizationStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingAuthorizationStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingAuthorizationStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_authorization_amount_details.rs b/generated/stripe_shared/src/issuing_authorization_amount_details.rs index f4d63c2f2..0f6e901cb 100644 --- a/generated/stripe_shared/src/issuing_authorization_amount_details.rs +++ b/generated/stripe_shared/src/issuing_authorization_amount_details.rs @@ -1,7 +1,98 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingAuthorizationAmountDetails { /// The fee charged by the ATM for the cash withdrawal. pub atm_fee: Option, /// The amount of cash requested by the cardholder. pub cashback_amount: Option, } +#[doc(hidden)] +pub struct IssuingAuthorizationAmountDetailsBuilder { + atm_fee: Option>, + cashback_amount: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingAuthorizationAmountDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { atm_fee: Deserialize::default(), cashback_amount: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { atm_fee: self.atm_fee?, cashback_amount: self.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 { + 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..db54f7f25 100644 --- a/generated/stripe_shared/src/issuing_authorization_authentication_exemption.rs +++ b/generated/stripe_shared/src/issuing_authorization_authentication_exemption.rs @@ -1,11 +1,102 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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(feature = "serde", serde(rename = "type"))] pub type_: IssuingAuthorizationAuthenticationExemptionType, } +#[doc(hidden)] +pub struct IssuingAuthorizationAuthenticationExemptionBuilder { + claimed_by: Option, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingAuthorizationAuthenticationExemptionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { claimed_by: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { claimed_by: self.claimed_by?, type_: self.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 { + 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 { @@ -44,6 +135,7 @@ impl std::fmt::Debug for IssuingAuthorizationAuthenticationExemptionClaimedBy { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingAuthorizationAuthenticationExemptionClaimedBy { fn serialize(&self, serializer: S) -> Result where @@ -52,6 +144,25 @@ impl serde::Serialize for IssuingAuthorizationAuthenticationExemptionClaimedBy { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingAuthorizationAuthenticationExemptionClaimedBy { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingAuthorizationAuthenticationExemptionClaimedBy::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationAuthenticationExemptionClaimedBy); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingAuthorizationAuthenticationExemptionClaimedBy { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -104,6 +215,7 @@ impl std::fmt::Debug for IssuingAuthorizationAuthenticationExemptionType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingAuthorizationAuthenticationExemptionType { fn serialize(&self, serializer: S) -> Result where @@ -112,6 +224,25 @@ impl serde::Serialize for IssuingAuthorizationAuthenticationExemptionType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingAuthorizationAuthenticationExemptionType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingAuthorizationAuthenticationExemptionType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationAuthenticationExemptionType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingAuthorizationAuthenticationExemptionType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_authorization_merchant_data.rs b/generated/stripe_shared/src/issuing_authorization_merchant_data.rs index b88adc535..a99809000 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,138 @@ pub struct IssuingAuthorizationMerchantData { /// URL provided by the merchant on a 3DS request pub url: Option, } +#[doc(hidden)] +pub struct IssuingAuthorizationMerchantDataBuilder { + category: Option, + category_code: Option, + city: Option>, + country: Option>, + name: Option>, + network_id: Option, + postal_code: Option>, + state: Option>, + terminal_id: Option>, + url: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingAuthorizationMerchantDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + category: self.category.take()?, + category_code: self.category_code.take()?, + city: self.city.take()?, + country: self.country.take()?, + name: self.name.take()?, + network_id: self.network_id.take()?, + postal_code: self.postal_code.take()?, + state: self.state.take()?, + terminal_id: self.terminal_id.take()?, + url: self.url.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..b6e02d266 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,111 @@ 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, } +#[doc(hidden)] +pub struct IssuingAuthorizationNetworkDataBuilder { + acquiring_institution_id: Option>, + system_trace_audit_number: Option>, + transaction_id: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingAuthorizationNetworkDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + acquiring_institution_id: self.acquiring_institution_id.take()?, + system_trace_audit_number: self.system_trace_audit_number.take()?, + transaction_id: self.transaction_id.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..f15a6aeb3 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,127 @@ pub struct IssuingAuthorizationPendingRequest { /// Takes on values between 1 and 99. pub network_risk_score: Option, } +#[doc(hidden)] +pub struct IssuingAuthorizationPendingRequestBuilder { + amount: Option, + amount_details: Option>, + currency: Option, + is_amount_controllable: Option, + merchant_amount: Option, + merchant_currency: Option, + network_risk_score: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingAuthorizationPendingRequestBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount: self.amount?, + amount_details: self.amount_details?, + currency: self.currency?, + is_amount_controllable: self.is_amount_controllable?, + merchant_amount: self.merchant_amount?, + merchant_currency: self.merchant_currency?, + network_risk_score: self.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 { + 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..d646a046f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,155 @@ pub struct IssuingAuthorizationRequest { /// Referred to by networks as transmission time. pub requested_at: Option, } +#[doc(hidden)] +pub struct IssuingAuthorizationRequestBuilder { + amount: Option, + amount_details: Option>, + approved: Option, + authorization_code: Option>, + created: Option, + currency: Option, + merchant_amount: Option, + merchant_currency: Option, + network_risk_score: Option>, + reason: Option, + reason_message: Option>, + requested_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingAuthorizationRequestBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount: self.amount?, + amount_details: self.amount_details?, + approved: self.approved?, + authorization_code: self.authorization_code.take()?, + created: self.created?, + currency: self.currency?, + merchant_amount: self.merchant_amount?, + merchant_currency: self.merchant_currency?, + network_risk_score: self.network_risk_score?, + reason: self.reason?, + reason_message: self.reason_message.take()?, + requested_at: self.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 { + 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] @@ -114,6 +265,7 @@ impl std::fmt::Debug for IssuingAuthorizationRequestReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingAuthorizationRequestReason { fn serialize(&self, serializer: S) -> Result where @@ -122,10 +274,29 @@ impl serde::Serialize for IssuingAuthorizationRequestReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingAuthorizationRequestReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingAuthorizationRequestReason::from_str(s) + .unwrap_or(IssuingAuthorizationRequestReason::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationRequestReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingAuthorizationRequestReason { fn deserialize>(deserializer: D) -> Result { 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)) } } 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..7f9c1ba0f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingAuthorizationThreeDSecure { /// The outcome of the 3D Secure authentication request. pub result: IssuingAuthorizationThreeDSecureResult, } +#[doc(hidden)] +pub struct IssuingAuthorizationThreeDSecureBuilder { + result: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingAuthorizationThreeDSecureBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { result: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { result: self.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 { + 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 { @@ -47,6 +135,7 @@ impl std::fmt::Debug for IssuingAuthorizationThreeDSecureResult { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingAuthorizationThreeDSecureResult { fn serialize(&self, serializer: S) -> Result where @@ -55,6 +144,24 @@ impl serde::Serialize for IssuingAuthorizationThreeDSecureResult { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingAuthorizationThreeDSecureResult { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingAuthorizationThreeDSecureResult::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationThreeDSecureResult); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingAuthorizationThreeDSecureResult { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_authorization_treasury.rs b/generated/stripe_shared/src/issuing_authorization_treasury.rs index 58eac0bde..ada8f0cd7 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingAuthorizationTreasury { /// The array of [ReceivedCredits](https://stripe.com/docs/api/treasury/received_credits) associated with this authorization. pub received_credits: Vec, @@ -7,3 +9,103 @@ pub struct IssuingAuthorizationTreasury { /// The Treasury [Transaction](https://stripe.com/docs/api/treasury/transactions) associated with this authorization. pub transaction: Option, } +#[doc(hidden)] +pub struct IssuingAuthorizationTreasuryBuilder { + received_credits: Option>, + received_debits: Option>, + transaction: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingAuthorizationTreasuryBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + received_credits: Deserialize::default(), + received_debits: Deserialize::default(), + transaction: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + received_credits: self.received_credits.take()?, + received_debits: self.received_debits.take()?, + transaction: self.transaction.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..e83b05e8c 100644 --- a/generated/stripe_shared/src/issuing_authorization_verification_data.rs +++ b/generated/stripe_shared/src/issuing_authorization_verification_data.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -16,6 +18,137 @@ pub struct IssuingAuthorizationVerificationData { /// 3D Secure details. pub three_d_secure: Option, } +#[doc(hidden)] +pub struct IssuingAuthorizationVerificationDataBuilder { + address_line1_check: Option, + address_postal_code_check: Option, + authentication_exemption: + Option>, + cvc_check: Option, + expiry_check: Option, + postal_code: Option>, + three_d_secure: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingAuthorizationVerificationDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + address_line1_check: self.address_line1_check?, + address_postal_code_check: self.address_postal_code_check?, + authentication_exemption: self.authentication_exemption?, + cvc_check: self.cvc_check?, + expiry_check: self.expiry_check?, + postal_code: self.postal_code.take()?, + three_d_secure: self.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 { + 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 { @@ -57,6 +190,7 @@ impl std::fmt::Debug for IssuingAuthorizationVerificationDataAddressLine1Check { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingAuthorizationVerificationDataAddressLine1Check { fn serialize(&self, serializer: S) -> Result where @@ -65,6 +199,27 @@ impl serde::Serialize for IssuingAuthorizationVerificationDataAddressLine1Check serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingAuthorizationVerificationDataAddressLine1Check { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingAuthorizationVerificationDataAddressLine1Check::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationVerificationDataAddressLine1Check); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingAuthorizationVerificationDataAddressLine1Check { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -117,6 +272,7 @@ impl std::fmt::Debug for IssuingAuthorizationVerificationDataAddressPostalCodeCh f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingAuthorizationVerificationDataAddressPostalCodeCheck { fn serialize(&self, serializer: S) -> Result where @@ -125,6 +281,29 @@ impl serde::Serialize for IssuingAuthorizationVerificationDataAddressPostalCodeC serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingAuthorizationVerificationDataAddressPostalCodeCheck { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingAuthorizationVerificationDataAddressPostalCodeCheck::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + IssuingAuthorizationVerificationDataAddressPostalCodeCheck +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingAuthorizationVerificationDataAddressPostalCodeCheck { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -177,6 +356,7 @@ impl std::fmt::Debug for IssuingAuthorizationVerificationDataCvcCheck { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingAuthorizationVerificationDataCvcCheck { fn serialize(&self, serializer: S) -> Result where @@ -185,6 +365,25 @@ impl serde::Serialize for IssuingAuthorizationVerificationDataCvcCheck { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingAuthorizationVerificationDataCvcCheck { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingAuthorizationVerificationDataCvcCheck::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationVerificationDataCvcCheck); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingAuthorizationVerificationDataCvcCheck { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -237,6 +436,7 @@ impl std::fmt::Debug for IssuingAuthorizationVerificationDataExpiryCheck { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingAuthorizationVerificationDataExpiryCheck { fn serialize(&self, serializer: S) -> Result where @@ -245,6 +445,25 @@ impl serde::Serialize for IssuingAuthorizationVerificationDataExpiryCheck { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingAuthorizationVerificationDataExpiryCheck { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingAuthorizationVerificationDataExpiryCheck::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingAuthorizationVerificationDataExpiryCheck); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingAuthorizationVerificationDataExpiryCheck { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_card.rs b/generated/stripe_shared/src/issuing_card.rs index 27602fc82..f4c42eaa5 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// 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, /// Unique identifier for the object. pub id: stripe_shared::IssuingCardId, @@ -37,8 +37,9 @@ 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 representing the object's type. Objects of the same type share the same value. + pub object: IssuingCardObject, /// The latest card that replaces this card, if any. pub replaced_by: Option>, /// The card this card replaces, if any. @@ -53,11 +54,215 @@ pub struct IssuingCard { /// Defaults to `inactive`. pub status: stripe_shared::IssuingCardStatus, /// The type of the card. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: stripe_shared::IssuingCardType, /// Information relating to digital wallets (like Apple Pay and Google Pay). pub wallets: Option, } +#[doc(hidden)] +pub struct IssuingCardBuilder { + brand: Option, + cancellation_reason: Option>, + cardholder: Option, + created: Option, + currency: Option, + cvc: Option>, + exp_month: Option, + exp_year: Option, + financial_account: Option>, + id: Option, + last4: Option, + livemode: Option, + metadata: Option>, + number: Option>, + object: Option, + replaced_by: Option>>, + replacement_for: Option>>, + replacement_reason: Option>, + shipping: Option>, + spending_controls: Option, + status: Option, + type_: Option, + wallets: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + brand: self.brand.take()?, + cancellation_reason: self.cancellation_reason?, + cardholder: self.cardholder.take()?, + created: self.created?, + currency: self.currency?, + cvc: self.cvc.take()?, + exp_month: self.exp_month?, + exp_year: self.exp_year?, + financial_account: self.financial_account.take()?, + id: self.id.take()?, + last4: self.last4.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + number: self.number.take()?, + object: self.object?, + replaced_by: self.replaced_by.take()?, + replacement_for: self.replacement_for.take()?, + replacement_reason: self.replacement_reason?, + shipping: self.shipping.take()?, + spending_controls: self.spending_controls.take()?, + status: self.status?, + type_: self.type_?, + wallets: self.wallets.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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 { @@ -99,6 +304,7 @@ impl std::fmt::Debug for IssuingCardCancellationReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingCardCancellationReason { fn serialize(&self, serializer: S) -> Result where @@ -107,6 +313,22 @@ impl serde::Serialize for IssuingCardCancellationReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardCancellationReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardCancellationReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardCancellationReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardCancellationReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -116,6 +338,74 @@ impl<'de> serde::Deserialize<'de> for IssuingCardCancellationReason { }) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum IssuingCardObject { + IssuingCard, +} +impl IssuingCardObject { + pub fn as_str(self) -> &'static str { + use IssuingCardObject::*; + match self { + IssuingCard => "issuing.card", + } + } +} + +impl std::str::FromStr for IssuingCardObject { + type Err = (); + fn from_str(s: &str) -> Result { + use IssuingCardObject::*; + match s { + "issuing.card" => Ok(IssuingCard), + _ => Err(()), + } + } +} +impl std::fmt::Display for IssuingCardObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for IssuingCardObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for IssuingCardObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for IssuingCardObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for IssuingCardObject { + fn deserialize>(deserializer: D) -> 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 IssuingCardObject")) + } +} impl stripe_types::Object for IssuingCard { type Id = stripe_shared::IssuingCardId; fn id(&self) -> &Self::Id { @@ -174,6 +464,22 @@ impl serde::Serialize for IssuingCardReplacementReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardReplacementReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardReplacementReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardReplacementReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardReplacementReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -230,6 +536,22 @@ impl serde::Serialize for IssuingCardStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -283,6 +605,22 @@ impl serde::Serialize for IssuingCardType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_card_apple_pay.rs b/generated/stripe_shared/src/issuing_card_apple_pay.rs index b968c6e43..1ae42718f 100644 --- a/generated/stripe_shared/src/issuing_card_apple_pay.rs +++ b/generated/stripe_shared/src/issuing_card_apple_pay.rs @@ -1,10 +1,101 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingCardApplePay { /// Apple Pay Eligibility pub eligible: bool, /// Reason the card is ineligible for Apple Pay pub ineligible_reason: Option, } +#[doc(hidden)] +pub struct IssuingCardApplePayBuilder { + eligible: Option, + ineligible_reason: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardApplePayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { eligible: Deserialize::default(), ineligible_reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { eligible: self.eligible?, ineligible_reason: self.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 { + 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 { @@ -46,6 +137,7 @@ impl std::fmt::Debug for IssuingCardApplePayIneligibleReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingCardApplePayIneligibleReason { fn serialize(&self, serializer: S) -> Result where @@ -54,6 +146,23 @@ impl serde::Serialize for IssuingCardApplePayIneligibleReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardApplePayIneligibleReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(IssuingCardApplePayIneligibleReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardApplePayIneligibleReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardApplePayIneligibleReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_card_authorization_controls.rs b/generated/stripe_shared/src/issuing_card_authorization_controls.rs index f1428a4e5..145fd137b 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,119 @@ pub struct IssuingCardAuthorizationControls { /// Currency of the amounts within `spending_limits`. Always the same as the currency of the card. pub spending_limits_currency: Option, } +#[doc(hidden)] +pub struct IssuingCardAuthorizationControlsBuilder { + allowed_categories: Option>>, + blocked_categories: Option>>, + spending_limits: Option>>, + spending_limits_currency: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardAuthorizationControlsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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) + } + + _ => ::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 { + Some(Self::Out { + allowed_categories: self.allowed_categories.take()?, + blocked_categories: self.blocked_categories.take()?, + spending_limits: self.spending_limits.take()?, + spending_limits_currency: self.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 { + 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`. @@ -1028,6 +1143,7 @@ impl std::fmt::Debug for IssuingCardAuthorizationControlsAllowedCategories { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingCardAuthorizationControlsAllowedCategories { fn serialize(&self, serializer: S) -> Result where @@ -1036,11 +1152,30 @@ impl serde::Serialize for IssuingCardAuthorizationControlsAllowedCategories { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardAuthorizationControlsAllowedCategories { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingCardAuthorizationControlsAllowedCategories::from_str(s) + .unwrap_or(IssuingCardAuthorizationControlsAllowedCategories::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardAuthorizationControlsAllowedCategories); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardAuthorizationControlsAllowedCategories { fn deserialize>(deserializer: D) -> Result { 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)) } } /// Array of strings containing [categories](https://stripe.com/docs/api#issuing_authorization_object-merchant_data-category) of authorizations to decline. @@ -2058,6 +2193,7 @@ impl std::fmt::Debug for IssuingCardAuthorizationControlsBlockedCategories { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingCardAuthorizationControlsBlockedCategories { fn serialize(&self, serializer: S) -> Result where @@ -2066,10 +2202,29 @@ impl serde::Serialize for IssuingCardAuthorizationControlsBlockedCategories { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardAuthorizationControlsBlockedCategories { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingCardAuthorizationControlsBlockedCategories::from_str(s) + .unwrap_or(IssuingCardAuthorizationControlsBlockedCategories::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardAuthorizationControlsBlockedCategories); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardAuthorizationControlsBlockedCategories { fn deserialize>(deserializer: D) -> Result { 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)) } } diff --git a/generated/stripe_shared/src/issuing_card_google_pay.rs b/generated/stripe_shared/src/issuing_card_google_pay.rs index 0b8418878..f62159447 100644 --- a/generated/stripe_shared/src/issuing_card_google_pay.rs +++ b/generated/stripe_shared/src/issuing_card_google_pay.rs @@ -1,10 +1,101 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingCardGooglePay { /// Google Pay Eligibility pub eligible: bool, /// Reason the card is ineligible for Google Pay pub ineligible_reason: Option, } +#[doc(hidden)] +pub struct IssuingCardGooglePayBuilder { + eligible: Option, + ineligible_reason: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardGooglePayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { eligible: Deserialize::default(), ineligible_reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { eligible: self.eligible?, ineligible_reason: self.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 { + 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 { @@ -46,6 +137,7 @@ impl std::fmt::Debug for IssuingCardGooglePayIneligibleReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingCardGooglePayIneligibleReason { fn serialize(&self, serializer: S) -> Result where @@ -54,6 +146,23 @@ impl serde::Serialize for IssuingCardGooglePayIneligibleReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardGooglePayIneligibleReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(IssuingCardGooglePayIneligibleReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardGooglePayIneligibleReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardGooglePayIneligibleReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_card_shipping.rs b/generated/stripe_shared/src/issuing_card_shipping.rs index 2abc86aad..da737ce35 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingCardShipping { pub address: stripe_shared::Address, /// The delivery company that shipped a card. @@ -27,9 +29,154 @@ 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, /// Packaging options. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: IssuingCardShippingType, } +#[doc(hidden)] +pub struct IssuingCardShippingBuilder { + address: Option, + carrier: Option>, + customs: Option>, + eta: Option>, + name: Option, + phone_number: Option>, + require_signature: Option>, + service: Option, + status: Option>, + tracking_number: Option>, + tracking_url: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardShippingBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + address: self.address.take()?, + carrier: self.carrier?, + customs: self.customs.take()?, + eta: self.eta?, + name: self.name.take()?, + phone_number: self.phone_number.take()?, + require_signature: self.require_signature?, + service: self.service?, + status: self.status?, + tracking_number: self.tracking_number.take()?, + tracking_url: self.tracking_url.take()?, + type_: self.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 { + 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 { @@ -74,6 +221,7 @@ impl std::fmt::Debug for IssuingCardShippingCarrier { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingCardShippingCarrier { fn serialize(&self, serializer: S) -> Result where @@ -82,6 +230,22 @@ impl serde::Serialize for IssuingCardShippingCarrier { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardShippingCarrier { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardShippingCarrier::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardShippingCarrier); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardShippingCarrier { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -131,6 +295,7 @@ impl std::fmt::Debug for IssuingCardShippingService { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingCardShippingService { fn serialize(&self, serializer: S) -> Result where @@ -139,6 +304,22 @@ impl serde::Serialize for IssuingCardShippingService { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardShippingService { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardShippingService::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardShippingService); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardShippingService { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -197,6 +378,7 @@ impl std::fmt::Debug for IssuingCardShippingStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingCardShippingStatus { fn serialize(&self, serializer: S) -> Result where @@ -205,6 +387,22 @@ impl serde::Serialize for IssuingCardShippingStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardShippingStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardShippingStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardShippingStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardShippingStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -251,6 +449,7 @@ impl std::fmt::Debug for IssuingCardShippingType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingCardShippingType { fn serialize(&self, serializer: S) -> Result where @@ -259,6 +458,22 @@ impl serde::Serialize for IssuingCardShippingType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardShippingType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardShippingType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardShippingType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardShippingType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_card_shipping_customs.rs b/generated/stripe_shared/src/issuing_card_shipping_customs.rs index 71c6bc68e..1bb20a0b2 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingCardShippingCustoms { /// A registration number used for customs in Europe. /// See [](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) for the EU. pub eori_number: Option, } +#[doc(hidden)] +pub struct IssuingCardShippingCustomsBuilder { + eori_number: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardShippingCustomsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { eori_number: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { eori_number: self.eori_number.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..59b5518dc 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,106 @@ pub struct IssuingCardSpendingLimit { /// Interval (or event) to which the amount applies. pub interval: IssuingCardSpendingLimitInterval, } +#[doc(hidden)] +pub struct IssuingCardSpendingLimitBuilder { + amount: Option, + categories: Option>>, + interval: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardSpendingLimitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + categories: Deserialize::default(), + interval: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + categories: self.categories.take()?, + interval: self.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 { + 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)] @@ -1023,6 +1125,7 @@ impl std::fmt::Debug for IssuingCardSpendingLimitCategories { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingCardSpendingLimitCategories { fn serialize(&self, serializer: S) -> Result where @@ -1031,11 +1134,30 @@ impl serde::Serialize for IssuingCardSpendingLimitCategories { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardSpendingLimitCategories { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingCardSpendingLimitCategories::from_str(s) + .unwrap_or(IssuingCardSpendingLimitCategories::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardSpendingLimitCategories); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardSpendingLimitCategories { fn deserialize>(deserializer: D) -> Result { 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)) } } /// Interval (or event) to which the amount applies. @@ -1088,6 +1210,7 @@ impl std::fmt::Debug for IssuingCardSpendingLimitInterval { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingCardSpendingLimitInterval { fn serialize(&self, serializer: S) -> Result where @@ -1096,6 +1219,23 @@ impl serde::Serialize for IssuingCardSpendingLimitInterval { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardSpendingLimitInterval { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(IssuingCardSpendingLimitInterval::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardSpendingLimitInterval); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardSpendingLimitInterval { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_card_wallets.rs b/generated/stripe_shared/src/issuing_card_wallets.rs index d3a3840df..307d282bb 100644 --- a/generated/stripe_shared/src/issuing_card_wallets.rs +++ b/generated/stripe_shared/src/issuing_card_wallets.rs @@ -1,7 +1,113 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct IssuingCardWalletsBuilder { + apple_pay: Option, + google_pay: Option, + primary_account_identifier: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardWalletsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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) + } + + _ => ::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 { + Some(Self::Out { + apple_pay: self.apple_pay?, + google_pay: self.google_pay?, + primary_account_identifier: self.primary_account_identifier.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..ebda4978a 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingCardholder { pub billing: stripe_shared::IssuingCardholderAddress, /// Additional information about a `company` cardholder. @@ -23,6 +25,8 @@ pub struct IssuingCardholder { pub metadata: std::collections::HashMap, /// The cardholder's name. This will be printed on cards issued to them. pub name: String, + /// String representing the object's type. Objects of the same type share the same value. + pub object: IssuingCardholderObject, /// The cardholder's phone number. /// This is required for all cardholders who will be creating EU cards. /// See the [3D Secure documentation](https://stripe.com/docs/issuing/3d-secure#when-is-3d-secure-applied) for more details. @@ -39,9 +43,242 @@ 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(feature = "serde", serde(rename = "type"))] pub type_: stripe_shared::IssuingCardholderType, } +#[doc(hidden)] +pub struct IssuingCardholderBuilder { + billing: Option, + company: Option>, + created: Option, + email: Option>, + id: Option, + individual: Option>, + livemode: Option, + metadata: Option>, + name: Option, + object: Option, + phone_number: Option>, + preferred_locales: Option>>, + requirements: Option, + spending_controls: Option>, + status: Option, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardholderBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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_), + + _ => ::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(), + object: 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 { + Some(Self::Out { + billing: self.billing.take()?, + company: self.company?, + created: self.created?, + email: self.email.take()?, + id: self.id.take()?, + individual: self.individual.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + name: self.name.take()?, + object: self.object?, + phone_number: self.phone_number.take()?, + preferred_locales: self.preferred_locales.take()?, + requirements: self.requirements.take()?, + spending_controls: self.spending_controls.take()?, + status: self.status?, + type_: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum IssuingCardholderObject { + IssuingCardholder, +} +impl IssuingCardholderObject { + pub fn as_str(self) -> &'static str { + use IssuingCardholderObject::*; + match self { + IssuingCardholder => "issuing.cardholder", + } + } +} + +impl std::str::FromStr for IssuingCardholderObject { + type Err = (); + fn from_str(s: &str) -> Result { + use IssuingCardholderObject::*; + match s { + "issuing.cardholder" => Ok(IssuingCardholder), + _ => Err(()), + } + } +} +impl std::fmt::Display for IssuingCardholderObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for IssuingCardholderObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for IssuingCardholderObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for IssuingCardholderObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardholderObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardholderObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for IssuingCardholderObject { + fn deserialize>(deserializer: D) -> 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 IssuingCardholderObject")) + } +} impl stripe_types::Object for IssuingCardholder { type Id = stripe_shared::IssuingCardholderId; fn id(&self) -> &Self::Id { @@ -103,6 +340,23 @@ impl serde::Serialize for IssuingCardholderPreferredLocales { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardholderPreferredLocales { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(IssuingCardholderPreferredLocales::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardholderPreferredLocales); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardholderPreferredLocales { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -160,6 +414,22 @@ impl serde::Serialize for IssuingCardholderStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardholderStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardholderStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardholderStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardholderStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -213,6 +483,22 @@ impl serde::Serialize for IssuingCardholderType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardholderType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingCardholderType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardholderType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardholderType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_cardholder_address.rs b/generated/stripe_shared/src/issuing_cardholder_address.rs index ed0c54052..d6fb4cc92 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingCardholderAddress { pub address: stripe_shared::Address, } +#[doc(hidden)] +pub struct IssuingCardholderAddressBuilder { + address: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardholderAddressBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { address: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { address: self.address.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..5c37d6123 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,121 @@ pub struct IssuingCardholderAuthorizationControls { /// Currency of the amounts within `spending_limits`. pub spending_limits_currency: Option, } +#[doc(hidden)] +pub struct IssuingCardholderAuthorizationControlsBuilder { + allowed_categories: + Option>>, + blocked_categories: + Option>>, + spending_limits: Option>>, + spending_limits_currency: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardholderAuthorizationControlsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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) + } + + _ => ::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 { + Some(Self::Out { + allowed_categories: self.allowed_categories.take()?, + blocked_categories: self.blocked_categories.take()?, + spending_limits: self.spending_limits.take()?, + spending_limits_currency: self.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 { + 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`. @@ -1028,6 +1145,7 @@ impl std::fmt::Debug for IssuingCardholderAuthorizationControlsAllowedCategories f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingCardholderAuthorizationControlsAllowedCategories { fn serialize(&self, serializer: S) -> Result where @@ -1036,12 +1154,32 @@ impl serde::Serialize for IssuingCardholderAuthorizationControlsAllowedCategorie serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardholderAuthorizationControlsAllowedCategories { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingCardholderAuthorizationControlsAllowedCategories::from_str(s) + .unwrap_or(IssuingCardholderAuthorizationControlsAllowedCategories::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardholderAuthorizationControlsAllowedCategories); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardholderAuthorizationControlsAllowedCategories { fn deserialize>(deserializer: D) -> Result { 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)) } } /// Array of strings containing [categories](https://stripe.com/docs/api#issuing_authorization_object-merchant_data-category) of authorizations to decline. @@ -2059,6 +2197,7 @@ impl std::fmt::Debug for IssuingCardholderAuthorizationControlsBlockedCategories f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingCardholderAuthorizationControlsBlockedCategories { fn serialize(&self, serializer: S) -> Result where @@ -2067,11 +2206,31 @@ impl serde::Serialize for IssuingCardholderAuthorizationControlsBlockedCategorie serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardholderAuthorizationControlsBlockedCategories { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingCardholderAuthorizationControlsBlockedCategories::from_str(s) + .unwrap_or(IssuingCardholderAuthorizationControlsBlockedCategories::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardholderAuthorizationControlsBlockedCategories); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardholderAuthorizationControlsBlockedCategories { fn deserialize>(deserializer: D) -> Result { 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)) } } diff --git a/generated/stripe_shared/src/issuing_cardholder_card_issuing.rs b/generated/stripe_shared/src/issuing_cardholder_card_issuing.rs index bd905a1c8..80d797664 100644 --- a/generated/stripe_shared/src/issuing_cardholder_card_issuing.rs +++ b/generated/stripe_shared/src/issuing_cardholder_card_issuing.rs @@ -1,6 +1,96 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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. pub user_terms_acceptance: Option, } +#[doc(hidden)] +pub struct IssuingCardholderCardIssuingBuilder { + user_terms_acceptance: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardholderCardIssuingBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { user_terms_acceptance: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { user_terms_acceptance: self.user_terms_acceptance.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..e6117a9dd 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingCardholderCompany { /// Whether the company's business ID number was provided. pub tax_id_provided: bool, } +#[doc(hidden)] +pub struct IssuingCardholderCompanyBuilder { + tax_id_provided: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardholderCompanyBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { tax_id_provided: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { tax_id_provided: self.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 { + 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..1704d6d27 100644 --- a/generated/stripe_shared/src/issuing_cardholder_id_document.rs +++ b/generated/stripe_shared/src/issuing_cardholder_id_document.rs @@ -1,7 +1,98 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, /// 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>, } +#[doc(hidden)] +pub struct IssuingCardholderIdDocumentBuilder { + back: Option>>, + front: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardholderIdDocumentBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { back: Deserialize::default(), front: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { back: self.back.take()?, front: self.front.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..26c54e692 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingCardholderIndividual { /// Information related to the card_issuing program for this cardholder. - #[serde(skip_serializing_if = "Option::is_none")] pub card_issuing: Option, /// The date of birth of this cardholder. pub dob: Option, @@ -16,3 +17,113 @@ pub struct IssuingCardholderIndividual { /// Government-issued ID document for this cardholder. pub verification: Option, } +#[doc(hidden)] +pub struct IssuingCardholderIndividualBuilder { + card_issuing: Option>, + dob: Option>, + first_name: Option>, + last_name: Option>, + verification: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardholderIndividualBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + card_issuing: self.card_issuing.take()?, + dob: self.dob?, + first_name: self.first_name.take()?, + last_name: self.last_name.take()?, + verification: self.verification.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..cd5e61fe8 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingCardholderIndividualDob { /// The day of birth, between 1 and 31. pub day: Option, @@ -7,3 +9,99 @@ pub struct IssuingCardholderIndividualDob { /// The four-digit year of birth. pub year: Option, } +#[doc(hidden)] +pub struct IssuingCardholderIndividualDobBuilder { + day: Option>, + month: Option>, + year: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardholderIndividualDobBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + day: Deserialize::default(), + month: Deserialize::default(), + year: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { day: self.day?, month: self.month?, year: self.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 { + 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..536912568 100644 --- a/generated/stripe_shared/src/issuing_cardholder_requirements.rs +++ b/generated/stripe_shared/src/issuing_cardholder_requirements.rs @@ -1,10 +1,104 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingCardholderRequirements { /// If `disabled_reason` is present, all cards will decline authorizations with `cardholder_verification_required` reason. pub disabled_reason: Option, /// Array of fields that need to be collected in order to verify and re-enable the cardholder. pub past_due: Option>, } +#[doc(hidden)] +pub struct IssuingCardholderRequirementsBuilder { + disabled_reason: Option>, + past_due: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardholderRequirementsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { disabled_reason: Deserialize::default(), past_due: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + disabled_reason: self.disabled_reason?, + past_due: self.past_due.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -49,6 +143,7 @@ impl std::fmt::Debug for IssuingCardholderRequirementsDisabledReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingCardholderRequirementsDisabledReason { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +152,25 @@ impl serde::Serialize for IssuingCardholderRequirementsDisabledReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardholderRequirementsDisabledReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingCardholderRequirementsDisabledReason::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardholderRequirementsDisabledReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardholderRequirementsDisabledReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -135,6 +249,7 @@ impl std::fmt::Debug for IssuingCardholderRequirementsPastDue { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingCardholderRequirementsPastDue { fn serialize(&self, serializer: S) -> Result where @@ -143,6 +258,23 @@ impl serde::Serialize for IssuingCardholderRequirementsPastDue { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardholderRequirementsPastDue { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(IssuingCardholderRequirementsPastDue::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardholderRequirementsPastDue); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardholderRequirementsPastDue { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_cardholder_spending_limit.rs b/generated/stripe_shared/src/issuing_cardholder_spending_limit.rs index 4ca0340cc..c26e0f40b 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,106 @@ pub struct IssuingCardholderSpendingLimit { /// Interval (or event) to which the amount applies. pub interval: IssuingCardholderSpendingLimitInterval, } +#[doc(hidden)] +pub struct IssuingCardholderSpendingLimitBuilder { + amount: Option, + categories: Option>>, + interval: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardholderSpendingLimitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + categories: Deserialize::default(), + interval: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + categories: self.categories.take()?, + interval: self.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 { + 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)] @@ -1023,6 +1125,7 @@ impl std::fmt::Debug for IssuingCardholderSpendingLimitCategories { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingCardholderSpendingLimitCategories { fn serialize(&self, serializer: S) -> Result where @@ -1031,11 +1134,30 @@ impl serde::Serialize for IssuingCardholderSpendingLimitCategories { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardholderSpendingLimitCategories { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingCardholderSpendingLimitCategories::from_str(s) + .unwrap_or(IssuingCardholderSpendingLimitCategories::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardholderSpendingLimitCategories); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardholderSpendingLimitCategories { fn deserialize>(deserializer: D) -> Result { 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)) } } /// Interval (or event) to which the amount applies. @@ -1088,6 +1210,7 @@ impl std::fmt::Debug for IssuingCardholderSpendingLimitInterval { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingCardholderSpendingLimitInterval { fn serialize(&self, serializer: S) -> Result where @@ -1096,6 +1219,24 @@ impl serde::Serialize for IssuingCardholderSpendingLimitInterval { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingCardholderSpendingLimitInterval { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingCardholderSpendingLimitInterval::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingCardholderSpendingLimitInterval); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingCardholderSpendingLimitInterval { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..01f607adb 100644 --- a/generated/stripe_shared/src/issuing_cardholder_user_terms_acceptance.rs +++ b/generated/stripe_shared/src/issuing_cardholder_user_terms_acceptance.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingCardholderUserTermsAcceptance { /// The Unix timestamp marking when the cardholder accepted the Authorized User Terms. pub date: Option, @@ -7,3 +9,103 @@ pub struct IssuingCardholderUserTermsAcceptance { /// The user agent of the browser from which the cardholder accepted the Authorized User Terms. pub user_agent: Option, } +#[doc(hidden)] +pub struct IssuingCardholderUserTermsAcceptanceBuilder { + date: Option>, + ip: Option>, + user_agent: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardholderUserTermsAcceptanceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + date: Deserialize::default(), + ip: Deserialize::default(), + user_agent: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + date: self.date?, + ip: self.ip.take()?, + user_agent: self.user_agent.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..1fbfa2188 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingCardholderVerification { /// An identifying document, either a passport or local ID card. pub document: Option, } +#[doc(hidden)] +pub struct IssuingCardholderVerificationBuilder { + document: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingCardholderVerificationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { document: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { document: self.document.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..d82f7abff 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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). @@ -22,14 +24,230 @@ pub struct IssuingDispute { /// 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 representing the object's type. Objects of the same type share the same value. + pub object: IssuingDisputeObject, /// Current status of the dispute. pub status: stripe_shared::IssuingDisputeStatus, /// The transaction being disputed. pub transaction: stripe_types::Expandable, /// [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, } +#[doc(hidden)] +pub struct IssuingDisputeBuilder { + amount: Option, + balance_transactions: Option>>, + created: Option, + currency: Option, + evidence: Option, + id: Option, + livemode: Option, + metadata: Option>, + object: Option, + status: Option, + transaction: Option>, + treasury: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingDisputeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "status" => Deserialize::begin(&mut self.status), + "transaction" => Deserialize::begin(&mut self.transaction), + "treasury" => Deserialize::begin(&mut self.treasury), + + _ => ::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(), + object: Deserialize::default(), + status: Deserialize::default(), + transaction: Deserialize::default(), + treasury: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + balance_transactions: self.balance_transactions.take()?, + created: self.created?, + currency: self.currency?, + evidence: self.evidence.take()?, + id: self.id.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + status: self.status?, + transaction: self.transaction.take()?, + treasury: self.treasury.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum IssuingDisputeObject { + IssuingDispute, +} +impl IssuingDisputeObject { + pub fn as_str(self) -> &'static str { + use IssuingDisputeObject::*; + match self { + IssuingDispute => "issuing.dispute", + } + } +} + +impl std::str::FromStr for IssuingDisputeObject { + type Err = (); + fn from_str(s: &str) -> Result { + use IssuingDisputeObject::*; + match s { + "issuing.dispute" => Ok(IssuingDispute), + _ => Err(()), + } + } +} +impl std::fmt::Display for IssuingDisputeObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for IssuingDisputeObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for IssuingDisputeObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for IssuingDisputeObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingDisputeObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingDisputeObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for IssuingDisputeObject { + fn deserialize>(deserializer: D) -> 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 IssuingDisputeObject")) + } +} impl stripe_types::Object for IssuingDispute { type Id = stripe_shared::IssuingDisputeId; fn id(&self) -> &Self::Id { @@ -91,6 +309,22 @@ impl serde::Serialize for IssuingDisputeStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingDisputeStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingDisputeStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingDisputeStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingDisputeStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_dispute_canceled_evidence.rs b/generated/stripe_shared/src/issuing_dispute_canceled_evidence.rs index f060bf7a0..d3b8bf7fb 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingDisputeCanceledEvidence { /// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute. pub additional_documentation: Option>, @@ -21,6 +23,153 @@ pub struct IssuingDisputeCanceledEvidence { /// Date when the product was returned or attempted to be returned. pub returned_at: Option, } +#[doc(hidden)] +pub struct IssuingDisputeCanceledEvidenceBuilder { + additional_documentation: Option>>, + canceled_at: Option>, + cancellation_policy_provided: Option>, + cancellation_reason: Option>, + expected_at: Option>, + explanation: Option>, + product_description: Option>, + product_type: Option>, + return_status: Option>, + returned_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingDisputeCanceledEvidenceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + additional_documentation: self.additional_documentation.take()?, + canceled_at: self.canceled_at?, + cancellation_policy_provided: self.cancellation_policy_provided?, + cancellation_reason: self.cancellation_reason.take()?, + expected_at: self.expected_at?, + explanation: self.explanation.take()?, + product_description: self.product_description.take()?, + product_type: self.product_type?, + return_status: self.return_status?, + returned_at: self.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 { + 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 { @@ -59,6 +208,7 @@ impl std::fmt::Debug for IssuingDisputeCanceledEvidenceProductType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingDisputeCanceledEvidenceProductType { fn serialize(&self, serializer: S) -> Result where @@ -67,6 +217,24 @@ impl serde::Serialize for IssuingDisputeCanceledEvidenceProductType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingDisputeCanceledEvidenceProductType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingDisputeCanceledEvidenceProductType::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingDisputeCanceledEvidenceProductType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingDisputeCanceledEvidenceProductType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -114,6 +282,7 @@ impl std::fmt::Debug for IssuingDisputeCanceledEvidenceReturnStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingDisputeCanceledEvidenceReturnStatus { fn serialize(&self, serializer: S) -> Result where @@ -122,6 +291,25 @@ impl serde::Serialize for IssuingDisputeCanceledEvidenceReturnStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingDisputeCanceledEvidenceReturnStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingDisputeCanceledEvidenceReturnStatus::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingDisputeCanceledEvidenceReturnStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingDisputeCanceledEvidenceReturnStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_dispute_duplicate_evidence.rs b/generated/stripe_shared/src/issuing_dispute_duplicate_evidence.rs index 816a47a52..68473c801 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingDisputeDuplicateEvidence { /// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute. pub additional_documentation: Option>, @@ -14,3 +16,124 @@ pub struct IssuingDisputeDuplicateEvidence { /// Of the two or more transactions that are copies of each other, this is original undisputed one. pub original_transaction: Option, } +#[doc(hidden)] +pub struct IssuingDisputeDuplicateEvidenceBuilder { + additional_documentation: Option>>, + card_statement: Option>>, + cash_receipt: Option>>, + check_image: Option>>, + explanation: Option>, + original_transaction: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingDisputeDuplicateEvidenceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + additional_documentation: self.additional_documentation.take()?, + card_statement: self.card_statement.take()?, + cash_receipt: self.cash_receipt.take()?, + check_image: self.check_image.take()?, + explanation: self.explanation.take()?, + original_transaction: self.original_transaction.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..0b72a076e 100644 --- a/generated/stripe_shared/src/issuing_dispute_evidence.rs +++ b/generated/stripe_shared/src/issuing_dispute_evidence.rs @@ -1,24 +1,154 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingDisputeEvidence { - #[serde(skip_serializing_if = "Option::is_none")] pub canceled: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub duplicate: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub fraudulent: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub merchandise_not_as_described: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub not_received: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub other: Option, /// 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, } +#[doc(hidden)] +pub struct IssuingDisputeEvidenceBuilder { + canceled: Option>, + duplicate: Option>, + fraudulent: Option>, + merchandise_not_as_described: + Option>, + not_received: Option>, + other: Option>, + reason: Option, + service_not_as_described: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingDisputeEvidenceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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) + } + + _ => ::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 { + Some(Self::Out { + canceled: self.canceled.take()?, + duplicate: self.duplicate.take()?, + fraudulent: self.fraudulent.take()?, + merchandise_not_as_described: self.merchandise_not_as_described.take()?, + not_received: self.not_received.take()?, + other: self.other.take()?, + reason: self.reason?, + service_not_as_described: self.service_not_as_described.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -72,6 +202,7 @@ impl std::fmt::Debug for IssuingDisputeEvidenceReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingDisputeEvidenceReason { fn serialize(&self, serializer: S) -> Result where @@ -80,6 +211,22 @@ impl serde::Serialize for IssuingDisputeEvidenceReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingDisputeEvidenceReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingDisputeEvidenceReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingDisputeEvidenceReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingDisputeEvidenceReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_dispute_fraudulent_evidence.rs b/generated/stripe_shared/src/issuing_dispute_fraudulent_evidence.rs index 36058d9c0..ff3da5a37 100644 --- a/generated/stripe_shared/src/issuing_dispute_fraudulent_evidence.rs +++ b/generated/stripe_shared/src/issuing_dispute_fraudulent_evidence.rs @@ -1,7 +1,108 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingDisputeFraudulentEvidence { /// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute. pub additional_documentation: Option>, /// Explanation of why the cardholder is disputing this transaction. pub explanation: Option, } +#[doc(hidden)] +pub struct IssuingDisputeFraudulentEvidenceBuilder { + additional_documentation: Option>>, + explanation: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingDisputeFraudulentEvidenceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + additional_documentation: Deserialize::default(), + explanation: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + additional_documentation: self.additional_documentation.take()?, + explanation: self.explanation.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..1e3ea340f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingDisputeMerchandiseNotAsDescribedEvidence { /// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute. pub additional_documentation: Option>, @@ -13,6 +15,127 @@ pub struct IssuingDisputeMerchandiseNotAsDescribedEvidence { /// Date when the product was returned or attempted to be returned. pub returned_at: Option, } +#[doc(hidden)] +pub struct IssuingDisputeMerchandiseNotAsDescribedEvidenceBuilder { + additional_documentation: Option>>, + explanation: Option>, + received_at: Option>, + return_description: Option>, + return_status: Option>, + returned_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingDisputeMerchandiseNotAsDescribedEvidenceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + additional_documentation: self.additional_documentation.take()?, + explanation: self.explanation.take()?, + received_at: self.received_at?, + return_description: self.return_description.take()?, + return_status: self.return_status?, + returned_at: self.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 { + 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 { @@ -51,6 +174,7 @@ impl std::fmt::Debug for IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnSt f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus { fn serialize(&self, serializer: S) -> Result where @@ -59,6 +183,29 @@ impl serde::Serialize for IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnS serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingDisputeMerchandiseNotAsDescribedEvidenceReturnStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..fed478136 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingDisputeNotReceivedEvidence { /// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute. pub additional_documentation: Option>, @@ -11,6 +13,122 @@ pub struct IssuingDisputeNotReceivedEvidence { /// Whether the product was a merchandise or service. pub product_type: Option, } +#[doc(hidden)] +pub struct IssuingDisputeNotReceivedEvidenceBuilder { + additional_documentation: Option>>, + expected_at: Option>, + explanation: Option>, + product_description: Option>, + product_type: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingDisputeNotReceivedEvidenceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + additional_documentation: self.additional_documentation.take()?, + expected_at: self.expected_at?, + explanation: self.explanation.take()?, + product_description: self.product_description.take()?, + product_type: self.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 { + 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 { @@ -49,6 +167,7 @@ impl std::fmt::Debug for IssuingDisputeNotReceivedEvidenceProductType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingDisputeNotReceivedEvidenceProductType { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +176,25 @@ impl serde::Serialize for IssuingDisputeNotReceivedEvidenceProductType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingDisputeNotReceivedEvidenceProductType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingDisputeNotReceivedEvidenceProductType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingDisputeNotReceivedEvidenceProductType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingDisputeNotReceivedEvidenceProductType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_dispute_other_evidence.rs b/generated/stripe_shared/src/issuing_dispute_other_evidence.rs index 471711d49..f9dbc1242 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingDisputeOtherEvidence { /// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute. pub additional_documentation: Option>, @@ -9,6 +11,117 @@ pub struct IssuingDisputeOtherEvidence { /// Whether the product was a merchandise or service. pub product_type: Option, } +#[doc(hidden)] +pub struct IssuingDisputeOtherEvidenceBuilder { + additional_documentation: Option>>, + explanation: Option>, + product_description: Option>, + product_type: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingDisputeOtherEvidenceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + additional_documentation: self.additional_documentation.take()?, + explanation: self.explanation.take()?, + product_description: self.product_description.take()?, + product_type: self.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 { + 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 { @@ -47,6 +160,7 @@ impl std::fmt::Debug for IssuingDisputeOtherEvidenceProductType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingDisputeOtherEvidenceProductType { fn serialize(&self, serializer: S) -> Result where @@ -55,6 +169,24 @@ impl serde::Serialize for IssuingDisputeOtherEvidenceProductType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingDisputeOtherEvidenceProductType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingDisputeOtherEvidenceProductType::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingDisputeOtherEvidenceProductType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingDisputeOtherEvidenceProductType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..006eedd16 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingDisputeServiceNotAsDescribedEvidence { /// (ID of a [file upload](https://stripe.com/docs/guides/file-upload)) Additional documentation supporting the dispute. pub additional_documentation: Option>, @@ -11,3 +13,119 @@ pub struct IssuingDisputeServiceNotAsDescribedEvidence { /// Date when the product was received. pub received_at: Option, } +#[doc(hidden)] +pub struct IssuingDisputeServiceNotAsDescribedEvidenceBuilder { + additional_documentation: Option>>, + canceled_at: Option>, + cancellation_reason: Option>, + explanation: Option>, + received_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingDisputeServiceNotAsDescribedEvidenceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + additional_documentation: self.additional_documentation.take()?, + canceled_at: self.canceled_at?, + cancellation_reason: self.cancellation_reason.take()?, + explanation: self.explanation.take()?, + received_at: self.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 { + 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..f89d0063f 100644 --- a/generated/stripe_shared/src/issuing_dispute_treasury.rs +++ b/generated/stripe_shared/src/issuing_dispute_treasury.rs @@ -1,7 +1,101 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingDisputeTreasury { /// The Treasury [DebitReversal](https://stripe.com/docs/api/treasury/debit_reversals) representing this Issuing dispute. pub debit_reversal: Option, /// The Treasury [ReceivedDebit](https://stripe.com/docs/api/treasury/received_debits) that is being disputed. pub received_debit: String, } +#[doc(hidden)] +pub struct IssuingDisputeTreasuryBuilder { + debit_reversal: Option>, + received_debit: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingDisputeTreasuryBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { debit_reversal: Deserialize::default(), received_debit: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + debit_reversal: self.debit_reversal.take()?, + received_debit: self.received_debit.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..0d2dc22a0 100644 --- a/generated/stripe_shared/src/issuing_network_token_address.rs +++ b/generated/stripe_shared/src/issuing_network_token_address.rs @@ -1,7 +1,98 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct IssuingNetworkTokenAddressBuilder { + line1: Option, + postal_code: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingNetworkTokenAddressBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { line1: Deserialize::default(), postal_code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { line1: self.line1.take()?, postal_code: self.postal_code.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..2d629a6cc 100644 --- a/generated/stripe_shared/src/issuing_network_token_device.rs +++ b/generated/stripe_shared/src/issuing_network_token_device.rs @@ -1,26 +1,139 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingNetworkTokenDevice { /// An obfuscated ID derived from the device ID. - #[serde(skip_serializing_if = "Option::is_none")] pub device_fingerprint: Option, /// The IP address of the device at provisioning time. - #[serde(skip_serializing_if = "Option::is_none")] pub ip_address: Option, /// 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, /// The name of the device used for tokenization. - #[serde(skip_serializing_if = "Option::is_none")] pub name: Option, /// The phone number of the device used for tokenization. - #[serde(skip_serializing_if = "Option::is_none")] pub phone_number: Option, /// The type of device used for tokenization. - #[serde(rename = "type")] - #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: Option, } +#[doc(hidden)] +pub struct IssuingNetworkTokenDeviceBuilder { + device_fingerprint: Option>, + ip_address: Option>, + location: Option>, + name: Option>, + phone_number: Option>, + type_: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingNetworkTokenDeviceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + device_fingerprint: self.device_fingerprint.take()?, + ip_address: self.ip_address.take()?, + location: self.location.take()?, + name: self.name.take()?, + phone_number: self.phone_number.take()?, + type_: self.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 { + 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 { @@ -62,6 +175,7 @@ impl std::fmt::Debug for IssuingNetworkTokenDeviceType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingNetworkTokenDeviceType { fn serialize(&self, serializer: S) -> Result where @@ -70,6 +184,22 @@ impl serde::Serialize for IssuingNetworkTokenDeviceType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingNetworkTokenDeviceType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingNetworkTokenDeviceType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingNetworkTokenDeviceType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingNetworkTokenDeviceType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_network_token_mastercard.rs b/generated/stripe_shared/src/issuing_network_token_mastercard.rs index a76c0a20c..95e0f6e3a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// The network-unique identifier for the token. pub token_reference_id: String, @@ -9,6 +10,116 @@ 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, } +#[doc(hidden)] +pub struct IssuingNetworkTokenMastercardBuilder { + card_reference_id: Option>, + token_reference_id: Option, + token_requestor_id: Option, + token_requestor_name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingNetworkTokenMastercardBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + card_reference_id: self.card_reference_id.take()?, + token_reference_id: self.token_reference_id.take()?, + token_requestor_id: self.token_requestor_id.take()?, + token_requestor_name: self.token_requestor_name.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..944f18e43 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,126 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingNetworkTokenNetworkData { - #[serde(skip_serializing_if = "Option::is_none")] pub device: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub mastercard: Option, /// 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(feature = "serde", serde(rename = "type"))] pub type_: IssuingNetworkTokenNetworkDataType, - #[serde(skip_serializing_if = "Option::is_none")] pub visa: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub wallet_provider: Option, } +#[doc(hidden)] +pub struct IssuingNetworkTokenNetworkDataBuilder { + device: Option>, + mastercard: Option>, + type_: Option, + visa: Option>, + wallet_provider: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingNetworkTokenNetworkDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + device: self.device.take()?, + mastercard: self.mastercard.take()?, + type_: self.type_?, + visa: self.visa.take()?, + wallet_provider: self.wallet_provider.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)] @@ -52,6 +160,7 @@ impl std::fmt::Debug for IssuingNetworkTokenNetworkDataType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingNetworkTokenNetworkDataType { fn serialize(&self, serializer: S) -> Result where @@ -60,6 +169,23 @@ impl serde::Serialize for IssuingNetworkTokenNetworkDataType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingNetworkTokenNetworkDataType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(IssuingNetworkTokenNetworkDataType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingNetworkTokenNetworkDataType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingNetworkTokenNetworkDataType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_network_token_visa.rs b/generated/stripe_shared/src/issuing_network_token_visa.rs index a88180197..36f93f0cb 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingNetworkTokenVisa { /// A unique reference ID from Visa to represent the card account number. pub card_reference_id: String, @@ -8,6 +10,114 @@ 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, } +#[doc(hidden)] +pub struct IssuingNetworkTokenVisaBuilder { + card_reference_id: Option, + token_reference_id: Option, + token_requestor_id: Option, + token_risk_score: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingNetworkTokenVisaBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + card_reference_id: self.card_reference_id.take()?, + token_reference_id: self.token_reference_id.take()?, + token_requestor_id: self.token_requestor_id.take()?, + token_risk_score: self.token_risk_score.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..1a30fddbc 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,181 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// 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, /// The method used for tokenizing a card. - #[serde(skip_serializing_if = "Option::is_none")] pub card_number_source: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cardholder_address: Option, /// The name of the cardholder tokenizing the card. - #[serde(skip_serializing_if = "Option::is_none")] pub cardholder_name: Option, /// 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, /// 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, /// The reasons for suggested tokenization given by the card network. - #[serde(skip_serializing_if = "Option::is_none")] pub reason_codes: Option>, /// The recommendation on responding to the tokenization request. - #[serde(skip_serializing_if = "Option::is_none")] pub suggested_decision: Option, /// 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, } +#[doc(hidden)] +pub struct IssuingNetworkTokenWalletProviderBuilder { + account_id: Option>, + account_trust_score: Option>, + card_number_source: Option>, + cardholder_address: Option>, + cardholder_name: Option>, + device_trust_score: Option>, + hashed_account_email_address: Option>, + reason_codes: Option>>, + suggested_decision: Option>, + suggested_decision_version: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingNetworkTokenWalletProviderBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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) + } + + _ => ::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 { + Some(Self::Out { + account_id: self.account_id.take()?, + account_trust_score: self.account_trust_score?, + card_number_source: self.card_number_source?, + cardholder_address: self.cardholder_address.take()?, + cardholder_name: self.cardholder_name.take()?, + device_trust_score: self.device_trust_score?, + hashed_account_email_address: self.hashed_account_email_address.take()?, + reason_codes: self.reason_codes.take()?, + suggested_decision: self.suggested_decision?, + suggested_decision_version: self.suggested_decision_version.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -75,6 +220,7 @@ impl std::fmt::Debug for IssuingNetworkTokenWalletProviderCardNumberSource { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingNetworkTokenWalletProviderCardNumberSource { fn serialize(&self, serializer: S) -> Result where @@ -83,6 +229,25 @@ impl serde::Serialize for IssuingNetworkTokenWalletProviderCardNumberSource { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingNetworkTokenWalletProviderCardNumberSource { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingNetworkTokenWalletProviderCardNumberSource::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingNetworkTokenWalletProviderCardNumberSource); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingNetworkTokenWalletProviderCardNumberSource { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -222,6 +387,7 @@ impl std::fmt::Debug for IssuingNetworkTokenWalletProviderReasonCodes { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingNetworkTokenWalletProviderReasonCodes { fn serialize(&self, serializer: S) -> Result where @@ -230,11 +396,30 @@ impl serde::Serialize for IssuingNetworkTokenWalletProviderReasonCodes { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingNetworkTokenWalletProviderReasonCodes { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingNetworkTokenWalletProviderReasonCodes::from_str(s) + .unwrap_or(IssuingNetworkTokenWalletProviderReasonCodes::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingNetworkTokenWalletProviderReasonCodes); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingNetworkTokenWalletProviderReasonCodes { fn deserialize>(deserializer: D) -> Result { 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)) } } /// The recommendation on responding to the tokenization request. @@ -278,6 +463,7 @@ impl std::fmt::Debug for IssuingNetworkTokenWalletProviderSuggestedDecision { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingNetworkTokenWalletProviderSuggestedDecision { fn serialize(&self, serializer: S) -> Result where @@ -286,6 +472,25 @@ impl serde::Serialize for IssuingNetworkTokenWalletProviderSuggestedDecision { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingNetworkTokenWalletProviderSuggestedDecision { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + IssuingNetworkTokenWalletProviderSuggestedDecision::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingNetworkTokenWalletProviderSuggestedDecision); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingNetworkTokenWalletProviderSuggestedDecision { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_token.rs b/generated/stripe_shared/src/issuing_token.rs index 2867187c1..3908239a7 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingToken { /// Card associated with this token. pub card: stripe_types::Expandable, @@ -13,23 +15,171 @@ 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, /// 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, /// Time at which the token was last updated by the card network. /// Measured in seconds since the Unix epoch. pub network_updated_at: stripe_types::Timestamp, + /// String representing the object's type. Objects of the same type share the same value. + pub object: IssuingTokenObject, /// 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, } +#[doc(hidden)] +pub struct IssuingTokenBuilder { + card: Option>, + created: Option, + device_fingerprint: Option>, + id: Option, + last4: Option>, + livemode: Option, + network: Option, + network_data: Option>, + network_updated_at: Option, + object: Option, + status: Option, + wallet_provider: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingTokenBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "status" => Deserialize::begin(&mut self.status), + "wallet_provider" => Deserialize::begin(&mut self.wallet_provider), + + _ => ::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(), + object: Deserialize::default(), + status: Deserialize::default(), + wallet_provider: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + card: self.card.take()?, + created: self.created?, + device_fingerprint: self.device_fingerprint.take()?, + id: self.id.take()?, + last4: self.last4.take()?, + livemode: self.livemode?, + network: self.network?, + network_data: self.network_data.take()?, + network_updated_at: self.network_updated_at?, + object: self.object?, + status: self.status?, + wallet_provider: self.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 { + 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)?) + } + "object" => b.object = 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 { @@ -68,6 +218,7 @@ impl std::fmt::Debug for IssuingTokenNetwork { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingTokenNetwork { fn serialize(&self, serializer: S) -> Result where @@ -76,6 +227,22 @@ impl serde::Serialize for IssuingTokenNetwork { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingTokenNetwork { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingTokenNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingTokenNetwork); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingTokenNetwork { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -84,6 +251,74 @@ impl<'de> serde::Deserialize<'de> for IssuingTokenNetwork { .map_err(|_| serde::de::Error::custom("Unknown value for IssuingTokenNetwork")) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum IssuingTokenObject { + IssuingToken, +} +impl IssuingTokenObject { + pub fn as_str(self) -> &'static str { + use IssuingTokenObject::*; + match self { + IssuingToken => "issuing.token", + } + } +} + +impl std::str::FromStr for IssuingTokenObject { + type Err = (); + fn from_str(s: &str) -> Result { + use IssuingTokenObject::*; + match s { + "issuing.token" => Ok(IssuingToken), + _ => Err(()), + } + } +} +impl std::fmt::Display for IssuingTokenObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for IssuingTokenObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for IssuingTokenObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for IssuingTokenObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingTokenObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingTokenObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for IssuingTokenObject { + fn deserialize>(deserializer: D) -> 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 IssuingTokenObject")) + } +} /// The digital wallet for this token, if one was used. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingTokenWalletProvider { @@ -125,6 +360,7 @@ impl std::fmt::Debug for IssuingTokenWalletProvider { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingTokenWalletProvider { fn serialize(&self, serializer: S) -> Result where @@ -133,6 +369,22 @@ impl serde::Serialize for IssuingTokenWalletProvider { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingTokenWalletProvider { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingTokenWalletProvider::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingTokenWalletProvider); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingTokenWalletProvider { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -199,6 +451,22 @@ impl serde::Serialize for IssuingTokenStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingTokenStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingTokenStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingTokenStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingTokenStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_transaction.rs b/generated/stripe_shared/src/issuing_transaction.rs index c7251e7ec..b78ba6dc3 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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). @@ -43,21 +45,287 @@ pub struct IssuingTransaction { pub metadata: std::collections::HashMap, /// Details about the transaction, such as processing dates, set by the card network. pub network_data: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: IssuingTransactionObject, /// Additional purchase information that is optionally provided by the merchant. pub purchase_details: Option, /// [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>, /// [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, /// The nature of the transaction. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", 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, } +#[doc(hidden)] +pub struct IssuingTransactionBuilder { + amount: Option, + amount_details: Option>, + authorization: Option>>, + balance_transaction: + Option>>, + card: Option>, + cardholder: Option>>, + created: Option, + currency: Option, + dispute: Option>>, + id: Option, + livemode: Option, + merchant_amount: Option, + merchant_currency: Option, + merchant_data: Option, + metadata: Option>, + network_data: Option>, + object: Option, + purchase_details: Option>, + token: Option>>, + treasury: Option>, + type_: Option, + wallet: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingTransactionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: Deserialize::default(), + purchase_details: Deserialize::default(), + token: Deserialize::default(), + treasury: Deserialize::default(), + type_: Deserialize::default(), + wallet: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + amount_details: self.amount_details?, + authorization: self.authorization.take()?, + balance_transaction: self.balance_transaction.take()?, + card: self.card.take()?, + cardholder: self.cardholder.take()?, + created: self.created?, + currency: self.currency?, + dispute: self.dispute.take()?, + id: self.id.take()?, + livemode: self.livemode?, + merchant_amount: self.merchant_amount?, + merchant_currency: self.merchant_currency?, + merchant_data: self.merchant_data.take()?, + metadata: self.metadata.take()?, + network_data: self.network_data.take()?, + object: self.object?, + purchase_details: self.purchase_details.take()?, + token: self.token.take()?, + treasury: self.treasury.take()?, + type_: self.type_?, + wallet: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum IssuingTransactionObject { + IssuingTransaction, +} +impl IssuingTransactionObject { + pub fn as_str(self) -> &'static str { + use IssuingTransactionObject::*; + match self { + IssuingTransaction => "issuing.transaction", + } + } +} + +impl std::str::FromStr for IssuingTransactionObject { + type Err = (); + fn from_str(s: &str) -> Result { + use IssuingTransactionObject::*; + match s { + "issuing.transaction" => Ok(IssuingTransaction), + _ => Err(()), + } + } +} +impl std::fmt::Display for IssuingTransactionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for IssuingTransactionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for IssuingTransactionObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for IssuingTransactionObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingTransactionObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingTransactionObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for IssuingTransactionObject { + fn deserialize>(deserializer: D) -> 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 IssuingTransactionObject")) + } +} /// The digital wallet used for this transaction. One of `apple_pay`, `google_pay`, or `samsung_pay`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum IssuingTransactionWallet { @@ -99,6 +367,7 @@ impl std::fmt::Debug for IssuingTransactionWallet { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for IssuingTransactionWallet { fn serialize(&self, serializer: S) -> Result where @@ -107,6 +376,22 @@ impl serde::Serialize for IssuingTransactionWallet { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingTransactionWallet { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingTransactionWallet::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingTransactionWallet); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingTransactionWallet { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -167,6 +452,22 @@ impl serde::Serialize for IssuingTransactionType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for IssuingTransactionType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(IssuingTransactionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(IssuingTransactionType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for IssuingTransactionType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/issuing_transaction_amount_details.rs b/generated/stripe_shared/src/issuing_transaction_amount_details.rs index 8c5db148b..a79a6b325 100644 --- a/generated/stripe_shared/src/issuing_transaction_amount_details.rs +++ b/generated/stripe_shared/src/issuing_transaction_amount_details.rs @@ -1,7 +1,98 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingTransactionAmountDetails { /// The fee charged by the ATM for the cash withdrawal. pub atm_fee: Option, /// The amount of cash requested by the cardholder. pub cashback_amount: Option, } +#[doc(hidden)] +pub struct IssuingTransactionAmountDetailsBuilder { + atm_fee: Option>, + cashback_amount: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingTransactionAmountDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { atm_fee: Deserialize::default(), cashback_amount: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { atm_fee: self.atm_fee?, cashback_amount: self.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 { + 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..ae532d8e2 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingTransactionFlightData { /// The time that the flight departed. pub departure_at: Option, @@ -11,3 +13,113 @@ pub struct IssuingTransactionFlightData { /// The travel agency that issued the ticket. pub travel_agency: Option, } +#[doc(hidden)] +pub struct IssuingTransactionFlightDataBuilder { + departure_at: Option>, + passenger_name: Option>, + refundable: Option>, + segments: Option>>, + travel_agency: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingTransactionFlightDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + departure_at: self.departure_at?, + passenger_name: self.passenger_name.take()?, + refundable: self.refundable?, + segments: self.segments.take()?, + travel_agency: self.travel_agency.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..b89bc66d3 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingTransactionFlightDataLeg { /// The three-letter IATA airport code of the flight's destination. pub arrival_airport_code: Option, @@ -13,3 +15,122 @@ pub struct IssuingTransactionFlightDataLeg { /// Whether a stopover is allowed on this flight. pub stopover_allowed: Option, } +#[doc(hidden)] +pub struct IssuingTransactionFlightDataLegBuilder { + arrival_airport_code: Option>, + carrier: Option>, + departure_airport_code: Option>, + flight_number: Option>, + service_class: Option>, + stopover_allowed: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingTransactionFlightDataLegBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + arrival_airport_code: self.arrival_airport_code.take()?, + carrier: self.carrier.take()?, + departure_airport_code: self.departure_airport_code.take()?, + flight_number: self.flight_number.take()?, + service_class: self.service_class.take()?, + stopover_allowed: self.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 { + 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..3a2eb0d80 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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(feature = "serde", serde(rename = "type"))] pub type_: String, /// The units for `volume_decimal`. One of `us_gallon` or `liter`. pub unit: String, @@ -11,3 +13,108 @@ 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, } +#[doc(hidden)] +pub struct IssuingTransactionFuelDataBuilder { + type_: Option, + unit: Option, + unit_cost_decimal: Option, + volume_decimal: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingTransactionFuelDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + type_: self.type_.take()?, + unit: self.unit.take()?, + unit_cost_decimal: self.unit_cost_decimal.take()?, + volume_decimal: self.volume_decimal.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..c1a56cc3e 100644 --- a/generated/stripe_shared/src/issuing_transaction_lodging_data.rs +++ b/generated/stripe_shared/src/issuing_transaction_lodging_data.rs @@ -1,7 +1,98 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingTransactionLodgingData { /// The time of checking into the lodging. pub check_in_at: Option, /// The number of nights stayed at the lodging. pub nights: Option, } +#[doc(hidden)] +pub struct IssuingTransactionLodgingDataBuilder { + check_in_at: Option>, + nights: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingTransactionLodgingDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { check_in_at: Deserialize::default(), nights: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { check_in_at: self.check_in_at?, nights: self.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 { + 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..535dc0f4d 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,105 @@ 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, } +#[doc(hidden)] +pub struct IssuingTransactionNetworkDataBuilder { + authorization_code: Option>, + processing_date: Option>, + transaction_id: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingTransactionNetworkDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + authorization_code: Deserialize::default(), + processing_date: Deserialize::default(), + transaction_id: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + authorization_code: self.authorization_code.take()?, + processing_date: self.processing_date.take()?, + transaction_id: self.transaction_id.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..74cc2eaec 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingTransactionPurchaseDetails { /// Information about the flight that was purchased with this transaction. pub flight: Option, @@ -11,3 +13,113 @@ pub struct IssuingTransactionPurchaseDetails { /// A merchant-specific order number. pub reference: Option, } +#[doc(hidden)] +pub struct IssuingTransactionPurchaseDetailsBuilder { + flight: Option>, + fuel: Option>, + lodging: Option>, + receipt: Option>>, + reference: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingTransactionPurchaseDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + flight: self.flight.take()?, + fuel: self.fuel.take()?, + lodging: self.lodging?, + receipt: self.receipt.take()?, + reference: self.reference.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..c7aa830a7 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct IssuingTransactionReceiptData { /// The description of the item. The maximum length of this field is 26 characters. pub description: Option, @@ -9,3 +11,108 @@ pub struct IssuingTransactionReceiptData { /// The unit cost of the item in cents. pub unit_cost: Option, } +#[doc(hidden)] +pub struct IssuingTransactionReceiptDataBuilder { + description: Option>, + quantity: Option>, + total: Option>, + unit_cost: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingTransactionReceiptDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + description: self.description.take()?, + quantity: self.quantity?, + total: self.total?, + unit_cost: self.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 { + 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..d9844d096 100644 --- a/generated/stripe_shared/src/issuing_transaction_treasury.rs +++ b/generated/stripe_shared/src/issuing_transaction_treasury.rs @@ -1,7 +1,101 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// The Treasury [ReceivedDebit](https://stripe.com/docs/api/treasury/received_debits) representing this Issuing transaction if it is a capture. pub received_debit: Option, } +#[doc(hidden)] +pub struct IssuingTransactionTreasuryBuilder { + received_credit: Option>, + received_debit: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: IssuingTransactionTreasuryBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { received_credit: Deserialize::default(), received_debit: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + received_credit: self.received_credit.take()?, + received_debit: self.received_debit.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..93f689276 100644 --- a/generated/stripe_shared/src/legal_entity_company.rs +++ b/generated/stripe_shared/src/legal_entity_company.rs @@ -1,64 +1,231 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct LegalEntityCompany { - #[serde(skip_serializing_if = "Option::is_none")] pub address: Option, /// The Kana variation of the company's primary address (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub address_kana: Option, /// The Kanji variation of the company's primary address (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub address_kanji: Option, /// 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, /// 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, /// 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, /// The purpose code to use for export transactions (India only). - #[serde(skip_serializing_if = "Option::is_none")] pub export_purpose_code: Option, /// The company's legal name. - #[serde(skip_serializing_if = "Option::is_none")] pub name: Option, /// The Kana variation of the company's legal name (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub name_kana: Option, /// The Kanji variation of the company's legal name (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub name_kanji: Option, /// 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, /// 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, /// The company's phone number (used for verification). - #[serde(skip_serializing_if = "Option::is_none")] pub phone: Option, /// 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, /// Whether the company's business ID number was provided. - #[serde(skip_serializing_if = "Option::is_none")] pub tax_id_provided: Option, /// 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, /// Whether the company's business VAT number was provided. - #[serde(skip_serializing_if = "Option::is_none")] pub vat_id_provided: Option, /// Information on the verification state of the company. - #[serde(skip_serializing_if = "Option::is_none")] pub verification: Option, } +#[doc(hidden)] +pub struct LegalEntityCompanyBuilder { + address: Option>, + address_kana: Option>, + address_kanji: Option>, + directors_provided: Option>, + executives_provided: Option>, + export_license_id: Option>, + export_purpose_code: Option>, + name: Option>, + name_kana: Option>, + name_kanji: Option>, + owners_provided: Option>, + ownership_declaration: Option>, + phone: Option>, + structure: Option>, + tax_id_provided: Option>, + tax_id_registrar: Option>, + vat_id_provided: Option>, + verification: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: LegalEntityCompanyBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + address: self.address.take()?, + address_kana: self.address_kana.take()?, + address_kanji: self.address_kanji.take()?, + directors_provided: self.directors_provided?, + executives_provided: self.executives_provided?, + export_license_id: self.export_license_id.take()?, + export_purpose_code: self.export_purpose_code.take()?, + name: self.name.take()?, + name_kana: self.name_kana.take()?, + name_kanji: self.name_kanji.take()?, + owners_provided: self.owners_provided?, + ownership_declaration: self.ownership_declaration.take()?, + phone: self.phone.take()?, + structure: self.structure?, + tax_id_provided: self.tax_id_provided?, + tax_id_registrar: self.tax_id_registrar.take()?, + vat_id_provided: self.vat_id_provided?, + verification: self.verification.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)] @@ -165,6 +332,7 @@ impl std::fmt::Debug for LegalEntityCompanyStructure { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for LegalEntityCompanyStructure { fn serialize(&self, serializer: S) -> Result where @@ -173,10 +341,29 @@ impl serde::Serialize for LegalEntityCompanyStructure { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for LegalEntityCompanyStructure { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + LegalEntityCompanyStructure::from_str(s) + .unwrap_or(LegalEntityCompanyStructure::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(LegalEntityCompanyStructure); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for LegalEntityCompanyStructure { fn deserialize>(deserializer: D) -> Result { 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)) } } diff --git a/generated/stripe_shared/src/legal_entity_company_verification.rs b/generated/stripe_shared/src/legal_entity_company_verification.rs index cbe5a09d7..2c34adff8 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct LegalEntityCompanyVerification { pub document: stripe_shared::LegalEntityCompanyVerificationDocument, } +#[doc(hidden)] +pub struct LegalEntityCompanyVerificationBuilder { + document: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: LegalEntityCompanyVerificationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { document: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { document: self.document.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..469911699 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, @@ -10,3 +12,108 @@ 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>, } +#[doc(hidden)] +pub struct LegalEntityCompanyVerificationDocumentBuilder { + back: Option>>, + details: Option>, + details_code: Option>, + front: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: LegalEntityCompanyVerificationDocumentBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + back: self.back.take()?, + details: self.details.take()?, + details_code: self.details_code.take()?, + front: self.front.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..96138920c 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct LegalEntityDob { /// The day of birth, between 1 and 31. pub day: Option, @@ -7,3 +9,99 @@ pub struct LegalEntityDob { /// The four-digit year of birth. pub year: Option, } +#[doc(hidden)] +pub struct LegalEntityDobBuilder { + day: Option>, + month: Option>, + year: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: LegalEntityDobBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + day: Deserialize::default(), + month: Deserialize::default(), + year: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { day: self.day?, month: self.month?, year: self.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 { + 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..02254d597 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct LegalEntityJapanAddress { /// City/Ward. pub city: Option, @@ -15,3 +17,123 @@ pub struct LegalEntityJapanAddress { /// Town/cho-me. pub town: Option, } +#[doc(hidden)] +pub struct LegalEntityJapanAddressBuilder { + city: Option>, + country: Option>, + line1: Option>, + line2: Option>, + postal_code: Option>, + state: Option>, + town: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: LegalEntityJapanAddressBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + city: self.city.take()?, + country: self.country.take()?, + line1: self.line1.take()?, + line2: self.line2.take()?, + postal_code: self.postal_code.take()?, + state: self.state.take()?, + town: self.town.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..ee26be93f 100644 --- a/generated/stripe_shared/src/legal_entity_person_verification.rs +++ b/generated/stripe_shared/src/legal_entity_person_verification.rs @@ -1,19 +1,129 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// 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, /// 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, - #[serde(skip_serializing_if = "Option::is_none")] pub document: Option, /// The state of verification for the person. /// Possible values are `unverified`, `pending`, or `verified`. pub status: String, } +#[doc(hidden)] +pub struct LegalEntityPersonVerificationBuilder { + additional_document: Option>, + details: Option>, + details_code: Option>, + document: Option>, + status: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: LegalEntityPersonVerificationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + additional_document: self.additional_document.take()?, + details: self.details.take()?, + details_code: self.details_code.take()?, + document: self.document.take()?, + status: self.status.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..f87705e86 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, @@ -11,3 +13,108 @@ 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>, } +#[doc(hidden)] +pub struct LegalEntityPersonVerificationDocumentBuilder { + back: Option>>, + details: Option>, + details_code: Option>, + front: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: LegalEntityPersonVerificationDocumentBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + back: self.back.take()?, + details: self.details.take()?, + details_code: self.details_code.take()?, + front: self.front.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..8daeb8a63 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct LegalEntityUboDeclaration { /// The Unix timestamp marking when the beneficial owner attestation was made. pub date: Option, @@ -7,3 +9,103 @@ pub struct LegalEntityUboDeclaration { /// The user-agent string from the browser where the beneficial owner attestation was made. pub user_agent: Option, } +#[doc(hidden)] +pub struct LegalEntityUboDeclarationBuilder { + date: Option>, + ip: Option>, + user_agent: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: LegalEntityUboDeclarationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + date: Deserialize::default(), + ip: Deserialize::default(), + user_agent: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + date: self.date?, + ip: self.ip.take()?, + user_agent: self.user_agent.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..b7d553645 100644 --- a/generated/stripe_shared/src/level3.rs +++ b/generated/stripe_shared/src/level3.rs @@ -1,13 +1,129 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Level3 { - #[serde(skip_serializing_if = "Option::is_none")] pub customer_reference: Option, pub line_items: Vec, pub merchant_reference: String, - #[serde(skip_serializing_if = "Option::is_none")] pub shipping_address_zip: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub shipping_amount: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub shipping_from_zip: Option, } +#[doc(hidden)] +pub struct Level3Builder { + customer_reference: Option>, + line_items: Option>, + merchant_reference: Option, + shipping_address_zip: Option>, + shipping_amount: Option>, + shipping_from_zip: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: Level3Builder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + customer_reference: self.customer_reference.take()?, + line_items: self.line_items.take()?, + merchant_reference: self.merchant_reference.take()?, + shipping_address_zip: self.shipping_address_zip.take()?, + shipping_amount: self.shipping_amount?, + shipping_from_zip: self.shipping_from_zip.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..ddfbde27a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Level3LineItems { pub discount_amount: Option, pub product_code: String, @@ -7,3 +9,120 @@ pub struct Level3LineItems { pub tax_amount: Option, pub unit_cost: Option, } +#[doc(hidden)] +pub struct Level3LineItemsBuilder { + discount_amount: Option>, + product_code: Option, + product_description: Option, + quantity: Option>, + tax_amount: Option>, + unit_cost: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: Level3LineItemsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + discount_amount: self.discount_amount?, + product_code: self.product_code.take()?, + product_description: self.product_description.take()?, + quantity: self.quantity?, + tax_amount: self.tax_amount?, + unit_cost: self.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 { + 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..015852922 100644 --- a/generated/stripe_shared/src/line_items_discount_amount.rs +++ b/generated/stripe_shared/src/line_items_discount_amount.rs @@ -1,6 +1,97 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct LineItemsDiscountAmount { /// The amount discounted. pub amount: i64, pub discount: stripe_shared::Discount, } +#[doc(hidden)] +pub struct LineItemsDiscountAmountBuilder { + amount: Option, + discount: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: LineItemsDiscountAmountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), discount: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { amount: self.amount?, discount: self.discount.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..32a868cb8 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct LineItemsTaxAmount { /// Amount of tax applied for this rate. pub amount: i64, @@ -9,6 +11,111 @@ pub struct LineItemsTaxAmount { /// The amount on which tax is calculated, in cents (or local equivalent). pub taxable_amount: Option, } +#[doc(hidden)] +pub struct LineItemsTaxAmountBuilder { + amount: Option, + rate: Option, + taxability_reason: Option>, + taxable_amount: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: LineItemsTaxAmountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount: self.amount?, + rate: self.rate.take()?, + taxability_reason: self.taxability_reason?, + taxable_amount: self.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 { + 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)] @@ -91,6 +198,7 @@ impl std::fmt::Debug for LineItemsTaxAmountTaxabilityReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for LineItemsTaxAmountTaxabilityReason { fn serialize(&self, serializer: S) -> Result where @@ -99,10 +207,29 @@ impl serde::Serialize for LineItemsTaxAmountTaxabilityReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for LineItemsTaxAmountTaxabilityReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + LineItemsTaxAmountTaxabilityReason::from_str(s) + .unwrap_or(LineItemsTaxAmountTaxabilityReason::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(LineItemsTaxAmountTaxabilityReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for LineItemsTaxAmountTaxabilityReason { fn deserialize>(deserializer: D) -> Result { 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)) } } 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..7bac9d588 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,115 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, /// Data features requested to be retrieved upon account creation. pub prefetch: Option>, /// 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, } +#[doc(hidden)] +pub struct LinkedAccountOptionsUsBankAccountBuilder { + permissions: Option>>, + prefetch: Option>>, + return_url: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: LinkedAccountOptionsUsBankAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + permissions: Deserialize::default(), + prefetch: Deserialize::default(), + return_url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + permissions: self.permissions.take()?, + prefetch: self.prefetch.take()?, + return_url: self.return_url.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -54,6 +154,7 @@ impl std::fmt::Debug for LinkedAccountOptionsUsBankAccountPermissions { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for LinkedAccountOptionsUsBankAccountPermissions { fn serialize(&self, serializer: S) -> Result where @@ -62,6 +163,25 @@ impl serde::Serialize for LinkedAccountOptionsUsBankAccountPermissions { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for LinkedAccountOptionsUsBankAccountPermissions { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + LinkedAccountOptionsUsBankAccountPermissions::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(LinkedAccountOptionsUsBankAccountPermissions); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for LinkedAccountOptionsUsBankAccountPermissions { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -111,6 +231,7 @@ impl std::fmt::Debug for LinkedAccountOptionsUsBankAccountPrefetch { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for LinkedAccountOptionsUsBankAccountPrefetch { fn serialize(&self, serializer: S) -> Result where @@ -119,6 +240,24 @@ impl serde::Serialize for LinkedAccountOptionsUsBankAccountPrefetch { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for LinkedAccountOptionsUsBankAccountPrefetch { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + LinkedAccountOptionsUsBankAccountPrefetch::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(LinkedAccountOptionsUsBankAccountPrefetch); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for LinkedAccountOptionsUsBankAccountPrefetch { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/mandate.rs b/generated/stripe_shared/src/mandate.rs index 362aadcd3..f822cb120 100644 --- a/generated/stripe_shared/src/mandate.rs +++ b/generated/stripe_shared/src/mandate.rs @@ -1,29 +1,238 @@ /// A Mandate is a record of the permission that your customer gives you to debit their payment method. /// /// For more details see <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: MandateObject, /// The account (if any) that the mandate is intended for. - #[serde(skip_serializing_if = "Option::is_none")] pub on_behalf_of: Option, /// ID of the payment method associated with this mandate. pub payment_method: stripe_types::Expandable, pub payment_method_details: stripe_shared::MandatePaymentMethodDetails, - #[serde(skip_serializing_if = "Option::is_none")] pub single_use: Option, /// 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(feature = "serde", serde(rename = "type"))] pub type_: MandateType, } +#[doc(hidden)] +pub struct MandateBuilder { + customer_acceptance: Option, + id: Option, + livemode: Option, + multi_use: Option>, + object: Option, + on_behalf_of: Option>, + payment_method: Option>, + payment_method_details: Option, + single_use: Option>, + status: Option, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: MandateBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + customer_acceptance: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + multi_use: Deserialize::default(), + object: 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 { + Some(Self::Out { + customer_acceptance: self.customer_acceptance.take()?, + id: self.id.take()?, + livemode: self.livemode?, + multi_use: self.multi_use?, + object: self.object?, + on_behalf_of: self.on_behalf_of.take()?, + payment_method: self.payment_method.take()?, + payment_method_details: self.payment_method_details.take()?, + single_use: self.single_use?, + status: self.status?, + type_: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum MandateObject { + Mandate, +} +impl MandateObject { + pub fn as_str(self) -> &'static str { + use MandateObject::*; + match self { + Mandate => "mandate", + } + } +} + +impl std::str::FromStr for MandateObject { + type Err = (); + fn from_str(s: &str) -> Result { + use MandateObject::*; + match s { + "mandate" => Ok(Mandate), + _ => Err(()), + } + } +} +impl std::fmt::Display for MandateObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for MandateObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for MandateObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for MandateObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(MandateObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(MandateObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for MandateObject { + fn deserialize>(deserializer: D) -> 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 MandateObject")) + } +} /// The mandate status indicates whether or not you can use it to initiate a payment. #[derive(Copy, Clone, Eq, PartialEq)] pub enum MandateStatus { @@ -65,6 +274,7 @@ impl std::fmt::Debug for MandateStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for MandateStatus { fn serialize(&self, serializer: S) -> Result where @@ -73,6 +283,22 @@ impl serde::Serialize for MandateStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for MandateStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(MandateStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(MandateStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for MandateStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -118,6 +344,7 @@ impl std::fmt::Debug for MandateType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for MandateType { fn serialize(&self, serializer: S) -> Result where @@ -126,6 +353,22 @@ impl serde::Serialize for MandateType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for MandateType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(MandateType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(MandateType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for MandateType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/mandate_acss_debit.rs b/generated/stripe_shared/src/mandate_acss_debit.rs index c890abade..4a4b14aea 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, /// Description of the interval. /// Only required if the 'payment_schedule' parameter is 'interval' or 'combined'. @@ -11,6 +12,113 @@ pub struct MandateAcssDebit { /// Transaction type of the mandate. pub transaction_type: MandateAcssDebitTransactionType, } +#[doc(hidden)] +pub struct MandateAcssDebitBuilder { + default_for: Option>>, + interval_description: Option>, + payment_schedule: Option, + transaction_type: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: MandateAcssDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + default_for: self.default_for.take()?, + interval_description: self.interval_description.take()?, + payment_schedule: self.payment_schedule?, + transaction_type: self.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 { + 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 { @@ -49,6 +157,7 @@ impl std::fmt::Debug for MandateAcssDebitDefaultFor { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for MandateAcssDebitDefaultFor { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +166,22 @@ impl serde::Serialize for MandateAcssDebitDefaultFor { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for MandateAcssDebitDefaultFor { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(MandateAcssDebitDefaultFor::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(MandateAcssDebitDefaultFor); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for MandateAcssDebitDefaultFor { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -106,6 +231,7 @@ impl std::fmt::Debug for MandateAcssDebitPaymentSchedule { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for MandateAcssDebitPaymentSchedule { fn serialize(&self, serializer: S) -> Result where @@ -114,6 +240,23 @@ impl serde::Serialize for MandateAcssDebitPaymentSchedule { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for MandateAcssDebitPaymentSchedule { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(MandateAcssDebitPaymentSchedule::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(MandateAcssDebitPaymentSchedule); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for MandateAcssDebitPaymentSchedule { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -161,6 +304,7 @@ impl std::fmt::Debug for MandateAcssDebitTransactionType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for MandateAcssDebitTransactionType { fn serialize(&self, serializer: S) -> Result where @@ -169,6 +313,23 @@ impl serde::Serialize for MandateAcssDebitTransactionType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for MandateAcssDebitTransactionType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(MandateAcssDebitTransactionType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(MandateAcssDebitTransactionType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for MandateAcssDebitTransactionType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/mandate_au_becs_debit.rs b/generated/stripe_shared/src/mandate_au_becs_debit.rs index f1e02f406..b1c9b47cc 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct MandateAuBecsDebitBuilder { + url: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: MandateAuBecsDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { url: self.url.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..dba090726 100644 --- a/generated/stripe_shared/src/mandate_bacs_debit.rs +++ b/generated/stripe_shared/src/mandate_bacs_debit.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct MandateBacsDebit { /// The status of the mandate on the Bacs network. /// Can be one of `pending`, `revoked`, `refused`, or `accepted`. @@ -10,6 +12,111 @@ pub struct MandateBacsDebit { /// The URL that will contain the mandate that the customer has signed. pub url: String, } +#[doc(hidden)] +pub struct MandateBacsDebitBuilder { + network_status: Option, + reference: Option, + revocation_reason: Option>, + url: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: MandateBacsDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "revocation_reason" => Deserialize::begin(&mut self.revocation_reason), + "url" => Deserialize::begin(&mut self.url), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + network_status: Deserialize::default(), + reference: Deserialize::default(), + revocation_reason: Deserialize::default(), + url: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + network_status: self.network_status?, + reference: self.reference.take()?, + revocation_reason: self.revocation_reason?, + url: self.url.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "revocation_reason" => b.revocation_reason = 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)] @@ -55,6 +162,7 @@ impl std::fmt::Debug for MandateBacsDebitNetworkStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for MandateBacsDebitNetworkStatus { fn serialize(&self, serializer: S) -> Result where @@ -63,6 +171,22 @@ impl serde::Serialize for MandateBacsDebitNetworkStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for MandateBacsDebitNetworkStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(MandateBacsDebitNetworkStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(MandateBacsDebitNetworkStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for MandateBacsDebitNetworkStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -119,6 +243,7 @@ impl std::fmt::Debug for MandateBacsDebitRevocationReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for MandateBacsDebitRevocationReason { fn serialize(&self, serializer: S) -> Result where @@ -127,6 +252,23 @@ impl serde::Serialize for MandateBacsDebitRevocationReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for MandateBacsDebitRevocationReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(MandateBacsDebitRevocationReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(MandateBacsDebitRevocationReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for MandateBacsDebitRevocationReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/mandate_cashapp.rs b/generated/stripe_shared/src/mandate_cashapp.rs index e28fa9bba..4327a91c8 100644 --- a/generated/stripe_shared/src/mandate_cashapp.rs +++ b/generated/stripe_shared/src/mandate_cashapp.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct MandateCashapp {} +#[doc(hidden)] +pub struct MandateCashappBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: MandateCashappBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..685474c20 100644 --- a/generated/stripe_shared/src/mandate_link.rs +++ b/generated/stripe_shared/src/mandate_link.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct MandateLink {} +#[doc(hidden)] +pub struct MandateLinkBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: MandateLinkBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..89b3df299 100644 --- a/generated/stripe_shared/src/mandate_multi_use.rs +++ b/generated/stripe_shared/src/mandate_multi_use.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct MandateMultiUse {} +#[doc(hidden)] +pub struct MandateMultiUseBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: MandateMultiUseBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..905883462 100644 --- a/generated/stripe_shared/src/mandate_payment_method_details.rs +++ b/generated/stripe_shared/src/mandate_payment_method_details.rs @@ -1,25 +1,153 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct MandatePaymentMethodDetails { - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cashapp: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub paypal: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option, /// 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(feature = "serde", serde(rename = "type"))] pub type_: String, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option, } +#[doc(hidden)] +pub struct MandatePaymentMethodDetailsBuilder { + acss_debit: Option>, + au_becs_debit: Option>, + bacs_debit: Option>, + card: Option>, + cashapp: Option>, + link: Option>, + paypal: Option>, + sepa_debit: Option>, + type_: Option, + us_bank_account: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: MandatePaymentMethodDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + acss_debit: self.acss_debit.take()?, + au_becs_debit: self.au_becs_debit.take()?, + bacs_debit: self.bacs_debit.take()?, + card: self.card?, + cashapp: self.cashapp?, + link: self.link?, + paypal: self.paypal.take()?, + sepa_debit: self.sepa_debit.take()?, + type_: self.type_.take()?, + us_bank_account: self.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 { + 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..6efd6b41f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,97 @@ pub struct MandatePaypal { /// PayPal account PayerID. This identifier uniquely identifies the PayPal customer. pub payer_id: Option, } +#[doc(hidden)] +pub struct MandatePaypalBuilder { + billing_agreement_id: Option>, + payer_id: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: MandatePaypalBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { billing_agreement_id: Deserialize::default(), payer_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + billing_agreement_id: self.billing_agreement_id.take()?, + payer_id: self.payer_id.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..d76cbc624 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct MandateSepaDebit { /// The unique reference of the mandate. pub reference: String, @@ -6,3 +8,92 @@ pub struct MandateSepaDebit { /// This URL generally contains sensitive information about the customer and should be shared with them exclusively. pub url: String, } +#[doc(hidden)] +pub struct MandateSepaDebitBuilder { + reference: Option, + url: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: MandateSepaDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { reference: Deserialize::default(), url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { reference: self.reference.take()?, url: self.url.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..821abe89d 100644 --- a/generated/stripe_shared/src/mandate_single_use.rs +++ b/generated/stripe_shared/src/mandate_single_use.rs @@ -1,7 +1,98 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct MandateSingleUseBuilder { + amount: Option, + currency: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: MandateSingleUseBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), currency: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { amount: self.amount?, currency: self.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 { + 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..b49b91fa4 100644 --- a/generated/stripe_shared/src/mandate_us_bank_account.rs +++ b/generated/stripe_shared/src/mandate_us_bank_account.rs @@ -1,9 +1,96 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct MandateUsBankAccount { /// Mandate collection method - #[serde(skip_serializing_if = "Option::is_none")] pub collection_method: Option, } +#[doc(hidden)] +pub struct MandateUsBankAccountBuilder { + collection_method: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: MandateUsBankAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: MandateUsBankAccountBuilder::deser_default(), + })) + } + } + + impl MapBuilder for MandateUsBankAccountBuilder { + type Out = MandateUsBankAccount; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "collection_method" => Deserialize::begin(&mut self.collection_method), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { collection_method: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { collection_method: self.collection_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 MandateUsBankAccount { + type Builder = MandateUsBankAccountBuilder; + } + + impl FromValueOpt for MandateUsBankAccount { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = MandateUsBankAccountBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "collection_method" => b.collection_method = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Mandate collection method #[derive(Copy, Clone, Eq, PartialEq)] pub enum MandateUsBankAccountCollectionMethod { @@ -39,6 +126,7 @@ impl std::fmt::Debug for MandateUsBankAccountCollectionMethod { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for MandateUsBankAccountCollectionMethod { fn serialize(&self, serializer: S) -> Result where @@ -47,6 +135,23 @@ impl serde::Serialize for MandateUsBankAccountCollectionMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for MandateUsBankAccountCollectionMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(MandateUsBankAccountCollectionMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(MandateUsBankAccountCollectionMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for MandateUsBankAccountCollectionMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/mod.rs b/generated/stripe_shared/src/mod.rs index 5f938b9c6..46b968610 100644 --- a/generated/stripe_shared/src/mod.rs +++ b/generated/stripe_shared/src/mod.rs @@ -8,6 +8,8 @@ //! reexported. extern crate self as stripe_shared; + +miniserde::make_place!(Place); #[doc(hidden)] pub mod account; #[doc(inline)] diff --git a/generated/stripe_shared/src/networks.rs b/generated/stripe_shared/src/networks.rs index 2e272069d..f786790d5 100644 --- a/generated/stripe_shared/src/networks.rs +++ b/generated/stripe_shared/src/networks.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Networks { /// All available networks for the card. pub available: Vec, @@ -6,3 +8,89 @@ pub struct Networks { /// Can be `cartes_bancaires`, `mastercard`, `visa` or `invalid_preference` if requested network is not valid for the card. pub preferred: Option, } +#[doc(hidden)] +pub struct NetworksBuilder { + available: Option>, + preferred: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: NetworksBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { available: Deserialize::default(), preferred: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { available: self.available.take()?, preferred: self.preferred.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..88adcbd86 100644 --- a/generated/stripe_shared/src/notification_event_data.rs +++ b/generated/stripe_shared/src/notification_event_data.rs @@ -1,11 +1,108 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + #[cfg_attr(feature = "serde", serde(with = "stripe_types::with_serde_json"))] + pub object: miniserde::json::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, + #[cfg_attr(feature = "serde", serde(with = "stripe_types::with_serde_json_opt"))] + pub previous_attributes: Option, } +#[doc(hidden)] +pub struct NotificationEventDataBuilder { + object: Option, + previous_attributes: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: NotificationEventDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { object: Deserialize::default(), previous_attributes: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + object: self.object.take()?, + previous_attributes: self.previous_attributes.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..a8c57c1b3 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,92 @@ pub struct NotificationEventRequest { /// *Note: This property is populated only for events on or after May 23, 2017*. pub idempotency_key: Option, } +#[doc(hidden)] +pub struct NotificationEventRequestBuilder { + id: Option>, + idempotency_key: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: NotificationEventRequestBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { id: Deserialize::default(), idempotency_key: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { id: self.id.take()?, idempotency_key: self.idempotency_key.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..ca4cd1abb 100644 --- a/generated/stripe_shared/src/offline_acceptance.rs +++ b/generated/stripe_shared/src/offline_acceptance.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct OfflineAcceptance {} +#[doc(hidden)] +pub struct OfflineAcceptanceBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: OfflineAcceptanceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..0bae6fe53 100644 --- a/generated/stripe_shared/src/online_acceptance.rs +++ b/generated/stripe_shared/src/online_acceptance.rs @@ -1,7 +1,101 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct OnlineAcceptance { /// The customer accepts the mandate from this IP address. pub ip_address: Option, /// The customer accepts the mandate using the user agent of the browser. pub user_agent: Option, } +#[doc(hidden)] +pub struct OnlineAcceptanceBuilder { + ip_address: Option>, + user_agent: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: OnlineAcceptanceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { ip_address: Deserialize::default(), user_agent: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + ip_address: self.ip_address.take()?, + user_agent: self.user_agent.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..a081a1f58 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PackageDimensions { /// Height, in inches. pub height: f64, @@ -9,3 +11,108 @@ pub struct PackageDimensions { /// Width, in inches. pub width: f64, } +#[doc(hidden)] +pub struct PackageDimensionsBuilder { + height: Option, + length: Option, + weight: Option, + width: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PackageDimensionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + height: Deserialize::default(), + length: Deserialize::default(), + weight: Deserialize::default(), + width: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + height: self.height?, + length: self.length?, + weight: self.weight?, + width: self.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 { + 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..6bce732af 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentFlowsAmountDetails { - #[serde(skip_serializing_if = "Option::is_none")] pub tip: Option, } +#[doc(hidden)] +pub struct PaymentFlowsAmountDetailsBuilder { + tip: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentFlowsAmountDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { tip: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { tip: self.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 { + 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..2a33c24b5 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentFlowsAmountDetailsResourceTip { /// Portion of the amount that corresponds to a tip. - #[serde(skip_serializing_if = "Option::is_none")] pub amount: Option, } +#[doc(hidden)] +pub struct PaymentFlowsAmountDetailsResourceTipBuilder { + amount: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentFlowsAmountDetailsResourceTipBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { amount: self.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 { + 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..8dcc549a7 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,104 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// Automatically calculates compatible payment methods pub enabled: bool, } +#[doc(hidden)] +pub struct PaymentFlowsAutomaticPaymentMethodsPaymentIntentBuilder { + allow_redirects: Option>, + enabled: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentFlowsAutomaticPaymentMethodsPaymentIntentBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { allow_redirects: Deserialize::default(), enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { allow_redirects: self.allow_redirects?, enabled: self.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 { + 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. @@ -50,6 +140,7 @@ impl std::fmt::Debug for PaymentFlowsAutomaticPaymentMethodsPaymentIntentAllowRe f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentFlowsAutomaticPaymentMethodsPaymentIntentAllowRedirects { fn serialize(&self, serializer: S) -> Result where @@ -58,6 +149,29 @@ impl serde::Serialize for PaymentFlowsAutomaticPaymentMethodsPaymentIntentAllowR serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentFlowsAutomaticPaymentMethodsPaymentIntentAllowRedirects { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentFlowsAutomaticPaymentMethodsPaymentIntentAllowRedirects::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentFlowsAutomaticPaymentMethodsPaymentIntentAllowRedirects +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for 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..669e6f997 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,104 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// Automatically calculates compatible payment methods pub enabled: Option, } +#[doc(hidden)] +pub struct PaymentFlowsAutomaticPaymentMethodsSetupIntentBuilder { + allow_redirects: Option>, + enabled: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentFlowsAutomaticPaymentMethodsSetupIntentBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { allow_redirects: Deserialize::default(), enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { allow_redirects: self.allow_redirects?, enabled: self.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 { + 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. @@ -50,6 +140,7 @@ impl std::fmt::Debug for PaymentFlowsAutomaticPaymentMethodsSetupIntentAllowRedi f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentFlowsAutomaticPaymentMethodsSetupIntentAllowRedirects { fn serialize(&self, serializer: S) -> Result where @@ -58,6 +149,29 @@ impl serde::Serialize for PaymentFlowsAutomaticPaymentMethodsSetupIntentAllowRed serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentFlowsAutomaticPaymentMethodsSetupIntentAllowRedirects { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentFlowsAutomaticPaymentMethodsSetupIntentAllowRedirects::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentFlowsAutomaticPaymentMethodsSetupIntentAllowRedirects +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentFlowsAutomaticPaymentMethodsSetupIntentAllowRedirects { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..f16cbc5cb 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentFlowsPrivatePaymentMethodsAlipay {} +#[doc(hidden)] +pub struct PaymentFlowsPrivatePaymentMethodsAlipayBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentFlowsPrivatePaymentMethodsAlipayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..fb761783c 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// Uniquely identifies this particular Alipay account. /// You can use this attribute to check whether two Alipay accounts are the same. @@ -10,3 +11,103 @@ pub struct PaymentFlowsPrivatePaymentMethodsAlipayDetails { /// Transaction ID of this particular Alipay transaction. pub transaction_id: Option, } +#[doc(hidden)] +pub struct PaymentFlowsPrivatePaymentMethodsAlipayDetailsBuilder { + buyer_id: Option>, + fingerprint: Option>, + transaction_id: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentFlowsPrivatePaymentMethodsAlipayDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + buyer_id: Deserialize::default(), + fingerprint: Deserialize::default(), + transaction_id: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + buyer_id: self.buyer_id.take()?, + fingerprint: self.fingerprint.take()?, + transaction_id: self.transaction_id.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..e43dad425 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,9 +1,102 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorization { /// Indicates whether or not the capture window is extended beyond the standard authorization. pub status: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus, } +#[doc(hidden)] +pub struct PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationBuilder { + status: Option, + +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } +} + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationBuilder, +} + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + status: Deserialize::default(), + + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { status: self.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 { + 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 @@ -45,11 +138,28 @@ impl std::fmt::Debug for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResource f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesExtendedAuthorizationExtendedAuthorizationStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..12f77c089 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,9 +1,102 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorization { /// Indicates whether or not the incremental authorization feature is supported. pub status: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus, } +#[doc(hidden)] +pub struct PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationBuilder { + status: Option, + +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } +} + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationBuilder, +} + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + status: Deserialize::default(), + + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { status: self.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 { + 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 @@ -45,11 +138,28 @@ impl std::fmt::Debug for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResource f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesIncrementalAuthorizationIncrementalAuthorizationStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..6e8525dca 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,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercapture { /// The maximum amount that can be captured. pub maximum_amount_capturable: i64, @@ -6,6 +8,102 @@ pub maximum_amount_capturable: i64, pub status: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus, } +#[doc(hidden)] +pub struct PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureBuilder { + maximum_amount_capturable: Option, +status: Option, + +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } +} + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureBuilder, +} + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + maximum_amount_capturable: Deserialize::default(), +status: Deserialize::default(), + + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { maximum_amount_capturable: self.maximum_amount_capturable?, +status: self.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 { + 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 @@ -47,11 +145,28 @@ impl std::fmt::Debug for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResource f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceEnterpriseFeaturesOvercaptureOvercaptureStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..ef4677cb3 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticapture { /// Indicates whether or not multiple captures are supported. pub status: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus, } +#[doc(hidden)] +pub struct PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureBuilder { + status: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { status: self.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 { + 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 { @@ -45,6 +133,7 @@ impl std::fmt::Debug for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResource f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus { @@ -55,6 +144,31 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentFlowsPrivatePaymentMethodsCardDetailsApiResourceMulticaptureStatus +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for 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..c24b2fdbd 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentFlowsPrivatePaymentMethodsKlarnaDob { /// The day of birth, between 1 and 31. pub day: Option, @@ -7,3 +9,99 @@ pub struct PaymentFlowsPrivatePaymentMethodsKlarnaDob { /// The four-digit year of birth. pub year: Option, } +#[doc(hidden)] +pub struct PaymentFlowsPrivatePaymentMethodsKlarnaDobBuilder { + day: Option>, + month: Option>, + year: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentFlowsPrivatePaymentMethodsKlarnaDobBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + day: Deserialize::default(), + month: Deserialize::default(), + year: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { day: self.day?, month: self.month?, year: self.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 { + 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..1a4a2cbad 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// Amount that this PaymentIntent collects. pub amount_received: i64, @@ -80,6 +81,8 @@ pub struct PaymentIntent { pub metadata: std::collections::HashMap, /// If present, this property tells you what actions you need to take in order for your customer to fulfill a payment using the provided source. pub next_action: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: PaymentIntentObject, /// The account (if any) for which the funds of the PaymentIntent are intended. /// See the PaymentIntents [use case for connected accounts](https://stripe.com/docs/payments/connected-accounts) for details. pub on_behalf_of: Option>, @@ -129,6 +132,323 @@ 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, } +#[doc(hidden)] +pub struct PaymentIntentBuilder { + amount: Option, + amount_capturable: Option, + amount_details: Option>, + amount_received: Option, + application: Option>>, + application_fee_amount: Option>, + automatic_payment_methods: + Option>, + canceled_at: Option>, + cancellation_reason: Option>, + capture_method: Option, + client_secret: Option>, + confirmation_method: Option, + created: Option, + currency: Option, + customer: Option>>, + description: Option>, + id: Option, + invoice: Option>>, + last_payment_error: Option>>, + latest_charge: Option>>, + livemode: Option, + metadata: Option>, + next_action: Option>, + object: Option, + on_behalf_of: Option>>, + payment_method: Option>>, + payment_method_configuration_details: + Option>, + payment_method_options: Option>, + payment_method_types: Option>, + processing: Option>, + receipt_email: Option>, + review: Option>>, + setup_future_usage: Option>, + shipping: Option>, + source: Option>>, + statement_descriptor: Option>, + statement_descriptor_suffix: Option>, + status: Option, + transfer_data: Option>, + transfer_group: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + amount: self.amount?, + amount_capturable: self.amount_capturable?, + amount_details: self.amount_details?, + amount_received: self.amount_received?, + application: self.application.take()?, + application_fee_amount: self.application_fee_amount?, + automatic_payment_methods: self.automatic_payment_methods?, + canceled_at: self.canceled_at?, + cancellation_reason: self.cancellation_reason?, + capture_method: self.capture_method?, + client_secret: self.client_secret.take()?, + confirmation_method: self.confirmation_method?, + created: self.created?, + currency: self.currency?, + customer: self.customer.take()?, + description: self.description.take()?, + id: self.id.take()?, + invoice: self.invoice.take()?, + last_payment_error: self.last_payment_error.take()?, + latest_charge: self.latest_charge.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + next_action: self.next_action.take()?, + object: self.object?, + on_behalf_of: self.on_behalf_of.take()?, + payment_method: self.payment_method.take()?, + payment_method_configuration_details: self + .payment_method_configuration_details + .take()?, + payment_method_options: self.payment_method_options.take()?, + payment_method_types: self.payment_method_types.take()?, + processing: self.processing?, + receipt_email: self.receipt_email.take()?, + review: self.review.take()?, + setup_future_usage: self.setup_future_usage?, + shipping: self.shipping.take()?, + source: self.source.take()?, + statement_descriptor: self.statement_descriptor.take()?, + statement_descriptor_suffix: self.statement_descriptor_suffix.take()?, + status: self.status?, + transfer_data: self.transfer_data.take()?, + transfer_group: self.transfer_group.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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 { @@ -182,6 +502,7 @@ impl std::fmt::Debug for PaymentIntentCancellationReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentCancellationReason { fn serialize(&self, serializer: S) -> Result where @@ -190,6 +511,23 @@ impl serde::Serialize for PaymentIntentCancellationReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentCancellationReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(PaymentIntentCancellationReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentIntentCancellationReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentCancellationReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -199,6 +537,74 @@ impl<'de> serde::Deserialize<'de> for PaymentIntentCancellationReason { }) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum PaymentIntentObject { + PaymentIntent, +} +impl PaymentIntentObject { + pub fn as_str(self) -> &'static str { + use PaymentIntentObject::*; + match self { + PaymentIntent => "payment_intent", + } + } +} + +impl std::str::FromStr for PaymentIntentObject { + type Err = (); + fn from_str(s: &str) -> Result { + use PaymentIntentObject::*; + match s { + "payment_intent" => Ok(PaymentIntent), + _ => Err(()), + } + } +} +impl std::fmt::Display for PaymentIntentObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for PaymentIntentObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for PaymentIntentObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for PaymentIntentObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentIntentObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for PaymentIntentObject { + fn deserialize>(deserializer: D) -> 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 PaymentIntentObject")) + } +} /// 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)] @@ -253,6 +659,7 @@ impl std::fmt::Debug for PaymentIntentStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentStatus { fn serialize(&self, serializer: S) -> Result where @@ -261,6 +668,22 @@ impl serde::Serialize for PaymentIntentStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentIntentStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -324,6 +747,22 @@ impl serde::Serialize for PaymentIntentCaptureMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentCaptureMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentIntentCaptureMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentCaptureMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -377,6 +816,23 @@ impl serde::Serialize for PaymentIntentConfirmationMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentConfirmationMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(PaymentIntentConfirmationMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentIntentConfirmationMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentConfirmationMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -431,6 +887,22 @@ impl serde::Serialize for PaymentIntentSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentIntentSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_intent_card_processing.rs b/generated/stripe_shared/src/payment_intent_card_processing.rs index 1ba024f23..3d0730ea1 100644 --- a/generated/stripe_shared/src/payment_intent_card_processing.rs +++ b/generated/stripe_shared/src/payment_intent_card_processing.rs @@ -1,5 +1,95 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentCardProcessing { - #[serde(skip_serializing_if = "Option::is_none")] pub customer_notification: Option, } +#[doc(hidden)] +pub struct PaymentIntentCardProcessingBuilder { + customer_notification: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentCardProcessingBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { customer_notification: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { customer_notification: self.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 { + 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..78e9244d3 100644 --- a/generated/stripe_shared/src/payment_intent_next_action.rs +++ b/generated/stripe_shared/src/payment_intent_next_action.rs @@ -1,51 +1,279 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentNextAction { - #[serde(skip_serializing_if = "Option::is_none")] pub alipay_handle_redirect: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub boleto_display_details: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub card_await_notification: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cashapp_handle_redirect_or_display_qr_code: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub display_bank_transfer_instructions: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub konbini_display_details: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub oxxo_display_details: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub paynow_display_qr_code: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pix_display_qr_code: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub promptpay_display_qr_code: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub redirect_to_url: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub swish_handle_redirect_or_display_qr_code: Option, /// 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(feature = "serde", 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(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "serde", serde(with = "stripe_types::with_serde_json_opt"))] + pub use_stripe_sdk: Option, pub verify_with_microdeposits: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub wechat_pay_display_qr_code: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub wechat_pay_redirect_to_android_app: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub wechat_pay_redirect_to_ios_app: Option, } +#[doc(hidden)] +pub struct PaymentIntentNextActionBuilder { + alipay_handle_redirect: + Option>, + boleto_display_details: Option>, + card_await_notification: + Option>, + cashapp_handle_redirect_or_display_qr_code: + Option>, + display_bank_transfer_instructions: + Option>, + konbini_display_details: Option>, + oxxo_display_details: Option>, + paynow_display_qr_code: + Option>, + pix_display_qr_code: Option>, + promptpay_display_qr_code: + Option>, + redirect_to_url: Option>, + swish_handle_redirect_or_display_qr_code: + Option>, + type_: Option, + use_stripe_sdk: Option>, + verify_with_microdeposits: + Option>, + wechat_pay_display_qr_code: + Option>, + wechat_pay_redirect_to_android_app: + Option>, + wechat_pay_redirect_to_ios_app: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "swish_handle_redirect_or_display_qr_code" => { + Deserialize::begin(&mut self.swish_handle_redirect_or_display_qr_code) + } + "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) + } + + _ => ::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(), + swish_handle_redirect_or_display_qr_code: 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 { + Some(Self::Out { + alipay_handle_redirect: self.alipay_handle_redirect.take()?, + boleto_display_details: self.boleto_display_details.take()?, + card_await_notification: self.card_await_notification?, + cashapp_handle_redirect_or_display_qr_code: self + .cashapp_handle_redirect_or_display_qr_code + .take()?, + display_bank_transfer_instructions: self + .display_bank_transfer_instructions + .take()?, + konbini_display_details: self.konbini_display_details.take()?, + oxxo_display_details: self.oxxo_display_details.take()?, + paynow_display_qr_code: self.paynow_display_qr_code.take()?, + pix_display_qr_code: self.pix_display_qr_code.take()?, + promptpay_display_qr_code: self.promptpay_display_qr_code.take()?, + redirect_to_url: self.redirect_to_url.take()?, + swish_handle_redirect_or_display_qr_code: self + .swish_handle_redirect_or_display_qr_code + .take()?, + type_: self.type_.take()?, + use_stripe_sdk: self.use_stripe_sdk.take()?, + verify_with_microdeposits: self.verify_with_microdeposits.take()?, + wechat_pay_display_qr_code: self.wechat_pay_display_qr_code.take()?, + wechat_pay_redirect_to_android_app: self + .wechat_pay_redirect_to_android_app + .take()?, + wechat_pay_redirect_to_ios_app: self.wechat_pay_redirect_to_ios_app.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "swish_handle_redirect_or_display_qr_code" => { + b.swish_handle_redirect_or_display_qr_code = + 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..d36082535 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -9,3 +11,108 @@ pub struct PaymentIntentNextActionAlipayHandleRedirect { /// The URL you must redirect your customer to in order to authenticate the payment. pub url: Option, } +#[doc(hidden)] +pub struct PaymentIntentNextActionAlipayHandleRedirectBuilder { + native_data: Option>, + native_url: Option>, + return_url: Option>, + url: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionAlipayHandleRedirectBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + native_data: self.native_data.take()?, + native_url: self.native_url.take()?, + return_url: self.return_url.take()?, + url: self.url.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..314101e4a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentNextActionBoleto { /// The timestamp after which the boleto expires. pub expires_at: Option, @@ -9,3 +11,110 @@ pub struct PaymentIntentNextActionBoleto { /// The URL to the downloadable boleto voucher PDF. pub pdf: Option, } +#[doc(hidden)] +pub struct PaymentIntentNextActionBoletoBuilder { + expires_at: Option>, + hosted_voucher_url: Option>, + number: Option>, + pdf: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionBoletoBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + expires_at: self.expires_at?, + hosted_voucher_url: self.hosted_voucher_url.take()?, + number: self.number.take()?, + pdf: self.pdf.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..92033d691 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,102 @@ pub struct PaymentIntentNextActionCardAwaitNotification { /// For payments of lower amount, no customer action is required. pub customer_approval_required: Option, } +#[doc(hidden)] +pub struct PaymentIntentNextActionCardAwaitNotificationBuilder { + charge_attempt_at: Option>, + customer_approval_required: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionCardAwaitNotificationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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) + } + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + charge_attempt_at: Deserialize::default(), + customer_approval_required: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + charge_attempt_at: self.charge_attempt_at?, + customer_approval_required: self.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 { + 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..b7c96e237 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,106 @@ pub struct PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCode { pub mobile_auth_url: String, pub qr_code: stripe_shared::PaymentIntentNextActionCashappQrCode, } +#[doc(hidden)] +pub struct PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCodeBuilder { + hosted_instructions_url: Option, + mobile_auth_url: Option, + qr_code: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionCashappHandleRedirectOrDisplayQrCodeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + hosted_instructions_url: self.hosted_instructions_url.take()?, + mobile_auth_url: self.mobile_auth_url.take()?, + qr_code: self.qr_code.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..ded2c6195 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentNextActionCashappQrCode { /// The date (unix timestamp) when the QR code expires. pub expires_at: stripe_types::Timestamp, @@ -7,3 +9,103 @@ pub struct PaymentIntentNextActionCashappQrCode { /// The image_url_svg string used to render QR code pub image_url_svg: String, } +#[doc(hidden)] +pub struct PaymentIntentNextActionCashappQrCodeBuilder { + expires_at: Option, + image_url_png: Option, + image_url_svg: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionCashappQrCodeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + expires_at: self.expires_at?, + image_url_png: self.image_url_png.take()?, + image_url_svg: self.image_url_svg.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..99224bcfe 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentNextActionDisplayBankTransferInstructions { /// The remaining amount that needs to be transferred to complete the payment. pub amount_remaining: Option, @@ -6,7 +8,6 @@ pub struct PaymentIntentNextActionDisplayBankTransferInstructions { /// Must be a [supported currency](https://stripe.com/docs/currencies). pub currency: Option, /// 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>, /// A link to a hosted page that guides your customer through completing the transfer. @@ -15,9 +16,131 @@ pub struct PaymentIntentNextActionDisplayBankTransferInstructions { /// Instruct your customer to include this code in the reference or memo field of their bank transfer. pub reference: Option, /// Type of bank transfer - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: PaymentIntentNextActionDisplayBankTransferInstructionsType, } +#[doc(hidden)] +pub struct PaymentIntentNextActionDisplayBankTransferInstructionsBuilder { + amount_remaining: Option>, + currency: Option>, + financial_addresses: + Option>>, + hosted_instructions_url: Option>, + reference: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionDisplayBankTransferInstructionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + amount_remaining: self.amount_remaining?, + currency: self.currency?, + financial_addresses: self.financial_addresses.take()?, + hosted_instructions_url: self.hosted_instructions_url.take()?, + reference: self.reference.take()?, + type_: self.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 { + 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 { @@ -65,6 +188,7 @@ impl std::fmt::Debug for PaymentIntentNextActionDisplayBankTransferInstructionsT f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentNextActionDisplayBankTransferInstructionsType { fn serialize(&self, serializer: S) -> Result where @@ -73,6 +197,29 @@ impl serde::Serialize for PaymentIntentNextActionDisplayBankTransferInstructions serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentNextActionDisplayBankTransferInstructionsType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentNextActionDisplayBankTransferInstructionsType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentIntentNextActionDisplayBankTransferInstructionsType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentNextActionDisplayBankTransferInstructionsType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..af24b8e5d 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentNextActionDisplayOxxoDetails { /// The timestamp after which the OXXO voucher expires. pub expires_after: Option, @@ -7,3 +9,105 @@ pub struct PaymentIntentNextActionDisplayOxxoDetails { /// OXXO reference number. pub number: Option, } +#[doc(hidden)] +pub struct PaymentIntentNextActionDisplayOxxoDetailsBuilder { + expires_after: Option>, + hosted_voucher_url: Option>, + number: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionDisplayOxxoDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + expires_after: Deserialize::default(), + hosted_voucher_url: Deserialize::default(), + number: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + expires_after: self.expires_after?, + hosted_voucher_url: self.hosted_voucher_url.take()?, + number: self.number.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..37f7fe0c9 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentNextActionKonbini { /// The timestamp at which the pending Konbini payment expires. pub expires_at: stripe_types::Timestamp, @@ -6,3 +8,105 @@ pub struct PaymentIntentNextActionKonbini { pub hosted_voucher_url: Option, pub stores: stripe_shared::PaymentIntentNextActionKonbiniStores, } +#[doc(hidden)] +pub struct PaymentIntentNextActionKonbiniBuilder { + expires_at: Option, + hosted_voucher_url: Option>, + stores: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionKonbiniBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + expires_at: Deserialize::default(), + hosted_voucher_url: Deserialize::default(), + stores: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + expires_at: self.expires_at?, + hosted_voucher_url: self.hosted_voucher_url.take()?, + stores: self.stores.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..bdc815cdb 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,106 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentNextActionKonbiniFamilymart { /// The confirmation number. - #[serde(skip_serializing_if = "Option::is_none")] pub confirmation_number: Option, /// The payment code. pub payment_code: String, } +#[doc(hidden)] +pub struct PaymentIntentNextActionKonbiniFamilymartBuilder { + confirmation_number: Option>, + payment_code: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionKonbiniFamilymartBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + confirmation_number: Deserialize::default(), + payment_code: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + confirmation_number: self.confirmation_number.take()?, + payment_code: self.payment_code.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..d65ced784 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,106 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentNextActionKonbiniLawson { /// The confirmation number. - #[serde(skip_serializing_if = "Option::is_none")] pub confirmation_number: Option, /// The payment code. pub payment_code: String, } +#[doc(hidden)] +pub struct PaymentIntentNextActionKonbiniLawsonBuilder { + confirmation_number: Option>, + payment_code: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionKonbiniLawsonBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + confirmation_number: Deserialize::default(), + payment_code: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + confirmation_number: self.confirmation_number.take()?, + payment_code: self.payment_code.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..ffbecd125 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,106 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentNextActionKonbiniMinistop { /// The confirmation number. - #[serde(skip_serializing_if = "Option::is_none")] pub confirmation_number: Option, /// The payment code. pub payment_code: String, } +#[doc(hidden)] +pub struct PaymentIntentNextActionKonbiniMinistopBuilder { + confirmation_number: Option>, + payment_code: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionKonbiniMinistopBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + confirmation_number: Deserialize::default(), + payment_code: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + confirmation_number: self.confirmation_number.take()?, + payment_code: self.payment_code.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..5a36d3059 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,106 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentNextActionKonbiniSeicomart { /// The confirmation number. - #[serde(skip_serializing_if = "Option::is_none")] pub confirmation_number: Option, /// The payment code. pub payment_code: String, } +#[doc(hidden)] +pub struct PaymentIntentNextActionKonbiniSeicomartBuilder { + confirmation_number: Option>, + payment_code: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionKonbiniSeicomartBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + confirmation_number: Deserialize::default(), + payment_code: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + confirmation_number: self.confirmation_number.take()?, + payment_code: self.payment_code.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..5182b7988 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentNextActionKonbiniStores { /// FamilyMart instruction details. pub familymart: Option, @@ -9,3 +11,108 @@ pub struct PaymentIntentNextActionKonbiniStores { /// Seicomart instruction details. pub seicomart: Option, } +#[doc(hidden)] +pub struct PaymentIntentNextActionKonbiniStoresBuilder { + familymart: Option>, + lawson: Option>, + ministop: Option>, + seicomart: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionKonbiniStoresBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + familymart: Deserialize::default(), + lawson: Deserialize::default(), + ministop: Deserialize::default(), + seicomart: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + familymart: self.familymart.take()?, + lawson: self.lawson.take()?, + ministop: self.ministop.take()?, + seicomart: self.seicomart.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..d00bbb357 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,110 @@ pub struct PaymentIntentNextActionPaynowDisplayQrCode { /// The image_url_svg string used to render QR code pub image_url_svg: String, } +#[doc(hidden)] +pub struct PaymentIntentNextActionPaynowDisplayQrCodeBuilder { + data: Option, + hosted_instructions_url: Option>, + image_url_png: Option, + image_url_svg: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionPaynowDisplayQrCodeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + data: self.data.take()?, + hosted_instructions_url: self.hosted_instructions_url.take()?, + image_url_png: self.image_url_png.take()?, + image_url_svg: self.image_url_svg.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..ecb59c4fd 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,127 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// The date (unix timestamp) when the PIX expires. - #[serde(skip_serializing_if = "Option::is_none")] pub expires_at: Option, /// 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, /// The image_url_png string used to render png QR code - #[serde(skip_serializing_if = "Option::is_none")] pub image_url_png: Option, /// The image_url_svg string used to render svg QR code - #[serde(skip_serializing_if = "Option::is_none")] pub image_url_svg: Option, } +#[doc(hidden)] +pub struct PaymentIntentNextActionPixDisplayQrCodeBuilder { + data: Option>, + expires_at: Option>, + hosted_instructions_url: Option>, + image_url_png: Option>, + image_url_svg: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionPixDisplayQrCodeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + data: self.data.take()?, + expires_at: self.expires_at?, + hosted_instructions_url: self.hosted_instructions_url.take()?, + image_url_png: self.image_url_png.take()?, + image_url_svg: self.image_url_svg.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..0333a9f8e 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,110 @@ 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, } +#[doc(hidden)] +pub struct PaymentIntentNextActionPromptpayDisplayQrCodeBuilder { + data: Option, + hosted_instructions_url: Option, + image_url_png: Option, + image_url_svg: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionPromptpayDisplayQrCodeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + data: self.data.take()?, + hosted_instructions_url: self.hosted_instructions_url.take()?, + image_url_png: self.image_url_png.take()?, + image_url_svg: self.image_url_svg.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..6a5277f1c 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,98 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// The URL you must redirect your customer to in order to authenticate the payment. pub url: Option, } +#[doc(hidden)] +pub struct PaymentIntentNextActionRedirectToUrlBuilder { + return_url: Option>, + url: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionRedirectToUrlBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { return_url: Deserialize::default(), url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { return_url: self.return_url.take()?, url: self.url.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 index 0a4692b1a..3984499fb 100644 --- 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 @@ -1,11 +1,115 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// The url for mobile redirect based auth - #[serde(skip_serializing_if = "Option::is_none")] pub mobile_auth_url: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub qr_code: Option, } +#[doc(hidden)] +pub struct PaymentIntentNextActionSwishHandleRedirectOrDisplayQrCodeBuilder { + hosted_instructions_url: Option>, + mobile_auth_url: Option>, + qr_code: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionSwishHandleRedirectOrDisplayQrCode { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionSwishHandleRedirectOrDisplayQrCodeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: + PaymentIntentNextActionSwishHandleRedirectOrDisplayQrCodeBuilder::deser_default( + ), + })) + } + } + + impl MapBuilder for PaymentIntentNextActionSwishHandleRedirectOrDisplayQrCodeBuilder { + type Out = PaymentIntentNextActionSwishHandleRedirectOrDisplayQrCode; + 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), + + _ => ::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 { + Some(Self::Out { + hosted_instructions_url: self.hosted_instructions_url.take()?, + mobile_auth_url: self.mobile_auth_url.take()?, + qr_code: self.qr_code.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionSwishHandleRedirectOrDisplayQrCode { + type Builder = PaymentIntentNextActionSwishHandleRedirectOrDisplayQrCodeBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionSwishHandleRedirectOrDisplayQrCode { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = + PaymentIntentNextActionSwishHandleRedirectOrDisplayQrCodeBuilder::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_swish_qr_code.rs b/generated/stripe_shared/src/payment_intent_next_action_swish_qr_code.rs index 410c69da5..42d520a5d 100644 --- 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 @@ -1,12 +1,111 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// The image_url_png string used to render QR code - #[serde(skip_serializing_if = "Option::is_none")] pub image_url_png: Option, /// The image_url_svg string used to render QR code - #[serde(skip_serializing_if = "Option::is_none")] pub image_url_svg: Option, } +#[doc(hidden)] +pub struct PaymentIntentNextActionSwishQrCodeBuilder { + data: Option>, + image_url_png: Option>, + image_url_svg: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentNextActionSwishQrCode { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionSwishQrCodeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: PaymentIntentNextActionSwishQrCodeBuilder::deser_default(), + })) + } + } + + impl MapBuilder for PaymentIntentNextActionSwishQrCodeBuilder { + type Out = PaymentIntentNextActionSwishQrCode; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "data" => Deserialize::begin(&mut self.data), + "image_url_png" => Deserialize::begin(&mut self.image_url_png), + "image_url_svg" => Deserialize::begin(&mut self.image_url_svg), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + data: Deserialize::default(), + image_url_png: Deserialize::default(), + image_url_svg: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + data: self.data.take()?, + image_url_png: self.image_url_png.take()?, + image_url_svg: self.image_url_svg.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentIntentNextActionSwishQrCode { + type Builder = PaymentIntentNextActionSwishQrCodeBuilder; + } + + impl FromValueOpt for PaymentIntentNextActionSwishQrCode { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentNextActionSwishQrCodeBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "data" => b.data = 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_verify_with_microdeposits.rs b/generated/stripe_shared/src/payment_intent_next_action_verify_with_microdeposits.rs index 135a45185..860b6cbfc 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentNextActionVerifyWithMicrodeposits { /// The timestamp when the microdeposits are expected to land. pub arrival_date: stripe_types::Timestamp, @@ -8,6 +10,109 @@ pub struct PaymentIntentNextActionVerifyWithMicrodeposits { /// Used to distinguish between different verification methods. pub microdeposit_type: Option, } +#[doc(hidden)] +pub struct PaymentIntentNextActionVerifyWithMicrodepositsBuilder { + arrival_date: Option, + hosted_verification_url: Option, + microdeposit_type: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionVerifyWithMicrodepositsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + arrival_date: self.arrival_date?, + hosted_verification_url: self.hosted_verification_url.take()?, + microdeposit_type: self.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 { + 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)] @@ -47,6 +152,7 @@ impl std::fmt::Debug for PaymentIntentNextActionVerifyWithMicrodepositsMicrodepo f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentNextActionVerifyWithMicrodepositsMicrodepositType { fn serialize(&self, serializer: S) -> Result where @@ -55,6 +161,29 @@ impl serde::Serialize for PaymentIntentNextActionVerifyWithMicrodepositsMicrodep serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentNextActionVerifyWithMicrodepositsMicrodepositType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentNextActionVerifyWithMicrodepositsMicrodepositType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentIntentNextActionVerifyWithMicrodepositsMicrodepositType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for 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..805e9f221 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentNextActionWechatPayDisplayQrCode { /// The data being used to generate QR code pub data: String, @@ -11,3 +13,115 @@ pub struct PaymentIntentNextActionWechatPayDisplayQrCode { /// The image_url_svg string used to render QR code pub image_url_svg: String, } +#[doc(hidden)] +pub struct PaymentIntentNextActionWechatPayDisplayQrCodeBuilder { + data: Option, + hosted_instructions_url: Option, + image_data_url: Option, + image_url_png: Option, + image_url_svg: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionWechatPayDisplayQrCodeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + data: self.data.take()?, + hosted_instructions_url: self.hosted_instructions_url.take()?, + image_data_url: self.image_data_url.take()?, + image_url_png: self.image_url_png.take()?, + image_url_svg: self.image_url_svg.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..47fa592d1 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentNextActionWechatPayRedirectToAndroidApp { /// app_id is the APP ID registered on WeChat open platform pub app_id: String, @@ -15,3 +17,125 @@ pub struct PaymentIntentNextActionWechatPayRedirectToAndroidApp { /// Specifies the current time in epoch format pub timestamp: String, } +#[doc(hidden)] +pub struct PaymentIntentNextActionWechatPayRedirectToAndroidAppBuilder { + app_id: Option, + nonce_str: Option, + package: Option, + partner_id: Option, + prepay_id: Option, + sign: Option, + timestamp: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionWechatPayRedirectToAndroidAppBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + app_id: self.app_id.take()?, + nonce_str: self.nonce_str.take()?, + package: self.package.take()?, + partner_id: self.partner_id.take()?, + prepay_id: self.prepay_id.take()?, + sign: self.sign.take()?, + timestamp: self.timestamp.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..74c356024 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentNextActionWechatPayRedirectToIosApp { /// An universal link that redirect to WeChat Pay app pub native_url: String, } +#[doc(hidden)] +pub struct PaymentIntentNextActionWechatPayRedirectToIosAppBuilder { + native_url: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentNextActionWechatPayRedirectToIosAppBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { native_url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { native_url: self.native_url.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..d9b35177c 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,300 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentPaymentMethodOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub affirm: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub afterpay_clearpay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub alipay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bancontact: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub blik: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub card_present: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cashapp: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub customer_balance: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub fpx: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub giropay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub grabpay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub interac_present: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub konbini: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub oxxo: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub paynow: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub paypal: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pix: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub promptpay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub revolut_pay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub swish: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub wechat_pay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub zip: Option, } +#[doc(hidden)] +pub struct PaymentIntentPaymentMethodOptionsBuilder { + acss_debit: Option>, + affirm: Option>, + afterpay_clearpay: Option>, + alipay: Option>, + au_becs_debit: Option>, + bacs_debit: Option>, + bancontact: Option>, + blik: Option>, + boleto: Option>, + card: Option>, + card_present: Option>, + cashapp: Option>, + customer_balance: Option>, + eps: Option>, + fpx: Option>, + giropay: Option>, + grabpay: Option>, + ideal: Option>, + interac_present: Option>, + klarna: Option>, + konbini: Option>, + link: Option>, + oxxo: Option>, + p24: Option>, + paynow: Option>, + paypal: Option>, + pix: Option>, + promptpay: Option>, + revolut_pay: Option>, + sepa_debit: Option>, + sofort: Option>, + swish: Option>, + us_bank_account: Option>, + wechat_pay: Option>, + zip: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "swish" => Deserialize::begin(&mut self.swish), + "us_bank_account" => Deserialize::begin(&mut self.us_bank_account), + "wechat_pay" => Deserialize::begin(&mut self.wechat_pay), + "zip" => Deserialize::begin(&mut self.zip), + + _ => ::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(), + swish: Deserialize::default(), + us_bank_account: Deserialize::default(), + wechat_pay: Deserialize::default(), + zip: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + acss_debit: self.acss_debit.take()?, + affirm: self.affirm.take()?, + afterpay_clearpay: self.afterpay_clearpay.take()?, + alipay: self.alipay?, + au_becs_debit: self.au_becs_debit?, + bacs_debit: self.bacs_debit?, + bancontact: self.bancontact?, + blik: self.blik?, + boleto: self.boleto?, + card: self.card.take()?, + card_present: self.card_present?, + cashapp: self.cashapp?, + customer_balance: self.customer_balance.take()?, + eps: self.eps?, + fpx: self.fpx?, + giropay: self.giropay?, + grabpay: self.grabpay?, + ideal: self.ideal?, + interac_present: self.interac_present?, + klarna: self.klarna.take()?, + konbini: self.konbini.take()?, + link: self.link.take()?, + oxxo: self.oxxo?, + p24: self.p24?, + paynow: self.paynow?, + paypal: self.paypal.take()?, + pix: self.pix?, + promptpay: self.promptpay?, + revolut_pay: self.revolut_pay?, + sepa_debit: self.sepa_debit?, + sofort: self.sofort?, + swish: self.swish.take()?, + us_bank_account: self.us_bank_account.take()?, + wechat_pay: self.wechat_pay.take()?, + zip: self.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 { + 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)?), + "swish" => b.swish = 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..c56f868b0 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,6 +1,7 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentPaymentMethodOptionsAcssDebit { - #[serde(skip_serializing_if = "Option::is_none")] pub mandate_options: Option, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. @@ -9,12 +10,116 @@ pub struct PaymentIntentPaymentMethodOptionsAcssDebit { /// 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, /// Bank account verification method. - #[serde(skip_serializing_if = "Option::is_none")] pub verification_method: Option, } +#[doc(hidden)] +pub struct PaymentIntentPaymentMethodOptionsAcssDebitBuilder { + mandate_options: + Option>, + setup_future_usage: Option>, + verification_method: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentPaymentMethodOptionsAcssDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + mandate_options: self.mandate_options.take()?, + setup_future_usage: self.setup_future_usage?, + verification_method: self.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 { + 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. @@ -61,6 +166,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUs f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -69,6 +175,29 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureU serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsAcssDebitSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -121,6 +250,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsAcssDebitVerificationM f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod { fn serialize(&self, serializer: S) -> Result where @@ -129,6 +259,29 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsAcssDebitVerification serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsAcssDebitVerificationMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..10dec9cdb 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentPaymentMethodOptionsAuBecsDebit { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,97 @@ 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, } +#[doc(hidden)] +pub struct PaymentIntentPaymentMethodOptionsAuBecsDebitBuilder { + setup_future_usage: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentPaymentMethodOptionsAuBecsDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -55,6 +145,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsAuBecsDebitSetupFuture f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -63,6 +154,29 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutur serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsAuBecsDebitSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..79f95ff03 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,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentPaymentMethodOptionsBlik { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ pub struct PaymentIntentPaymentMethodOptionsBlik { /// 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, } +#[doc(hidden)] +pub struct PaymentIntentPaymentMethodOptionsBlikBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentPaymentMethodOptionsBlikBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: PaymentIntentPaymentMethodOptionsBlikBuilder::deser_default(), + })) + } + } + + impl MapBuilder for PaymentIntentPaymentMethodOptionsBlikBuilder { + type Out = PaymentIntentPaymentMethodOptionsBlik; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 PaymentIntentPaymentMethodOptionsBlik { + type Builder = PaymentIntentPaymentMethodOptionsBlikBuilder; + } + + impl FromValueOpt for PaymentIntentPaymentMethodOptionsBlik { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentPaymentMethodOptionsBlikBuilder::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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,27 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsBlikSetupFutureUsage serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsBlikSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsBlikSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsBlikSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..3235aa74f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// Installment details for this payment (Mexico only). /// @@ -14,18 +15,14 @@ pub struct PaymentIntentPaymentMethodOptionsCard { /// Can be only set confirm-time. pub network: Option, /// 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, /// 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, /// 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, /// Request ability to [overcapture](https://stripe.com/docs/payments/overcapture) for this PaymentIntent. - #[serde(skip_serializing_if = "Option::is_none")] pub request_overcapture: Option, /// 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. @@ -34,7 +31,6 @@ pub struct PaymentIntentPaymentMethodOptionsCard { pub request_three_d_secure: Option, /// 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, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -42,21 +38,199 @@ pub struct PaymentIntentPaymentMethodOptionsCard { /// 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, /// 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, /// 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, } +#[doc(hidden)] +pub struct PaymentIntentPaymentMethodOptionsCardBuilder { + capture_method: Option>, + installments: Option>, + mandate_options: Option>, + network: Option>, + request_extended_authorization: + Option>, + request_incremental_authorization: + Option>, + request_multicapture: Option>, + request_overcapture: Option>, + request_three_d_secure: + Option>, + require_cvc_recollection: Option>, + setup_future_usage: Option>, + statement_descriptor_suffix_kana: Option>, + statement_descriptor_suffix_kanji: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentPaymentMethodOptionsCardBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "require_cvc_recollection" => { + Deserialize::begin(&mut self.require_cvc_recollection) + } + "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) + } + + _ => ::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(), + require_cvc_recollection: 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 { + Some(Self::Out { + capture_method: self.capture_method?, + installments: self.installments.take()?, + mandate_options: self.mandate_options.take()?, + network: self.network?, + request_extended_authorization: self.request_extended_authorization?, + request_incremental_authorization: self.request_incremental_authorization?, + request_multicapture: self.request_multicapture?, + request_overcapture: self.request_overcapture?, + request_three_d_secure: self.request_three_d_secure?, + require_cvc_recollection: self.require_cvc_recollection?, + setup_future_usage: self.setup_future_usage?, + statement_descriptor_suffix_kana: self.statement_descriptor_suffix_kana.take()?, + statement_descriptor_suffix_kanji: self.statement_descriptor_suffix_kanji.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?) + } + "require_cvc_recollection" => { + b.require_cvc_recollection = 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 { @@ -92,6 +266,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardCaptureMethod { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardCaptureMethod { fn serialize(&self, serializer: S) -> Result where @@ -100,6 +275,25 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardCaptureMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardCaptureMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsCardCaptureMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsCardCaptureMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardCaptureMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -178,6 +372,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardNetwork { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardNetwork { fn serialize(&self, serializer: S) -> Result where @@ -186,6 +381,25 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardNetwork { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardNetwork { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsCardNetwork::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsCardNetwork); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardNetwork { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -235,6 +449,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardRequestExtendedAut f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization { fn serialize(&self, serializer: S) -> Result where @@ -243,6 +458,29 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardRequestExtendedAu serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardRequestExtendedAuthorization { @@ -290,6 +528,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardRequestIncremental f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { fn serialize(&self, serializer: S) -> Result where @@ -298,6 +537,31 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardRequestIncrementa serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardRequestIncrementalAuthorization { @@ -345,6 +609,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardRequestMulticaptur f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardRequestMulticapture { fn serialize(&self, serializer: S) -> Result where @@ -353,6 +618,29 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardRequestMulticaptu serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardRequestMulticapture { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsCardRequestMulticapture::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentIntentPaymentMethodOptionsCardRequestMulticapture +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardRequestMulticapture { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -402,6 +690,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardRequestOvercapture f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardRequestOvercapture { fn serialize(&self, serializer: S) -> Result where @@ -410,6 +699,27 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardRequestOvercaptur serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardRequestOvercapture { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsCardRequestOvercapture::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsCardRequestOvercapture); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardRequestOvercapture { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -465,6 +775,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardRequestThreeDSecur f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure { fn serialize(&self, serializer: S) -> Result where @@ -473,6 +784,29 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardRequestThreeDSecu serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardRequestThreeDSecure { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -530,6 +864,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsCardSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -538,6 +873,27 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsCardSetupFutureUsage serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsCardSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsCardSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsCardSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsCardSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..0d2140e4e 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentPaymentMethodOptionsEps { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct PaymentIntentPaymentMethodOptionsEpsBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentPaymentMethodOptionsEpsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,25 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsEpsSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..f7c284ec9 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// \[Deprecated\] This is a legacy parameter that no longer has any function. pub persistent_token: Option, @@ -11,9 +12,110 @@ 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, } +#[doc(hidden)] +pub struct PaymentIntentPaymentMethodOptionsLinkBuilder { + capture_method: Option>, + persistent_token: Option>, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentPaymentMethodOptionsLinkBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + capture_method: self.capture_method?, + persistent_token: self.persistent_token.take()?, + setup_future_usage: self.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 { + 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 { @@ -49,6 +151,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsLinkCaptureMethod { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsLinkCaptureMethod { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +160,25 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsLinkCaptureMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsLinkCaptureMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsLinkCaptureMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsLinkCaptureMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsLinkCaptureMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -111,6 +233,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsLinkSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsLinkSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -119,6 +242,27 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsLinkSetupFutureUsage serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsLinkSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsLinkSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsLinkSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsLinkSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..4215eee5c 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,7 +1,8 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit { /// A URL for custom mandate text - #[serde(skip_serializing_if = "Option::is_none")] pub custom_mandate_url: Option, /// Description of the interval. /// Only required if the 'payment_schedule' parameter is 'interval' or 'combined'. @@ -13,6 +14,119 @@ pub struct PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebit { pub transaction_type: Option, } +#[doc(hidden)] +pub struct PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder { + custom_mandate_url: Option>, + interval_description: Option>, + payment_schedule: + Option>, + transaction_type: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + custom_mandate_url: self.custom_mandate_url.take()?, + interval_description: self.interval_description.take()?, + payment_schedule: self.payment_schedule?, + transaction_type: self.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 { + 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 { @@ -54,6 +168,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebi f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule { fn serialize(&self, serializer: S) -> Result where @@ -62,6 +177,31 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDeb serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule { @@ -109,6 +249,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebi f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType { fn serialize(&self, serializer: S) -> Result where @@ -117,6 +258,31 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDeb serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for 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..db2cdef41 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,86 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebit {} +#[doc(hidden)] +pub struct PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..d2cbebaaf 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,6 +1,7 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentPaymentMethodOptionsSepaDebit { - #[serde(skip_serializing_if = "Option::is_none")] pub mandate_options: Option, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. @@ -9,9 +10,106 @@ pub struct PaymentIntentPaymentMethodOptionsSepaDebit { /// 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, } +#[doc(hidden)] +pub struct PaymentIntentPaymentMethodOptionsSepaDebitBuilder { + mandate_options: + Option>, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentPaymentMethodOptionsSepaDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + mandate_options: Deserialize::default(), + setup_future_usage: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + mandate_options: self.mandate_options?, + setup_future_usage: self.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 { + 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. @@ -58,6 +156,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUs f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -66,6 +165,29 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsSepaDebitSetupFutureU serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsSepaDebitSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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 index f535e0d86..ca7df093a 100644 --- a/generated/stripe_shared/src/payment_intent_payment_method_options_swish.rs +++ b/generated/stripe_shared/src/payment_intent_payment_method_options_swish.rs @@ -1,7 +1,8 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -9,9 +10,102 @@ pub struct PaymentIntentPaymentMethodOptionsSwish { /// 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, } +#[doc(hidden)] +pub struct PaymentIntentPaymentMethodOptionsSwishBuilder { + reference: Option>, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentIntentPaymentMethodOptionsSwish { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentPaymentMethodOptionsSwishBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: PaymentIntentPaymentMethodOptionsSwishBuilder::deser_default(), + })) + } + } + + impl MapBuilder for PaymentIntentPaymentMethodOptionsSwishBuilder { + type Out = PaymentIntentPaymentMethodOptionsSwish; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "reference" => Deserialize::begin(&mut self.reference), + "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { reference: Deserialize::default(), setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + reference: self.reference.take()?, + setup_future_usage: self.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 PaymentIntentPaymentMethodOptionsSwish { + type Builder = PaymentIntentPaymentMethodOptionsSwishBuilder; + } + + impl FromValueOpt for PaymentIntentPaymentMethodOptionsSwish { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentIntentPaymentMethodOptionsSwishBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "reference" => b.reference = 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. @@ -52,6 +146,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -60,6 +155,27 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsSwishSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..3a57f4842 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,11 +1,10 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentPaymentMethodOptionsUsBankAccount { - #[serde(skip_serializing_if = "Option::is_none")] pub financial_connections: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub mandate_options: Option, /// Preferred transaction settlement speed - #[serde(skip_serializing_if = "Option::is_none")] pub preferred_settlement_speed: Option, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. @@ -14,13 +13,134 @@ pub struct PaymentIntentPaymentMethodOptionsUsBankAccount { /// 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, /// Bank account verification method. - #[serde(skip_serializing_if = "Option::is_none")] pub verification_method: Option, } +#[doc(hidden)] +pub struct PaymentIntentPaymentMethodOptionsUsBankAccountBuilder { + financial_connections: Option>, + mandate_options: Option>, + preferred_settlement_speed: + Option>, + setup_future_usage: + Option>, + verification_method: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentPaymentMethodOptionsUsBankAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "mandate_options" => Deserialize::begin(&mut self.mandate_options), + "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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + financial_connections: Deserialize::default(), + mandate_options: Deserialize::default(), + preferred_settlement_speed: Deserialize::default(), + setup_future_usage: Deserialize::default(), + verification_method: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + financial_connections: self.financial_connections.take()?, + mandate_options: self.mandate_options?, + preferred_settlement_speed: self.preferred_settlement_speed?, + setup_future_usage: self.setup_future_usage?, + verification_method: self.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 { + 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)?) + } + "mandate_options" => b.mandate_options = 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 { @@ -59,6 +179,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsUsBankAccountPreferred f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { fn serialize(&self, serializer: S) -> Result where @@ -67,6 +188,31 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsUsBankAccountPreferre serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsUsBankAccountPreferredSettlementSpeed { @@ -122,6 +268,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutu f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -130,6 +277,29 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsUsBankAccountSetupFut serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsUsBankAccountSetupFutureUsage { @@ -184,6 +354,7 @@ impl std::fmt::Debug for PaymentIntentPaymentMethodOptionsUsBankAccountVerificat f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod { fn serialize(&self, serializer: S) -> Result where @@ -192,6 +363,29 @@ impl serde::Serialize for PaymentIntentPaymentMethodOptionsUsBankAccountVerifica serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentPaymentMethodOptionsUsBankAccountVerificationMethod { diff --git a/generated/stripe_shared/src/payment_intent_processing.rs b/generated/stripe_shared/src/payment_intent_processing.rs index 249bfa825..44e9d73e4 100644 --- a/generated/stripe_shared/src/payment_intent_processing.rs +++ b/generated/stripe_shared/src/payment_intent_processing.rs @@ -1,11 +1,101 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentIntentProcessing { - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option, /// Type of the payment method for which payment is in `processing` state, one of `card`. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: PaymentIntentProcessingType, } +#[doc(hidden)] +pub struct PaymentIntentProcessingBuilder { + card: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentProcessingBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { card: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { card: self.card?, type_: self.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 { + 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 { @@ -41,6 +131,7 @@ impl std::fmt::Debug for PaymentIntentProcessingType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentIntentProcessingType { fn serialize(&self, serializer: S) -> Result where @@ -49,6 +140,22 @@ impl serde::Serialize for PaymentIntentProcessingType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentIntentProcessingType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentIntentProcessingType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentIntentProcessingType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentIntentProcessingType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..5761cb061 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,100 @@ pub struct PaymentIntentProcessingCustomerNotification { /// If customer approval is required, they need to provide approval before this time. pub completes_at: Option, } +#[doc(hidden)] +pub struct PaymentIntentProcessingCustomerNotificationBuilder { + approval_requested: Option>, + completes_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentIntentProcessingCustomerNotificationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + approval_requested: Deserialize::default(), + completes_at: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + approval_requested: self.approval_requested?, + completes_at: self.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 { + 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..2752d5676 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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. @@ -42,13 +44,14 @@ pub struct PaymentLink { /// Configuration for creating invoice for payment mode payment links. pub invoice_creation: Option, /// The line items representing what is being sold. - #[serde(skip_serializing_if = "Option::is_none")] pub line_items: Option>, /// 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 representing the object's type. Objects of the same type share the same value. + pub object: PaymentLinkObject, /// The account on behalf of which to charge. /// See the [Connect documentation](https://support.stripe.com/questions/sending-invoices-on-behalf-of-connected-accounts) for details. pub on_behalf_of: Option>, @@ -78,6 +81,283 @@ pub struct PaymentLink { /// The public URL that can be shared with customers. pub url: String, } +#[doc(hidden)] +pub struct PaymentLinkBuilder { + active: Option, + after_completion: Option, + allow_promotion_codes: Option, + application: Option>>, + application_fee_amount: Option>, + application_fee_percent: Option>, + automatic_tax: Option, + billing_address_collection: Option, + consent_collection: Option>, + currency: Option, + custom_fields: Option>, + custom_text: Option, + customer_creation: Option, + id: Option, + inactive_message: Option>, + invoice_creation: Option>, + line_items: Option>>, + livemode: Option, + metadata: Option>, + object: Option, + on_behalf_of: Option>>, + payment_intent_data: Option>, + payment_method_collection: Option, + payment_method_types: Option>>, + phone_number_collection: Option, + restrictions: Option>, + shipping_address_collection: + Option>, + shipping_options: Option>, + submit_type: Option, + subscription_data: Option>, + tax_id_collection: Option, + transfer_data: Option>, + url: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinkBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "inactive_message" => Deserialize::begin(&mut self.inactive_message), + "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), + "object" => Deserialize::begin(&mut self.object), + "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), + "restrictions" => Deserialize::begin(&mut self.restrictions), + "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), + + _ => ::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(), + inactive_message: Deserialize::default(), + invoice_creation: Deserialize::default(), + line_items: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + object: 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(), + restrictions: 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 { + Some(Self::Out { + active: self.active?, + after_completion: self.after_completion.take()?, + allow_promotion_codes: self.allow_promotion_codes?, + application: self.application.take()?, + application_fee_amount: self.application_fee_amount?, + application_fee_percent: self.application_fee_percent?, + automatic_tax: self.automatic_tax.take()?, + billing_address_collection: self.billing_address_collection?, + consent_collection: self.consent_collection?, + currency: self.currency?, + custom_fields: self.custom_fields.take()?, + custom_text: self.custom_text.take()?, + customer_creation: self.customer_creation?, + id: self.id.take()?, + inactive_message: self.inactive_message.take()?, + invoice_creation: self.invoice_creation.take()?, + line_items: self.line_items.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + on_behalf_of: self.on_behalf_of.take()?, + payment_intent_data: self.payment_intent_data.take()?, + payment_method_collection: self.payment_method_collection?, + payment_method_types: self.payment_method_types.take()?, + phone_number_collection: self.phone_number_collection?, + restrictions: self.restrictions?, + shipping_address_collection: self.shipping_address_collection.take()?, + shipping_options: self.shipping_options.take()?, + submit_type: self.submit_type?, + subscription_data: self.subscription_data.take()?, + tax_id_collection: self.tax_id_collection?, + transfer_data: self.transfer_data.take()?, + url: self.url.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "inactive_message" => b.inactive_message = 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)?), + "object" => b.object = 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)?) + } + "restrictions" => b.restrictions = 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 { @@ -116,6 +396,7 @@ impl std::fmt::Debug for PaymentLinkCustomerCreation { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentLinkCustomerCreation { fn serialize(&self, serializer: S) -> Result where @@ -124,6 +405,22 @@ impl serde::Serialize for PaymentLinkCustomerCreation { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentLinkCustomerCreation { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentLinkCustomerCreation::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentLinkCustomerCreation); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentLinkCustomerCreation { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -132,6 +429,74 @@ impl<'de> serde::Deserialize<'de> for PaymentLinkCustomerCreation { .map_err(|_| serde::de::Error::custom("Unknown value for PaymentLinkCustomerCreation")) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum PaymentLinkObject { + PaymentLink, +} +impl PaymentLinkObject { + pub fn as_str(self) -> &'static str { + use PaymentLinkObject::*; + match self { + PaymentLink => "payment_link", + } + } +} + +impl std::str::FromStr for PaymentLinkObject { + type Err = (); + fn from_str(s: &str) -> Result { + use PaymentLinkObject::*; + match s { + "payment_link" => Ok(PaymentLink), + _ => Err(()), + } + } +} +impl std::fmt::Display for PaymentLinkObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for PaymentLinkObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for PaymentLinkObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for PaymentLinkObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentLinkObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentLinkObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for PaymentLinkObject { + fn deserialize>(deserializer: D) -> 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 PaymentLinkObject")) + } +} /// Configuration for collecting a payment method during checkout. #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentLinkPaymentMethodCollection { @@ -170,6 +535,7 @@ impl std::fmt::Debug for PaymentLinkPaymentMethodCollection { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentLinkPaymentMethodCollection { fn serialize(&self, serializer: S) -> Result where @@ -178,6 +544,23 @@ impl serde::Serialize for PaymentLinkPaymentMethodCollection { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentLinkPaymentMethodCollection { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(PaymentLinkPaymentMethodCollection::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentLinkPaymentMethodCollection); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentLinkPaymentMethodCollection { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -239,6 +622,23 @@ impl serde::Serialize for PaymentLinkBillingAddressCollection { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentLinkBillingAddressCollection { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(PaymentLinkBillingAddressCollection::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentLinkBillingAddressCollection); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentLinkBillingAddressCollection { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -378,11 +778,30 @@ impl serde::Serialize for PaymentLinkPaymentMethodTypes { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentLinkPaymentMethodTypes { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentLinkPaymentMethodTypes::from_str(s) + .unwrap_or(PaymentLinkPaymentMethodTypes::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentLinkPaymentMethodTypes); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentLinkPaymentMethodTypes { fn deserialize>(deserializer: D) -> Result { 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)) } } #[derive(Copy, Clone, Eq, PartialEq)] @@ -436,6 +855,22 @@ impl serde::Serialize for PaymentLinkSubmitType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentLinkSubmitType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentLinkSubmitType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentLinkSubmitType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentLinkSubmitType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..0610c6ca4 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,117 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourceAfterCompletion { - #[serde(skip_serializing_if = "Option::is_none")] pub hosted_confirmation: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub redirect: Option, /// The specified behavior after the purchase is complete. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: PaymentLinksResourceAfterCompletionType, } +#[doc(hidden)] +pub struct PaymentLinksResourceAfterCompletionBuilder { + hosted_confirmation: + Option>, + redirect: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceAfterCompletionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + hosted_confirmation: Deserialize::default(), + redirect: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + hosted_confirmation: self.hosted_confirmation.take()?, + redirect: self.redirect.take()?, + type_: self.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 { + 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 { @@ -47,6 +150,7 @@ impl std::fmt::Debug for PaymentLinksResourceAfterCompletionType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentLinksResourceAfterCompletionType { fn serialize(&self, serializer: S) -> Result where @@ -55,6 +159,24 @@ impl serde::Serialize for PaymentLinksResourceAfterCompletionType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentLinksResourceAfterCompletionType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentLinksResourceAfterCompletionType::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentLinksResourceAfterCompletionType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentLinksResourceAfterCompletionType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..8634531c4 100644 --- a/generated/stripe_shared/src/payment_links_resource_automatic_tax.rs +++ b/generated/stripe_shared/src/payment_links_resource_automatic_tax.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourceAutomaticTax { /// If `true`, tax will be calculated automatically using the customer's location. pub enabled: bool, @@ -7,3 +9,92 @@ pub struct PaymentLinksResourceAutomaticTax { /// The tax transaction is returned in the report of the connected account. pub liability: Option, } +#[doc(hidden)] +pub struct PaymentLinksResourceAutomaticTaxBuilder { + enabled: Option, + liability: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceAutomaticTaxBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "liability" => Deserialize::begin(&mut self.liability), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default(), liability: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.enabled?, liability: self.liability.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "liability" => b.liability = 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 index 5459c9fd9..e93608285 100644 --- a/generated/stripe_shared/src/payment_links_resource_completed_sessions.rs +++ b/generated/stripe_shared/src/payment_links_resource_completed_sessions.rs @@ -1,7 +1,98 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct PaymentLinksResourceCompletedSessionsBuilder { + count: Option, + limit: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceCompletedSessions { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceCompletedSessionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: PaymentLinksResourceCompletedSessionsBuilder::deser_default(), + })) + } + } + + impl MapBuilder for PaymentLinksResourceCompletedSessionsBuilder { + type Out = PaymentLinksResourceCompletedSessions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "count" => Deserialize::begin(&mut self.count), + "limit" => Deserialize::begin(&mut self.limit), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { count: Deserialize::default(), limit: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { count: self.count?, limit: self.limit? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceCompletedSessions { + type Builder = PaymentLinksResourceCompletedSessionsBuilder; + } + + impl FromValueOpt for PaymentLinksResourceCompletedSessions { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceCompletedSessionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "count" => b.count = Some(FromValueOpt::from_value(v)?), + "limit" => b.limit = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; 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..36d8a2638 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,95 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourceCompletionBehaviorConfirmationPage { /// The custom message that is displayed to the customer after the purchase is complete. pub custom_message: Option, } +#[doc(hidden)] +pub struct PaymentLinksResourceCompletionBehaviorConfirmationPageBuilder { + custom_message: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceCompletionBehaviorConfirmationPageBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { custom_message: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { custom_message: self.custom_message.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..36d6d5c01 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourceCompletionBehaviorRedirect { /// The URL the customer will be redirected to after the purchase is complete. pub url: String, } +#[doc(hidden)] +pub struct PaymentLinksResourceCompletionBehaviorRedirectBuilder { + url: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceCompletionBehaviorRedirectBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { url: self.url.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..ee5429c81 100644 --- a/generated/stripe_shared/src/payment_links_resource_consent_collection.rs +++ b/generated/stripe_shared/src/payment_links_resource_consent_collection.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourceConsentCollection { /// Settings related to the payment method reuse text shown in the Checkout UI. pub payment_method_reuse_agreement: @@ -9,6 +11,111 @@ pub struct PaymentLinksResourceConsentCollection { /// If set to `none`, customers won't be shown a checkbox to accept the terms of service. pub terms_of_service: Option, } +#[doc(hidden)] +pub struct PaymentLinksResourceConsentCollectionBuilder { + payment_method_reuse_agreement: + Option>, + promotions: Option>, + terms_of_service: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceConsentCollectionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + "payment_method_reuse_agreement" => { + Deserialize::begin(&mut self.payment_method_reuse_agreement) + } + "promotions" => Deserialize::begin(&mut self.promotions), + "terms_of_service" => Deserialize::begin(&mut self.terms_of_service), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + payment_method_reuse_agreement: Deserialize::default(), + promotions: Deserialize::default(), + terms_of_service: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + payment_method_reuse_agreement: self.payment_method_reuse_agreement?, + promotions: self.promotions?, + terms_of_service: self.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 { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceConsentCollectionBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "payment_method_reuse_agreement" => { + b.payment_method_reuse_agreement = Some(FromValueOpt::from_value(v)?) + } + "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 { @@ -47,6 +154,7 @@ impl std::fmt::Debug for PaymentLinksResourceConsentCollectionPromotions { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentLinksResourceConsentCollectionPromotions { fn serialize(&self, serializer: S) -> Result where @@ -55,6 +163,25 @@ impl serde::Serialize for PaymentLinksResourceConsentCollectionPromotions { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentLinksResourceConsentCollectionPromotions { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentLinksResourceConsentCollectionPromotions::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentLinksResourceConsentCollectionPromotions); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentLinksResourceConsentCollectionPromotions { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -105,6 +232,7 @@ impl std::fmt::Debug for PaymentLinksResourceConsentCollectionTermsOfService { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentLinksResourceConsentCollectionTermsOfService { fn serialize(&self, serializer: S) -> Result where @@ -113,6 +241,25 @@ impl serde::Serialize for PaymentLinksResourceConsentCollectionTermsOfService { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentLinksResourceConsentCollectionTermsOfService { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentLinksResourceConsentCollectionTermsOfService::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentLinksResourceConsentCollectionTermsOfService); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentLinksResourceConsentCollectionTermsOfService { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..4f4041d0c 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,141 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourceCustomFields { - #[serde(skip_serializing_if = "Option::is_none")] pub dropdown: Option, /// 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, /// 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, /// The type of the field. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: PaymentLinksResourceCustomFieldsType, } +#[doc(hidden)] +pub struct PaymentLinksResourceCustomFieldsBuilder { + dropdown: Option>, + key: Option, + label: Option, + numeric: Option>, + optional: Option, + text: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceCustomFieldsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + dropdown: self.dropdown.take()?, + key: self.key.take()?, + label: self.label.take()?, + numeric: self.numeric?, + optional: self.optional?, + text: self.text?, + type_: self.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 { + 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 { @@ -58,6 +177,7 @@ impl std::fmt::Debug for PaymentLinksResourceCustomFieldsType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentLinksResourceCustomFieldsType { fn serialize(&self, serializer: S) -> Result where @@ -66,6 +186,23 @@ impl serde::Serialize for PaymentLinksResourceCustomFieldsType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentLinksResourceCustomFieldsType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(PaymentLinksResourceCustomFieldsType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentLinksResourceCustomFieldsType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentLinksResourceCustomFieldsType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..48c83914c 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourceCustomFieldsDropdown { /// The options available for the customer to select. Up to 200 options allowed. pub options: Vec, } +#[doc(hidden)] +pub struct PaymentLinksResourceCustomFieldsDropdownBuilder { + options: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceCustomFieldsDropdownBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { options: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { options: self.options.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..063aee7d0 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourceCustomFieldsDropdownOption { /// The label for the option, displayed to the customer. Up to 100 characters. pub label: String, @@ -6,3 +8,92 @@ pub struct PaymentLinksResourceCustomFieldsDropdownOption { /// Must be unique to this option, alphanumeric, and up to 100 characters. pub value: String, } +#[doc(hidden)] +pub struct PaymentLinksResourceCustomFieldsDropdownOptionBuilder { + label: Option, + value: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceCustomFieldsDropdownOptionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { label: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { label: self.label.take()?, value: self.value.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..2137db581 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,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourceCustomFieldsLabel { /// Custom text for the label, displayed to the customer. Up to 50 characters. pub custom: Option, /// The type of the label. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: PaymentLinksResourceCustomFieldsLabelType, } +#[doc(hidden)] +pub struct PaymentLinksResourceCustomFieldsLabelBuilder { + custom: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceCustomFieldsLabelBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { custom: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { custom: self.custom.take()?, type_: self.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 { + 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 { @@ -41,6 +132,7 @@ impl std::fmt::Debug for PaymentLinksResourceCustomFieldsLabelType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentLinksResourceCustomFieldsLabelType { fn serialize(&self, serializer: S) -> Result where @@ -49,6 +141,24 @@ impl serde::Serialize for PaymentLinksResourceCustomFieldsLabelType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentLinksResourceCustomFieldsLabelType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentLinksResourceCustomFieldsLabelType::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentLinksResourceCustomFieldsLabelType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentLinksResourceCustomFieldsLabelType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..bd1f05303 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,101 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourceCustomFieldsNumeric { /// The maximum character length constraint for the customer's input. pub maximum_length: Option, /// The minimum character length requirement for the customer's input. pub minimum_length: Option, } +#[doc(hidden)] +pub struct PaymentLinksResourceCustomFieldsNumericBuilder { + maximum_length: Option>, + minimum_length: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceCustomFieldsNumericBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { maximum_length: Deserialize::default(), minimum_length: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + maximum_length: self.maximum_length?, + minimum_length: self.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 { + 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..a95ba40bd 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,101 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourceCustomFieldsText { /// The maximum character length constraint for the customer's input. pub maximum_length: Option, /// The minimum character length requirement for the customer's input. pub minimum_length: Option, } +#[doc(hidden)] +pub struct PaymentLinksResourceCustomFieldsTextBuilder { + maximum_length: Option>, + minimum_length: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceCustomFieldsTextBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { maximum_length: Deserialize::default(), minimum_length: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + maximum_length: self.maximum_length?, + minimum_length: self.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 { + 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..ae92f8781 100644 --- a/generated/stripe_shared/src/payment_links_resource_custom_text.rs +++ b/generated/stripe_shared/src/payment_links_resource_custom_text.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourceCustomText { /// Custom text that should be displayed after the payment confirmation button. pub after_submit: Option, @@ -9,3 +11,113 @@ 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, } +#[doc(hidden)] +pub struct PaymentLinksResourceCustomTextBuilder { + after_submit: Option>, + shipping_address: Option>, + submit: Option>, + terms_of_service_acceptance: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceCustomTextBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + "after_submit" => Deserialize::begin(&mut self.after_submit), + "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) + } + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + after_submit: Deserialize::default(), + shipping_address: Deserialize::default(), + submit: Deserialize::default(), + terms_of_service_acceptance: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + after_submit: self.after_submit.take()?, + shipping_address: self.shipping_address.take()?, + submit: self.submit.take()?, + terms_of_service_acceptance: self.terms_of_service_acceptance.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceCustomTextBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "after_submit" => b.after_submit = Some(FromValueOpt::from_value(v)?), + "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..7becc51bd 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourceCustomTextPosition { /// Text may be up to 1200 characters in length. pub message: String, } +#[doc(hidden)] +pub struct PaymentLinksResourceCustomTextPositionBuilder { + message: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceCustomTextPositionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { message: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { message: self.message.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..0a803a30b 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,98 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct PaymentLinksResourceInvoiceCreationBuilder { + enabled: Option, + invoice_data: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceInvoiceCreationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default(), invoice_data: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.enabled?, invoice_data: self.invoice_data.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..1a9d86804 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourceInvoiceSettings { /// The account tax IDs associated with the invoice. pub account_tax_ids: Option>>, @@ -17,3 +19,123 @@ pub struct PaymentLinksResourceInvoiceSettings { /// Options for invoice PDF rendering. pub rendering_options: Option, } +#[doc(hidden)] +pub struct PaymentLinksResourceInvoiceSettingsBuilder { + account_tax_ids: Option>>>, + custom_fields: Option>>, + description: Option>, + footer: Option>, + issuer: Option>, + metadata: Option>>, + rendering_options: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceInvoiceSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "issuer" => Deserialize::begin(&mut self.issuer), + "metadata" => Deserialize::begin(&mut self.metadata), + "rendering_options" => Deserialize::begin(&mut self.rendering_options), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_tax_ids: Deserialize::default(), + custom_fields: Deserialize::default(), + description: Deserialize::default(), + footer: Deserialize::default(), + issuer: Deserialize::default(), + metadata: Deserialize::default(), + rendering_options: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account_tax_ids: self.account_tax_ids.take()?, + custom_fields: self.custom_fields.take()?, + description: self.description.take()?, + footer: self.footer.take()?, + issuer: self.issuer.take()?, + metadata: self.metadata.take()?, + rendering_options: self.rendering_options.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "issuer" => b.issuer = 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..f5575a9f8 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourcePaymentIntentData { /// Indicates when the funds will be captured from the customer's account. pub capture_method: Option, @@ -19,6 +21,134 @@ pub struct PaymentLinksResourcePaymentIntentData { /// See the PaymentIntents [use case for connected accounts](https://stripe.com/docs/connect/separate-charges-and-transfers) for details. pub transfer_group: Option, } +#[doc(hidden)] +pub struct PaymentLinksResourcePaymentIntentDataBuilder { + capture_method: Option>, + description: Option>, + metadata: Option>, + setup_future_usage: Option>, + statement_descriptor: Option>, + statement_descriptor_suffix: Option>, + transfer_group: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourcePaymentIntentDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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) + } + "transfer_group" => Deserialize::begin(&mut self.transfer_group), + + _ => ::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(), + transfer_group: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + capture_method: self.capture_method?, + description: self.description.take()?, + metadata: self.metadata.take()?, + setup_future_usage: self.setup_future_usage?, + statement_descriptor: self.statement_descriptor.take()?, + statement_descriptor_suffix: self.statement_descriptor_suffix.take()?, + transfer_group: self.transfer_group.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?) + } + "transfer_group" => b.transfer_group = 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 { @@ -60,6 +190,7 @@ impl std::fmt::Debug for PaymentLinksResourcePaymentIntentDataCaptureMethod { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentLinksResourcePaymentIntentDataCaptureMethod { fn serialize(&self, serializer: S) -> Result where @@ -68,6 +199,25 @@ impl serde::Serialize for PaymentLinksResourcePaymentIntentDataCaptureMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentLinksResourcePaymentIntentDataCaptureMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentLinksResourcePaymentIntentDataCaptureMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentLinksResourcePaymentIntentDataCaptureMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentLinksResourcePaymentIntentDataCaptureMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -117,6 +267,7 @@ impl std::fmt::Debug for PaymentLinksResourcePaymentIntentDataSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentLinksResourcePaymentIntentDataSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -125,6 +276,27 @@ impl serde::Serialize for PaymentLinksResourcePaymentIntentDataSetupFutureUsage serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentLinksResourcePaymentIntentDataSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentLinksResourcePaymentIntentDataSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentLinksResourcePaymentIntentDataSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentLinksResourcePaymentIntentDataSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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 index dff5dd838..1b69548a6 100644 --- 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 @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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. @@ -6,6 +8,92 @@ pub struct PaymentLinksResourcePaymentMethodReuseAgreement { /// When set to `hidden`, the payment method reuse agreement text will always be hidden in the UI. pub position: PaymentLinksResourcePaymentMethodReuseAgreementPosition, } +#[doc(hidden)] +pub struct PaymentLinksResourcePaymentMethodReuseAgreementBuilder { + position: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourcePaymentMethodReuseAgreement { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourcePaymentMethodReuseAgreementBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: PaymentLinksResourcePaymentMethodReuseAgreementBuilder::deser_default(), + })) + } + } + + impl MapBuilder for PaymentLinksResourcePaymentMethodReuseAgreementBuilder { + type Out = PaymentLinksResourcePaymentMethodReuseAgreement; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "position" => Deserialize::begin(&mut self.position), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { position: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { position: self.position? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourcePaymentMethodReuseAgreement { + type Builder = PaymentLinksResourcePaymentMethodReuseAgreementBuilder; + } + + impl FromValueOpt for PaymentLinksResourcePaymentMethodReuseAgreement { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourcePaymentMethodReuseAgreementBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "position" => b.position = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Determines the position and visibility of the payment method reuse agreement in the UI. /// When set to `auto`, Stripe's defaults will be used. /// @@ -47,6 +135,7 @@ impl std::fmt::Debug for PaymentLinksResourcePaymentMethodReuseAgreementPosition f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentLinksResourcePaymentMethodReuseAgreementPosition { fn serialize(&self, serializer: S) -> Result where @@ -55,6 +144,27 @@ impl serde::Serialize for PaymentLinksResourcePaymentMethodReuseAgreementPositio serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentLinksResourcePaymentMethodReuseAgreementPosition { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentLinksResourcePaymentMethodReuseAgreementPosition::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentLinksResourcePaymentMethodReuseAgreementPosition); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentLinksResourcePaymentMethodReuseAgreementPosition { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..3c2f9893a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourcePhoneNumberCollection { /// If `true`, a phone number will be collected during checkout. pub enabled: bool, } +#[doc(hidden)] +pub struct PaymentLinksResourcePhoneNumberCollectionBuilder { + enabled: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourcePhoneNumberCollectionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.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 { + 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 index 697c4612a..0bf589fe0 100644 --- a/generated/stripe_shared/src/payment_links_resource_restrictions.rs +++ b/generated/stripe_shared/src/payment_links_resource_restrictions.rs @@ -1,4 +1,94 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourceRestrictions { pub completed_sessions: stripe_shared::PaymentLinksResourceCompletedSessions, } +#[doc(hidden)] +pub struct PaymentLinksResourceRestrictionsBuilder { + completed_sessions: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceRestrictions { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceRestrictionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: PaymentLinksResourceRestrictionsBuilder::deser_default(), + })) + } + } + + impl MapBuilder for PaymentLinksResourceRestrictionsBuilder { + type Out = PaymentLinksResourceRestrictions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "completed_sessions" => Deserialize::begin(&mut self.completed_sessions), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { completed_sessions: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { completed_sessions: self.completed_sessions? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceRestrictions { + type Builder = PaymentLinksResourceRestrictionsBuilder; + } + + impl FromValueOpt for PaymentLinksResourceRestrictions { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceRestrictionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "completed_sessions" => { + b.completed_sessions = Some(FromValueOpt::from_value(v)?) + } + + _ => {} + } + } + b.take_out() + } + } +}; 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..3e47f5b29 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct PaymentLinksResourceShippingAddressCollectionBuilder { + allowed_countries: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceShippingAddressCollectionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { allowed_countries: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { allowed_countries: self.allowed_countries.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)] @@ -752,6 +840,7 @@ impl std::fmt::Debug for PaymentLinksResourceShippingAddressCollectionAllowedCou f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentLinksResourceShippingAddressCollectionAllowedCountries { fn serialize(&self, serializer: S) -> Result where @@ -760,13 +849,35 @@ impl serde::Serialize for PaymentLinksResourceShippingAddressCollectionAllowedCo serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentLinksResourceShippingAddressCollectionAllowedCountries { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentLinksResourceShippingAddressCollectionAllowedCountries::from_str(s) + .unwrap_or(PaymentLinksResourceShippingAddressCollectionAllowedCountries::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentLinksResourceShippingAddressCollectionAllowedCountries +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentLinksResourceShippingAddressCollectionAllowedCountries { fn deserialize>(deserializer: D) -> Result { 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)) } } 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..066eb8a9c 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,101 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct PaymentLinksResourceShippingOptionBuilder { + shipping_amount: Option, + shipping_rate: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceShippingOptionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { shipping_amount: Deserialize::default(), shipping_rate: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + shipping_amount: self.shipping_amount?, + shipping_rate: self.shipping_rate.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..a7ebe08c6 100644 --- a/generated/stripe_shared/src/payment_links_resource_subscription_data.rs +++ b/generated/stripe_shared/src/payment_links_resource_subscription_data.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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. @@ -11,3 +13,113 @@ pub struct PaymentLinksResourceSubscriptionData { /// Settings related to subscription trials. pub trial_settings: Option, } +#[doc(hidden)] +pub struct PaymentLinksResourceSubscriptionDataBuilder { + description: Option>, + invoice_settings: Option, + metadata: Option>, + trial_period_days: Option>, + trial_settings: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceSubscriptionDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "invoice_settings" => Deserialize::begin(&mut self.invoice_settings), + "metadata" => Deserialize::begin(&mut self.metadata), + "trial_period_days" => Deserialize::begin(&mut self.trial_period_days), + "trial_settings" => Deserialize::begin(&mut self.trial_settings), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + description: Deserialize::default(), + invoice_settings: Deserialize::default(), + metadata: Deserialize::default(), + trial_period_days: Deserialize::default(), + trial_settings: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + description: self.description.take()?, + invoice_settings: self.invoice_settings.take()?, + metadata: self.metadata.take()?, + trial_period_days: self.trial_period_days?, + trial_settings: self.trial_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 PaymentLinksResourceSubscriptionData { + type Builder = PaymentLinksResourceSubscriptionDataBuilder; + } + + impl FromValueOpt for PaymentLinksResourceSubscriptionData { + fn from_value(v: Value) -> Option { + 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)?), + "invoice_settings" => b.invoice_settings = 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)?), + "trial_settings" => b.trial_settings = 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 index 67c6c7750..aa4b5c56c 100644 --- 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 @@ -1,4 +1,93 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourceSubscriptionDataInvoiceSettings { pub issuer: stripe_shared::ConnectAccountReference, } +#[doc(hidden)] +pub struct PaymentLinksResourceSubscriptionDataInvoiceSettingsBuilder { + issuer: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentLinksResourceSubscriptionDataInvoiceSettings { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceSubscriptionDataInvoiceSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: PaymentLinksResourceSubscriptionDataInvoiceSettingsBuilder::deser_default( + ), + })) + } + } + + impl MapBuilder for PaymentLinksResourceSubscriptionDataInvoiceSettingsBuilder { + type Out = PaymentLinksResourceSubscriptionDataInvoiceSettings; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "issuer" => Deserialize::begin(&mut self.issuer), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { issuer: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { issuer: self.issuer.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentLinksResourceSubscriptionDataInvoiceSettings { + type Builder = PaymentLinksResourceSubscriptionDataInvoiceSettingsBuilder; + } + + impl FromValueOpt for PaymentLinksResourceSubscriptionDataInvoiceSettings { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentLinksResourceSubscriptionDataInvoiceSettingsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "issuer" => b.issuer = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; 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..242642c1f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentLinksResourceTaxIdCollection { /// Indicates whether tax ID collection is enabled for the session. pub enabled: bool, } +#[doc(hidden)] +pub struct PaymentLinksResourceTaxIdCollectionBuilder { + enabled: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceTaxIdCollectionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.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 { + 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..f2b6be555 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,92 @@ pub struct PaymentLinksResourceTransferData { /// The connected account receiving the transfer. pub destination: stripe_types::Expandable, } +#[doc(hidden)] +pub struct PaymentLinksResourceTransferDataBuilder { + amount: Option>, + destination: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentLinksResourceTransferDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), destination: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { amount: self.amount?, destination: self.destination.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..5cf18880e 100644 --- a/generated/stripe_shared/src/payment_method.rs +++ b/generated/stripe_shared/src/payment_method.rs @@ -5,99 +5,440 @@ /// 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethod { - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub affirm: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub afterpay_clearpay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub alipay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bancontact: Option, pub billing_details: stripe_shared::BillingDetails, - #[serde(skip_serializing_if = "Option::is_none")] pub blik: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub card_present: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cashapp: Option, /// 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>, - #[serde(skip_serializing_if = "Option::is_none")] pub customer_balance: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub fpx: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub giropay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub grabpay: Option, /// Unique identifier for the object. pub id: stripe_shared::PaymentMethodId, - #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub interac_present: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub konbini: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option, /// 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>, - #[serde(skip_serializing_if = "Option::is_none")] + /// String representing the object's type. Objects of the same type share the same value. + pub object: PaymentMethodObject, pub oxxo: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub paynow: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub paypal: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pix: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub promptpay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub radar_options: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub revolut_pay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub swish: Option, /// 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(feature = "serde", serde(rename = "type"))] pub type_: PaymentMethodType, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub wechat_pay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub zip: Option, } +#[doc(hidden)] +pub struct PaymentMethodBuilder { + acss_debit: Option>, + affirm: Option>, + afterpay_clearpay: Option>, + alipay: Option>, + au_becs_debit: Option>, + bacs_debit: Option>, + bancontact: Option>, + billing_details: Option, + blik: Option>, + boleto: Option>, + card: Option>, + card_present: Option>, + cashapp: Option>, + created: Option, + customer: Option>>, + customer_balance: Option>, + eps: Option>, + fpx: Option>, + giropay: Option>, + grabpay: Option>, + id: Option, + ideal: Option>, + interac_present: Option>, + klarna: Option>, + konbini: Option>, + link: Option>, + livemode: Option, + metadata: Option>>, + object: Option, + oxxo: Option>, + p24: Option>, + paynow: Option>, + paypal: Option>, + pix: Option>, + promptpay: Option>, + radar_options: Option>, + revolut_pay: Option>, + sepa_debit: Option>, + sofort: Option>, + swish: Option>, + type_: Option, + us_bank_account: Option>, + wechat_pay: Option>, + zip: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + "swish" => Deserialize::begin(&mut self.swish), + "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), + + _ => ::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(), + object: 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(), + swish: Deserialize::default(), + type_: Deserialize::default(), + us_bank_account: Deserialize::default(), + wechat_pay: Deserialize::default(), + zip: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + acss_debit: self.acss_debit.take()?, + affirm: self.affirm?, + afterpay_clearpay: self.afterpay_clearpay?, + alipay: self.alipay?, + au_becs_debit: self.au_becs_debit.take()?, + bacs_debit: self.bacs_debit.take()?, + bancontact: self.bancontact?, + billing_details: self.billing_details.take()?, + blik: self.blik?, + boleto: self.boleto.take()?, + card: self.card.take()?, + card_present: self.card_present.take()?, + cashapp: self.cashapp.take()?, + created: self.created?, + customer: self.customer.take()?, + customer_balance: self.customer_balance?, + eps: self.eps?, + fpx: self.fpx?, + giropay: self.giropay?, + grabpay: self.grabpay?, + id: self.id.take()?, + ideal: self.ideal?, + interac_present: self.interac_present.take()?, + klarna: self.klarna?, + konbini: self.konbini?, + link: self.link.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + oxxo: self.oxxo?, + p24: self.p24?, + paynow: self.paynow?, + paypal: self.paypal.take()?, + pix: self.pix?, + promptpay: self.promptpay?, + radar_options: self.radar_options.take()?, + revolut_pay: self.revolut_pay?, + sepa_debit: self.sepa_debit.take()?, + sofort: self.sofort.take()?, + swish: self.swish?, + type_: self.type_?, + us_bank_account: self.us_bank_account.take()?, + wechat_pay: self.wechat_pay?, + zip: self.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 { + 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)?), + "object" => b.object = 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)?), + "swish" => b.swish = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum PaymentMethodObject { + PaymentMethod, +} +impl PaymentMethodObject { + pub fn as_str(self) -> &'static str { + use PaymentMethodObject::*; + match self { + PaymentMethod => "payment_method", + } + } +} + +impl std::str::FromStr for PaymentMethodObject { + type Err = (); + fn from_str(s: &str) -> Result { + use PaymentMethodObject::*; + match s { + "payment_method" => Ok(PaymentMethod), + _ => Err(()), + } + } +} +impl std::fmt::Display for PaymentMethodObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for PaymentMethodObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for PaymentMethodObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for PaymentMethodObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for PaymentMethodObject { + fn deserialize>(deserializer: D) -> 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 PaymentMethodObject")) + } +} /// 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. @@ -241,6 +582,7 @@ impl std::fmt::Debug for PaymentMethodType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodType { fn serialize(&self, serializer: S) -> Result where @@ -249,11 +591,27 @@ impl serde::Serialize for PaymentMethodType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodType::from_str(s).unwrap_or(PaymentMethodType::Unknown)); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodType { fn deserialize>(deserializer: D) -> Result { 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)) } } impl stripe_types::Object for PaymentMethod { diff --git a/generated/stripe_shared/src/payment_method_acss_debit.rs b/generated/stripe_shared/src/payment_method_acss_debit.rs index cf687891c..63f069ffa 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodAcssDebit { /// Name of the bank associated with the bank account. pub bank_name: Option, @@ -12,3 +14,115 @@ pub struct PaymentMethodAcssDebit { /// Transit number of the bank account. pub transit_number: Option, } +#[doc(hidden)] +pub struct PaymentMethodAcssDebitBuilder { + bank_name: Option>, + fingerprint: Option>, + institution_number: Option>, + last4: Option>, + transit_number: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodAcssDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank_name: self.bank_name.take()?, + fingerprint: self.fingerprint.take()?, + institution_number: self.institution_number.take()?, + last4: self.last4.take()?, + transit_number: self.transit_number.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..12635823d 100644 --- a/generated/stripe_shared/src/payment_method_affirm.rs +++ b/generated/stripe_shared/src/payment_method_affirm.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodAffirm {} +#[doc(hidden)] +pub struct PaymentMethodAffirmBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodAffirmBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..436200545 100644 --- a/generated/stripe_shared/src/payment_method_afterpay_clearpay.rs +++ b/generated/stripe_shared/src/payment_method_afterpay_clearpay.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodAfterpayClearpay {} +#[doc(hidden)] +pub struct PaymentMethodAfterpayClearpayBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodAfterpayClearpayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..819b498fb 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodAuBecsDebit { /// Six-digit number identifying bank and branch associated with this bank account. pub bsb_number: Option, @@ -8,3 +10,103 @@ pub struct PaymentMethodAuBecsDebit { /// Last four digits of the bank account number. pub last4: Option, } +#[doc(hidden)] +pub struct PaymentMethodAuBecsDebitBuilder { + bsb_number: Option>, + fingerprint: Option>, + last4: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodAuBecsDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bsb_number: Deserialize::default(), + fingerprint: Deserialize::default(), + last4: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + bsb_number: self.bsb_number.take()?, + fingerprint: self.fingerprint.take()?, + last4: self.last4.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..698d1ce83 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,103 @@ pub struct PaymentMethodBacsDebit { /// Sort code of the bank account. (e.g., `10-20-30`) pub sort_code: Option, } +#[doc(hidden)] +pub struct PaymentMethodBacsDebitBuilder { + fingerprint: Option>, + last4: Option>, + sort_code: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodBacsDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + fingerprint: Deserialize::default(), + last4: Deserialize::default(), + sort_code: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + fingerprint: self.fingerprint.take()?, + last4: self.last4.take()?, + sort_code: self.sort_code.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..8e1e8b644 100644 --- a/generated/stripe_shared/src/payment_method_bancontact.rs +++ b/generated/stripe_shared/src/payment_method_bancontact.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodBancontact {} +#[doc(hidden)] +pub struct PaymentMethodBancontactBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodBancontactBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..69383b9e0 100644 --- a/generated/stripe_shared/src/payment_method_blik.rs +++ b/generated/stripe_shared/src/payment_method_blik.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodBlik {} +#[doc(hidden)] +pub struct PaymentMethodBlikBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodBlikBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..2994e1f91 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodBoleto { /// Uniquely identifies the customer tax id (CNPJ or CPF) pub tax_id: String, } +#[doc(hidden)] +pub struct PaymentMethodBoletoBuilder { + tax_id: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodBoletoBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { tax_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { tax_id: self.tax_id.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..329a6d63f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// 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, /// 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, /// 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, /// 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, /// The last four digits of the card. pub last4: String, @@ -42,3 +40,160 @@ pub struct PaymentMethodCard { /// If this Card is part of a card wallet, this contains the details of the card wallet. pub wallet: Option, } +#[doc(hidden)] +pub struct PaymentMethodCardBuilder { + brand: Option, + checks: Option>, + country: Option>, + description: Option>, + exp_month: Option, + exp_year: Option, + fingerprint: Option>, + funding: Option, + iin: Option>, + issuer: Option>, + last4: Option, + networks: Option>, + three_d_secure_usage: Option>, + wallet: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodCardBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + brand: self.brand.take()?, + checks: self.checks.take()?, + country: self.country.take()?, + description: self.description.take()?, + exp_month: self.exp_month?, + exp_year: self.exp_year?, + fingerprint: self.fingerprint.take()?, + funding: self.funding.take()?, + iin: self.iin.take()?, + issuer: self.issuer.take()?, + last4: self.last4.take()?, + networks: self.networks.take()?, + three_d_secure_usage: self.three_d_secure_usage?, + wallet: self.wallet.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..10a8d254b 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -7,3 +9,109 @@ pub struct PaymentMethodCardChecks { /// If a CVC was provided, results of the check, one of `pass`, `fail`, `unavailable`, or `unchecked`. pub cvc_check: Option, } +#[doc(hidden)] +pub struct PaymentMethodCardChecksBuilder { + address_line1_check: Option>, + address_postal_code_check: Option>, + cvc_check: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodCardChecksBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + address_line1_check: self.address_line1_check.take()?, + address_postal_code_check: self.address_postal_code_check.take()?, + cvc_check: self.cvc_check.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..2a91681a8 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// 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, /// Two-digit number representing the card's expiration month. pub exp_month: i64, @@ -29,11 +30,9 @@ pub struct PaymentMethodCardPresent { pub funding: Option, /// 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, /// 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, /// The last four digits of the card. pub last4: Option, @@ -42,6 +41,156 @@ pub struct PaymentMethodCardPresent { /// How card details were read in this transaction. pub read_method: Option, } +#[doc(hidden)] +pub struct PaymentMethodCardPresentBuilder { + brand: Option>, + cardholder_name: Option>, + country: Option>, + description: Option>, + exp_month: Option, + exp_year: Option, + fingerprint: Option>, + funding: Option>, + iin: Option>, + issuer: Option>, + last4: Option>, + networks: Option>, + read_method: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodCardPresentBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + brand: self.brand.take()?, + cardholder_name: self.cardholder_name.take()?, + country: self.country.take()?, + description: self.description.take()?, + exp_month: self.exp_month?, + exp_year: self.exp_year?, + fingerprint: self.fingerprint.take()?, + funding: self.funding.take()?, + iin: self.iin.take()?, + issuer: self.issuer.take()?, + last4: self.last4.take()?, + networks: self.networks.take()?, + read_method: self.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 { + 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 { @@ -89,6 +238,7 @@ impl std::fmt::Debug for PaymentMethodCardPresentReadMethod { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodCardPresentReadMethod { fn serialize(&self, serializer: S) -> Result where @@ -97,6 +247,23 @@ impl serde::Serialize for PaymentMethodCardPresentReadMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodCardPresentReadMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(PaymentMethodCardPresentReadMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodCardPresentReadMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodCardPresentReadMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..5d921f369 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,98 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodCardPresentNetworks { /// All available networks for the card. pub available: Vec, /// The preferred network for the card. pub preferred: Option, } +#[doc(hidden)] +pub struct PaymentMethodCardPresentNetworksBuilder { + available: Option>, + preferred: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodCardPresentNetworksBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { available: Deserialize::default(), preferred: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { available: self.available.take()?, preferred: self.preferred.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..d3d2b5e23 100644 --- a/generated/stripe_shared/src/payment_method_card_wallet.rs +++ b/generated/stripe_shared/src/payment_method_card_wallet.rs @@ -1,27 +1,155 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodCardWallet { - #[serde(skip_serializing_if = "Option::is_none")] pub amex_express_checkout: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub apple_pay: Option, /// (For tokenized numbers only.) The last four digits of the device account number. pub dynamic_last4: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub google_pay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub masterpass: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub samsung_pay: Option, /// 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(feature = "serde", serde(rename = "type"))] pub type_: PaymentMethodCardWalletType, - #[serde(skip_serializing_if = "Option::is_none")] pub visa_checkout: Option, } +#[doc(hidden)] +pub struct PaymentMethodCardWalletBuilder { + amex_express_checkout: + Option>, + apple_pay: Option>, + dynamic_last4: Option>, + google_pay: Option>, + link: Option>, + masterpass: Option>, + samsung_pay: Option>, + type_: Option, + visa_checkout: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodCardWalletBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amex_express_checkout: self.amex_express_checkout?, + apple_pay: self.apple_pay?, + dynamic_last4: self.dynamic_last4.take()?, + google_pay: self.google_pay?, + link: self.link?, + masterpass: self.masterpass.take()?, + samsung_pay: self.samsung_pay?, + type_: self.type_?, + visa_checkout: self.visa_checkout.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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. @@ -77,6 +205,7 @@ impl std::fmt::Debug for PaymentMethodCardWalletType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodCardWalletType { fn serialize(&self, serializer: S) -> Result where @@ -85,6 +214,22 @@ impl serde::Serialize for PaymentMethodCardWalletType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodCardWalletType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodCardWalletType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodCardWalletType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodCardWalletType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..947c12ed1 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodCardWalletAmexExpressCheckout {} +#[doc(hidden)] +pub struct PaymentMethodCardWalletAmexExpressCheckoutBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodCardWalletAmexExpressCheckoutBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..fa0445970 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodCardWalletApplePay {} +#[doc(hidden)] +pub struct PaymentMethodCardWalletApplePayBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodCardWalletApplePayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..e38addbf9 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodCardWalletGooglePay {} +#[doc(hidden)] +pub struct PaymentMethodCardWalletGooglePayBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodCardWalletGooglePayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..88e96bd2b 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodCardWalletLink {} +#[doc(hidden)] +pub struct PaymentMethodCardWalletLinkBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodCardWalletLinkBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..fea303fda 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,108 @@ pub struct PaymentMethodCardWalletMasterpass { /// They cannot be set or mutated. pub shipping_address: Option, } +#[doc(hidden)] +pub struct PaymentMethodCardWalletMasterpassBuilder { + billing_address: Option>, + email: Option>, + name: Option>, + shipping_address: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodCardWalletMasterpassBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + billing_address: self.billing_address.take()?, + email: self.email.take()?, + name: self.name.take()?, + shipping_address: self.shipping_address.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..482fa3863 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodCardWalletSamsungPay {} +#[doc(hidden)] +pub struct PaymentMethodCardWalletSamsungPayBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodCardWalletSamsungPayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..f147b1ceb 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,108 @@ pub struct PaymentMethodCardWalletVisaCheckout { /// They cannot be set or mutated. pub shipping_address: Option, } +#[doc(hidden)] +pub struct PaymentMethodCardWalletVisaCheckoutBuilder { + billing_address: Option>, + email: Option>, + name: Option>, + shipping_address: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodCardWalletVisaCheckoutBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + billing_address: self.billing_address.take()?, + email: self.email.take()?, + name: self.name.take()?, + shipping_address: self.shipping_address.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..af8b35a8d 100644 --- a/generated/stripe_shared/src/payment_method_cashapp.rs +++ b/generated/stripe_shared/src/payment_method_cashapp.rs @@ -1,7 +1,98 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodCashapp { /// A unique and immutable identifier assigned by Cash App to every buyer. pub buyer_id: Option, /// A public identifier for buyers using Cash App. pub cashtag: Option, } +#[doc(hidden)] +pub struct PaymentMethodCashappBuilder { + buyer_id: Option>, + cashtag: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodCashappBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { buyer_id: Deserialize::default(), cashtag: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { buyer_id: self.buyer_id.take()?, cashtag: self.cashtag.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..9361a5690 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,100 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodConfigBizPaymentMethodConfigurationDetails { /// ID of the payment method configuration used. pub id: String, /// ID of the parent payment method configuration used. pub parent: Option, } +#[doc(hidden)] +pub struct PaymentMethodConfigBizPaymentMethodConfigurationDetailsBuilder { + id: Option, + parent: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodConfigBizPaymentMethodConfigurationDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { id: Deserialize::default(), parent: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { id: self.id.take()?, parent: self.parent.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..323c1b4b9 100644 --- a/generated/stripe_shared/src/payment_method_customer_balance.rs +++ b/generated/stripe_shared/src/payment_method_customer_balance.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodCustomerBalance {} +#[doc(hidden)] +pub struct PaymentMethodCustomerBalanceBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodCustomerBalanceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..7ee8bc90f 100644 --- a/generated/stripe_shared/src/payment_method_details.rs +++ b/generated/stripe_shared/src/payment_method_details.rs @@ -1,90 +1,350 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetails { - #[serde(skip_serializing_if = "Option::is_none")] pub ach_credit_transfer: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub ach_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub affirm: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub afterpay_clearpay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub alipay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bancontact: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub blik: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub card_present: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cashapp: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub customer_balance: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub fpx: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub giropay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub grabpay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub interac_present: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub konbini: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub multibanco: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub oxxo: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub paynow: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub paypal: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pix: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub promptpay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub revolut_pay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_credit_transfer: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub stripe_account: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub swish: Option, /// 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(feature = "serde", serde(rename = "type"))] pub type_: String, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub wechat: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub wechat_pay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub zip: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsBuilder { + ach_credit_transfer: Option>, + ach_debit: Option>, + acss_debit: Option>, + affirm: Option>, + afterpay_clearpay: Option>, + alipay: Option>, + au_becs_debit: Option>, + bacs_debit: Option>, + bancontact: Option>, + blik: Option>, + boleto: Option>, + card: Option>, + card_present: Option>, + cashapp: Option>, + customer_balance: Option>, + eps: Option>, + fpx: Option>, + giropay: Option>, + grabpay: Option>, + ideal: Option>, + interac_present: Option>, + klarna: Option>, + konbini: Option>, + link: Option>, + multibanco: Option>, + oxxo: Option>, + p24: Option>, + paynow: Option>, + paypal: Option>, + pix: Option>, + promptpay: Option>, + revolut_pay: Option>, + sepa_credit_transfer: Option>, + sepa_debit: Option>, + sofort: Option>, + stripe_account: Option>, + swish: Option>, + type_: Option, + us_bank_account: Option>, + wechat: Option>, + wechat_pay: Option>, + zip: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "swish" => Deserialize::begin(&mut self.swish), + "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), + + _ => ::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(), + swish: 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 { + Some(Self::Out { + ach_credit_transfer: self.ach_credit_transfer.take()?, + ach_debit: self.ach_debit.take()?, + acss_debit: self.acss_debit.take()?, + affirm: self.affirm?, + afterpay_clearpay: self.afterpay_clearpay.take()?, + alipay: self.alipay.take()?, + au_becs_debit: self.au_becs_debit.take()?, + bacs_debit: self.bacs_debit.take()?, + bancontact: self.bancontact.take()?, + blik: self.blik?, + boleto: self.boleto.take()?, + card: self.card.take()?, + card_present: self.card_present.take()?, + cashapp: self.cashapp.take()?, + customer_balance: self.customer_balance?, + eps: self.eps.take()?, + fpx: self.fpx.take()?, + giropay: self.giropay.take()?, + grabpay: self.grabpay.take()?, + ideal: self.ideal.take()?, + interac_present: self.interac_present.take()?, + klarna: self.klarna.take()?, + konbini: self.konbini?, + link: self.link.take()?, + multibanco: self.multibanco.take()?, + oxxo: self.oxxo.take()?, + p24: self.p24.take()?, + paynow: self.paynow.take()?, + paypal: self.paypal.take()?, + pix: self.pix.take()?, + promptpay: self.promptpay.take()?, + revolut_pay: self.revolut_pay?, + sepa_credit_transfer: self.sepa_credit_transfer.take()?, + sepa_debit: self.sepa_debit.take()?, + sofort: self.sofort.take()?, + stripe_account: self.stripe_account?, + swish: self.swish.take()?, + type_: self.type_.take()?, + us_bank_account: self.us_bank_account.take()?, + wechat: self.wechat?, + wechat_pay: self.wechat_pay.take()?, + zip: self.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 { + 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)?), + "swish" => b.swish = 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..e792feb4d 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsAchCreditTransfer { /// Account number to transfer funds to. pub account_number: Option, @@ -9,3 +11,108 @@ pub struct PaymentMethodDetailsAchCreditTransfer { /// SWIFT code of the bank associated with the routing number. pub swift_code: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsAchCreditTransferBuilder { + account_number: Option>, + bank_name: Option>, + routing_number: Option>, + swift_code: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsAchCreditTransferBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + account_number: self.account_number.take()?, + bank_name: self.bank_name.take()?, + routing_number: self.routing_number.take()?, + swift_code: self.swift_code.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..cca8a604f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsAchDebit { /// Type of entity that holds the account. This can be either `individual` or `company`. pub account_holder_type: Option, @@ -14,6 +16,123 @@ pub struct PaymentMethodDetailsAchDebit { /// Routing transit number of the bank account. pub routing_number: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsAchDebitBuilder { + account_holder_type: Option>, + bank_name: Option>, + country: Option>, + fingerprint: Option>, + last4: Option>, + routing_number: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsAchDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + account_holder_type: self.account_holder_type?, + bank_name: self.bank_name.take()?, + country: self.country.take()?, + fingerprint: self.fingerprint.take()?, + last4: self.last4.take()?, + routing_number: self.routing_number.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -52,6 +171,7 @@ impl std::fmt::Debug for PaymentMethodDetailsAchDebitAccountHolderType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsAchDebitAccountHolderType { fn serialize(&self, serializer: S) -> Result where @@ -60,6 +180,25 @@ impl serde::Serialize for PaymentMethodDetailsAchDebitAccountHolderType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsAchDebitAccountHolderType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodDetailsAchDebitAccountHolderType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsAchDebitAccountHolderType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsAchDebitAccountHolderType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..4ce848556 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsAcssDebit { /// Name of the bank associated with the bank account. pub bank_name: Option, @@ -10,8 +12,124 @@ pub struct PaymentMethodDetailsAcssDebit { /// Last four digits of the bank account number. pub last4: Option, /// ID of the mandate used to make this payment. - #[serde(skip_serializing_if = "Option::is_none")] pub mandate: Option, /// Transit number of the bank account. pub transit_number: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsAcssDebitBuilder { + bank_name: Option>, + fingerprint: Option>, + institution_number: Option>, + last4: Option>, + mandate: Option>, + transit_number: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsAcssDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank_name: self.bank_name.take()?, + fingerprint: self.fingerprint.take()?, + institution_number: self.institution_number.take()?, + last4: self.last4.take()?, + mandate: self.mandate.take()?, + transit_number: self.transit_number.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..144ad66c8 100644 --- a/generated/stripe_shared/src/payment_method_details_affirm.rs +++ b/generated/stripe_shared/src/payment_method_details_affirm.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsAffirm {} +#[doc(hidden)] +pub struct PaymentMethodDetailsAffirmBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsAffirmBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..476f2adf3 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,98 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsAfterpayClearpay { /// The Afterpay order ID associated with this payment intent. pub order_id: Option, /// Order identifier shown to the merchant in Afterpay’s online portal. pub reference: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsAfterpayClearpayBuilder { + order_id: Option>, + reference: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsAfterpayClearpayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { order_id: Deserialize::default(), reference: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { order_id: self.order_id.take()?, reference: self.reference.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..509c28cd4 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsAuBecsDebit { /// Bank-State-Branch number of the bank account. pub bsb_number: Option, @@ -8,6 +10,110 @@ pub struct PaymentMethodDetailsAuBecsDebit { /// Last four digits of the bank account number. pub last4: Option, /// ID of the mandate used to make this payment. - #[serde(skip_serializing_if = "Option::is_none")] pub mandate: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsAuBecsDebitBuilder { + bsb_number: Option>, + fingerprint: Option>, + last4: Option>, + mandate: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsAuBecsDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bsb_number: self.bsb_number.take()?, + fingerprint: self.fingerprint.take()?, + last4: self.last4.take()?, + mandate: self.mandate.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..ac622feaf 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,108 @@ pub struct PaymentMethodDetailsBacsDebit { /// Sort code of the bank account. (e.g., `10-20-30`) pub sort_code: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsBacsDebitBuilder { + fingerprint: Option>, + last4: Option>, + mandate: Option>, + sort_code: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsBacsDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + fingerprint: self.fingerprint.take()?, + last4: self.last4.take()?, + mandate: self.mandate.take()?, + sort_code: self.sort_code.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..85277fb51 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsBancontact { /// Bank code of bank associated with the bank account. pub bank_code: Option, @@ -19,6 +21,139 @@ pub struct PaymentMethodDetailsBancontact { /// (if supported) at the time of authorization or settlement. They cannot be set or mutated. pub verified_name: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsBancontactBuilder { + bank_code: Option>, + bank_name: Option>, + bic: Option>, + generated_sepa_debit: Option>>, + generated_sepa_debit_mandate: Option>>, + iban_last4: Option>, + preferred_language: Option>, + verified_name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsBancontactBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank_code: self.bank_code.take()?, + bank_name: self.bank_name.take()?, + bic: self.bic.take()?, + generated_sepa_debit: self.generated_sepa_debit.take()?, + generated_sepa_debit_mandate: self.generated_sepa_debit_mandate.take()?, + iban_last4: self.iban_last4.take()?, + preferred_language: self.preferred_language?, + verified_name: self.verified_name.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)] @@ -64,6 +199,7 @@ impl std::fmt::Debug for PaymentMethodDetailsBancontactPreferredLanguage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsBancontactPreferredLanguage { fn serialize(&self, serializer: S) -> Result where @@ -72,6 +208,25 @@ impl serde::Serialize for PaymentMethodDetailsBancontactPreferredLanguage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsBancontactPreferredLanguage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodDetailsBancontactPreferredLanguage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsBancontactPreferredLanguage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsBancontactPreferredLanguage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_details_blik.rs b/generated/stripe_shared/src/payment_method_details_blik.rs index d19223ff9..4447a1525 100644 --- a/generated/stripe_shared/src/payment_method_details_blik.rs +++ b/generated/stripe_shared/src/payment_method_details_blik.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsBlik {} +#[doc(hidden)] +pub struct PaymentMethodDetailsBlikBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsBlikBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..aa17f8b69 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsBoleto { /// The tax ID of the customer (CPF for individuals consumers or CNPJ for businesses consumers) pub tax_id: String, } +#[doc(hidden)] +pub struct PaymentMethodDetailsBoletoBuilder { + tax_id: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsBoletoBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { tax_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { tax_id: self.tax_id.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..ed6df5274 100644 --- a/generated/stripe_shared/src/payment_method_details_card.rs +++ b/generated/stripe_shared/src/payment_method_details_card.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsCard { /// The authorized amount. pub amount_authorized: Option, @@ -6,7 +8,6 @@ pub amount_authorized: Option, /// Can be `amex`, `diners`, `discover`, `eftpos_au`, `jcb`, `mastercard`, `unionpay`, `visa`, or `unknown`. pub brand: Option, /// 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, /// Check results by Card networks on Card address and CVC at time of payment. pub checks: Option, @@ -15,28 +16,23 @@ pub checks: Option, pub country: Option, /// 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, /// Two-digit number representing the card's expiration month. 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, /// 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, /// Card funding type. Can be `credit`, `debit`, `prepaid`, or `unknown`. pub funding: Option, /// 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, -#[serde(skip_serializing_if = "Option::is_none")] pub incremental_authorization: Option, /// Installment details for this payment (Mexico only). /// @@ -44,24 +40,19 @@ pub incremental_authorization: Option, /// 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, /// The last four digits of the card. pub last4: Option, /// ID of the mandate used to make this payment or created by it. pub mandate: Option, /// True if this payment was marked as MOTO and out of scope for SCA. -#[serde(skip_serializing_if = "Option::is_none")] pub moto: Option, -#[serde(skip_serializing_if = "Option::is_none")] pub multicapture: Option, /// 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, /// 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, -#[serde(skip_serializing_if = "Option::is_none")] pub overcapture: Option, /// Populated if this transaction used 3D Secure authentication. pub three_d_secure: Option, @@ -69,3 +60,215 @@ pub three_d_secure: Option, pub wallet: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsCardBuilder { + amount_authorized: Option>, +brand: Option>, +capture_before: Option>, +checks: Option>, +country: Option>, +description: Option>, +exp_month: Option, +exp_year: Option, +extended_authorization: Option>, +fingerprint: Option>, +funding: Option>, +iin: Option>, +incremental_authorization: Option>, +installments: Option>, +issuer: Option>, +last4: Option>, +mandate: Option>, +moto: Option>, +multicapture: Option>, +network: Option>, +network_token: Option>, +overcapture: Option>, +three_d_secure: Option>, +wallet: Option>, + +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsCardBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount_authorized: self.amount_authorized?, + brand: self.brand.take()?, + capture_before: self.capture_before?, + checks: self.checks.take()?, + country: self.country.take()?, + description: self.description.take()?, + exp_month: self.exp_month?, + exp_year: self.exp_year?, + extended_authorization: self.extended_authorization?, + fingerprint: self.fingerprint.take()?, + funding: self.funding.take()?, + iin: self.iin.take()?, + incremental_authorization: self.incremental_authorization?, + installments: self.installments?, + issuer: self.issuer.take()?, + last4: self.last4.take()?, + mandate: self.mandate.take()?, + moto: self.moto?, + multicapture: self.multicapture?, + network: self.network.take()?, + network_token: self.network_token?, + overcapture: self.overcapture?, + three_d_secure: self.three_d_secure.take()?, + wallet: self.wallet.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..0083300c8 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -7,3 +9,109 @@ pub struct PaymentMethodDetailsCardChecks { /// If a CVC was provided, results of the check, one of `pass`, `fail`, `unavailable`, or `unchecked`. pub cvc_check: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsCardChecksBuilder { + address_line1_check: Option>, + address_postal_code_check: Option>, + cvc_check: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsCardChecksBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + address_line1_check: self.address_line1_check.take()?, + address_postal_code_check: self.address_postal_code_check.take()?, + cvc_check: self.cvc_check.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..55eb00a42 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsCardInstallments { /// Installment plan selected for the payment. pub plan: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsCardInstallmentsBuilder { + plan: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsCardInstallmentsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { plan: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { plan: self.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 { + 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..0db1d59b0 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -6,9 +8,105 @@ pub struct PaymentMethodDetailsCardInstallmentsPlan { /// One of `month`. pub interval: Option, /// Type of installment plan, one of `fixed_count`. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: PaymentMethodDetailsCardInstallmentsPlanType, } +#[doc(hidden)] +pub struct PaymentMethodDetailsCardInstallmentsPlanBuilder { + count: Option>, + interval: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsCardInstallmentsPlanBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + count: Deserialize::default(), + interval: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { count: self.count?, interval: self.interval?, type_: self.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 { + 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)] @@ -45,6 +143,7 @@ impl std::fmt::Debug for PaymentMethodDetailsCardInstallmentsPlanInterval { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsCardInstallmentsPlanInterval { fn serialize(&self, serializer: S) -> Result where @@ -53,6 +152,25 @@ impl serde::Serialize for PaymentMethodDetailsCardInstallmentsPlanInterval { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsCardInstallmentsPlanInterval { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodDetailsCardInstallmentsPlanInterval::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsCardInstallmentsPlanInterval); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsCardInstallmentsPlanInterval { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -99,6 +217,7 @@ impl std::fmt::Debug for PaymentMethodDetailsCardInstallmentsPlanType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsCardInstallmentsPlanType { fn serialize(&self, serializer: S) -> Result where @@ -107,6 +226,25 @@ impl serde::Serialize for PaymentMethodDetailsCardInstallmentsPlanType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsCardInstallmentsPlanType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodDetailsCardInstallmentsPlanType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsCardInstallmentsPlanType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsCardInstallmentsPlanType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..08a8b81be 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsCardNetworkToken { /// Indicates if Stripe used a network token, either user provided or Stripe managed when processing the transaction. pub used: bool, } +#[doc(hidden)] +pub struct PaymentMethodDetailsCardNetworkTokenBuilder { + used: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsCardNetworkTokenBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { used: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { used: self.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 { + 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..c7db75e1a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsCardPresent { /// The authorized amount pub amount_authorized: Option, @@ -6,7 +8,6 @@ pub struct PaymentMethodDetailsCardPresent { /// Can be `amex`, `diners`, `discover`, `eftpos_au`, `jcb`, `mastercard`, `unionpay`, `visa`, or `unknown`. pub brand: Option, /// 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, /// 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, /// 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, /// Authorization response cryptogram. pub emv_auth_data: Option, @@ -39,14 +39,12 @@ pub struct PaymentMethodDetailsCardPresent { pub generated_card: Option, /// 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, /// 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, /// The last four digits of the card. pub last4: Option, @@ -62,6 +60,202 @@ pub struct PaymentMethodDetailsCardPresent { /// A collection of fields required to be displayed on receipts. Only required for EMV transactions. pub receipt: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsCardPresentBuilder { + amount_authorized: Option>, + brand: Option>, + capture_before: Option>, + cardholder_name: Option>, + country: Option>, + description: Option>, + emv_auth_data: Option>, + exp_month: Option, + exp_year: Option, + fingerprint: Option>, + funding: Option>, + generated_card: Option>, + iin: Option>, + incremental_authorization_supported: Option, + issuer: Option>, + last4: Option>, + network: Option>, + offline: Option>, + overcapture_supported: Option, + read_method: Option>, + receipt: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsCardPresentBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount_authorized: self.amount_authorized?, + brand: self.brand.take()?, + capture_before: self.capture_before?, + cardholder_name: self.cardholder_name.take()?, + country: self.country.take()?, + description: self.description.take()?, + emv_auth_data: self.emv_auth_data.take()?, + exp_month: self.exp_month?, + exp_year: self.exp_year?, + fingerprint: self.fingerprint.take()?, + funding: self.funding.take()?, + generated_card: self.generated_card.take()?, + iin: self.iin.take()?, + incremental_authorization_supported: self.incremental_authorization_supported?, + issuer: self.issuer.take()?, + last4: self.last4.take()?, + network: self.network.take()?, + offline: self.offline?, + overcapture_supported: self.overcapture_supported?, + read_method: self.read_method?, + receipt: self.receipt.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -109,6 +303,7 @@ impl std::fmt::Debug for PaymentMethodDetailsCardPresentReadMethod { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsCardPresentReadMethod { fn serialize(&self, serializer: S) -> Result where @@ -117,6 +312,24 @@ impl serde::Serialize for PaymentMethodDetailsCardPresentReadMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsCardPresentReadMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodDetailsCardPresentReadMethod::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsCardPresentReadMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsCardPresentReadMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..082452d09 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsCardPresentOffline { /// Time at which the payment was collected while offline pub stored_at: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsCardPresentOfflineBuilder { + stored_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsCardPresentOfflineBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { stored_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { stored_at: self.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 { + 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..54697a1c4 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsCardPresentReceipt { /// The type of account being debited or credited - #[serde(skip_serializing_if = "Option::is_none")] pub account_type: Option, /// EMV tag 9F26, cryptogram generated by the integrated circuit chip. pub application_cryptogram: Option, @@ -20,6 +21,162 @@ pub struct PaymentMethodDetailsCardPresentReceipt { /// An indication of various EMV functions performed during the transaction. pub transaction_status_information: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsCardPresentReceiptBuilder { + account_type: Option>, + application_cryptogram: Option>, + application_preferred_name: Option>, + authorization_code: Option>, + authorization_response_code: Option>, + cardholder_verification_method: Option>, + dedicated_file_name: Option>, + terminal_verification_results: Option>, + transaction_status_information: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsCardPresentReceiptBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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) + } + + _ => ::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 { + Some(Self::Out { + account_type: self.account_type?, + application_cryptogram: self.application_cryptogram.take()?, + application_preferred_name: self.application_preferred_name.take()?, + authorization_code: self.authorization_code.take()?, + authorization_response_code: self.authorization_response_code.take()?, + cardholder_verification_method: self.cardholder_verification_method.take()?, + dedicated_file_name: self.dedicated_file_name.take()?, + terminal_verification_results: self.terminal_verification_results.take()?, + transaction_status_information: self.transaction_status_information.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -64,6 +221,7 @@ impl std::fmt::Debug for PaymentMethodDetailsCardPresentReceiptAccountType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsCardPresentReceiptAccountType { fn serialize(&self, serializer: S) -> Result where @@ -72,6 +230,25 @@ impl serde::Serialize for PaymentMethodDetailsCardPresentReceiptAccountType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsCardPresentReceiptAccountType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodDetailsCardPresentReceiptAccountType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsCardPresentReceiptAccountType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsCardPresentReceiptAccountType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..ef6fceb0a 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,156 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsCardWallet { - #[serde(skip_serializing_if = "Option::is_none")] pub amex_express_checkout: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub apple_pay: Option, /// (For tokenized numbers only.) The last four digits of the device account number. pub dynamic_last4: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub google_pay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub masterpass: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub samsung_pay: Option, /// 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(feature = "serde", serde(rename = "type"))] pub type_: PaymentMethodDetailsCardWalletType, - #[serde(skip_serializing_if = "Option::is_none")] pub visa_checkout: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsCardWalletBuilder { + amex_express_checkout: + Option>, + apple_pay: Option>, + dynamic_last4: Option>, + google_pay: Option>, + link: Option>, + masterpass: Option>, + samsung_pay: Option>, + type_: Option, + visa_checkout: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsCardWalletBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amex_express_checkout: self.amex_express_checkout?, + apple_pay: self.apple_pay?, + dynamic_last4: self.dynamic_last4.take()?, + google_pay: self.google_pay?, + link: self.link?, + masterpass: self.masterpass.take()?, + samsung_pay: self.samsung_pay?, + type_: self.type_?, + visa_checkout: self.visa_checkout.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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. @@ -78,6 +206,7 @@ impl std::fmt::Debug for PaymentMethodDetailsCardWalletType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsCardWalletType { fn serialize(&self, serializer: S) -> Result where @@ -86,6 +215,23 @@ impl serde::Serialize for PaymentMethodDetailsCardWalletType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsCardWalletType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(PaymentMethodDetailsCardWalletType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsCardWalletType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsCardWalletType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..18343e5d6 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsCardWalletAmexExpressCheckout {} +#[doc(hidden)] +pub struct PaymentMethodDetailsCardWalletAmexExpressCheckoutBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsCardWalletAmexExpressCheckoutBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..2c7c0664a 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsCardWalletApplePay {} +#[doc(hidden)] +pub struct PaymentMethodDetailsCardWalletApplePayBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsCardWalletApplePayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..85dbaccec 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsCardWalletGooglePay {} +#[doc(hidden)] +pub struct PaymentMethodDetailsCardWalletGooglePayBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsCardWalletGooglePayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..8f4105e6c 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsCardWalletLink {} +#[doc(hidden)] +pub struct PaymentMethodDetailsCardWalletLinkBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsCardWalletLinkBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..e95d2ff0a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,108 @@ pub struct PaymentMethodDetailsCardWalletMasterpass { /// They cannot be set or mutated. pub shipping_address: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsCardWalletMasterpassBuilder { + billing_address: Option>, + email: Option>, + name: Option>, + shipping_address: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsCardWalletMasterpassBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + billing_address: self.billing_address.take()?, + email: self.email.take()?, + name: self.name.take()?, + shipping_address: self.shipping_address.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..29311ca26 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsCardWalletSamsungPay {} +#[doc(hidden)] +pub struct PaymentMethodDetailsCardWalletSamsungPayBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsCardWalletSamsungPayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..3ea837a63 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,108 @@ pub struct PaymentMethodDetailsCardWalletVisaCheckout { /// They cannot be set or mutated. pub shipping_address: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsCardWalletVisaCheckoutBuilder { + billing_address: Option>, + email: Option>, + name: Option>, + shipping_address: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsCardWalletVisaCheckoutBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + billing_address: self.billing_address.take()?, + email: self.email.take()?, + name: self.name.take()?, + shipping_address: self.shipping_address.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..7621d59c3 100644 --- a/generated/stripe_shared/src/payment_method_details_cashapp.rs +++ b/generated/stripe_shared/src/payment_method_details_cashapp.rs @@ -1,7 +1,98 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsCashapp { /// A unique and immutable identifier assigned by Cash App to every buyer. pub buyer_id: Option, /// A public identifier for buyers using Cash App. pub cashtag: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsCashappBuilder { + buyer_id: Option>, + cashtag: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsCashappBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { buyer_id: Deserialize::default(), cashtag: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { buyer_id: self.buyer_id.take()?, cashtag: self.cashtag.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..263b05760 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsCustomerBalance {} +#[doc(hidden)] +pub struct PaymentMethodDetailsCustomerBalanceBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsCustomerBalanceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..f50449c22 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,95 @@ pub struct PaymentMethodDetailsEps { /// EPS rarely provides this information so the attribute is usually empty. pub verified_name: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsEpsBuilder { + bank: Option>, + verified_name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsEpsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank: Deserialize::default(), verified_name: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { bank: self.bank?, verified_name: self.verified_name.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)] @@ -129,6 +220,7 @@ impl std::fmt::Debug for PaymentMethodDetailsEpsBank { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsEpsBank { fn serialize(&self, serializer: S) -> Result where @@ -137,10 +229,29 @@ impl serde::Serialize for PaymentMethodDetailsEpsBank { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsEpsBank { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodDetailsEpsBank::from_str(s) + .unwrap_or(PaymentMethodDetailsEpsBank::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsEpsBank); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsEpsBank { fn deserialize>(deserializer: D) -> Result { 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)) } } diff --git a/generated/stripe_shared/src/payment_method_details_fpx.rs b/generated/stripe_shared/src/payment_method_details_fpx.rs index 1fd4679be..88dfbe579 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsFpx { /// Account holder type, if provided. Can be one of `individual` or `company`. pub account_holder_type: Option, @@ -8,6 +10,108 @@ pub struct PaymentMethodDetailsFpx { /// Unique transaction id generated by FPX for every request from the merchant pub transaction_id: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsFpxBuilder { + account_holder_type: Option>, + bank: Option, + transaction_id: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsFpxBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account_holder_type: Deserialize::default(), + bank: Deserialize::default(), + transaction_id: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account_holder_type: self.account_holder_type?, + bank: self.bank?, + transaction_id: self.transaction_id.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -46,6 +150,7 @@ impl std::fmt::Debug for PaymentMethodDetailsFpxAccountHolderType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsFpxAccountHolderType { fn serialize(&self, serializer: S) -> Result where @@ -54,6 +159,24 @@ impl serde::Serialize for PaymentMethodDetailsFpxAccountHolderType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsFpxAccountHolderType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodDetailsFpxAccountHolderType::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsFpxAccountHolderType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsFpxAccountHolderType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -166,6 +289,7 @@ impl std::fmt::Debug for PaymentMethodDetailsFpxBank { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsFpxBank { fn serialize(&self, serializer: S) -> Result where @@ -174,10 +298,29 @@ impl serde::Serialize for PaymentMethodDetailsFpxBank { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsFpxBank { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodDetailsFpxBank::from_str(s) + .unwrap_or(PaymentMethodDetailsFpxBank::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsFpxBank); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsFpxBank { fn deserialize>(deserializer: D) -> Result { 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)) } } diff --git a/generated/stripe_shared/src/payment_method_details_giropay.rs b/generated/stripe_shared/src/payment_method_details_giropay.rs index 0c8a75eb6..b831db7f2 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsGiropay { /// Bank code of bank associated with the bank account. pub bank_code: Option, @@ -11,3 +13,108 @@ pub struct PaymentMethodDetailsGiropay { /// Giropay rarely provides this information so the attribute is usually empty. pub verified_name: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsGiropayBuilder { + bank_code: Option>, + bank_name: Option>, + bic: Option>, + verified_name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsGiropayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank_code: self.bank_code.take()?, + bank_name: self.bank_name.take()?, + bic: self.bic.take()?, + verified_name: self.verified_name.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..a337f752f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsGrabpay { /// Unique transaction id generated by GrabPay pub transaction_id: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsGrabpayBuilder { + transaction_id: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsGrabpayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { transaction_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { transaction_id: self.transaction_id.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..161bf2f83 100644 --- a/generated/stripe_shared/src/payment_method_details_ideal.rs +++ b/generated/stripe_shared/src/payment_method_details_ideal.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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`. @@ -15,6 +17,127 @@ pub struct PaymentMethodDetailsIdeal { /// (if supported) at the time of authorization or settlement. They cannot be set or mutated. pub verified_name: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsIdealBuilder { + bank: Option>, + bic: Option>, + generated_sepa_debit: Option>>, + generated_sepa_debit_mandate: Option>>, + iban_last4: Option>, + verified_name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsIdealBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank: self.bank?, + bic: self.bic?, + generated_sepa_debit: self.generated_sepa_debit.take()?, + generated_sepa_debit_mandate: self.generated_sepa_debit_mandate.take()?, + iban_last4: self.iban_last4.take()?, + verified_name: self.verified_name.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -100,6 +223,7 @@ impl std::fmt::Debug for PaymentMethodDetailsIdealBank { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsIdealBank { fn serialize(&self, serializer: S) -> Result where @@ -108,11 +232,30 @@ impl serde::Serialize for PaymentMethodDetailsIdealBank { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsIdealBank { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodDetailsIdealBank::from_str(s) + .unwrap_or(PaymentMethodDetailsIdealBank::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsIdealBank); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsIdealBank { fn deserialize>(deserializer: D) -> Result { 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)) } } /// The Bank Identifier Code of the customer's bank. @@ -202,6 +345,7 @@ impl std::fmt::Debug for PaymentMethodDetailsIdealBic { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsIdealBic { fn serialize(&self, serializer: S) -> Result where @@ -210,10 +354,29 @@ impl serde::Serialize for PaymentMethodDetailsIdealBic { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsIdealBic { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodDetailsIdealBic::from_str(s) + .unwrap_or(PaymentMethodDetailsIdealBic::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsIdealBic); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsIdealBic { fn deserialize>(deserializer: D) -> Result { 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)) } } 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..1cd221b21 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsInteracPresent { /// Card brand. Can be `interac`, `mastercard` or `visa`. pub brand: Option, @@ -12,7 +14,6 @@ pub struct PaymentMethodDetailsInteracPresent { pub country: Option, /// 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, /// Authorization response cryptogram. pub emv_auth_data: Option, @@ -33,11 +34,9 @@ pub struct PaymentMethodDetailsInteracPresent { pub generated_card: Option, /// 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, /// 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, /// The last four digits of the card. pub last4: Option, @@ -51,6 +50,176 @@ pub struct PaymentMethodDetailsInteracPresent { /// A collection of fields required to be displayed on receipts. Only required for EMV transactions. pub receipt: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsInteracPresentBuilder { + brand: Option>, + cardholder_name: Option>, + country: Option>, + description: Option>, + emv_auth_data: Option>, + exp_month: Option, + exp_year: Option, + fingerprint: Option>, + funding: Option>, + generated_card: Option>, + iin: Option>, + issuer: Option>, + last4: Option>, + network: Option>, + preferred_locales: Option>>, + read_method: Option>, + receipt: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsInteracPresentBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + brand: self.brand.take()?, + cardholder_name: self.cardholder_name.take()?, + country: self.country.take()?, + description: self.description.take()?, + emv_auth_data: self.emv_auth_data.take()?, + exp_month: self.exp_month?, + exp_year: self.exp_year?, + fingerprint: self.fingerprint.take()?, + funding: self.funding.take()?, + generated_card: self.generated_card.take()?, + iin: self.iin.take()?, + issuer: self.issuer.take()?, + last4: self.last4.take()?, + network: self.network.take()?, + preferred_locales: self.preferred_locales.take()?, + read_method: self.read_method?, + receipt: self.receipt.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -98,6 +267,7 @@ impl std::fmt::Debug for PaymentMethodDetailsInteracPresentReadMethod { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsInteracPresentReadMethod { fn serialize(&self, serializer: S) -> Result where @@ -106,6 +276,25 @@ impl serde::Serialize for PaymentMethodDetailsInteracPresentReadMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsInteracPresentReadMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodDetailsInteracPresentReadMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsInteracPresentReadMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsInteracPresentReadMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..79d4298f4 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsInteracPresentReceipt { /// The type of account being debited or credited - #[serde(skip_serializing_if = "Option::is_none")] pub account_type: Option, /// EMV tag 9F26, cryptogram generated by the integrated circuit chip. pub application_cryptogram: Option, @@ -20,6 +21,162 @@ pub struct PaymentMethodDetailsInteracPresentReceipt { /// An indication of various EMV functions performed during the transaction. pub transaction_status_information: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsInteracPresentReceiptBuilder { + account_type: Option>, + application_cryptogram: Option>, + application_preferred_name: Option>, + authorization_code: Option>, + authorization_response_code: Option>, + cardholder_verification_method: Option>, + dedicated_file_name: Option>, + terminal_verification_results: Option>, + transaction_status_information: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsInteracPresentReceiptBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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) + } + + _ => ::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 { + Some(Self::Out { + account_type: self.account_type?, + application_cryptogram: self.application_cryptogram.take()?, + application_preferred_name: self.application_preferred_name.take()?, + authorization_code: self.authorization_code.take()?, + authorization_response_code: self.authorization_response_code.take()?, + cardholder_verification_method: self.cardholder_verification_method.take()?, + dedicated_file_name: self.dedicated_file_name.take()?, + terminal_verification_results: self.terminal_verification_results.take()?, + transaction_status_information: self.transaction_status_information.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -61,6 +218,7 @@ impl std::fmt::Debug for PaymentMethodDetailsInteracPresentReceiptAccountType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsInteracPresentReceiptAccountType { fn serialize(&self, serializer: S) -> Result where @@ -69,6 +227,25 @@ impl serde::Serialize for PaymentMethodDetailsInteracPresentReceiptAccountType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsInteracPresentReceiptAccountType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodDetailsInteracPresentReceiptAccountType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsInteracPresentReceiptAccountType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsInteracPresentReceiptAccountType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_details_klarna.rs b/generated/stripe_shared/src/payment_method_details_klarna.rs index 47d911fbe..13c7a2ff5 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,100 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodDetailsKlarnaBuilder { + payment_method_category: Option>, + preferred_locale: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsKlarnaBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + payment_method_category: Deserialize::default(), + preferred_locale: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + payment_method_category: self.payment_method_category.take()?, + preferred_locale: self.preferred_locale.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..505699df5 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsKonbini { /// If the payment succeeded, this contains the details of the convenience store where the payment was completed. pub store: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsKonbiniBuilder { + store: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsKonbiniBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { store: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { store: self.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 { + 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..d9eca77a2 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsKonbiniStore { /// The name of the convenience store chain where the payment was completed. pub chain: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsKonbiniStoreBuilder { + chain: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsKonbiniStoreBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { chain: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { chain: self.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 { + 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 { @@ -47,6 +135,7 @@ impl std::fmt::Debug for PaymentMethodDetailsKonbiniStoreChain { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsKonbiniStoreChain { fn serialize(&self, serializer: S) -> Result where @@ -55,6 +144,23 @@ impl serde::Serialize for PaymentMethodDetailsKonbiniStoreChain { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsKonbiniStoreChain { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(PaymentMethodDetailsKonbiniStoreChain::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsKonbiniStoreChain); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsKonbiniStoreChain { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_details_link.rs b/generated/stripe_shared/src/payment_method_details_link.rs index 987e76d1d..21ec02c43 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct PaymentMethodDetailsLinkBuilder { + country: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsLinkBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { country: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { country: self.country.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..d5a9e82b5 100644 --- a/generated/stripe_shared/src/payment_method_details_multibanco.rs +++ b/generated/stripe_shared/src/payment_method_details_multibanco.rs @@ -1,7 +1,98 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsMultibanco { /// Entity number associated with this Multibanco payment. pub entity: Option, /// Reference number associated with this Multibanco payment. pub reference: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsMultibancoBuilder { + entity: Option>, + reference: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsMultibancoBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { entity: Deserialize::default(), reference: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { entity: self.entity.take()?, reference: self.reference.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..187cf217c 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsOxxo { /// OXXO reference number pub number: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsOxxoBuilder { + number: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsOxxoBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { number: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { number: self.number.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..08439339e 100644 --- a/generated/stripe_shared/src/payment_method_details_p24.rs +++ b/generated/stripe_shared/src/payment_method_details_p24.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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`. @@ -10,6 +12,106 @@ pub struct PaymentMethodDetailsP24 { /// Przelewy24 rarely provides this information so the attribute is usually empty. pub verified_name: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsP24Builder { + bank: Option>, + reference: Option>, + verified_name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsP24Builder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank: Deserialize::default(), + reference: Deserialize::default(), + verified_name: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + bank: self.bank?, + reference: self.reference.take()?, + verified_name: self.verified_name.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -125,6 +227,7 @@ impl std::fmt::Debug for PaymentMethodDetailsP24Bank { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsP24Bank { fn serialize(&self, serializer: S) -> Result where @@ -133,10 +236,29 @@ impl serde::Serialize for PaymentMethodDetailsP24Bank { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsP24Bank { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodDetailsP24Bank::from_str(s) + .unwrap_or(PaymentMethodDetailsP24Bank::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsP24Bank); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsP24Bank { fn deserialize>(deserializer: D) -> Result { 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)) } } diff --git a/generated/stripe_shared/src/payment_method_details_paynow.rs b/generated/stripe_shared/src/payment_method_details_paynow.rs index 7dbf13243..41900863e 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsPaynow { /// Reference number associated with this PayNow payment pub reference: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsPaynowBuilder { + reference: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsPaynowBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { reference: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { reference: self.reference.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..c000fc3ee 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,113 @@ pub struct PaymentMethodDetailsPaypal { /// A unique ID generated by PayPal for this transaction. pub transaction_id: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsPaypalBuilder { + payer_email: Option>, + payer_id: Option>, + payer_name: Option>, + seller_protection: Option>, + transaction_id: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsPaypalBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + payer_email: self.payer_email.take()?, + payer_id: self.payer_id.take()?, + payer_name: self.payer_name.take()?, + seller_protection: self.seller_protection.take()?, + transaction_id: self.transaction_id.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..464526184 100644 --- a/generated/stripe_shared/src/payment_method_details_pix.rs +++ b/generated/stripe_shared/src/payment_method_details_pix.rs @@ -1,6 +1,95 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsPix { /// Unique transaction id generated by BCB - #[serde(skip_serializing_if = "Option::is_none")] pub bank_transaction_id: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsPixBuilder { + bank_transaction_id: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsPixBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank_transaction_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { bank_transaction_id: self.bank_transaction_id.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..26c849d81 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsPromptpay { /// Bill reference generated by PromptPay pub reference: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsPromptpayBuilder { + reference: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsPromptpayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { reference: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { reference: self.reference.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..8fd2054c5 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsRevolutPay {} +#[doc(hidden)] +pub struct PaymentMethodDetailsRevolutPayBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsRevolutPayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..e0c883880 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsSepaCreditTransfer { /// Name of the bank associated with the bank account. pub bank_name: Option, @@ -7,3 +9,103 @@ pub struct PaymentMethodDetailsSepaCreditTransfer { /// IBAN of the bank account to transfer funds to. pub iban: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsSepaCreditTransferBuilder { + bank_name: Option>, + bic: Option>, + iban: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsSepaCreditTransferBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_name: Deserialize::default(), + bic: Deserialize::default(), + iban: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + bank_name: self.bank_name.take()?, + bic: self.bic.take()?, + iban: self.iban.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..95da90c32 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsSepaDebit { /// Bank code of bank associated with the bank account. pub bank_code: Option, @@ -15,3 +17,118 @@ pub struct PaymentMethodDetailsSepaDebit { /// Use this mandate ID to [retrieve the Mandate](https://stripe.com/docs/api/mandates/retrieve). pub mandate: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsSepaDebitBuilder { + bank_code: Option>, + branch_code: Option>, + country: Option>, + fingerprint: Option>, + last4: Option>, + mandate: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsSepaDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank_code: self.bank_code.take()?, + branch_code: self.branch_code.take()?, + country: self.country.take()?, + fingerprint: self.fingerprint.take()?, + last4: self.last4.take()?, + mandate: self.mandate.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..9c89b22a5 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsSofort { /// Bank code of bank associated with the bank account. pub bank_code: Option, @@ -21,6 +23,144 @@ pub struct PaymentMethodDetailsSofort { /// (if supported) at the time of authorization or settlement. They cannot be set or mutated. pub verified_name: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsSofortBuilder { + bank_code: Option>, + bank_name: Option>, + bic: Option>, + country: Option>, + generated_sepa_debit: Option>>, + generated_sepa_debit_mandate: Option>>, + iban_last4: Option>, + preferred_language: Option>, + verified_name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsSofortBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank_code: self.bank_code.take()?, + bank_name: self.bank_name.take()?, + bic: self.bic.take()?, + country: self.country.take()?, + generated_sepa_debit: self.generated_sepa_debit.take()?, + generated_sepa_debit_mandate: self.generated_sepa_debit_mandate.take()?, + iban_last4: self.iban_last4.take()?, + preferred_language: self.preferred_language?, + verified_name: self.verified_name.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)] @@ -75,6 +215,7 @@ impl std::fmt::Debug for PaymentMethodDetailsSofortPreferredLanguage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsSofortPreferredLanguage { fn serialize(&self, serializer: S) -> Result where @@ -83,6 +224,25 @@ impl serde::Serialize for PaymentMethodDetailsSofortPreferredLanguage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsSofortPreferredLanguage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodDetailsSofortPreferredLanguage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsSofortPreferredLanguage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsSofortPreferredLanguage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..b09fd08f5 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsStripeAccount {} +#[doc(hidden)] +pub struct PaymentMethodDetailsStripeAccountBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsStripeAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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 index 26525604f..64d08b05b 100644 --- a/generated/stripe_shared/src/payment_method_details_swish.rs +++ b/generated/stripe_shared/src/payment_method_details_swish.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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. @@ -8,3 +10,105 @@ pub struct PaymentMethodDetailsSwish { /// The last four digits of the Swish account phone number pub verified_phone_last4: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsSwishBuilder { + fingerprint: Option>, + payment_reference: Option>, + verified_phone_last4: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodDetailsSwish { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsSwishBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: PaymentMethodDetailsSwishBuilder::deser_default(), + })) + } + } + + impl MapBuilder for PaymentMethodDetailsSwishBuilder { + type Out = PaymentMethodDetailsSwish; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "fingerprint" => Deserialize::begin(&mut self.fingerprint), + "payment_reference" => Deserialize::begin(&mut self.payment_reference), + "verified_phone_last4" => Deserialize::begin(&mut self.verified_phone_last4), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + fingerprint: Deserialize::default(), + payment_reference: Deserialize::default(), + verified_phone_last4: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + fingerprint: self.fingerprint.take()?, + payment_reference: self.payment_reference.take()?, + verified_phone_last4: self.verified_phone_last4.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for PaymentMethodDetailsSwish { + type Builder = PaymentMethodDetailsSwishBuilder; + } + + impl FromValueOpt for PaymentMethodDetailsSwish { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodDetailsSwishBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "fingerprint" => b.fingerprint = Some(FromValueOpt::from_value(v)?), + "payment_reference" => b.payment_reference = Some(FromValueOpt::from_value(v)?), + "verified_phone_last4" => { + b.verified_phone_last4 = Some(FromValueOpt::from_value(v)?) + } + + _ => {} + } + } + b.take_out() + } + } +}; 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..b0c2134fe 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsUsBankAccount { /// Account holder type: individual or company. pub account_holder_type: Option, @@ -14,6 +16,123 @@ pub struct PaymentMethodDetailsUsBankAccount { /// Routing number of the bank account. pub routing_number: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsUsBankAccountBuilder { + account_holder_type: Option>, + account_type: Option>, + bank_name: Option>, + fingerprint: Option>, + last4: Option>, + routing_number: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsUsBankAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + account_holder_type: self.account_holder_type?, + account_type: self.account_type?, + bank_name: self.bank_name.take()?, + fingerprint: self.fingerprint.take()?, + last4: self.last4.take()?, + routing_number: self.routing_number.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -52,6 +171,7 @@ impl std::fmt::Debug for PaymentMethodDetailsUsBankAccountAccountHolderType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsUsBankAccountAccountHolderType { fn serialize(&self, serializer: S) -> Result where @@ -60,6 +180,25 @@ impl serde::Serialize for PaymentMethodDetailsUsBankAccountAccountHolderType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsUsBankAccountAccountHolderType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodDetailsUsBankAccountAccountHolderType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsUsBankAccountAccountHolderType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsUsBankAccountAccountHolderType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -109,6 +248,7 @@ impl std::fmt::Debug for PaymentMethodDetailsUsBankAccountAccountType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodDetailsUsBankAccountAccountType { fn serialize(&self, serializer: S) -> Result where @@ -117,6 +257,25 @@ impl serde::Serialize for PaymentMethodDetailsUsBankAccountAccountType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodDetailsUsBankAccountAccountType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodDetailsUsBankAccountAccountType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodDetailsUsBankAccountAccountType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodDetailsUsBankAccountAccountType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_details_wechat.rs b/generated/stripe_shared/src/payment_method_details_wechat.rs index 33dbea74d..8864fe310 100644 --- a/generated/stripe_shared/src/payment_method_details_wechat.rs +++ b/generated/stripe_shared/src/payment_method_details_wechat.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsWechat {} +#[doc(hidden)] +pub struct PaymentMethodDetailsWechatBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsWechatBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..055e90065 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,95 @@ pub struct PaymentMethodDetailsWechatPay { /// Transaction ID of this particular WeChat Pay transaction. pub transaction_id: Option, } +#[doc(hidden)] +pub struct PaymentMethodDetailsWechatPayBuilder { + fingerprint: Option>, + transaction_id: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsWechatPayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { fingerprint: Deserialize::default(), transaction_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + fingerprint: self.fingerprint.take()?, + transaction_id: self.transaction_id.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..c1c8778f1 100644 --- a/generated/stripe_shared/src/payment_method_details_zip.rs +++ b/generated/stripe_shared/src/payment_method_details_zip.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodDetailsZip {} +#[doc(hidden)] +pub struct PaymentMethodDetailsZipBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodDetailsZipBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..9a830e25e 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct PaymentMethodEpsBuilder { + bank: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodEpsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { bank: self.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 { + 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)] @@ -125,6 +213,7 @@ impl std::fmt::Debug for PaymentMethodEpsBank { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodEpsBank { fn serialize(&self, serializer: S) -> Result where @@ -133,10 +222,26 @@ impl serde::Serialize for PaymentMethodEpsBank { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodEpsBank { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodEpsBank::from_str(s).unwrap_or(PaymentMethodEpsBank::Unknown)); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodEpsBank); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodEpsBank { fn deserialize>(deserializer: D) -> Result { 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)) } } diff --git a/generated/stripe_shared/src/payment_method_fpx.rs b/generated/stripe_shared/src/payment_method_fpx.rs index faf3c8fd6..e7441ad51 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodFpx { /// Account holder type, if provided. Can be one of `individual` or `company`. pub account_holder_type: Option, @@ -6,6 +8,97 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodFpxBuilder { + account_holder_type: Option>, + bank: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodFpxBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { account_holder_type: Deserialize::default(), bank: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { account_holder_type: self.account_holder_type?, bank: self.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 { + 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 { @@ -44,6 +137,7 @@ impl std::fmt::Debug for PaymentMethodFpxAccountHolderType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodFpxAccountHolderType { fn serialize(&self, serializer: S) -> Result where @@ -52,6 +146,23 @@ impl serde::Serialize for PaymentMethodFpxAccountHolderType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodFpxAccountHolderType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(PaymentMethodFpxAccountHolderType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodFpxAccountHolderType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodFpxAccountHolderType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -164,6 +275,7 @@ impl std::fmt::Debug for PaymentMethodFpxBank { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodFpxBank { fn serialize(&self, serializer: S) -> Result where @@ -172,10 +284,26 @@ impl serde::Serialize for PaymentMethodFpxBank { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodFpxBank { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodFpxBank::from_str(s).unwrap_or(PaymentMethodFpxBank::Unknown)); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodFpxBank); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodFpxBank { fn deserialize>(deserializer: D) -> Result { 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)) } } diff --git a/generated/stripe_shared/src/payment_method_giropay.rs b/generated/stripe_shared/src/payment_method_giropay.rs index 1003535de..a3a9d6b4b 100644 --- a/generated/stripe_shared/src/payment_method_giropay.rs +++ b/generated/stripe_shared/src/payment_method_giropay.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodGiropay {} +#[doc(hidden)] +pub struct PaymentMethodGiropayBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodGiropayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..988968099 100644 --- a/generated/stripe_shared/src/payment_method_grabpay.rs +++ b/generated/stripe_shared/src/payment_method_grabpay.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodGrabpay {} +#[doc(hidden)] +pub struct PaymentMethodGrabpayBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodGrabpayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..8dc456b80 100644 --- a/generated/stripe_shared/src/payment_method_ideal.rs +++ b/generated/stripe_shared/src/payment_method_ideal.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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`. @@ -6,6 +8,95 @@ pub struct PaymentMethodIdeal { /// The Bank Identifier Code of the customer's bank, if the bank was provided. pub bic: Option, } +#[doc(hidden)] +pub struct PaymentMethodIdealBuilder { + bank: Option>, + bic: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodIdealBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank: Deserialize::default(), bic: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { bank: self.bank?, bic: self.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 { + 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`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -91,6 +182,7 @@ impl std::fmt::Debug for PaymentMethodIdealBank { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodIdealBank { fn serialize(&self, serializer: S) -> Result where @@ -99,11 +191,28 @@ impl serde::Serialize for PaymentMethodIdealBank { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodIdealBank { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(PaymentMethodIdealBank::from_str(s).unwrap_or(PaymentMethodIdealBank::Unknown)); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodIdealBank); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodIdealBank { fn deserialize>(deserializer: D) -> Result { 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)) } } /// The Bank Identifier Code of the customer's bank, if the bank was provided. @@ -193,6 +302,7 @@ impl std::fmt::Debug for PaymentMethodIdealBic { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodIdealBic { fn serialize(&self, serializer: S) -> Result where @@ -201,10 +311,27 @@ impl serde::Serialize for PaymentMethodIdealBic { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodIdealBic { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(PaymentMethodIdealBic::from_str(s).unwrap_or(PaymentMethodIdealBic::Unknown)); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodIdealBic); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodIdealBic { fn deserialize>(deserializer: D) -> Result { 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)) } } diff --git a/generated/stripe_shared/src/payment_method_interac_present.rs b/generated/stripe_shared/src/payment_method_interac_present.rs index 32e84af30..a941031fa 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodInteracPresent { /// Card brand. Can be `interac`, `mastercard` or `visa`. pub brand: Option, @@ -12,7 +14,6 @@ pub struct PaymentMethodInteracPresent { pub country: Option, /// 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, /// Two-digit number representing the card's expiration month. pub exp_month: i64, @@ -28,11 +29,9 @@ pub struct PaymentMethodInteracPresent { pub funding: Option, /// 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, /// 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, /// The last four digits of the card. pub last4: Option, @@ -43,6 +42,161 @@ pub struct PaymentMethodInteracPresent { /// How card details were read in this transaction. pub read_method: Option, } +#[doc(hidden)] +pub struct PaymentMethodInteracPresentBuilder { + brand: Option>, + cardholder_name: Option>, + country: Option>, + description: Option>, + exp_month: Option, + exp_year: Option, + fingerprint: Option>, + funding: Option>, + iin: Option>, + issuer: Option>, + last4: Option>, + networks: Option>, + preferred_locales: Option>>, + read_method: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodInteracPresentBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + brand: self.brand.take()?, + cardholder_name: self.cardholder_name.take()?, + country: self.country.take()?, + description: self.description.take()?, + exp_month: self.exp_month?, + exp_year: self.exp_year?, + fingerprint: self.fingerprint.take()?, + funding: self.funding.take()?, + iin: self.iin.take()?, + issuer: self.issuer.take()?, + last4: self.last4.take()?, + networks: self.networks.take()?, + preferred_locales: self.preferred_locales.take()?, + read_method: self.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 { + 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 { @@ -90,6 +244,7 @@ impl std::fmt::Debug for PaymentMethodInteracPresentReadMethod { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodInteracPresentReadMethod { fn serialize(&self, serializer: S) -> Result where @@ -98,6 +253,23 @@ impl serde::Serialize for PaymentMethodInteracPresentReadMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodInteracPresentReadMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(PaymentMethodInteracPresentReadMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodInteracPresentReadMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodInteracPresentReadMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_klarna.rs b/generated/stripe_shared/src/payment_method_klarna.rs index 310d1c2b1..98df592e2 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodKlarna { /// The customer's date of birth, if provided. pub dob: Option, } +#[doc(hidden)] +pub struct PaymentMethodKlarnaBuilder { + dob: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodKlarnaBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { dob: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { dob: self.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 { + 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..27459cf5b 100644 --- a/generated/stripe_shared/src/payment_method_konbini.rs +++ b/generated/stripe_shared/src/payment_method_konbini.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodKonbini {} +#[doc(hidden)] +pub struct PaymentMethodKonbiniBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodKonbiniBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..2514a874c 100644 --- a/generated/stripe_shared/src/payment_method_link.rs +++ b/generated/stripe_shared/src/payment_method_link.rs @@ -1,8 +1,101 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodLink { /// Account owner's email address. pub email: Option, /// \[Deprecated\] This is a legacy parameter that no longer has any function. - #[serde(skip_serializing_if = "Option::is_none")] pub persistent_token: Option, } +#[doc(hidden)] +pub struct PaymentMethodLinkBuilder { + email: Option>, + persistent_token: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodLinkBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { email: Deserialize::default(), persistent_token: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + email: self.email.take()?, + persistent_token: self.persistent_token.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..ce8d43b19 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// Preferred language of the Affirm authorization page that the customer is redirected to. - #[serde(skip_serializing_if = "Option::is_none")] pub preferred_locale: Option, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -12,9 +12,110 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsAffirmBuilder { + capture_method: Option>, + preferred_locale: Option>, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsAffirmBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + capture_method: self.capture_method?, + preferred_locale: self.preferred_locale.take()?, + setup_future_usage: self.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 { + 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 { @@ -50,6 +151,7 @@ impl std::fmt::Debug for PaymentMethodOptionsAffirmCaptureMethod { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsAffirmCaptureMethod { fn serialize(&self, serializer: S) -> Result where @@ -58,6 +160,24 @@ impl serde::Serialize for PaymentMethodOptionsAffirmCaptureMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsAffirmCaptureMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsAffirmCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsAffirmCaptureMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsAffirmCaptureMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -107,6 +227,7 @@ impl std::fmt::Debug for PaymentMethodOptionsAffirmSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsAffirmSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -115,6 +236,25 @@ impl serde::Serialize for PaymentMethodOptionsAffirmSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsAffirmSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsAffirmSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsAffirmSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsAffirmSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..6cc14e64e 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// 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,110 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsAfterpayClearpayBuilder { + capture_method: Option>, + reference: Option>, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsAfterpayClearpayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + capture_method: Deserialize::default(), + reference: Deserialize::default(), + setup_future_usage: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + capture_method: self.capture_method?, + reference: self.reference.take()?, + setup_future_usage: self.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 { + 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 { @@ -51,6 +153,7 @@ impl std::fmt::Debug for PaymentMethodOptionsAfterpayClearpayCaptureMethod { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsAfterpayClearpayCaptureMethod { fn serialize(&self, serializer: S) -> Result where @@ -59,6 +162,25 @@ impl serde::Serialize for PaymentMethodOptionsAfterpayClearpayCaptureMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsAfterpayClearpayCaptureMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsAfterpayClearpayCaptureMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsAfterpayClearpayCaptureMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsAfterpayClearpayCaptureMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -110,6 +232,7 @@ impl std::fmt::Debug for PaymentMethodOptionsAfterpayClearpaySetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsAfterpayClearpaySetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -118,6 +241,25 @@ impl serde::Serialize for PaymentMethodOptionsAfterpayClearpaySetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsAfterpayClearpaySetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsAfterpayClearpaySetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsAfterpayClearpaySetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsAfterpayClearpaySetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_options_alipay.rs b/generated/stripe_shared/src/payment_method_options_alipay.rs index 9013c291f..3e1b468ac 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsAlipay { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsAlipayBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsAlipayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -52,6 +141,7 @@ impl std::fmt::Debug for PaymentMethodOptionsAlipaySetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsAlipaySetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -60,6 +150,25 @@ impl serde::Serialize for PaymentMethodOptionsAlipaySetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsAlipaySetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsAlipaySetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsAlipaySetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsAlipaySetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..ef7de2f39 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsBacsDebit { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsBacsDebitBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsBacsDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -55,6 +144,7 @@ impl std::fmt::Debug for PaymentMethodOptionsBacsDebitSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsBacsDebitSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -63,6 +153,25 @@ impl serde::Serialize for PaymentMethodOptionsBacsDebitSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsBacsDebitSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsBacsDebitSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsBacsDebitSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsBacsDebitSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_options_bancontact.rs b/generated/stripe_shared/src/payment_method_options_bancontact.rs index dfc086ae3..40bf6ca1e 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsBancontact { /// Preferred language of the Bancontact authorization page that the customer is redirected to. pub preferred_language: PaymentMethodOptionsBancontactPreferredLanguage, @@ -8,9 +10,107 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsBancontactBuilder { + preferred_language: Option, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsBancontactBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + preferred_language: Deserialize::default(), + setup_future_usage: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + preferred_language: self.preferred_language?, + setup_future_usage: self.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 { + 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 { @@ -55,6 +155,7 @@ impl std::fmt::Debug for PaymentMethodOptionsBancontactPreferredLanguage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsBancontactPreferredLanguage { fn serialize(&self, serializer: S) -> Result where @@ -63,6 +164,25 @@ impl serde::Serialize for PaymentMethodOptionsBancontactPreferredLanguage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsBancontactPreferredLanguage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsBancontactPreferredLanguage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsBancontactPreferredLanguage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsBancontactPreferredLanguage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -117,6 +237,7 @@ impl std::fmt::Debug for PaymentMethodOptionsBancontactSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsBancontactSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -125,6 +246,25 @@ impl serde::Serialize for PaymentMethodOptionsBancontactSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsBancontactSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsBancontactSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsBancontactSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsBancontactSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_options_boleto.rs b/generated/stripe_shared/src/payment_method_options_boleto.rs index 3e72deb93..65764726c 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,107 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsBoletoBuilder { + expires_after_days: Option, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsBoletoBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + expires_after_days: Deserialize::default(), + setup_future_usage: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + expires_after_days: self.expires_after_days?, + setup_future_usage: self.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 { + 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. @@ -58,6 +158,7 @@ impl std::fmt::Debug for PaymentMethodOptionsBoletoSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsBoletoSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -66,6 +167,25 @@ impl serde::Serialize for PaymentMethodOptionsBoletoSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsBoletoSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsBoletoSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsBoletoSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsBoletoSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..42a2cbad6 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsCardInstallments { /// Installment plans that may be selected for this PaymentIntent. pub available_plans: Option>, @@ -7,3 +9,103 @@ pub struct PaymentMethodOptionsCardInstallments { /// Installment plan selected for this PaymentIntent. pub plan: Option, } +#[doc(hidden)] +pub struct PaymentMethodOptionsCardInstallmentsBuilder { + available_plans: Option>>, + enabled: Option, + plan: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsCardInstallmentsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + available_plans: Deserialize::default(), + enabled: Deserialize::default(), + plan: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + available_plans: self.available_plans.take()?, + enabled: self.enabled?, + plan: self.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 { + 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..397373b28 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsCardMandateOptions { /// Amount to be charged for future payments. pub amount: i64, @@ -26,6 +28,136 @@ pub struct PaymentMethodOptionsCardMandateOptions { /// Specifies the type of mandates supported. Possible values are `india`. pub supported_types: Option>, } +#[doc(hidden)] +pub struct PaymentMethodOptionsCardMandateOptionsBuilder { + amount: Option, + amount_type: Option, + description: Option>, + end_date: Option>, + interval: Option, + interval_count: Option>, + reference: Option, + start_date: Option, + supported_types: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsCardMandateOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount: self.amount?, + amount_type: self.amount_type?, + description: self.description.take()?, + end_date: self.end_date?, + interval: self.interval?, + interval_count: self.interval_count?, + reference: self.reference.take()?, + start_date: self.start_date?, + supported_types: self.supported_types.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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. @@ -66,6 +198,7 @@ impl std::fmt::Debug for PaymentMethodOptionsCardMandateOptionsAmountType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsCardMandateOptionsAmountType { fn serialize(&self, serializer: S) -> Result where @@ -74,6 +207,25 @@ impl serde::Serialize for PaymentMethodOptionsCardMandateOptionsAmountType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsCardMandateOptionsAmountType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsCardMandateOptionsAmountType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCardMandateOptionsAmountType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCardMandateOptionsAmountType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -132,6 +284,7 @@ impl std::fmt::Debug for PaymentMethodOptionsCardMandateOptionsInterval { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsCardMandateOptionsInterval { fn serialize(&self, serializer: S) -> Result where @@ -140,6 +293,25 @@ impl serde::Serialize for PaymentMethodOptionsCardMandateOptionsInterval { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsCardMandateOptionsInterval { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsCardMandateOptionsInterval::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCardMandateOptionsInterval); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCardMandateOptionsInterval { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -186,6 +358,7 @@ impl std::fmt::Debug for PaymentMethodOptionsCardMandateOptionsSupportedTypes { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsCardMandateOptionsSupportedTypes { fn serialize(&self, serializer: S) -> Result where @@ -194,6 +367,25 @@ impl serde::Serialize for PaymentMethodOptionsCardMandateOptionsSupportedTypes { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsCardMandateOptionsSupportedTypes { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsCardMandateOptionsSupportedTypes::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCardMandateOptionsSupportedTypes); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCardMandateOptionsSupportedTypes { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..85f073ee9 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -6,3 +8,108 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsCardPresentBuilder { + request_extended_authorization: Option>, + request_incremental_authorization_support: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsCardPresentBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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) + } + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + request_extended_authorization: Deserialize::default(), + request_incremental_authorization_support: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + request_extended_authorization: self.request_extended_authorization?, + request_incremental_authorization_support: self + .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 { + 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..9f3b0efbf 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -9,9 +10,105 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsCashappBuilder { + capture_method: Option>, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsCashappBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + capture_method: Deserialize::default(), + setup_future_usage: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + capture_method: self.capture_method?, + setup_future_usage: self.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 { + 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 { @@ -47,6 +144,7 @@ impl std::fmt::Debug for PaymentMethodOptionsCashappCaptureMethod { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsCashappCaptureMethod { fn serialize(&self, serializer: S) -> Result where @@ -55,6 +153,24 @@ impl serde::Serialize for PaymentMethodOptionsCashappCaptureMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsCashappCaptureMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsCashappCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCashappCaptureMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCashappCaptureMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -110,6 +226,7 @@ impl std::fmt::Debug for PaymentMethodOptionsCashappSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsCashappSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -118,6 +235,25 @@ impl serde::Serialize for PaymentMethodOptionsCashappSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsCashappSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsCashappSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCashappSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCashappSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..7081b8ac3 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsCustomerBalance { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_transfer: Option, /// 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,110 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsCustomerBalanceBuilder { + bank_transfer: Option>, + funding_type: Option>, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsCustomerBalanceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank_transfer: self.bank_transfer.take()?, + funding_type: self.funding_type?, + setup_future_usage: self.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 { + 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)] @@ -50,6 +152,7 @@ impl std::fmt::Debug for PaymentMethodOptionsCustomerBalanceFundingType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsCustomerBalanceFundingType { fn serialize(&self, serializer: S) -> Result where @@ -58,6 +161,25 @@ impl serde::Serialize for PaymentMethodOptionsCustomerBalanceFundingType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsCustomerBalanceFundingType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsCustomerBalanceFundingType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCustomerBalanceFundingType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCustomerBalanceFundingType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -109,6 +231,7 @@ impl std::fmt::Debug for PaymentMethodOptionsCustomerBalanceSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsCustomerBalanceSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -117,6 +240,25 @@ impl serde::Serialize for PaymentMethodOptionsCustomerBalanceSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsCustomerBalanceSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsCustomerBalanceSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCustomerBalanceSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCustomerBalanceSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..d1d3c98e3 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,122 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsCustomerBalanceBankTransfer { - #[serde(skip_serializing_if = "Option::is_none")] pub eu_bank_transfer: Option, /// 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>, /// 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(feature = "serde", serde(rename = "type"))] pub type_: Option, } +#[doc(hidden)] +pub struct PaymentMethodOptionsCustomerBalanceBankTransferBuilder { + eu_bank_transfer: + Option>, + requested_address_types: + Option>>, + type_: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsCustomerBalanceBankTransferBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + eu_bank_transfer: self.eu_bank_transfer?, + requested_address_types: self.requested_address_types.take()?, + type_: self.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 { + 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. /// @@ -69,6 +173,7 @@ impl std::fmt::Debug for PaymentMethodOptionsCustomerBalanceBankTransferRequeste f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { fn serialize(&self, serializer: S) -> Result where @@ -77,6 +182,31 @@ impl serde::Serialize for PaymentMethodOptionsCustomerBalanceBankTransferRequest serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for PaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCustomerBalanceBankTransferRequestedAddressTypes { @@ -133,6 +263,7 @@ impl std::fmt::Debug for PaymentMethodOptionsCustomerBalanceBankTransferType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsCustomerBalanceBankTransferType { fn serialize(&self, serializer: S) -> Result where @@ -141,6 +272,25 @@ impl serde::Serialize for PaymentMethodOptionsCustomerBalanceBankTransferType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsCustomerBalanceBankTransferType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsCustomerBalanceBankTransferType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCustomerBalanceBankTransferType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCustomerBalanceBankTransferType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..344079d76 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsCustomerBalanceEuBankAccountBuilder { + country: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsCustomerBalanceEuBankAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { country: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { country: self.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 { + 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)] @@ -55,6 +143,7 @@ impl std::fmt::Debug for PaymentMethodOptionsCustomerBalanceEuBankAccountCountry f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsCustomerBalanceEuBankAccountCountry { fn serialize(&self, serializer: S) -> Result where @@ -63,6 +152,27 @@ impl serde::Serialize for PaymentMethodOptionsCustomerBalanceEuBankAccountCountr serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsCustomerBalanceEuBankAccountCountry { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsCustomerBalanceEuBankAccountCountry::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsCustomerBalanceEuBankAccountCountry); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsCustomerBalanceEuBankAccountCountry { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_options_fpx.rs b/generated/stripe_shared/src/payment_method_options_fpx.rs index 785d95521..07d7d10af 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsFpx { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsFpxBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsFpxBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for PaymentMethodOptionsFpxSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsFpxSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,24 @@ impl serde::Serialize for PaymentMethodOptionsFpxSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsFpxSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsFpxSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsFpxSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsFpxSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_options_giropay.rs b/generated/stripe_shared/src/payment_method_options_giropay.rs index 27b1695f9..f08de757d 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsGiropay { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsGiropayBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsGiropayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for PaymentMethodOptionsGiropaySetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsGiropaySetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,25 @@ impl serde::Serialize for PaymentMethodOptionsGiropaySetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsGiropaySetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsGiropaySetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsGiropaySetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsGiropaySetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_options_grabpay.rs b/generated/stripe_shared/src/payment_method_options_grabpay.rs index 9254d1f9d..90a310b88 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsGrabpay { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsGrabpayBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsGrabpayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for PaymentMethodOptionsGrabpaySetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsGrabpaySetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,25 @@ impl serde::Serialize for PaymentMethodOptionsGrabpaySetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsGrabpaySetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsGrabpaySetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsGrabpaySetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsGrabpaySetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_options_ideal.rs b/generated/stripe_shared/src/payment_method_options_ideal.rs index 7be10d3a4..880575708 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsIdeal { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsIdealBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsIdealBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -52,6 +141,7 @@ impl std::fmt::Debug for PaymentMethodOptionsIdealSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsIdealSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -60,6 +150,24 @@ impl serde::Serialize for PaymentMethodOptionsIdealSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsIdealSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsIdealSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsIdealSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsIdealSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..d769fe2a3 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsInteracPresent {} +#[doc(hidden)] +pub struct PaymentMethodOptionsInteracPresentBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsInteracPresentBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..61d873e3e 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// Preferred locale of the Klarna checkout page that the customer is redirected to. pub preferred_locale: Option, @@ -11,9 +12,110 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsKlarnaBuilder { + capture_method: Option>, + preferred_locale: Option>, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsKlarnaBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + capture_method: self.capture_method?, + preferred_locale: self.preferred_locale.take()?, + setup_future_usage: self.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 { + 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 { @@ -49,6 +151,7 @@ impl std::fmt::Debug for PaymentMethodOptionsKlarnaCaptureMethod { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsKlarnaCaptureMethod { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +160,24 @@ impl serde::Serialize for PaymentMethodOptionsKlarnaCaptureMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsKlarnaCaptureMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsKlarnaCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsKlarnaCaptureMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsKlarnaCaptureMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -106,6 +227,7 @@ impl std::fmt::Debug for PaymentMethodOptionsKlarnaSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsKlarnaSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -114,6 +236,25 @@ impl serde::Serialize for PaymentMethodOptionsKlarnaSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsKlarnaSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsKlarnaSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsKlarnaSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsKlarnaSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_options_konbini.rs b/generated/stripe_shared/src/payment_method_options_konbini.rs index 7efd4c2f4..046239062 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsKonbini { /// An optional 10 to 11 digit numeric-only string determining the confirmation code at applicable convenience stores. pub confirmation_number: Option, @@ -16,9 +18,126 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsKonbiniBuilder { + confirmation_number: Option>, + expires_after_days: Option>, + expires_at: Option>, + product_description: Option>, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsKonbiniBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + confirmation_number: self.confirmation_number.take()?, + expires_after_days: self.expires_after_days?, + expires_at: self.expires_at?, + product_description: self.product_description.take()?, + setup_future_usage: self.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 { + 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. @@ -59,6 +178,7 @@ impl std::fmt::Debug for PaymentMethodOptionsKonbiniSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsKonbiniSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -67,6 +187,25 @@ impl serde::Serialize for PaymentMethodOptionsKonbiniSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsKonbiniSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsKonbiniSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsKonbiniSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsKonbiniSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_options_oxxo.rs b/generated/stripe_shared/src/payment_method_options_oxxo.rs index a1867c77e..b249dffda 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,107 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsOxxoBuilder { + expires_after_days: Option, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsOxxoBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + expires_after_days: Deserialize::default(), + setup_future_usage: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + expires_after_days: self.expires_after_days?, + setup_future_usage: self.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 { + 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. @@ -52,6 +152,7 @@ impl std::fmt::Debug for PaymentMethodOptionsOxxoSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsOxxoSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -60,6 +161,24 @@ impl serde::Serialize for PaymentMethodOptionsOxxoSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsOxxoSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsOxxoSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsOxxoSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsOxxoSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_options_p24.rs b/generated/stripe_shared/src/payment_method_options_p24.rs index 3ba6d5541..cd32353f4 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsP24 { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsP24Builder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsP24Builder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for PaymentMethodOptionsP24SetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsP24SetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,24 @@ impl serde::Serialize for PaymentMethodOptionsP24SetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsP24SetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsP24SetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsP24SetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsP24SetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_options_paynow.rs b/generated/stripe_shared/src/payment_method_options_paynow.rs index 654aa47da..37767db18 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsPaynow { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsPaynowBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsPaynowBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for PaymentMethodOptionsPaynowSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsPaynowSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,25 @@ impl serde::Serialize for PaymentMethodOptionsPaynowSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsPaynowSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsPaynowSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsPaynowSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsPaynowSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_options_paypal.rs b/generated/stripe_shared/src/payment_method_options_paypal.rs index 241d948c6..c82047182 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// Preferred locale of the PayPal checkout page that the customer is redirected to. pub preferred_locale: Option, @@ -14,9 +15,115 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsPaypalBuilder { + capture_method: Option>, + preferred_locale: Option>, + reference: Option>, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsPaypalBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + capture_method: self.capture_method?, + preferred_locale: self.preferred_locale.take()?, + reference: self.reference.take()?, + setup_future_usage: self.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 { + 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 { @@ -52,6 +159,7 @@ impl std::fmt::Debug for PaymentMethodOptionsPaypalCaptureMethod { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsPaypalCaptureMethod { fn serialize(&self, serializer: S) -> Result where @@ -60,6 +168,24 @@ impl serde::Serialize for PaymentMethodOptionsPaypalCaptureMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsPaypalCaptureMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsPaypalCaptureMethod::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsPaypalCaptureMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsPaypalCaptureMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -112,6 +238,7 @@ impl std::fmt::Debug for PaymentMethodOptionsPaypalSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsPaypalSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -120,6 +247,25 @@ impl serde::Serialize for PaymentMethodOptionsPaypalSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsPaypalSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsPaypalSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsPaypalSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsPaypalSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_options_pix.rs b/generated/stripe_shared/src/payment_method_options_pix.rs index 6f79294d5..833ae89e0 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsPix { /// The number of seconds (between 10 and 1209600) after which Pix payment will expire. pub expires_after_seconds: Option, @@ -10,9 +12,112 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsPixBuilder { + expires_after_seconds: Option>, + expires_at: Option>, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsPixBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + expires_after_seconds: self.expires_after_seconds?, + expires_at: self.expires_at?, + setup_future_usage: self.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 { + 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. @@ -53,6 +158,7 @@ impl std::fmt::Debug for PaymentMethodOptionsPixSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsPixSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -61,6 +167,24 @@ impl serde::Serialize for PaymentMethodOptionsPixSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsPixSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsPixSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsPixSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsPixSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_options_promptpay.rs b/generated/stripe_shared/src/payment_method_options_promptpay.rs index a09bb6f57..3e95bed38 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsPromptpay { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsPromptpayBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsPromptpayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for PaymentMethodOptionsPromptpaySetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsPromptpaySetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,25 @@ impl serde::Serialize for PaymentMethodOptionsPromptpaySetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsPromptpaySetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsPromptpaySetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsPromptpaySetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsPromptpaySetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..85d35efaa 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsRevolutPay {} +#[doc(hidden)] +pub struct PaymentMethodOptionsRevolutPayBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsRevolutPayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..21e68fcf9 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsSofort { /// Preferred language of the SOFORT authorization page that the customer is redirected to. pub preferred_language: Option, @@ -8,9 +10,107 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsSofortBuilder { + preferred_language: Option>, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsSofortBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + preferred_language: Deserialize::default(), + setup_future_usage: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + preferred_language: self.preferred_language?, + setup_future_usage: self.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 { + 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 { @@ -64,6 +164,7 @@ impl std::fmt::Debug for PaymentMethodOptionsSofortPreferredLanguage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsSofortPreferredLanguage { fn serialize(&self, serializer: S) -> Result where @@ -72,6 +173,25 @@ impl serde::Serialize for PaymentMethodOptionsSofortPreferredLanguage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsSofortPreferredLanguage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsSofortPreferredLanguage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsSofortPreferredLanguage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsSofortPreferredLanguage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -126,6 +246,7 @@ impl std::fmt::Debug for PaymentMethodOptionsSofortSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsSofortSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -134,6 +255,25 @@ impl serde::Serialize for PaymentMethodOptionsSofortSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsSofortSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsSofortSetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsSofortSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsSofortSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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 index f7b0781c8..bac1e77eb 100644 --- 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 @@ -1,9 +1,97 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsUsBankAccountMandateOptions { /// Mandate collection method - #[serde(skip_serializing_if = "Option::is_none")] pub collection_method: Option, } +#[doc(hidden)] +pub struct PaymentMethodOptionsUsBankAccountMandateOptionsBuilder { + collection_method: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodOptionsUsBankAccountMandateOptions { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsUsBankAccountMandateOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: PaymentMethodOptionsUsBankAccountMandateOptionsBuilder::deser_default(), + })) + } + } + + impl MapBuilder for PaymentMethodOptionsUsBankAccountMandateOptionsBuilder { + type Out = PaymentMethodOptionsUsBankAccountMandateOptions; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "collection_method" => Deserialize::begin(&mut self.collection_method), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { collection_method: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { collection_method: self.collection_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 PaymentMethodOptionsUsBankAccountMandateOptions { + type Builder = PaymentMethodOptionsUsBankAccountMandateOptionsBuilder; + } + + impl FromValueOpt for PaymentMethodOptionsUsBankAccountMandateOptions { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodOptionsUsBankAccountMandateOptionsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "collection_method" => b.collection_method = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// Mandate collection method #[derive(Copy, Clone, Eq, PartialEq)] pub enum PaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { @@ -39,6 +127,7 @@ impl std::fmt::Debug for PaymentMethodOptionsUsBankAccountMandateOptionsCollecti f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { fn serialize(&self, serializer: S) -> Result where @@ -47,6 +136,29 @@ impl serde::Serialize for PaymentMethodOptionsUsBankAccountMandateOptionsCollect serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + PaymentMethodOptionsUsBankAccountMandateOptionsCollectionMethod +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> 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..b3dd7e962 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsWechatPay { /// The app ID registered with WeChat Pay. Only required when client is ios or android. pub app_id: Option, @@ -10,9 +12,110 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsWechatPayBuilder { + app_id: Option>, + client: Option>, + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsWechatPayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + app_id: Deserialize::default(), + client: Deserialize::default(), + setup_future_usage: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + app_id: self.app_id.take()?, + client: self.client?, + setup_future_usage: self.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 { + 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 { @@ -54,6 +157,7 @@ impl std::fmt::Debug for PaymentMethodOptionsWechatPayClient { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsWechatPayClient { fn serialize(&self, serializer: S) -> Result where @@ -62,6 +166,23 @@ impl serde::Serialize for PaymentMethodOptionsWechatPayClient { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsWechatPayClient { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(PaymentMethodOptionsWechatPayClient::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsWechatPayClient); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsWechatPayClient { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -111,6 +232,7 @@ impl std::fmt::Debug for PaymentMethodOptionsWechatPaySetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsWechatPaySetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -119,6 +241,25 @@ impl serde::Serialize for PaymentMethodOptionsWechatPaySetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsWechatPaySetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsWechatPaySetupFutureUsage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsWechatPaySetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsWechatPaySetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_options_zip.rs b/generated/stripe_shared/src/payment_method_options_zip.rs index 6a09ea1f5..e2c95c30b 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOptionsZip { /// Indicates that you intend to make future payments with this PaymentIntent's payment method. /// @@ -6,9 +8,96 @@ 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, } +#[doc(hidden)] +pub struct PaymentMethodOptionsZipBuilder { + setup_future_usage: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOptionsZipBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { setup_future_usage: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { setup_future_usage: self.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 { + 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. @@ -49,6 +138,7 @@ impl std::fmt::Debug for PaymentMethodOptionsZipSetupFutureUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodOptionsZipSetupFutureUsage { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +147,24 @@ impl serde::Serialize for PaymentMethodOptionsZipSetupFutureUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodOptionsZipSetupFutureUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodOptionsZipSetupFutureUsage::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodOptionsZipSetupFutureUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodOptionsZipSetupFutureUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/payment_method_oxxo.rs b/generated/stripe_shared/src/payment_method_oxxo.rs index 5680d3a17..d4c083d81 100644 --- a/generated/stripe_shared/src/payment_method_oxxo.rs +++ b/generated/stripe_shared/src/payment_method_oxxo.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodOxxo {} +#[doc(hidden)] +pub struct PaymentMethodOxxoBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodOxxoBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..fbad19d50 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodP24 { /// The customer's bank, if provided. pub bank: Option, } +#[doc(hidden)] +pub struct PaymentMethodP24Builder { + bank: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodP24Builder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { bank: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { bank: self.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 { + 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] @@ -117,6 +205,7 @@ impl std::fmt::Debug for PaymentMethodP24Bank { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodP24Bank { fn serialize(&self, serializer: S) -> Result where @@ -125,10 +214,26 @@ impl serde::Serialize for PaymentMethodP24Bank { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodP24Bank { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaymentMethodP24Bank::from_str(s).unwrap_or(PaymentMethodP24Bank::Unknown)); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodP24Bank); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodP24Bank { fn deserialize>(deserializer: D) -> Result { 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)) } } diff --git a/generated/stripe_shared/src/payment_method_paynow.rs b/generated/stripe_shared/src/payment_method_paynow.rs index e48602eee..405ced84a 100644 --- a/generated/stripe_shared/src/payment_method_paynow.rs +++ b/generated/stripe_shared/src/payment_method_paynow.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodPaynow {} +#[doc(hidden)] +pub struct PaymentMethodPaynowBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodPaynowBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..f3a243d1e 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,95 @@ pub struct PaymentMethodPaypal { /// PayPal account PayerID. This identifier uniquely identifies the PayPal customer. pub payer_id: Option, } +#[doc(hidden)] +pub struct PaymentMethodPaypalBuilder { + payer_email: Option>, + payer_id: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodPaypalBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { payer_email: Deserialize::default(), payer_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + payer_email: self.payer_email.take()?, + payer_id: self.payer_id.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..d73658288 100644 --- a/generated/stripe_shared/src/payment_method_pix.rs +++ b/generated/stripe_shared/src/payment_method_pix.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodPix {} +#[doc(hidden)] +pub struct PaymentMethodPixBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodPixBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..e872f6f3d 100644 --- a/generated/stripe_shared/src/payment_method_promptpay.rs +++ b/generated/stripe_shared/src/payment_method_promptpay.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodPromptpay {} +#[doc(hidden)] +pub struct PaymentMethodPromptpayBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodPromptpayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..25d8e66ec 100644 --- a/generated/stripe_shared/src/payment_method_revolut_pay.rs +++ b/generated/stripe_shared/src/payment_method_revolut_pay.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodRevolutPay {} +#[doc(hidden)] +pub struct PaymentMethodRevolutPayBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodRevolutPayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..0e95888fc 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodSepaDebit { /// Bank code of bank associated with the bank account. pub bank_code: Option, @@ -14,3 +16,118 @@ pub struct PaymentMethodSepaDebit { /// Last four characters of the IBAN. pub last4: Option, } +#[doc(hidden)] +pub struct PaymentMethodSepaDebitBuilder { + bank_code: Option>, + branch_code: Option>, + country: Option>, + fingerprint: Option>, + generated_from: Option>, + last4: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodSepaDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank_code: self.bank_code.take()?, + branch_code: self.branch_code.take()?, + country: self.country.take()?, + fingerprint: self.fingerprint.take()?, + generated_from: self.generated_from.take()?, + last4: self.last4.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..3f8c222e3 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodSofort { /// Two-letter ISO code representing the country the bank account is located in. pub country: Option, } +#[doc(hidden)] +pub struct PaymentMethodSofortBuilder { + country: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodSofortBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { country: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { country: self.country.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 index e47969890..b6a0f65b1 100644 --- a/generated/stripe_shared/src/payment_method_swish.rs +++ b/generated/stripe_shared/src/payment_method_swish.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodSwish {} +#[doc(hidden)] +pub struct PaymentMethodSwishBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for PaymentMethodSwish { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodSwishBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: PaymentMethodSwishBuilder::deser_default(), + })) + } + } + + impl MapBuilder for PaymentMethodSwishBuilder { + type Out = PaymentMethodSwish; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 PaymentMethodSwish { + type Builder = PaymentMethodSwishBuilder; + } + + impl FromValueOpt for PaymentMethodSwish { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = PaymentMethodSwishBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + _ => {} + } + } + b.take_out() + } + } +}; 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..b38a699ac 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodUsBankAccount { /// Account holder type: individual or company. pub account_holder_type: Option, @@ -20,6 +22,142 @@ pub struct PaymentMethodUsBankAccount { /// Contains information about the future reusability of this PaymentMethod. pub status_details: Option, } +#[doc(hidden)] +pub struct PaymentMethodUsBankAccountBuilder { + account_holder_type: Option>, + account_type: Option>, + bank_name: Option>, + financial_connections_account: Option>, + fingerprint: Option>, + last4: Option>, + networks: Option>, + routing_number: Option>, + status_details: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodUsBankAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + account_holder_type: self.account_holder_type?, + account_type: self.account_type?, + bank_name: self.bank_name.take()?, + financial_connections_account: self.financial_connections_account.take()?, + fingerprint: self.fingerprint.take()?, + last4: self.last4.take()?, + networks: self.networks.take()?, + routing_number: self.routing_number.take()?, + status_details: self.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 { + 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 { @@ -58,6 +196,7 @@ impl std::fmt::Debug for PaymentMethodUsBankAccountAccountHolderType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodUsBankAccountAccountHolderType { fn serialize(&self, serializer: S) -> Result where @@ -66,6 +205,25 @@ impl serde::Serialize for PaymentMethodUsBankAccountAccountHolderType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodUsBankAccountAccountHolderType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodUsBankAccountAccountHolderType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodUsBankAccountAccountHolderType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodUsBankAccountAccountHolderType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -115,6 +273,7 @@ impl std::fmt::Debug for PaymentMethodUsBankAccountAccountType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodUsBankAccountAccountType { fn serialize(&self, serializer: S) -> Result where @@ -123,6 +282,23 @@ impl serde::Serialize for PaymentMethodUsBankAccountAccountType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodUsBankAccountAccountType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(PaymentMethodUsBankAccountAccountType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodUsBankAccountAccountType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodUsBankAccountAccountType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..4b44f7772 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,101 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodUsBankAccountBlocked { /// The ACH network code that resulted in this block. pub network_code: Option, /// The reason why this PaymentMethod's fingerprint has been blocked pub reason: Option, } +#[doc(hidden)] +pub struct PaymentMethodUsBankAccountBlockedBuilder { + network_code: Option>, + reason: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodUsBankAccountBlockedBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { network_code: Deserialize::default(), reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { network_code: self.network_code?, reason: self.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 { + 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 { @@ -73,6 +164,7 @@ impl std::fmt::Debug for PaymentMethodUsBankAccountBlockedNetworkCode { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodUsBankAccountBlockedNetworkCode { fn serialize(&self, serializer: S) -> Result where @@ -81,6 +173,25 @@ impl serde::Serialize for PaymentMethodUsBankAccountBlockedNetworkCode { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodUsBankAccountBlockedNetworkCode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodUsBankAccountBlockedNetworkCode::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodUsBankAccountBlockedNetworkCode); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodUsBankAccountBlockedNetworkCode { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -142,6 +253,7 @@ impl std::fmt::Debug for PaymentMethodUsBankAccountBlockedReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaymentMethodUsBankAccountBlockedReason { fn serialize(&self, serializer: S) -> Result where @@ -150,6 +262,24 @@ impl serde::Serialize for PaymentMethodUsBankAccountBlockedReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaymentMethodUsBankAccountBlockedReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaymentMethodUsBankAccountBlockedReason::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaymentMethodUsBankAccountBlockedReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaymentMethodUsBankAccountBlockedReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..8404fa7db 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodUsBankAccountStatusDetails { - #[serde(skip_serializing_if = "Option::is_none")] pub blocked: Option, } +#[doc(hidden)] +pub struct PaymentMethodUsBankAccountStatusDetailsBuilder { + blocked: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodUsBankAccountStatusDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { blocked: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { blocked: self.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 { + 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..e186e3505 100644 --- a/generated/stripe_shared/src/payment_method_wechat_pay.rs +++ b/generated/stripe_shared/src/payment_method_wechat_pay.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodWechatPay {} +#[doc(hidden)] +pub struct PaymentMethodWechatPayBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodWechatPayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..cab6a4103 100644 --- a/generated/stripe_shared/src/payment_method_zip.rs +++ b/generated/stripe_shared/src/payment_method_zip.rs @@ -1,2 +1,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaymentMethodZip {} +#[doc(hidden)] +pub struct PaymentMethodZipBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaymentMethodZipBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..6d0a441a0 100644 --- a/generated/stripe_shared/src/payment_source.rs +++ b/generated/stripe_shared/src/payment_source.rs @@ -1,16 +1,103 @@ /// The resource representing a Stripe Polymorphic -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(tag = "object"))] pub enum PaymentSource { - #[serde(rename = "account")] + #[cfg_attr(feature = "serde", serde(rename = "account"))] Account(stripe_shared::Account), - #[serde(rename = "bank_account")] + #[cfg_attr(feature = "serde", serde(rename = "bank_account"))] BankAccount(stripe_shared::BankAccount), - #[serde(rename = "card")] + #[cfg_attr(feature = "serde", serde(rename = "card"))] Card(stripe_shared::Card), - #[serde(rename = "source")] + #[cfg_attr(feature = "serde", serde(rename = "source"))] Source(stripe_shared::Source), } + +#[derive(Default)] +pub struct PaymentSourceBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +const _: () = { + use 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, + builder: PaymentSourceBuilder, + } + + impl Deserialize for PaymentSource { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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 { + 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 { + 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..274f3bc18 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Payout { /// The amount (in cents (or local equivalent)) that transfers to your bank account or debit card. pub amount: i64, @@ -47,6 +49,8 @@ pub struct Payout { /// `instant` is supported for payouts to debit cards and bank accounts in certain countries. /// Learn more about [bank support for Instant Payouts](https://stripe.com/docs/payouts/instant-payouts-banks). pub method: String, + /// String representing the object's type. Objects of the same type share the same value. + pub object: PayoutObject, /// If the payout reverses another, this is the ID of the original payout. pub original_payout: Option>, /// 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. @@ -63,9 +67,285 @@ 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(feature = "serde", serde(rename = "type"))] pub type_: PayoutType, } +#[doc(hidden)] +pub struct PayoutBuilder { + amount: Option, + arrival_date: Option, + automatic: Option, + balance_transaction: + Option>>, + created: Option, + currency: Option, + description: Option>, + destination: Option>>, + failure_balance_transaction: + Option>>, + failure_code: Option>, + failure_message: Option>, + id: Option, + livemode: Option, + metadata: Option>>, + method: Option, + object: Option, + original_payout: Option>>, + reconciliation_status: Option, + reversed_by: Option>>, + source_type: Option, + statement_descriptor: Option>, + status: Option, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PayoutBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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_), + + _ => ::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(), + object: 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 { + Some(Self::Out { + amount: self.amount?, + arrival_date: self.arrival_date?, + automatic: self.automatic?, + balance_transaction: self.balance_transaction.take()?, + created: self.created?, + currency: self.currency?, + description: self.description.take()?, + destination: self.destination.take()?, + failure_balance_transaction: self.failure_balance_transaction.take()?, + failure_code: self.failure_code.take()?, + failure_message: self.failure_message.take()?, + id: self.id.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + method: self.method.take()?, + object: self.object?, + original_payout: self.original_payout.take()?, + reconciliation_status: self.reconciliation_status?, + reversed_by: self.reversed_by.take()?, + source_type: self.source_type.take()?, + statement_descriptor: self.statement_descriptor.take()?, + status: self.status.take()?, + type_: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum PayoutObject { + Payout, +} +impl PayoutObject { + pub fn as_str(self) -> &'static str { + use PayoutObject::*; + match self { + Payout => "payout", + } + } +} + +impl std::str::FromStr for PayoutObject { + type Err = (); + fn from_str(s: &str) -> Result { + use PayoutObject::*; + match s { + "payout" => Ok(Payout), + _ => Err(()), + } + } +} +impl std::fmt::Display for PayoutObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for PayoutObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for PayoutObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for PayoutObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PayoutObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PayoutObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for PayoutObject { + fn deserialize>(deserializer: D) -> 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 PayoutObject")) + } +} /// 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 { @@ -107,6 +387,7 @@ impl std::fmt::Debug for PayoutReconciliationStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PayoutReconciliationStatus { fn serialize(&self, serializer: S) -> Result where @@ -115,6 +396,22 @@ impl serde::Serialize for PayoutReconciliationStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PayoutReconciliationStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PayoutReconciliationStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PayoutReconciliationStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PayoutReconciliationStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -161,6 +458,7 @@ impl std::fmt::Debug for PayoutType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PayoutType { fn serialize(&self, serializer: S) -> Result where @@ -169,6 +467,22 @@ impl serde::Serialize for PayoutType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PayoutType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PayoutType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PayoutType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PayoutType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/paypal_seller_protection.rs b/generated/stripe_shared/src/paypal_seller_protection.rs index cf524141f..b35398ab3 100644 --- a/generated/stripe_shared/src/paypal_seller_protection.rs +++ b/generated/stripe_shared/src/paypal_seller_protection.rs @@ -1,10 +1,106 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PaypalSellerProtection { /// An array of conditions that are covered for the transaction, if applicable. pub dispute_categories: Option>, /// Indicates whether the transaction is eligible for PayPal's seller protection. pub status: PaypalSellerProtectionStatus, } +#[doc(hidden)] +pub struct PaypalSellerProtectionBuilder { + dispute_categories: Option>>, + status: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PaypalSellerProtectionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { dispute_categories: Deserialize::default(), status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + dispute_categories: self.dispute_categories.take()?, + status: self.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 { + 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 { @@ -43,6 +139,7 @@ impl std::fmt::Debug for PaypalSellerProtectionDisputeCategories { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaypalSellerProtectionDisputeCategories { fn serialize(&self, serializer: S) -> Result where @@ -51,6 +148,24 @@ impl serde::Serialize for PaypalSellerProtectionDisputeCategories { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaypalSellerProtectionDisputeCategories { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + PaypalSellerProtectionDisputeCategories::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaypalSellerProtectionDisputeCategories); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaypalSellerProtectionDisputeCategories { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -101,6 +216,7 @@ impl std::fmt::Debug for PaypalSellerProtectionStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PaypalSellerProtectionStatus { fn serialize(&self, serializer: S) -> Result where @@ -109,6 +225,22 @@ impl serde::Serialize for PaypalSellerProtectionStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PaypalSellerProtectionStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PaypalSellerProtectionStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PaypalSellerProtectionStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PaypalSellerProtectionStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/period.rs b/generated/stripe_shared/src/period.rs index 5dd14f7fd..b39e16f6e 100644 --- a/generated/stripe_shared/src/period.rs +++ b/generated/stripe_shared/src/period.rs @@ -1,7 +1,95 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// The start date of this usage period. All usage after this point in time is included. pub start: Option, } +#[doc(hidden)] +pub struct PeriodBuilder { + end: Option>, + start: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PeriodBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { end: Deserialize::default(), start: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { end: self.end?, start: self.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 { + 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..687ed150a 100644 --- a/generated/stripe_shared/src/person.rs +++ b/generated/stripe_shared/src/person.rs @@ -6,94 +6,392 @@ /// Related guide: [Handling identity verification with the API](https://stripe.com/docs/connect/handling-api-verification#person-information). /// /// For more details see <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Person { /// The account the person is associated with. - #[serde(skip_serializing_if = "Option::is_none")] pub account: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub additional_tos_acceptances: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub address: Option, /// The Kana variation of the person's address (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub address_kana: Option, /// The Kanji variation of the person's address (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub address_kanji: Option, /// 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, /// The person's email address. - #[serde(skip_serializing_if = "Option::is_none")] pub email: Option, /// The person's first name. - #[serde(skip_serializing_if = "Option::is_none")] pub first_name: Option, /// The Kana variation of the person's first name (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub first_name_kana: Option, /// The Kanji variation of the person's first name (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub first_name_kanji: Option, /// 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>, /// 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, /// The person's gender (International regulations require either "male" or "female"). - #[serde(skip_serializing_if = "Option::is_none")] pub gender: Option, /// 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, /// Whether the person's `id_number_secondary` was provided. - #[serde(skip_serializing_if = "Option::is_none")] pub id_number_secondary_provided: Option, /// The person's last name. - #[serde(skip_serializing_if = "Option::is_none")] pub last_name: Option, /// The Kana variation of the person's last name (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub last_name_kana: Option, /// The Kanji variation of the person's last name (Japan only). - #[serde(skip_serializing_if = "Option::is_none")] pub last_name_kanji: Option, /// The person's maiden name. - #[serde(skip_serializing_if = "Option::is_none")] pub maiden_name: Option, /// 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>, /// The country where the person is a national. - #[serde(skip_serializing_if = "Option::is_none")] pub nationality: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: PersonObject, /// The person's phone number. - #[serde(skip_serializing_if = "Option::is_none")] pub phone: Option, /// 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, - #[serde(skip_serializing_if = "Option::is_none")] pub registered_address: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub relationship: Option, /// 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, /// 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, - #[serde(skip_serializing_if = "Option::is_none")] pub verification: Option, } +#[doc(hidden)] +pub struct PersonBuilder { + account: Option>, + additional_tos_acceptances: Option>, + address: Option>, + address_kana: Option>, + address_kanji: Option>, + created: Option, + dob: Option>, + email: Option>, + first_name: Option>, + first_name_kana: Option>, + first_name_kanji: Option>, + full_name_aliases: Option>>, + future_requirements: Option>, + gender: Option>, + id: Option, + id_number_provided: Option>, + id_number_secondary_provided: Option>, + last_name: Option>, + last_name_kana: Option>, + last_name_kanji: Option>, + maiden_name: Option>, + metadata: Option>>, + nationality: Option>, + object: Option, + phone: Option>, + political_exposure: Option>, + registered_address: Option>, + relationship: Option>, + requirements: Option>, + ssn_last_4_provided: Option>, + verification: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PersonBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + account: self.account.take()?, + additional_tos_acceptances: self.additional_tos_acceptances.take()?, + address: self.address.take()?, + address_kana: self.address_kana.take()?, + address_kanji: self.address_kanji.take()?, + created: self.created?, + dob: self.dob?, + email: self.email.take()?, + first_name: self.first_name.take()?, + first_name_kana: self.first_name_kana.take()?, + first_name_kanji: self.first_name_kanji.take()?, + full_name_aliases: self.full_name_aliases.take()?, + future_requirements: self.future_requirements.take()?, + gender: self.gender.take()?, + id: self.id.take()?, + id_number_provided: self.id_number_provided?, + id_number_secondary_provided: self.id_number_secondary_provided?, + last_name: self.last_name.take()?, + last_name_kana: self.last_name_kana.take()?, + last_name_kanji: self.last_name_kanji.take()?, + maiden_name: self.maiden_name.take()?, + metadata: self.metadata.take()?, + nationality: self.nationality.take()?, + object: self.object?, + phone: self.phone.take()?, + political_exposure: self.political_exposure?, + registered_address: self.registered_address.take()?, + relationship: self.relationship.take()?, + requirements: self.requirements.take()?, + ssn_last_4_provided: self.ssn_last_4_provided?, + verification: self.verification.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum PersonObject { + Person, +} +impl PersonObject { + pub fn as_str(self) -> &'static str { + use PersonObject::*; + match self { + Person => "person", + } + } +} + +impl std::str::FromStr for PersonObject { + type Err = (); + fn from_str(s: &str) -> Result { + use PersonObject::*; + match s { + "person" => Ok(Person), + _ => Err(()), + } + } +} +impl std::fmt::Display for PersonObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for PersonObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for PersonObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for PersonObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PersonObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PersonObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for PersonObject { + fn deserialize>(deserializer: D) -> 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 PersonObject")) + } +} /// 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 { @@ -132,6 +430,7 @@ impl std::fmt::Debug for PersonPoliticalExposure { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for PersonPoliticalExposure { fn serialize(&self, serializer: S) -> Result where @@ -140,6 +439,22 @@ impl serde::Serialize for PersonPoliticalExposure { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PersonPoliticalExposure { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PersonPoliticalExposure::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PersonPoliticalExposure); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PersonPoliticalExposure { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/person_additional_tos_acceptance.rs b/generated/stripe_shared/src/person_additional_tos_acceptance.rs index e0d67e184..795a31852 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PersonAdditionalTosAcceptance { /// The Unix timestamp marking when the legal guardian accepted the service agreement. pub date: Option, @@ -7,3 +9,103 @@ pub struct PersonAdditionalTosAcceptance { /// The user agent of the browser from which the legal guardian accepted the service agreement. pub user_agent: Option, } +#[doc(hidden)] +pub struct PersonAdditionalTosAcceptanceBuilder { + date: Option>, + ip: Option>, + user_agent: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PersonAdditionalTosAcceptanceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + date: Deserialize::default(), + ip: Deserialize::default(), + user_agent: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + date: self.date?, + ip: self.ip.take()?, + user_agent: self.user_agent.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..fd58ca32a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PersonAdditionalTosAcceptances { pub account: stripe_shared::PersonAdditionalTosAcceptance, } +#[doc(hidden)] +pub struct PersonAdditionalTosAcceptancesBuilder { + account: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PersonAdditionalTosAcceptancesBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { account: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { account: self.account.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..0984af9f9 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PersonFutureRequirements { /// Fields that are due and can be satisfied by providing the corresponding alternative fields instead. pub alternatives: Option>, @@ -19,3 +21,120 @@ pub struct PersonFutureRequirements { /// If verification fails, these fields move to `eventually_due` or `currently_due`. pub pending_verification: Vec, } +#[doc(hidden)] +pub struct PersonFutureRequirementsBuilder { + alternatives: Option>>, + currently_due: Option>, + errors: Option>, + eventually_due: Option>, + past_due: Option>, + pending_verification: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PersonFutureRequirementsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + alternatives: self.alternatives.take()?, + currently_due: self.currently_due.take()?, + errors: self.errors.take()?, + eventually_due: self.eventually_due.take()?, + past_due: self.past_due.take()?, + pending_verification: self.pending_verification.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..3b0c8fa63 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,123 @@ pub struct PersonRelationship { /// The person's title (e.g., CEO, Support Engineer). pub title: Option, } +#[doc(hidden)] +pub struct PersonRelationshipBuilder { + director: Option>, + executive: Option>, + legal_guardian: Option>, + owner: Option>, + percent_ownership: Option>, + representative: Option>, + title: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PersonRelationshipBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + director: self.director?, + executive: self.executive?, + legal_guardian: self.legal_guardian?, + owner: self.owner?, + percent_ownership: self.percent_ownership?, + representative: self.representative?, + title: self.title.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..a80bf077d 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PersonRequirements { /// Fields that are due and can be satisfied by providing the corresponding alternative fields instead. pub alternatives: Option>, @@ -18,3 +20,120 @@ pub struct PersonRequirements { /// If verification fails, these fields move to `eventually_due`, `currently_due`, or `past_due`. pub pending_verification: Vec, } +#[doc(hidden)] +pub struct PersonRequirementsBuilder { + alternatives: Option>>, + currently_due: Option>, + errors: Option>, + eventually_due: Option>, + past_due: Option>, + pending_verification: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PersonRequirementsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + alternatives: self.alternatives.take()?, + currently_due: self.currently_due.take()?, + errors: self.errors.take()?, + eventually_due: self.eventually_due.take()?, + past_due: self.past_due.take()?, + pending_verification: self.pending_verification.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..401b64058 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Plan { /// Whether the plan can be used for new purchases. pub active: bool, @@ -49,12 +51,13 @@ pub struct Plan { pub metadata: Option>, /// A brief description of the plan, hidden from customers. pub nickname: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: PlanObject, /// The product whose pricing this plan determines. pub product: Option>, /// 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>, /// 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 +75,255 @@ pub struct Plan { /// Defaults to `licensed`. pub usage_type: stripe_shared::PlanUsageType, } +#[doc(hidden)] +pub struct PlanBuilder { + active: Option, + aggregate_usage: Option>, + amount: Option>, + amount_decimal: Option>, + billing_scheme: Option, + created: Option, + currency: Option, + id: Option, + interval: Option, + interval_count: Option, + livemode: Option, + metadata: Option>>, + nickname: Option>, + object: Option, + product: Option>>, + tiers: Option>>, + tiers_mode: Option>, + transform_usage: Option>, + trial_period_days: Option>, + usage_type: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PlanBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + active: self.active?, + aggregate_usage: self.aggregate_usage?, + amount: self.amount?, + amount_decimal: self.amount_decimal.take()?, + billing_scheme: self.billing_scheme?, + created: self.created?, + currency: self.currency?, + id: self.id.take()?, + interval: self.interval?, + interval_count: self.interval_count?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + nickname: self.nickname.take()?, + object: self.object?, + product: self.product.take()?, + tiers: self.tiers.take()?, + tiers_mode: self.tiers_mode?, + transform_usage: self.transform_usage?, + trial_period_days: self.trial_period_days?, + usage_type: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum PlanObject { + Plan, +} +impl PlanObject { + pub fn as_str(self) -> &'static str { + use PlanObject::*; + match self { + Plan => "plan", + } + } +} + +impl std::str::FromStr for PlanObject { + type Err = (); + fn from_str(s: &str) -> Result { + use PlanObject::*; + match s { + "plan" => Ok(Plan), + _ => Err(()), + } + } +} +impl std::fmt::Display for PlanObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for PlanObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for PlanObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for PlanObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PlanObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PlanObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for PlanObject { + fn deserialize>(deserializer: D) -> 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 PlanObject")) + } +} impl stripe_types::Object for Plan { type Id = stripe_shared::PlanId; fn id(&self) -> &Self::Id { @@ -130,6 +382,22 @@ impl serde::Serialize for PlanAggregateUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PlanAggregateUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PlanAggregateUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PlanAggregateUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PlanAggregateUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -183,6 +451,22 @@ impl serde::Serialize for PlanBillingScheme { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PlanBillingScheme { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PlanBillingScheme::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PlanBillingScheme); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PlanBillingScheme { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -242,6 +526,22 @@ impl serde::Serialize for PlanInterval { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PlanInterval { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PlanInterval::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PlanInterval); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PlanInterval { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -294,6 +594,22 @@ impl serde::Serialize for PlanTiersMode { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PlanTiersMode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PlanTiersMode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PlanTiersMode); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PlanTiersMode { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -346,6 +662,22 @@ impl serde::Serialize for PlanUsageType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PlanUsageType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PlanUsageType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PlanUsageType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PlanUsageType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/plan_tier.rs b/generated/stripe_shared/src/plan_tier.rs index ad338db35..a495f10d6 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PlanTier { /// Price for the entire tier. pub flat_amount: Option, @@ -11,3 +13,114 @@ pub struct PlanTier { /// Up to and including to this quantity will be contained in the tier. pub up_to: Option, } +#[doc(hidden)] +pub struct PlanTierBuilder { + flat_amount: Option>, + flat_amount_decimal: Option>, + unit_amount: Option>, + unit_amount_decimal: Option>, + up_to: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PlanTierBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + flat_amount: self.flat_amount?, + flat_amount_decimal: self.flat_amount_decimal.take()?, + unit_amount: self.unit_amount?, + unit_amount_decimal: self.unit_amount_decimal.take()?, + up_to: self.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 { + 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..002745f1d 100644 --- a/generated/stripe_shared/src/platform_tax_fee.rs +++ b/generated/stripe_shared/src/platform_tax_fee.rs @@ -1,15 +1,199 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PlatformTaxFee { /// The Connected account that incurred this charge. pub account: String, /// Unique identifier for the object. pub id: stripe_shared::PlatformTaxFeeId, + /// String representing the object's type. Objects of the same type share the same value. + pub object: PlatformTaxFeeObject, /// The payment object that caused this tax to be inflicted. pub source_transaction: String, /// The type of tax (VAT). - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: String, } +#[doc(hidden)] +pub struct PlatformTaxFeeBuilder { + account: Option, + id: Option, + object: Option, + source_transaction: Option, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PlatformTaxFeeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "source_transaction" => Deserialize::begin(&mut self.source_transaction), + "type" => Deserialize::begin(&mut self.type_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + source_transaction: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account: self.account.take()?, + id: self.id.take()?, + object: self.object?, + source_transaction: self.source_transaction.take()?, + type_: self.type_.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum PlatformTaxFeeObject { + PlatformTaxFee, +} +impl PlatformTaxFeeObject { + pub fn as_str(self) -> &'static str { + use PlatformTaxFeeObject::*; + match self { + PlatformTaxFee => "platform_tax_fee", + } + } +} + +impl std::str::FromStr for PlatformTaxFeeObject { + type Err = (); + fn from_str(s: &str) -> Result { + use PlatformTaxFeeObject::*; + match s { + "platform_tax_fee" => Ok(PlatformTaxFee), + _ => Err(()), + } + } +} +impl std::fmt::Display for PlatformTaxFeeObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for PlatformTaxFeeObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for PlatformTaxFeeObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for PlatformTaxFeeObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PlatformTaxFeeObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PlatformTaxFeeObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for PlatformTaxFeeObject { + fn deserialize>(deserializer: D) -> 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 PlatformTaxFeeObject")) + } +} 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..6cacbcbbe 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Price { /// Whether the price can be used for new purchases. pub active: bool, @@ -24,7 +26,6 @@ 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>, /// When set, provides configuration for the amount to be adjusted by the customer during Checkout Sessions and Payment Links. @@ -41,6 +42,8 @@ pub struct Price { pub metadata: std::collections::HashMap, /// A brief description of the price, hidden from customers. pub nickname: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: PriceObject, /// The ID of the product this price is associated with. pub product: stripe_types::Expandable, /// The recurring components of a price such as `interval` and `usage_type`. @@ -53,7 +56,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>, /// 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 +65,7 @@ pub struct Price { /// Cannot be combined with `tiers`. pub transform_quantity: Option, /// 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(feature = "serde", 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 +74,268 @@ pub struct Price { /// Only set if `billing_scheme=per_unit`. pub unit_amount_decimal: Option, } +#[doc(hidden)] +pub struct PriceBuilder { + active: Option, + billing_scheme: Option, + created: Option, + currency: Option, + currency_options: Option< + Option>, + >, + custom_unit_amount: Option>, + id: Option, + livemode: Option, + lookup_key: Option>, + metadata: Option>, + nickname: Option>, + object: Option, + product: Option>, + recurring: Option>, + tax_behavior: Option>, + tiers: Option>>, + tiers_mode: Option>, + transform_quantity: Option>, + type_: Option, + unit_amount: Option>, + unit_amount_decimal: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PriceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + active: self.active?, + billing_scheme: self.billing_scheme?, + created: self.created?, + currency: self.currency?, + currency_options: self.currency_options.take()?, + custom_unit_amount: self.custom_unit_amount?, + id: self.id.take()?, + livemode: self.livemode?, + lookup_key: self.lookup_key.take()?, + metadata: self.metadata.take()?, + nickname: self.nickname.take()?, + object: self.object?, + product: self.product.take()?, + recurring: self.recurring?, + tax_behavior: self.tax_behavior?, + tiers: self.tiers.take()?, + tiers_mode: self.tiers_mode?, + transform_quantity: self.transform_quantity?, + type_: self.type_?, + unit_amount: self.unit_amount?, + unit_amount_decimal: self.unit_amount_decimal.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum PriceObject { + Price, +} +impl PriceObject { + pub fn as_str(self) -> &'static str { + use PriceObject::*; + match self { + Price => "price", + } + } +} + +impl std::str::FromStr for PriceObject { + type Err = (); + fn from_str(s: &str) -> Result { + use PriceObject::*; + match s { + "price" => Ok(Price), + _ => Err(()), + } + } +} +impl std::fmt::Display for PriceObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for PriceObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for PriceObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for PriceObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PriceObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PriceObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for PriceObject { + fn deserialize>(deserializer: D) -> 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 PriceObject")) + } +} impl stripe_types::Object for Price { type Id = stripe_shared::PriceId; fn id(&self) -> &Self::Id { @@ -124,6 +388,22 @@ impl serde::Serialize for PriceBillingScheme { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PriceBillingScheme { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PriceBillingScheme::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PriceBillingScheme); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PriceBillingScheme { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -180,6 +460,22 @@ impl serde::Serialize for PriceTaxBehavior { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PriceTaxBehavior { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PriceTaxBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PriceTaxBehavior); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PriceTaxBehavior { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -233,6 +529,22 @@ impl serde::Serialize for PriceTiersMode { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PriceTiersMode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PriceTiersMode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PriceTiersMode); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PriceTiersMode { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -285,6 +597,22 @@ impl serde::Serialize for PriceType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for PriceType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PriceType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PriceType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for PriceType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/price_tier.rs b/generated/stripe_shared/src/price_tier.rs index 6cd47e0a1..1ff68fd25 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PriceTier { /// Price for the entire tier. pub flat_amount: Option, @@ -11,3 +13,114 @@ pub struct PriceTier { /// Up to and including to this quantity will be contained in the tier. pub up_to: Option, } +#[doc(hidden)] +pub struct PriceTierBuilder { + flat_amount: Option>, + flat_amount_decimal: Option>, + unit_amount: Option>, + unit_amount_decimal: Option>, + up_to: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PriceTierBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + flat_amount: self.flat_amount?, + flat_amount_decimal: self.flat_amount_decimal.take()?, + unit_amount: self.unit_amount?, + unit_amount_decimal: self.unit_amount_decimal.take()?, + up_to: self.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 { + 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..5e9a63ddb 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, /// 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. @@ -34,29 +35,277 @@ pub struct Product { pub metadata: std::collections::HashMap, /// The product's name, meant to be displayable to the customer. pub name: String, + /// String representing the object's type. Objects of the same type share the same value. + pub object: ProductObject, /// The dimensions of this product for shipping purposes. pub package_dimensions: Option, /// Whether this product is shipped (i.e., physical goods). pub shippable: Option, /// 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, /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID. pub tax_code: Option>, /// 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(feature = "serde", 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, /// 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, } +#[doc(hidden)] +pub struct ProductBuilder { + active: Option, + created: Option, + default_price: Option>>, + description: Option>, + features: Option>, + id: Option, + images: Option>, + livemode: Option, + metadata: Option>, + name: Option, + object: Option, + package_dimensions: Option>, + shippable: Option>, + statement_descriptor: Option>, + tax_code: Option>>, + type_: Option, + unit_label: Option>, + updated: Option, + url: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ProductBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + active: self.active?, + created: self.created?, + default_price: self.default_price.take()?, + description: self.description.take()?, + features: self.features.take()?, + id: self.id.take()?, + images: self.images.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + name: self.name.take()?, + object: self.object?, + package_dimensions: self.package_dimensions?, + shippable: self.shippable?, + statement_descriptor: self.statement_descriptor.take()?, + tax_code: self.tax_code.take()?, + type_: self.type_?, + unit_label: self.unit_label.take()?, + updated: self.updated?, + url: self.url.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ProductObject { + Product, +} +impl ProductObject { + pub fn as_str(self) -> &'static str { + use ProductObject::*; + match self { + Product => "product", + } + } +} + +impl std::str::FromStr for ProductObject { + type Err = (); + fn from_str(s: &str) -> Result { + use ProductObject::*; + match s { + "product" => Ok(Product), + _ => Err(()), + } + } +} +impl std::fmt::Display for ProductObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ProductObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for ProductObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for ProductObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ProductObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ProductObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ProductObject { + fn deserialize>(deserializer: D) -> 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 ProductObject")) + } +} impl stripe_types::Object for Product { type Id = stripe_shared::ProductId; fn id(&self) -> &Self::Id { @@ -109,6 +358,22 @@ impl serde::Serialize for ProductType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ProductType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ProductType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ProductType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ProductType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/product_feature.rs b/generated/stripe_shared/src/product_feature.rs index 996e4221e..c50a5cb57 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ProductFeature { /// The feature's name. Up to 80 characters long. - #[serde(skip_serializing_if = "Option::is_none")] pub name: Option, } +#[doc(hidden)] +pub struct ProductFeatureBuilder { + name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ProductFeatureBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { name: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { name: self.name.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..087e198f4 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct PromotionCode { /// Whether the promotion code is currently active. /// A promotion code is only active if the coupon is also valid. @@ -27,10 +29,230 @@ pub struct PromotionCode { /// 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>, + /// String representing the object's type. Objects of the same type share the same value. + pub object: PromotionCodeObject, pub restrictions: stripe_shared::PromotionCodesResourceRestrictions, /// Number of times this promotion code has been used. pub times_redeemed: i64, } +#[doc(hidden)] +pub struct PromotionCodeBuilder { + active: Option, + code: Option, + coupon: Option, + created: Option, + customer: Option>>, + expires_at: Option>, + id: Option, + livemode: Option, + max_redemptions: Option>, + metadata: Option>>, + object: Option, + restrictions: Option, + times_redeemed: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PromotionCodeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "restrictions" => Deserialize::begin(&mut self.restrictions), + "times_redeemed" => Deserialize::begin(&mut self.times_redeemed), + + _ => ::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(), + object: Deserialize::default(), + restrictions: Deserialize::default(), + times_redeemed: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + active: self.active?, + code: self.code.take()?, + coupon: self.coupon.take()?, + created: self.created?, + customer: self.customer.take()?, + expires_at: self.expires_at?, + id: self.id.take()?, + livemode: self.livemode?, + max_redemptions: self.max_redemptions?, + metadata: self.metadata.take()?, + object: self.object?, + restrictions: self.restrictions.take()?, + times_redeemed: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum PromotionCodeObject { + PromotionCode, +} +impl PromotionCodeObject { + pub fn as_str(self) -> &'static str { + use PromotionCodeObject::*; + match self { + PromotionCode => "promotion_code", + } + } +} + +impl std::str::FromStr for PromotionCodeObject { + type Err = (); + fn from_str(s: &str) -> Result { + use PromotionCodeObject::*; + match s { + "promotion_code" => Ok(PromotionCode), + _ => Err(()), + } + } +} +impl std::fmt::Display for PromotionCodeObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for PromotionCodeObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for PromotionCodeObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for PromotionCodeObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(PromotionCodeObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(PromotionCodeObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for PromotionCodeObject { + fn deserialize>(deserializer: D) -> 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 PromotionCodeObject")) + } +} 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..1bc115730 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct PromotionCodeCurrencyOptionBuilder { + minimum_amount: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PromotionCodeCurrencyOptionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { minimum_amount: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { minimum_amount: self.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 { + 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..faef0b140 100644 --- a/generated/stripe_shared/src/promotion_codes_resource_restrictions.rs +++ b/generated/stripe_shared/src/promotion_codes_resource_restrictions.rs @@ -1,8 +1,9 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -16,3 +17,119 @@ pub struct PromotionCodesResourceRestrictions { /// Three-letter [ISO code](https://stripe.com/docs/currencies) for minimum_amount pub minimum_amount_currency: Option, } +#[doc(hidden)] +pub struct PromotionCodesResourceRestrictionsBuilder { + currency_options: Option< + Option< + std::collections::HashMap< + stripe_types::Currency, + stripe_shared::PromotionCodeCurrencyOption, + >, + >, + >, + first_time_transaction: Option, + minimum_amount: Option>, + minimum_amount_currency: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: PromotionCodesResourceRestrictionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + currency_options: self.currency_options.take()?, + first_time_transaction: self.first_time_transaction?, + minimum_amount: self.minimum_amount?, + minimum_amount_currency: self.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 { + 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..62b96e749 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, /// The tax rates applied to this quote. - #[serde(skip_serializing_if = "Option::is_none")] pub default_tax_rates: Option>>, /// A description that will be displayed on the quote PDF. pub description: Option, @@ -56,7 +57,6 @@ pub struct Quote { pub invoice: Option>, pub invoice_settings: stripe_shared::InvoiceSettingQuoteSetting, /// A list of items the customer is being quoted for. - #[serde(skip_serializing_if = "Option::is_none")] pub line_items: Option>, /// 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, @@ -66,6 +66,8 @@ pub struct Quote { /// A unique number that identifies this particular quote. /// This number is assigned once the quote is [finalized](https://stripe.com/docs/quotes/overview#finalize). pub number: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: QuoteObject, /// The account on behalf of which to charge. /// See the [Connect documentation](https://support.stripe.com/questions/sending-invoices-on-behalf-of-connected-accounts) for details. pub on_behalf_of: Option>, @@ -84,6 +86,339 @@ pub struct Quote { /// 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, } +#[doc(hidden)] +pub struct QuoteBuilder { + amount_subtotal: Option, + amount_total: Option, + application: Option>>, + application_fee_amount: Option>, + application_fee_percent: Option>, + automatic_tax: Option, + collection_method: Option, + computed: Option, + created: Option, + currency: Option>, + customer: Option>>, + default_tax_rates: Option>>>, + description: Option>, + discounts: Option>>, + expires_at: Option, + footer: Option>, + from_quote: Option>, + header: Option>, + id: Option, + invoice: Option>>, + invoice_settings: Option, + line_items: Option>>, + livemode: Option, + metadata: Option>, + number: Option>, + object: Option, + on_behalf_of: Option>>, + status: Option, + status_transitions: Option, + subscription: Option>>, + subscription_data: Option, + subscription_schedule: + Option>>, + test_clock: Option>>, + total_details: Option, + transfer_data: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: QuoteBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + amount_subtotal: self.amount_subtotal?, + amount_total: self.amount_total?, + application: self.application.take()?, + application_fee_amount: self.application_fee_amount?, + application_fee_percent: self.application_fee_percent?, + automatic_tax: self.automatic_tax.take()?, + collection_method: self.collection_method?, + computed: self.computed.take()?, + created: self.created?, + currency: self.currency?, + customer: self.customer.take()?, + default_tax_rates: self.default_tax_rates.take()?, + description: self.description.take()?, + discounts: self.discounts.take()?, + expires_at: self.expires_at?, + footer: self.footer.take()?, + from_quote: self.from_quote.take()?, + header: self.header.take()?, + id: self.id.take()?, + invoice: self.invoice.take()?, + invoice_settings: self.invoice_settings.take()?, + line_items: self.line_items.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + number: self.number.take()?, + object: self.object?, + on_behalf_of: self.on_behalf_of.take()?, + status: self.status?, + status_transitions: self.status_transitions?, + subscription: self.subscription.take()?, + subscription_data: self.subscription_data.take()?, + subscription_schedule: self.subscription_schedule.take()?, + test_clock: self.test_clock.take()?, + total_details: self.total_details.take()?, + transfer_data: self.transfer_data.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum QuoteObject { + Quote, +} +impl QuoteObject { + pub fn as_str(self) -> &'static str { + use QuoteObject::*; + match self { + Quote => "quote", + } + } +} + +impl std::str::FromStr for QuoteObject { + type Err = (); + fn from_str(s: &str) -> Result { + use QuoteObject::*; + match s { + "quote" => Ok(Quote), + _ => Err(()), + } + } +} +impl std::fmt::Display for QuoteObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for QuoteObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for QuoteObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for QuoteObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(QuoteObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(QuoteObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for QuoteObject { + fn deserialize>(deserializer: D) -> 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 QuoteObject")) + } +} impl stripe_types::Object for Quote { type Id = stripe_shared::QuoteId; fn id(&self) -> &Self::Id { @@ -136,6 +471,22 @@ impl serde::Serialize for QuoteCollectionMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for QuoteCollectionMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(QuoteCollectionMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(QuoteCollectionMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for QuoteCollectionMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -195,6 +546,22 @@ impl serde::Serialize for QuoteStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for QuoteStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(QuoteStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(QuoteStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for QuoteStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/quotes_resource_automatic_tax.rs b/generated/stripe_shared/src/quotes_resource_automatic_tax.rs index 4b16b7111..e1bb0ef91 100644 --- a/generated/stripe_shared/src/quotes_resource_automatic_tax.rs +++ b/generated/stripe_shared/src/quotes_resource_automatic_tax.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct QuotesResourceAutomaticTax { /// Automatically calculate taxes pub enabled: bool, @@ -9,6 +11,106 @@ pub struct QuotesResourceAutomaticTax { /// The status of the most recent automated tax calculation for this quote. pub status: Option, } +#[doc(hidden)] +pub struct QuotesResourceAutomaticTaxBuilder { + enabled: Option, + liability: Option>, + status: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: QuotesResourceAutomaticTaxBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "liability" => Deserialize::begin(&mut self.liability), + "status" => Deserialize::begin(&mut self.status), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + enabled: Deserialize::default(), + liability: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + enabled: self.enabled?, + liability: self.liability.take()?, + status: self.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 { + 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)?), + "liability" => b.liability = 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 { @@ -50,6 +152,7 @@ impl std::fmt::Debug for QuotesResourceAutomaticTaxStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for QuotesResourceAutomaticTaxStatus { fn serialize(&self, serializer: S) -> Result where @@ -58,6 +161,23 @@ impl serde::Serialize for QuotesResourceAutomaticTaxStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for QuotesResourceAutomaticTaxStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(QuotesResourceAutomaticTaxStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(QuotesResourceAutomaticTaxStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for QuotesResourceAutomaticTaxStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/quotes_resource_computed.rs b/generated/stripe_shared/src/quotes_resource_computed.rs index 45192eec7..b2bdfbbea 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,92 @@ pub struct QuotesResourceComputed { pub recurring: Option, pub upfront: stripe_shared::QuotesResourceUpfront, } +#[doc(hidden)] +pub struct QuotesResourceComputedBuilder { + recurring: Option>, + upfront: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: QuotesResourceComputedBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { recurring: Deserialize::default(), upfront: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { recurring: self.recurring.take()?, upfront: self.upfront.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..b3eda24c2 100644 --- a/generated/stripe_shared/src/quotes_resource_from_quote.rs +++ b/generated/stripe_shared/src/quotes_resource_from_quote.rs @@ -1,7 +1,98 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct QuotesResourceFromQuoteBuilder { + is_revision: Option, + quote: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: QuotesResourceFromQuoteBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { is_revision: Deserialize::default(), quote: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { is_revision: self.is_revision?, quote: self.quote.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..f9db7cc08 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct QuotesResourceRecurring { /// Total before any discounts or taxes are applied. pub amount_subtotal: i64, @@ -11,6 +13,116 @@ pub struct QuotesResourceRecurring { pub interval_count: u64, pub total_details: stripe_shared::QuotesResourceTotalDetails, } +#[doc(hidden)] +pub struct QuotesResourceRecurringBuilder { + amount_subtotal: Option, + amount_total: Option, + interval: Option, + interval_count: Option, + total_details: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: QuotesResourceRecurringBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount_subtotal: self.amount_subtotal?, + amount_total: self.amount_total?, + interval: self.interval?, + interval_count: self.interval_count?, + total_details: self.total_details.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -55,6 +167,7 @@ impl std::fmt::Debug for QuotesResourceRecurringInterval { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for QuotesResourceRecurringInterval { fn serialize(&self, serializer: S) -> Result where @@ -63,6 +176,23 @@ impl serde::Serialize for QuotesResourceRecurringInterval { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for QuotesResourceRecurringInterval { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(QuotesResourceRecurringInterval::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(QuotesResourceRecurringInterval); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for QuotesResourceRecurringInterval { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/quotes_resource_status_transitions.rs b/generated/stripe_shared/src/quotes_resource_status_transitions.rs index 2e7f6345c..e408461dd 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct QuotesResourceStatusTransitions { /// The time that the quote was accepted. Measured in seconds since Unix epoch. pub accepted_at: Option, @@ -7,3 +9,103 @@ pub struct QuotesResourceStatusTransitions { /// The time that the quote was finalized. Measured in seconds since Unix epoch. pub finalized_at: Option, } +#[doc(hidden)] +pub struct QuotesResourceStatusTransitionsBuilder { + accepted_at: Option>, + canceled_at: Option>, + finalized_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: QuotesResourceStatusTransitionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + accepted_at: Deserialize::default(), + canceled_at: Deserialize::default(), + finalized_at: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + accepted_at: self.accepted_at?, + canceled_at: self.canceled_at?, + finalized_at: self.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 { + 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..427da17fd 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,108 @@ 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, } +#[doc(hidden)] +pub struct QuotesResourceSubscriptionDataSubscriptionDataBuilder { + description: Option>, + effective_date: Option>, + metadata: Option>>, + trial_period_days: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: QuotesResourceSubscriptionDataSubscriptionDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + description: self.description.take()?, + effective_date: self.effective_date?, + metadata: self.metadata.take()?, + trial_period_days: self.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 { + 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..216686a9c 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct QuotesResourceTotalDetails { /// This is the sum of all the discounts. pub amount_discount: i64, @@ -6,6 +8,110 @@ pub struct QuotesResourceTotalDetails { pub amount_shipping: Option, /// This is the sum of all the tax amounts. pub amount_tax: i64, - #[serde(skip_serializing_if = "Option::is_none")] pub breakdown: Option, } +#[doc(hidden)] +pub struct QuotesResourceTotalDetailsBuilder { + amount_discount: Option, + amount_shipping: Option>, + amount_tax: Option, + breakdown: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: QuotesResourceTotalDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount_discount: self.amount_discount?, + amount_shipping: self.amount_shipping?, + amount_tax: self.amount_tax?, + breakdown: self.breakdown.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..de7838deb 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,98 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct QuotesResourceTotalDetailsResourceBreakdown { /// The aggregated discounts. pub discounts: Vec, /// The aggregated tax amounts by rate. pub taxes: Vec, } +#[doc(hidden)] +pub struct QuotesResourceTotalDetailsResourceBreakdownBuilder { + discounts: Option>, + taxes: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: QuotesResourceTotalDetailsResourceBreakdownBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { discounts: Deserialize::default(), taxes: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { discounts: self.discounts.take()?, taxes: self.taxes.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..54932bf8f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,103 @@ pub struct QuotesResourceTransferData { /// The account where funds from the payment will be transferred to upon payment success. pub destination: stripe_types::Expandable, } +#[doc(hidden)] +pub struct QuotesResourceTransferDataBuilder { + amount: Option>, + amount_percent: Option>, + destination: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: QuotesResourceTransferDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + amount_percent: Deserialize::default(), + destination: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + amount_percent: self.amount_percent?, + destination: self.destination.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..4b171e784 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct QuotesResourceUpfront { /// Total before any discounts or taxes are applied. pub amount_subtotal: i64, @@ -6,7 +8,111 @@ 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>, pub total_details: stripe_shared::QuotesResourceTotalDetails, } +#[doc(hidden)] +pub struct QuotesResourceUpfrontBuilder { + amount_subtotal: Option, + amount_total: Option, + line_items: Option>>, + total_details: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: QuotesResourceUpfrontBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount_subtotal: self.amount_subtotal?, + amount_total: self.amount_total?, + line_items: self.line_items.take()?, + total_details: self.total_details.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..5ec8dc6d9 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct RadarRadarOptionsBuilder { + session: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: RadarRadarOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { session: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { session: self.session.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..765379b93 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct RadarReviewResourceLocation { /// The city where the payment originated. pub city: Option, @@ -11,3 +13,113 @@ pub struct RadarReviewResourceLocation { /// The state/county/province/region where the payment originated. pub region: Option, } +#[doc(hidden)] +pub struct RadarReviewResourceLocationBuilder { + city: Option>, + country: Option>, + latitude: Option>, + longitude: Option>, + region: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: RadarReviewResourceLocationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + city: self.city.take()?, + country: self.country.take()?, + latitude: self.latitude?, + longitude: self.longitude?, + region: self.region.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..7a1ceceb2 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct RadarReviewResourceSession { /// The browser used in this browser session (e.g., `Chrome`). pub browser: Option, @@ -9,3 +11,108 @@ pub struct RadarReviewResourceSession { /// The version for the browser session (e.g., `61.0.3163.100`). pub version: Option, } +#[doc(hidden)] +pub struct RadarReviewResourceSessionBuilder { + browser: Option>, + device: Option>, + platform: Option>, + version: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: RadarReviewResourceSessionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + browser: Deserialize::default(), + device: Deserialize::default(), + platform: Deserialize::default(), + version: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + browser: self.browser.take()?, + device: self.device.take()?, + platform: self.platform.take()?, + version: self.version.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..ae6a4e2ef 100644 --- a/generated/stripe_shared/src/recurring.rs +++ b/generated/stripe_shared/src/recurring.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Recurring { /// Specifies a usage aggregation strategy for prices of `usage_type=metered`. Defaults to `sum`. pub aggregate_usage: Option, @@ -16,6 +18,113 @@ pub struct Recurring { /// Defaults to `licensed`. pub usage_type: RecurringUsageType, } +#[doc(hidden)] +pub struct RecurringBuilder { + aggregate_usage: Option>, + interval: Option, + interval_count: Option, + trial_period_days: Option>, + usage_type: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: RecurringBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + aggregate_usage: self.aggregate_usage?, + interval: self.interval?, + interval_count: self.interval_count?, + trial_period_days: self.trial_period_days?, + usage_type: self.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 { + 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`. Defaults to `sum`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum RecurringAggregateUsage { @@ -60,6 +169,7 @@ impl std::fmt::Debug for RecurringAggregateUsage { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for RecurringAggregateUsage { fn serialize(&self, serializer: S) -> Result where @@ -68,6 +178,22 @@ impl serde::Serialize for RecurringAggregateUsage { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for RecurringAggregateUsage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(RecurringAggregateUsage::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(RecurringAggregateUsage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for RecurringAggregateUsage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -120,6 +246,7 @@ impl std::fmt::Debug for RecurringInterval { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for RecurringInterval { fn serialize(&self, serializer: S) -> Result where @@ -128,6 +255,22 @@ impl serde::Serialize for RecurringInterval { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for RecurringInterval { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(RecurringInterval::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(RecurringInterval); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for RecurringInterval { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -178,6 +321,7 @@ impl std::fmt::Debug for RecurringUsageType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for RecurringUsageType { fn serialize(&self, serializer: S) -> Result where @@ -186,6 +330,22 @@ impl serde::Serialize for RecurringUsageType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for RecurringUsageType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(RecurringUsageType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(RecurringUsageType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for RecurringUsageType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/refund.rs b/generated/stripe_shared/src/refund.rs index c48c33369..4d7fcbd6d 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Refund { /// Amount, in cents (or local equivalent). pub amount: i64, @@ -20,28 +22,24 @@ 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, - #[serde(skip_serializing_if = "Option::is_none")] pub destination_details: Option, /// 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>, /// 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, /// 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, /// 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>, - #[serde(skip_serializing_if = "Option::is_none")] pub next_action: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: RefundObject, /// ID of the PaymentIntent that's refunded. pub payment_intent: Option>, /// Reason for the refund, which is either user-provided (`duplicate`, `fraudulent`, or `requested_by_customer`) or generated by Stripe internally (`expired_uncaptured_charge`). @@ -59,6 +57,272 @@ pub struct Refund { /// This is only applicable if the charge was created using the destination parameter. pub transfer_reversal: Option>, } +#[doc(hidden)] +pub struct RefundBuilder { + amount: Option, + balance_transaction: + Option>>, + charge: Option>>, + created: Option, + currency: Option, + description: Option>, + destination_details: Option>, + failure_balance_transaction: + Option>>, + failure_reason: Option>, + id: Option, + instructions_email: Option>, + metadata: Option>>, + next_action: Option>, + object: Option, + payment_intent: Option>>, + reason: Option>, + receipt_number: Option>, + source_transfer_reversal: + Option>>, + status: Option>, + transfer_reversal: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: RefundBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "destination_details" => Deserialize::begin(&mut self.destination_details), + "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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + destination_details: 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(), + object: 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 { + Some(Self::Out { + amount: self.amount?, + balance_transaction: self.balance_transaction.take()?, + charge: self.charge.take()?, + created: self.created?, + currency: self.currency?, + description: self.description.take()?, + destination_details: self.destination_details.take()?, + failure_balance_transaction: self.failure_balance_transaction.take()?, + failure_reason: self.failure_reason.take()?, + id: self.id.take()?, + instructions_email: self.instructions_email.take()?, + metadata: self.metadata.take()?, + next_action: self.next_action.take()?, + object: self.object?, + payment_intent: self.payment_intent.take()?, + reason: self.reason?, + receipt_number: self.receipt_number.take()?, + source_transfer_reversal: self.source_transfer_reversal.take()?, + status: self.status.take()?, + transfer_reversal: self.transfer_reversal.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "destination_details" => { + b.destination_details = 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum RefundObject { + Refund, +} +impl RefundObject { + pub fn as_str(self) -> &'static str { + use RefundObject::*; + match self { + Refund => "refund", + } + } +} + +impl std::str::FromStr for RefundObject { + type Err = (); + fn from_str(s: &str) -> Result { + use RefundObject::*; + match s { + "refund" => Ok(Refund), + _ => Err(()), + } + } +} +impl std::fmt::Display for RefundObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for RefundObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for RefundObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for RefundObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(RefundObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(RefundObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for RefundObject { + fn deserialize>(deserializer: D) -> 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 RefundObject")) + } +} /// 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 { @@ -103,6 +367,7 @@ impl std::fmt::Debug for RefundReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for RefundReason { fn serialize(&self, serializer: S) -> Result where @@ -111,6 +376,22 @@ impl serde::Serialize for RefundReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for RefundReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(RefundReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(RefundReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for RefundReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/refund_destination_details.rs b/generated/stripe_shared/src/refund_destination_details.rs index a64f2802e..37b5c1436 100644 --- a/generated/stripe_shared/src/refund_destination_details.rs +++ b/generated/stripe_shared/src/refund_destination_details.rs @@ -1,64 +1,270 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct RefundDestinationDetails { - #[serde(skip_serializing_if = "Option::is_none")] pub affirm: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub afterpay_clearpay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub alipay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub au_bank_transfer: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub blik: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub br_bank_transfer: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cashapp: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub customer_cash_balance: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub eu_bank_transfer: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub gb_bank_transfer: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub giropay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub grabpay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub jp_bank_transfer: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub mx_bank_transfer: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub paynow: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub paypal: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pix: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub revolut: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub swish: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub th_bank_transfer: Option, /// 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")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: String, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_transfer: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub wechat_pay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub zip: Option, } +#[doc(hidden)] +pub struct RefundDestinationDetailsBuilder { + affirm: Option>, + afterpay_clearpay: Option>, + alipay: Option>, + au_bank_transfer: Option>, + blik: Option>, + br_bank_transfer: Option>, + card: Option>, + cashapp: Option>, + customer_cash_balance: Option>, + eps: Option>, + eu_bank_transfer: Option>, + gb_bank_transfer: Option>, + giropay: Option>, + grabpay: Option>, + jp_bank_transfer: Option>, + klarna: Option>, + mx_bank_transfer: Option>, + p24: Option>, + paynow: Option>, + paypal: Option>, + pix: Option>, + revolut: Option>, + sofort: Option>, + swish: Option>, + th_bank_transfer: Option>, + type_: Option, + us_bank_transfer: Option>, + wechat_pay: Option>, + zip: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for RefundDestinationDetails { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: RefundDestinationDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: RefundDestinationDetailsBuilder::deser_default(), + })) + } + } + + impl MapBuilder for RefundDestinationDetailsBuilder { + type Out = RefundDestinationDetails; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "affirm" => Deserialize::begin(&mut self.affirm), + "afterpay_clearpay" => Deserialize::begin(&mut self.afterpay_clearpay), + "alipay" => Deserialize::begin(&mut self.alipay), + "au_bank_transfer" => Deserialize::begin(&mut self.au_bank_transfer), + "blik" => Deserialize::begin(&mut self.blik), + "br_bank_transfer" => Deserialize::begin(&mut self.br_bank_transfer), + "card" => Deserialize::begin(&mut self.card), + "cashapp" => Deserialize::begin(&mut self.cashapp), + "customer_cash_balance" => Deserialize::begin(&mut self.customer_cash_balance), + "eps" => Deserialize::begin(&mut self.eps), + "eu_bank_transfer" => Deserialize::begin(&mut self.eu_bank_transfer), + "gb_bank_transfer" => Deserialize::begin(&mut self.gb_bank_transfer), + "giropay" => Deserialize::begin(&mut self.giropay), + "grabpay" => Deserialize::begin(&mut self.grabpay), + "jp_bank_transfer" => Deserialize::begin(&mut self.jp_bank_transfer), + "klarna" => Deserialize::begin(&mut self.klarna), + "mx_bank_transfer" => Deserialize::begin(&mut self.mx_bank_transfer), + "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" => Deserialize::begin(&mut self.revolut), + "sofort" => Deserialize::begin(&mut self.sofort), + "swish" => Deserialize::begin(&mut self.swish), + "th_bank_transfer" => Deserialize::begin(&mut self.th_bank_transfer), + "type" => Deserialize::begin(&mut self.type_), + "us_bank_transfer" => Deserialize::begin(&mut self.us_bank_transfer), + "wechat_pay" => Deserialize::begin(&mut self.wechat_pay), + "zip" => Deserialize::begin(&mut self.zip), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + affirm: Deserialize::default(), + afterpay_clearpay: Deserialize::default(), + alipay: Deserialize::default(), + au_bank_transfer: Deserialize::default(), + blik: Deserialize::default(), + br_bank_transfer: Deserialize::default(), + card: Deserialize::default(), + cashapp: Deserialize::default(), + customer_cash_balance: Deserialize::default(), + eps: Deserialize::default(), + eu_bank_transfer: Deserialize::default(), + gb_bank_transfer: Deserialize::default(), + giropay: Deserialize::default(), + grabpay: Deserialize::default(), + jp_bank_transfer: Deserialize::default(), + klarna: Deserialize::default(), + mx_bank_transfer: Deserialize::default(), + p24: Deserialize::default(), + paynow: Deserialize::default(), + paypal: Deserialize::default(), + pix: Deserialize::default(), + revolut: Deserialize::default(), + sofort: Deserialize::default(), + swish: Deserialize::default(), + th_bank_transfer: Deserialize::default(), + type_: Deserialize::default(), + us_bank_transfer: Deserialize::default(), + wechat_pay: Deserialize::default(), + zip: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + affirm: self.affirm?, + afterpay_clearpay: self.afterpay_clearpay?, + alipay: self.alipay?, + au_bank_transfer: self.au_bank_transfer?, + blik: self.blik.take()?, + br_bank_transfer: self.br_bank_transfer.take()?, + card: self.card.take()?, + cashapp: self.cashapp?, + customer_cash_balance: self.customer_cash_balance?, + eps: self.eps?, + eu_bank_transfer: self.eu_bank_transfer.take()?, + gb_bank_transfer: self.gb_bank_transfer.take()?, + giropay: self.giropay?, + grabpay: self.grabpay?, + jp_bank_transfer: self.jp_bank_transfer.take()?, + klarna: self.klarna?, + mx_bank_transfer: self.mx_bank_transfer.take()?, + p24: self.p24.take()?, + paynow: self.paynow?, + paypal: self.paypal?, + pix: self.pix?, + revolut: self.revolut?, + sofort: self.sofort?, + swish: self.swish.take()?, + th_bank_transfer: self.th_bank_transfer.take()?, + type_: self.type_.take()?, + us_bank_transfer: self.us_bank_transfer.take()?, + wechat_pay: self.wechat_pay?, + zip: self.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 RefundDestinationDetails { + type Builder = RefundDestinationDetailsBuilder; + } + + impl FromValueOpt for RefundDestinationDetails { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = RefundDestinationDetailsBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "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_bank_transfer" => b.au_bank_transfer = Some(FromValueOpt::from_value(v)?), + "blik" => b.blik = Some(FromValueOpt::from_value(v)?), + "br_bank_transfer" => b.br_bank_transfer = Some(FromValueOpt::from_value(v)?), + "card" => b.card = Some(FromValueOpt::from_value(v)?), + "cashapp" => b.cashapp = Some(FromValueOpt::from_value(v)?), + "customer_cash_balance" => { + b.customer_cash_balance = Some(FromValueOpt::from_value(v)?) + } + "eps" => b.eps = Some(FromValueOpt::from_value(v)?), + "eu_bank_transfer" => b.eu_bank_transfer = Some(FromValueOpt::from_value(v)?), + "gb_bank_transfer" => b.gb_bank_transfer = Some(FromValueOpt::from_value(v)?), + "giropay" => b.giropay = Some(FromValueOpt::from_value(v)?), + "grabpay" => b.grabpay = Some(FromValueOpt::from_value(v)?), + "jp_bank_transfer" => b.jp_bank_transfer = Some(FromValueOpt::from_value(v)?), + "klarna" => b.klarna = Some(FromValueOpt::from_value(v)?), + "mx_bank_transfer" => b.mx_bank_transfer = 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" => b.revolut = Some(FromValueOpt::from_value(v)?), + "sofort" => b.sofort = Some(FromValueOpt::from_value(v)?), + "swish" => b.swish = Some(FromValueOpt::from_value(v)?), + "th_bank_transfer" => b.th_bank_transfer = 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)?), + "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/refund_destination_details_card.rs b/generated/stripe_shared/src/refund_destination_details_card.rs index a3531e4d2..7f3c69d04 100644 --- a/generated/stripe_shared/src/refund_destination_details_card.rs +++ b/generated/stripe_shared/src/refund_destination_details_card.rs @@ -1,18 +1,122 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct RefundDestinationDetailsCard { /// Value of the reference number assigned to the refund. - #[serde(skip_serializing_if = "Option::is_none")] pub reference: Option, /// 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, /// Type of the reference number assigned to the refund. - #[serde(skip_serializing_if = "Option::is_none")] pub reference_type: Option, /// The type of refund. This can be `refund`, `reversal`, or `pending`. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: RefundDestinationDetailsCardType, } +#[doc(hidden)] +pub struct RefundDestinationDetailsCardBuilder { + reference: Option>, + reference_status: Option>, + reference_type: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for RefundDestinationDetailsCard { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: RefundDestinationDetailsCardBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: RefundDestinationDetailsCardBuilder::deser_default(), + })) + } + } + + impl MapBuilder for RefundDestinationDetailsCardBuilder { + type Out = RefundDestinationDetailsCard; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "reference" => Deserialize::begin(&mut self.reference), + "reference_status" => Deserialize::begin(&mut self.reference_status), + "reference_type" => Deserialize::begin(&mut self.reference_type), + "type" => Deserialize::begin(&mut self.type_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + reference: Deserialize::default(), + reference_status: Deserialize::default(), + reference_type: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + reference: self.reference.take()?, + reference_status: self.reference_status.take()?, + reference_type: self.reference_type.take()?, + type_: self.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 RefundDestinationDetailsCard { + type Builder = RefundDestinationDetailsCardBuilder; + } + + impl FromValueOpt for RefundDestinationDetailsCard { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = RefundDestinationDetailsCardBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "reference_status" => b.reference_status = Some(FromValueOpt::from_value(v)?), + "reference_type" => b.reference_type = Some(FromValueOpt::from_value(v)?), + "type" => b.type_ = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; /// The type of refund. This can be `refund`, `reversal`, or `pending`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum RefundDestinationDetailsCardType { @@ -54,6 +158,7 @@ impl std::fmt::Debug for RefundDestinationDetailsCardType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for RefundDestinationDetailsCardType { fn serialize(&self, serializer: S) -> Result where @@ -62,6 +167,23 @@ impl serde::Serialize for RefundDestinationDetailsCardType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for RefundDestinationDetailsCardType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(RefundDestinationDetailsCardType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(RefundDestinationDetailsCardType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for RefundDestinationDetailsCardType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/refund_destination_details_generic.rs b/generated/stripe_shared/src/refund_destination_details_generic.rs index 38af924b3..15140a4d5 100644 --- a/generated/stripe_shared/src/refund_destination_details_generic.rs +++ b/generated/stripe_shared/src/refund_destination_details_generic.rs @@ -1,7 +1,101 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct RefundDestinationDetailsGeneric { /// The reference assigned to the refund. pub reference: Option, /// Status of the reference on the refund. This can be `pending`, `available` or `unavailable`. pub reference_status: Option, } +#[doc(hidden)] +pub struct RefundDestinationDetailsGenericBuilder { + reference: Option>, + reference_status: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for RefundDestinationDetailsGeneric { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: RefundDestinationDetailsGenericBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: RefundDestinationDetailsGenericBuilder::deser_default(), + })) + } + } + + impl MapBuilder for RefundDestinationDetailsGenericBuilder { + type Out = RefundDestinationDetailsGeneric; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "reference" => Deserialize::begin(&mut self.reference), + "reference_status" => Deserialize::begin(&mut self.reference_status), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { reference: Deserialize::default(), reference_status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + reference: self.reference.take()?, + reference_status: self.reference_status.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for RefundDestinationDetailsGeneric { + type Builder = RefundDestinationDetailsGenericBuilder; + } + + impl FromValueOpt for RefundDestinationDetailsGeneric { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = RefundDestinationDetailsGenericBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "reference" => b.reference = Some(FromValueOpt::from_value(v)?), + "reference_status" => b.reference_status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/refund_next_action.rs b/generated/stripe_shared/src/refund_next_action.rs index 2073c3d0b..e47361c9d 100644 --- a/generated/stripe_shared/src/refund_next_action.rs +++ b/generated/stripe_shared/src/refund_next_action.rs @@ -1,8 +1,102 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct RefundNextAction { /// Contains the refund details. pub display_details: Option, /// Type of the next action to perform. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: String, } +#[doc(hidden)] +pub struct RefundNextActionBuilder { + display_details: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: RefundNextActionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { display_details: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + display_details: self.display_details.take()?, + type_: self.type_.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..9a8f815c1 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,97 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct RefundNextActionDisplayDetails { pub email_sent: stripe_shared::EmailSent, /// The expiry timestamp. pub expires_at: stripe_types::Timestamp, } +#[doc(hidden)] +pub struct RefundNextActionDisplayDetailsBuilder { + email_sent: Option, + expires_at: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: RefundNextActionDisplayDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { email_sent: Deserialize::default(), expires_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { email_sent: self.email_sent.take()?, expires_at: self.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 { + 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..a05fa7314 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ReserveTransaction { pub amount: i64, /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. @@ -8,6 +10,186 @@ pub struct ReserveTransaction { pub description: Option, /// Unique identifier for the object. pub id: stripe_shared::ReserveTransactionId, + /// String representing the object's type. Objects of the same type share the same value. + pub object: ReserveTransactionObject, +} +#[doc(hidden)] +pub struct ReserveTransactionBuilder { + amount: Option, + currency: Option, + description: Option>, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ReserveTransactionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + currency: Deserialize::default(), + description: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + currency: self.currency?, + description: self.description.take()?, + id: self.id.take()?, + object: self.object?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ReserveTransactionObject { + ReserveTransaction, +} +impl ReserveTransactionObject { + pub fn as_str(self) -> &'static str { + use ReserveTransactionObject::*; + match self { + ReserveTransaction => "reserve_transaction", + } + } +} + +impl std::str::FromStr for ReserveTransactionObject { + type Err = (); + fn from_str(s: &str) -> Result { + use ReserveTransactionObject::*; + match s { + "reserve_transaction" => Ok(ReserveTransaction), + _ => Err(()), + } + } +} +impl std::fmt::Display for ReserveTransactionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ReserveTransactionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for ReserveTransactionObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for ReserveTransactionObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ReserveTransactionObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ReserveTransactionObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ReserveTransactionObject { + fn deserialize>(deserializer: D) -> 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 ReserveTransactionObject")) + } } impl stripe_types::Object for ReserveTransaction { type Id = stripe_shared::ReserveTransactionId; diff --git a/generated/stripe_shared/src/review.rs b/generated/stripe_shared/src/review.rs index c173ea8b2..1d243fce1 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Review { /// The ZIP or postal code of the card used, if applicable. pub billing_zip: Option, @@ -24,12 +26,13 @@ pub struct Review { pub ip_address_location: Option, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: ReviewObject, /// If `true`, the review needs action. pub open: bool, /// 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>, /// The reason the review is currently open or closed. /// One of `rule`, `manual`, `approved`, `refunded`, `refunded_as_fraud`, `disputed`, or `redacted`. @@ -37,6 +40,160 @@ pub struct Review { /// Information related to the browsing session of the user who initiated the payment. pub session: Option, } +#[doc(hidden)] +pub struct ReviewBuilder { + billing_zip: Option>, + charge: Option>>, + closed_reason: Option>, + created: Option, + id: Option, + ip_address: Option>, + ip_address_location: Option>, + livemode: Option, + object: Option, + open: Option, + opened_reason: Option, + payment_intent: Option>>, + reason: Option, + session: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ReviewBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + billing_zip: self.billing_zip.take()?, + charge: self.charge.take()?, + closed_reason: self.closed_reason?, + created: self.created?, + id: self.id.take()?, + ip_address: self.ip_address.take()?, + ip_address_location: self.ip_address_location.take()?, + livemode: self.livemode?, + object: self.object?, + open: self.open?, + opened_reason: self.opened_reason?, + payment_intent: self.payment_intent.take()?, + reason: self.reason.take()?, + session: self.session.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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)] @@ -85,6 +242,7 @@ impl std::fmt::Debug for ReviewClosedReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ReviewClosedReason { fn serialize(&self, serializer: S) -> Result where @@ -93,6 +251,22 @@ impl serde::Serialize for ReviewClosedReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ReviewClosedReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ReviewClosedReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ReviewClosedReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ReviewClosedReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -101,6 +275,73 @@ impl<'de> serde::Deserialize<'de> for ReviewClosedReason { .map_err(|_| serde::de::Error::custom("Unknown value for ReviewClosedReason")) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ReviewObject { + Review, +} +impl ReviewObject { + pub fn as_str(self) -> &'static str { + use ReviewObject::*; + match self { + Review => "review", + } + } +} + +impl std::str::FromStr for ReviewObject { + type Err = (); + fn from_str(s: &str) -> Result { + use ReviewObject::*; + match s { + "review" => Ok(Review), + _ => Err(()), + } + } +} +impl std::fmt::Display for ReviewObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ReviewObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for ReviewObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for ReviewObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ReviewObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ReviewObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ReviewObject { + fn deserialize>(deserializer: D) -> 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 ReviewObject")) + } +} /// The reason the review was opened. One of `rule` or `manual`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ReviewOpenedReason { @@ -139,6 +380,7 @@ impl std::fmt::Debug for ReviewOpenedReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ReviewOpenedReason { fn serialize(&self, serializer: S) -> Result where @@ -147,6 +389,22 @@ impl serde::Serialize for ReviewOpenedReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ReviewOpenedReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ReviewOpenedReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ReviewOpenedReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ReviewOpenedReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/rule.rs b/generated/stripe_shared/src/rule.rs index c3c8c0bfb..0dd89c8b9 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Rule { /// The action taken on the payment. pub action: String, @@ -7,6 +9,103 @@ pub struct Rule { /// The predicate to evaluate the payment against. pub predicate: String, } +#[doc(hidden)] +pub struct RuleBuilder { + action: Option, + id: Option, + predicate: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: RuleBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + action: Deserialize::default(), + id: Deserialize::default(), + predicate: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + action: self.action.take()?, + id: self.id.take()?, + predicate: self.predicate.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..10e6ef43d 100644 --- a/generated/stripe_shared/src/schedules_phase_automatic_tax.rs +++ b/generated/stripe_shared/src/schedules_phase_automatic_tax.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SchedulesPhaseAutomaticTax { /// Whether Stripe automatically computes tax on invoices created during this phase. pub enabled: bool, @@ -7,3 +9,92 @@ pub struct SchedulesPhaseAutomaticTax { /// The tax transaction is returned in the report of the connected account. pub liability: Option, } +#[doc(hidden)] +pub struct SchedulesPhaseAutomaticTaxBuilder { + enabled: Option, + liability: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SchedulesPhaseAutomaticTaxBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "liability" => Deserialize::begin(&mut self.liability), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default(), liability: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.enabled?, liability: self.liability.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "liability" => b.liability = 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..36d1a05a4 100644 --- a/generated/stripe_shared/src/sepa_debit_generated_from.rs +++ b/generated/stripe_shared/src/sepa_debit_generated_from.rs @@ -1,7 +1,101 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SepaDebitGeneratedFrom { /// The ID of the Charge that generated this PaymentMethod, if any. pub charge: Option>, /// The ID of the SetupAttempt that generated this PaymentMethod, if any. pub setup_attempt: Option>, } +#[doc(hidden)] +pub struct SepaDebitGeneratedFromBuilder { + charge: Option>>, + setup_attempt: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SepaDebitGeneratedFromBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { charge: Deserialize::default(), setup_attempt: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + charge: self.charge.take()?, + setup_attempt: self.setup_attempt.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..03f740a12 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, @@ -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, /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -28,6 +29,8 @@ pub struct SetupAttempt { pub id: stripe_shared::SetupAttemptId, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: SetupAttemptObject, /// The value of [on_behalf_of](https://stripe.com/docs/api/setup_intents/object#setup_intent_object-on_behalf_of) on the SetupIntent at the time of this confirmation. pub on_behalf_of: Option>, /// ID of the payment method used with this SetupAttempt. @@ -42,6 +45,168 @@ 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, } +#[doc(hidden)] +pub struct SetupAttemptBuilder { + application: Option>>, + attach_to_self: Option>, + created: Option, + customer: Option>>, + flow_directions: Option>>, + id: Option, + livemode: Option, + object: Option, + on_behalf_of: Option>>, + payment_method: Option>, + payment_method_details: Option, + setup_error: Option>>, + setup_intent: Option>, + status: Option, + usage: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + application: self.application.take()?, + attach_to_self: self.attach_to_self?, + created: self.created?, + customer: self.customer.take()?, + flow_directions: self.flow_directions.take()?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + on_behalf_of: self.on_behalf_of.take()?, + payment_method: self.payment_method.take()?, + payment_method_details: self.payment_method_details.take()?, + setup_error: self.setup_error.take()?, + setup_intent: self.setup_intent.take()?, + status: self.status.take()?, + usage: self.usage.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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. @@ -84,6 +249,7 @@ impl std::fmt::Debug for SetupAttemptFlowDirections { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupAttemptFlowDirections { fn serialize(&self, serializer: S) -> Result where @@ -92,6 +258,22 @@ impl serde::Serialize for SetupAttemptFlowDirections { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupAttemptFlowDirections { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupAttemptFlowDirections::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SetupAttemptFlowDirections); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupAttemptFlowDirections { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -100,6 +282,74 @@ impl<'de> serde::Deserialize<'de> for SetupAttemptFlowDirections { .map_err(|_| serde::de::Error::custom("Unknown value for SetupAttemptFlowDirections")) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum SetupAttemptObject { + SetupAttempt, +} +impl SetupAttemptObject { + pub fn as_str(self) -> &'static str { + use SetupAttemptObject::*; + match self { + SetupAttempt => "setup_attempt", + } + } +} + +impl std::str::FromStr for SetupAttemptObject { + type Err = (); + fn from_str(s: &str) -> Result { + use SetupAttemptObject::*; + match s { + "setup_attempt" => Ok(SetupAttempt), + _ => Err(()), + } + } +} +impl std::fmt::Display for SetupAttemptObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for SetupAttemptObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for SetupAttemptObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for SetupAttemptObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupAttemptObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SetupAttemptObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for SetupAttemptObject { + fn deserialize>(deserializer: D) -> 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 SetupAttemptObject")) + } +} 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..8b4cdb2f7 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,190 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupAttemptPaymentMethodDetails { - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bacs_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bancontact: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub boleto: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub card_present: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cashapp: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub paypal: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option, /// 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(feature = "serde", serde(rename = "type"))] pub type_: String, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option, } +#[doc(hidden)] +pub struct SetupAttemptPaymentMethodDetailsBuilder { + acss_debit: Option>, + au_becs_debit: Option>, + bacs_debit: Option>, + bancontact: Option>, + boleto: Option>, + card: Option>, + card_present: Option>, + cashapp: Option>, + ideal: Option>, + klarna: Option>, + link: Option>, + paypal: Option>, + sepa_debit: Option>, + sofort: Option>, + type_: Option, + us_bank_account: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptPaymentMethodDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + acss_debit: self.acss_debit?, + au_becs_debit: self.au_becs_debit?, + bacs_debit: self.bacs_debit?, + bancontact: self.bancontact.take()?, + boleto: self.boleto?, + card: self.card.take()?, + card_present: self.card_present.take()?, + cashapp: self.cashapp?, + ideal: self.ideal.take()?, + klarna: self.klarna?, + link: self.link?, + paypal: self.paypal?, + sepa_debit: self.sepa_debit?, + sofort: self.sofort.take()?, + type_: self.type_.take()?, + us_bank_account: self.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 { + 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..8a1f29d9c 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupAttemptPaymentMethodDetailsAcssDebit {} +#[doc(hidden)] +pub struct SetupAttemptPaymentMethodDetailsAcssDebitBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptPaymentMethodDetailsAcssDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..c80068150 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupAttemptPaymentMethodDetailsAuBecsDebit {} +#[doc(hidden)] +pub struct SetupAttemptPaymentMethodDetailsAuBecsDebitBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptPaymentMethodDetailsAuBecsDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..3b60b74b9 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupAttemptPaymentMethodDetailsBacsDebit {} +#[doc(hidden)] +pub struct SetupAttemptPaymentMethodDetailsBacsDebitBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptPaymentMethodDetailsBacsDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..36c98ecd8 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupAttemptPaymentMethodDetailsBancontact { /// Bank code of bank associated with the bank account. pub bank_code: Option, @@ -19,6 +21,139 @@ pub struct SetupAttemptPaymentMethodDetailsBancontact { /// (if supported) at the time of authorization or settlement. They cannot be set or mutated. pub verified_name: Option, } +#[doc(hidden)] +pub struct SetupAttemptPaymentMethodDetailsBancontactBuilder { + bank_code: Option>, + bank_name: Option>, + bic: Option>, + generated_sepa_debit: Option>>, + generated_sepa_debit_mandate: Option>>, + iban_last4: Option>, + preferred_language: Option>, + verified_name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptPaymentMethodDetailsBancontactBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank_code: self.bank_code.take()?, + bank_name: self.bank_name.take()?, + bic: self.bic.take()?, + generated_sepa_debit: self.generated_sepa_debit.take()?, + generated_sepa_debit_mandate: self.generated_sepa_debit_mandate.take()?, + iban_last4: self.iban_last4.take()?, + preferred_language: self.preferred_language?, + verified_name: self.verified_name.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)] @@ -64,6 +199,7 @@ impl std::fmt::Debug for SetupAttemptPaymentMethodDetailsBancontactPreferredLang f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage { fn serialize(&self, serializer: S) -> Result where @@ -72,6 +208,29 @@ impl serde::Serialize for SetupAttemptPaymentMethodDetailsBancontactPreferredLan serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupAttemptPaymentMethodDetailsBancontactPreferredLanguage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..99b809fb5 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupAttemptPaymentMethodDetailsBoleto {} +#[doc(hidden)] +pub struct SetupAttemptPaymentMethodDetailsBoletoBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptPaymentMethodDetailsBoletoBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..c9b1a2cf2 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// 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, /// Two-digit number representing the card's expiration month. pub exp_month: Option, @@ -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, /// Card funding type. Can be `credit`, `debit`, `prepaid`, or `unknown`. pub funding: Option, /// 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, /// 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, /// The last four digits of the card. pub last4: Option, @@ -43,3 +41,158 @@ pub struct SetupAttemptPaymentMethodDetailsCard { /// If this Card is part of a card wallet, this contains the details of the card wallet. pub wallet: Option, } +#[doc(hidden)] +pub struct SetupAttemptPaymentMethodDetailsCardBuilder { + brand: Option>, + checks: Option>, + country: Option>, + description: Option>, + exp_month: Option>, + exp_year: Option>, + fingerprint: Option>, + funding: Option>, + iin: Option>, + issuer: Option>, + last4: Option>, + network: Option>, + three_d_secure: Option>, + wallet: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptPaymentMethodDetailsCardBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + brand: self.brand.take()?, + checks: self.checks.take()?, + country: self.country.take()?, + description: self.description.take()?, + exp_month: self.exp_month?, + exp_year: self.exp_year?, + fingerprint: self.fingerprint.take()?, + funding: self.funding.take()?, + iin: self.iin.take()?, + issuer: self.issuer.take()?, + last4: self.last4.take()?, + network: self.network.take()?, + three_d_secure: self.three_d_secure.take()?, + wallet: self.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 { + 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..85d50a547 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -7,3 +9,109 @@ pub struct SetupAttemptPaymentMethodDetailsCardChecks { /// If a CVC was provided, results of the check, one of `pass`, `fail`, `unavailable`, or `unchecked`. pub cvc_check: Option, } +#[doc(hidden)] +pub struct SetupAttemptPaymentMethodDetailsCardChecksBuilder { + address_line1_check: Option>, + address_postal_code_check: Option>, + cvc_check: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptPaymentMethodDetailsCardChecksBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + address_line1_check: self.address_line1_check.take()?, + address_postal_code_check: self.address_postal_code_check.take()?, + cvc_check: self.cvc_check.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..dd170f0f2 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupAttemptPaymentMethodDetailsCardPresent { /// The ID of the Card PaymentMethod which was generated by this SetupAttempt. pub generated_card: Option>, } +#[doc(hidden)] +pub struct SetupAttemptPaymentMethodDetailsCardPresentBuilder { + generated_card: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptPaymentMethodDetailsCardPresentBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { generated_card: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { generated_card: self.generated_card.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..f4083afcd 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,115 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupAttemptPaymentMethodDetailsCardWallet { - #[serde(skip_serializing_if = "Option::is_none")] pub apple_pay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub google_pay: Option, /// 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(feature = "serde", serde(rename = "type"))] pub type_: SetupAttemptPaymentMethodDetailsCardWalletType, } +#[doc(hidden)] +pub struct SetupAttemptPaymentMethodDetailsCardWalletBuilder { + apple_pay: Option>, + google_pay: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptPaymentMethodDetailsCardWalletBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + apple_pay: Deserialize::default(), + google_pay: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + apple_pay: self.apple_pay?, + google_pay: self.google_pay?, + type_: self.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 { + 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. @@ -53,6 +153,7 @@ impl std::fmt::Debug for SetupAttemptPaymentMethodDetailsCardWalletType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupAttemptPaymentMethodDetailsCardWalletType { fn serialize(&self, serializer: S) -> Result where @@ -61,6 +162,25 @@ impl serde::Serialize for SetupAttemptPaymentMethodDetailsCardWalletType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupAttemptPaymentMethodDetailsCardWalletType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SetupAttemptPaymentMethodDetailsCardWalletType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SetupAttemptPaymentMethodDetailsCardWalletType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupAttemptPaymentMethodDetailsCardWalletType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..746827aa6 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupAttemptPaymentMethodDetailsCashapp {} +#[doc(hidden)] +pub struct SetupAttemptPaymentMethodDetailsCashappBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptPaymentMethodDetailsCashappBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..851912770 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,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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`. @@ -15,6 +17,127 @@ pub struct SetupAttemptPaymentMethodDetailsIdeal { /// (if supported) at the time of authorization or settlement. They cannot be set or mutated. pub verified_name: Option, } +#[doc(hidden)] +pub struct SetupAttemptPaymentMethodDetailsIdealBuilder { + bank: Option>, + bic: Option>, + generated_sepa_debit: Option>>, + generated_sepa_debit_mandate: Option>>, + iban_last4: Option>, + verified_name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptPaymentMethodDetailsIdealBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank: self.bank?, + bic: self.bic?, + generated_sepa_debit: self.generated_sepa_debit.take()?, + generated_sepa_debit_mandate: self.generated_sepa_debit_mandate.take()?, + iban_last4: self.iban_last4.take()?, + verified_name: self.verified_name.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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`. #[derive(Copy, Clone, Eq, PartialEq)] @@ -100,6 +223,7 @@ impl std::fmt::Debug for SetupAttemptPaymentMethodDetailsIdealBank { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupAttemptPaymentMethodDetailsIdealBank { fn serialize(&self, serializer: S) -> Result where @@ -108,11 +232,30 @@ impl serde::Serialize for SetupAttemptPaymentMethodDetailsIdealBank { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupAttemptPaymentMethodDetailsIdealBank { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SetupAttemptPaymentMethodDetailsIdealBank::from_str(s) + .unwrap_or(SetupAttemptPaymentMethodDetailsIdealBank::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SetupAttemptPaymentMethodDetailsIdealBank); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupAttemptPaymentMethodDetailsIdealBank { fn deserialize>(deserializer: D) -> Result { 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)) } } /// The Bank Identifier Code of the customer's bank. @@ -202,6 +345,7 @@ impl std::fmt::Debug for SetupAttemptPaymentMethodDetailsIdealBic { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupAttemptPaymentMethodDetailsIdealBic { fn serialize(&self, serializer: S) -> Result where @@ -210,10 +354,29 @@ impl serde::Serialize for SetupAttemptPaymentMethodDetailsIdealBic { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupAttemptPaymentMethodDetailsIdealBic { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SetupAttemptPaymentMethodDetailsIdealBic::from_str(s) + .unwrap_or(SetupAttemptPaymentMethodDetailsIdealBic::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SetupAttemptPaymentMethodDetailsIdealBic); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupAttemptPaymentMethodDetailsIdealBic { fn deserialize>(deserializer: D) -> Result { 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)) } } 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..3d7cc867b 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupAttemptPaymentMethodDetailsKlarna {} +#[doc(hidden)] +pub struct SetupAttemptPaymentMethodDetailsKlarnaBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptPaymentMethodDetailsKlarnaBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..ae15a04d9 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupAttemptPaymentMethodDetailsLink {} +#[doc(hidden)] +pub struct SetupAttemptPaymentMethodDetailsLinkBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptPaymentMethodDetailsLinkBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..2b72d6500 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupAttemptPaymentMethodDetailsPaypal {} +#[doc(hidden)] +pub struct SetupAttemptPaymentMethodDetailsPaypalBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptPaymentMethodDetailsPaypalBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..bc2fbed12 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupAttemptPaymentMethodDetailsSepaDebit {} +#[doc(hidden)] +pub struct SetupAttemptPaymentMethodDetailsSepaDebitBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptPaymentMethodDetailsSepaDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..d3648ad7c 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupAttemptPaymentMethodDetailsSofort { /// Bank code of bank associated with the bank account. pub bank_code: Option, @@ -19,6 +21,139 @@ pub struct SetupAttemptPaymentMethodDetailsSofort { /// (if supported) at the time of authorization or settlement. They cannot be set or mutated. pub verified_name: Option, } +#[doc(hidden)] +pub struct SetupAttemptPaymentMethodDetailsSofortBuilder { + bank_code: Option>, + bank_name: Option>, + bic: Option>, + generated_sepa_debit: Option>>, + generated_sepa_debit_mandate: Option>>, + iban_last4: Option>, + preferred_language: Option>, + verified_name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptPaymentMethodDetailsSofortBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank_code: self.bank_code.take()?, + bank_name: self.bank_name.take()?, + bic: self.bic.take()?, + generated_sepa_debit: self.generated_sepa_debit.take()?, + generated_sepa_debit_mandate: self.generated_sepa_debit_mandate.take()?, + iban_last4: self.iban_last4.take()?, + preferred_language: self.preferred_language?, + verified_name: self.verified_name.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)] @@ -64,6 +199,7 @@ impl std::fmt::Debug for SetupAttemptPaymentMethodDetailsSofortPreferredLanguage f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupAttemptPaymentMethodDetailsSofortPreferredLanguage { fn serialize(&self, serializer: S) -> Result where @@ -72,6 +208,27 @@ impl serde::Serialize for SetupAttemptPaymentMethodDetailsSofortPreferredLanguag serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupAttemptPaymentMethodDetailsSofortPreferredLanguage { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SetupAttemptPaymentMethodDetailsSofortPreferredLanguage::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SetupAttemptPaymentMethodDetailsSofortPreferredLanguage); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupAttemptPaymentMethodDetailsSofortPreferredLanguage { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..2aad0d953 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,84 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupAttemptPaymentMethodDetailsUsBankAccount {} +#[doc(hidden)] +pub struct SetupAttemptPaymentMethodDetailsUsBankAccountBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupAttemptPaymentMethodDetailsUsBankAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..499d03702 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupIntent { /// ID of the Connect application that created the SetupIntent. pub application: Option>, @@ -29,7 +31,6 @@ 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, /// Settings for dynamic payment methods compatible with this Setup Intent pub automatic_payment_methods: @@ -72,6 +73,8 @@ pub struct SetupIntent { pub metadata: Option>, /// If present, this property tells you what actions you need to take in order for your customer to continue payment setup. pub next_action: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: SetupIntentObject, /// The account (if any) for which the setup is intended. pub on_behalf_of: Option>, /// ID of the payment method used with this SetupIntent. @@ -94,6 +97,304 @@ pub struct SetupIntent { /// If not provided, this value defaults to `off_session`. pub usage: String, } +#[doc(hidden)] +pub struct SetupIntentBuilder { + application: Option>>, + attach_to_self: Option>, + automatic_payment_methods: + Option>, + cancellation_reason: Option>, + client_secret: Option>, + created: Option, + customer: Option>>, + description: Option>, + flow_directions: Option>>, + id: Option, + last_setup_error: Option>>, + latest_attempt: Option>>, + livemode: Option, + mandate: Option>>, + metadata: Option>>, + next_action: Option>, + object: Option, + on_behalf_of: Option>>, + payment_method: Option>>, + payment_method_configuration_details: + Option>, + payment_method_options: Option>, + payment_method_types: Option>, + single_use_mandate: Option>>, + status: Option, + usage: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupIntentBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + application: self.application.take()?, + attach_to_self: self.attach_to_self?, + automatic_payment_methods: self.automatic_payment_methods?, + cancellation_reason: self.cancellation_reason?, + client_secret: self.client_secret.take()?, + created: self.created?, + customer: self.customer.take()?, + description: self.description.take()?, + flow_directions: self.flow_directions.take()?, + id: self.id.take()?, + last_setup_error: self.last_setup_error.take()?, + latest_attempt: self.latest_attempt.take()?, + livemode: self.livemode?, + mandate: self.mandate.take()?, + metadata: self.metadata.take()?, + next_action: self.next_action.take()?, + object: self.object?, + on_behalf_of: self.on_behalf_of.take()?, + payment_method: self.payment_method.take()?, + payment_method_configuration_details: self + .payment_method_configuration_details + .take()?, + payment_method_options: self.payment_method_options.take()?, + payment_method_types: self.payment_method_types.take()?, + single_use_mandate: self.single_use_mandate.take()?, + status: self.status?, + usage: self.usage.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum SetupIntentObject { + SetupIntent, +} +impl SetupIntentObject { + pub fn as_str(self) -> &'static str { + use SetupIntentObject::*; + match self { + SetupIntent => "setup_intent", + } + } +} + +impl std::str::FromStr for SetupIntentObject { + type Err = (); + fn from_str(s: &str) -> Result { + use SetupIntentObject::*; + match s { + "setup_intent" => Ok(SetupIntent), + _ => Err(()), + } + } +} +impl std::fmt::Display for SetupIntentObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for SetupIntentObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for SetupIntentObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for SetupIntentObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SetupIntentObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for SetupIntentObject { + fn deserialize>(deserializer: D) -> 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 SetupIntentObject")) + } +} /// [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 { @@ -144,6 +445,7 @@ impl std::fmt::Debug for SetupIntentStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupIntentStatus { fn serialize(&self, serializer: S) -> Result where @@ -152,6 +454,22 @@ impl serde::Serialize for SetupIntentStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupIntentStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SetupIntentStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupIntentStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -215,6 +533,22 @@ impl serde::Serialize for SetupIntentCancellationReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupIntentCancellationReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentCancellationReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SetupIntentCancellationReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupIntentCancellationReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -269,6 +603,22 @@ impl serde::Serialize for SetupIntentFlowDirections { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupIntentFlowDirections { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SetupIntentFlowDirections::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SetupIntentFlowDirections); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupIntentFlowDirections { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/setup_intent_next_action.rs b/generated/stripe_shared/src/setup_intent_next_action.rs index 896115660..7ea6105cf 100644 --- a/generated/stripe_shared/src/setup_intent_next_action.rs +++ b/generated/stripe_shared/src/setup_intent_next_action.rs @@ -1,18 +1,140 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupIntentNextAction { - #[serde(skip_serializing_if = "Option::is_none")] pub cashapp_handle_redirect_or_display_qr_code: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub redirect_to_url: Option, /// 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(feature = "serde", 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(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "serde", serde(with = "stripe_types::with_serde_json_opt"))] + pub use_stripe_sdk: Option, pub verify_with_microdeposits: Option, } +#[doc(hidden)] +pub struct SetupIntentNextActionBuilder { + cashapp_handle_redirect_or_display_qr_code: + Option>, + redirect_to_url: Option>, + type_: Option, + use_stripe_sdk: Option>, + verify_with_microdeposits: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupIntentNextActionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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) + } + + _ => ::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 { + Some(Self::Out { + cashapp_handle_redirect_or_display_qr_code: self + .cashapp_handle_redirect_or_display_qr_code + .take()?, + redirect_to_url: self.redirect_to_url.take()?, + type_: self.type_.take()?, + use_stripe_sdk: self.use_stripe_sdk.take()?, + verify_with_microdeposits: self.verify_with_microdeposits.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..0411e0c8c 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,98 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// The URL you must redirect your customer to in order to authenticate. pub url: Option, } +#[doc(hidden)] +pub struct SetupIntentNextActionRedirectToUrlBuilder { + return_url: Option>, + url: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupIntentNextActionRedirectToUrlBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { return_url: Deserialize::default(), url: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { return_url: self.return_url.take()?, url: self.url.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..f6a2f8d7b 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupIntentNextActionVerifyWithMicrodeposits { /// The timestamp when the microdeposits are expected to land. pub arrival_date: stripe_types::Timestamp, @@ -8,6 +10,108 @@ pub struct SetupIntentNextActionVerifyWithMicrodeposits { /// Used to distinguish between different verification methods. pub microdeposit_type: Option, } +#[doc(hidden)] +pub struct SetupIntentNextActionVerifyWithMicrodepositsBuilder { + arrival_date: Option, + hosted_verification_url: Option, + microdeposit_type: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupIntentNextActionVerifyWithMicrodepositsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + arrival_date: self.arrival_date?, + hosted_verification_url: self.hosted_verification_url.take()?, + microdeposit_type: self.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 { + 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)] @@ -47,6 +151,7 @@ impl std::fmt::Debug for SetupIntentNextActionVerifyWithMicrodepositsMicrodeposi f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType { fn serialize(&self, serializer: S) -> Result where @@ -55,6 +160,29 @@ impl serde::Serialize for SetupIntentNextActionVerifyWithMicrodepositsMicrodepos serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupIntentNextActionVerifyWithMicrodepositsMicrodepositType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..b571d7820 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,126 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupIntentPaymentMethodOptions { - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub link: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub paypal: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option, } +#[doc(hidden)] +pub struct SetupIntentPaymentMethodOptionsBuilder { + acss_debit: Option>, + card: Option>, + link: Option>, + paypal: Option>, + sepa_debit: Option>, + us_bank_account: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupIntentPaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + acss_debit: self.acss_debit.take()?, + card: self.card.take()?, + link: self.link.take()?, + paypal: self.paypal.take()?, + sepa_debit: self.sepa_debit?, + us_bank_account: self.us_bank_account.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..a350f07c4 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,117 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupIntentPaymentMethodOptionsAcssDebit { /// Currency supported by the bank account pub currency: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub mandate_options: Option, /// Bank account verification method. - #[serde(skip_serializing_if = "Option::is_none")] pub verification_method: Option, } +#[doc(hidden)] +pub struct SetupIntentPaymentMethodOptionsAcssDebitBuilder { + currency: Option>, + mandate_options: + Option>, + verification_method: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupIntentPaymentMethodOptionsAcssDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + currency: Deserialize::default(), + mandate_options: Deserialize::default(), + verification_method: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + currency: self.currency?, + mandate_options: self.mandate_options.take()?, + verification_method: self.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 { + 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 { @@ -47,6 +150,7 @@ impl std::fmt::Debug for SetupIntentPaymentMethodOptionsAcssDebitCurrency { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupIntentPaymentMethodOptionsAcssDebitCurrency { fn serialize(&self, serializer: S) -> Result where @@ -55,6 +159,25 @@ impl serde::Serialize for SetupIntentPaymentMethodOptionsAcssDebitCurrency { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsAcssDebitCurrency { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SetupIntentPaymentMethodOptionsAcssDebitCurrency::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsAcssDebitCurrency); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsAcssDebitCurrency { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -107,6 +230,7 @@ impl std::fmt::Debug for SetupIntentPaymentMethodOptionsAcssDebitVerificationMet f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod { fn serialize(&self, serializer: S) -> Result where @@ -115,6 +239,29 @@ impl serde::Serialize for SetupIntentPaymentMethodOptionsAcssDebitVerificationMe serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsAcssDebitVerificationMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..1c82b0b77 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupIntentPaymentMethodOptionsCard { /// Configuration options for setting up an eMandate for cards issued in India. pub mandate_options: Option, @@ -12,6 +14,109 @@ pub struct SetupIntentPaymentMethodOptionsCard { /// 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, } +#[doc(hidden)] +pub struct SetupIntentPaymentMethodOptionsCardBuilder { + mandate_options: + Option>, + network: Option>, + request_three_d_secure: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupIntentPaymentMethodOptionsCardBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + mandate_options: self.mandate_options.take()?, + network: self.network?, + request_three_d_secure: self.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 { + 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. @@ -79,6 +184,7 @@ impl std::fmt::Debug for SetupIntentPaymentMethodOptionsCardNetwork { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupIntentPaymentMethodOptionsCardNetwork { fn serialize(&self, serializer: S) -> Result where @@ -87,6 +193,25 @@ impl serde::Serialize for SetupIntentPaymentMethodOptionsCardNetwork { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsCardNetwork { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SetupIntentPaymentMethodOptionsCardNetwork::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsCardNetwork); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsCardNetwork { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -140,6 +265,7 @@ impl std::fmt::Debug for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure { fn serialize(&self, serializer: S) -> Result where @@ -148,6 +274,27 @@ impl serde::Serialize for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SetupIntentPaymentMethodOptionsCardRequestThreeDSecure::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SetupIntentPaymentMethodOptionsCardRequestThreeDSecure); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsCardRequestThreeDSecure { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..59d27f616 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupIntentPaymentMethodOptionsCardMandateOptions { /// Amount to be charged for future payments. pub amount: i64, @@ -30,6 +32,142 @@ pub struct SetupIntentPaymentMethodOptionsCardMandateOptions { pub supported_types: Option>, } +#[doc(hidden)] +pub struct SetupIntentPaymentMethodOptionsCardMandateOptionsBuilder { + amount: Option, + amount_type: Option, + currency: Option, + description: Option>, + end_date: Option>, + interval: Option, + interval_count: Option>, + reference: Option, + start_date: Option, + supported_types: + Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupIntentPaymentMethodOptionsCardMandateOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount: self.amount?, + amount_type: self.amount_type?, + currency: self.currency?, + description: self.description.take()?, + end_date: self.end_date?, + interval: self.interval?, + interval_count: self.interval_count?, + reference: self.reference.take()?, + start_date: self.start_date?, + supported_types: self.supported_types.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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. @@ -70,6 +208,7 @@ impl std::fmt::Debug for SetupIntentPaymentMethodOptionsCardMandateOptionsAmount f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType { fn serialize(&self, serializer: S) -> Result where @@ -78,6 +217,29 @@ impl serde::Serialize for SetupIntentPaymentMethodOptionsCardMandateOptionsAmoun serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsCardMandateOptionsAmountType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -136,6 +298,7 @@ impl std::fmt::Debug for SetupIntentPaymentMethodOptionsCardMandateOptionsInterv f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupIntentPaymentMethodOptionsCardMandateOptionsInterval { fn serialize(&self, serializer: S) -> Result where @@ -144,6 +307,29 @@ impl serde::Serialize for SetupIntentPaymentMethodOptionsCardMandateOptionsInter serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsCardMandateOptionsInterval { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SetupIntentPaymentMethodOptionsCardMandateOptionsInterval::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + SetupIntentPaymentMethodOptionsCardMandateOptionsInterval +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsCardMandateOptionsInterval { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -190,6 +376,7 @@ impl std::fmt::Debug for SetupIntentPaymentMethodOptionsCardMandateOptionsSuppor f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes { fn serialize(&self, serializer: S) -> Result where @@ -198,6 +385,29 @@ impl serde::Serialize for SetupIntentPaymentMethodOptionsCardMandateOptionsSuppo serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + SetupIntentPaymentMethodOptionsCardMandateOptionsSupportedTypes +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for 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..c69e58702 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupIntentPaymentMethodOptionsLink { /// \[Deprecated\] This is a legacy parameter that no longer has any function. pub persistent_token: Option, } +#[doc(hidden)] +pub struct SetupIntentPaymentMethodOptionsLinkBuilder { + persistent_token: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupIntentPaymentMethodOptionsLinkBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { persistent_token: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { persistent_token: self.persistent_token.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..8ee52eafb 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,10 +1,10 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit { /// A URL for custom mandate text - #[serde(skip_serializing_if = "Option::is_none")] pub custom_mandate_url: Option, /// List of Stripe products where this mandate can be selected automatically. - #[serde(skip_serializing_if = "Option::is_none")] pub default_for: Option>, /// Description of the interval. /// Only required if the 'payment_schedule' parameter is 'interval' or 'combined'. @@ -16,6 +16,125 @@ pub struct SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit { pub transaction_type: Option, } +#[doc(hidden)] +pub struct SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder { + custom_mandate_url: Option>, + default_for: + Option>>, + interval_description: Option>, + payment_schedule: + Option>, + transaction_type: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + custom_mandate_url: self.custom_mandate_url.take()?, + default_for: self.default_for.take()?, + interval_description: self.interval_description.take()?, + payment_schedule: self.payment_schedule?, + transaction_type: self.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 { + 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 { @@ -54,6 +173,7 @@ impl std::fmt::Debug for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitD f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor { fn serialize(&self, serializer: S) -> Result where @@ -62,6 +182,29 @@ impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitDefaultFor { @@ -112,6 +255,7 @@ impl std::fmt::Debug for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitP f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule { fn serialize(&self, serializer: S) -> Result where @@ -120,6 +264,31 @@ impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitPaymentSchedule { @@ -167,6 +336,7 @@ impl std::fmt::Debug for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitT f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType { fn serialize(&self, serializer: S) -> Result where @@ -175,6 +345,31 @@ impl serde::Serialize for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebit serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + SetupIntentPaymentMethodOptionsMandateOptionsAcssDebitTransactionType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for 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..979af23de 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,86 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupIntentPaymentMethodOptionsMandateOptionsSepaDebit {} +#[doc(hidden)] +pub struct SetupIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupIntentPaymentMethodOptionsMandateOptionsSepaDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..85363a482 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,96 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct SetupIntentPaymentMethodOptionsPaypalBuilder { + billing_agreement_id: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupIntentPaymentMethodOptionsPaypalBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { billing_agreement_id: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { billing_agreement_id: self.billing_agreement_id.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..c33a2d9b0 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,94 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupIntentPaymentMethodOptionsSepaDebit { - #[serde(skip_serializing_if = "Option::is_none")] pub mandate_options: Option, } +#[doc(hidden)] +pub struct SetupIntentPaymentMethodOptionsSepaDebitBuilder { + mandate_options: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupIntentPaymentMethodOptionsSepaDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { mandate_options: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { mandate_options: self.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 { + 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..8b7ea62a4 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,117 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SetupIntentPaymentMethodOptionsUsBankAccount { - #[serde(skip_serializing_if = "Option::is_none")] pub financial_connections: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub mandate_options: Option, /// Bank account verification method. - #[serde(skip_serializing_if = "Option::is_none")] pub verification_method: Option, } +#[doc(hidden)] +pub struct SetupIntentPaymentMethodOptionsUsBankAccountBuilder { + financial_connections: Option>, + mandate_options: Option>, + verification_method: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SetupIntentPaymentMethodOptionsUsBankAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "mandate_options" => Deserialize::begin(&mut self.mandate_options), + "verification_method" => Deserialize::begin(&mut self.verification_method), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + financial_connections: Deserialize::default(), + mandate_options: Deserialize::default(), + verification_method: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + financial_connections: self.financial_connections.take()?, + mandate_options: self.mandate_options?, + verification_method: self.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 { + 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)?) + } + "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 SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod { @@ -49,6 +153,7 @@ impl std::fmt::Debug for SetupIntentPaymentMethodOptionsUsBankAccountVerificatio f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +162,29 @@ impl serde::Serialize for SetupIntentPaymentMethodOptionsUsBankAccountVerificati serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SetupIntentPaymentMethodOptionsUsBankAccountVerificationMethod { diff --git a/generated/stripe_shared/src/shipping.rs b/generated/stripe_shared/src/shipping.rs index 4599cf4a5..8bc1eac22 100644 --- a/generated/stripe_shared/src/shipping.rs +++ b/generated/stripe_shared/src/shipping.rs @@ -1,18 +1,122 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Shipping { - #[serde(skip_serializing_if = "Option::is_none")] pub address: Option, /// The delivery service that shipped a physical product, such as Fedex, UPS, USPS, etc. - #[serde(skip_serializing_if = "Option::is_none")] pub carrier: Option, /// Recipient name. - #[serde(skip_serializing_if = "Option::is_none")] pub name: Option, /// Recipient phone (including extension). - #[serde(skip_serializing_if = "Option::is_none")] pub phone: Option, /// 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, } +#[doc(hidden)] +pub struct ShippingBuilder { + address: Option>, + carrier: Option>, + name: Option>, + phone: Option>, + tracking_number: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ShippingBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + address: self.address.take()?, + carrier: self.carrier.take()?, + name: self.name.take()?, + phone: self.phone.take()?, + tracking_number: self.tracking_number.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..c50571d71 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, - #[serde(skip_serializing_if = "Option::is_none")] pub fixed_amount: Option, /// Unique identifier for the object. pub id: stripe_shared::ShippingRateId, @@ -24,6 +25,8 @@ pub struct ShippingRate { /// 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 representing the object's type. Objects of the same type share the same value. + pub object: ShippingRateObject, /// Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. /// One of `inclusive`, `exclusive`, or `unspecified`. pub tax_behavior: Option, @@ -31,9 +34,222 @@ pub struct ShippingRate { /// The Shipping tax code is `txcd_92010001`. pub tax_code: Option>, /// The type of calculation to use on the shipping rate. Can only be `fixed_amount` for now. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: stripe_shared::ShippingRateType, } +#[doc(hidden)] +pub struct ShippingRateBuilder { + active: Option, + created: Option, + delivery_estimate: Option>, + display_name: Option>, + fixed_amount: Option>, + id: Option, + livemode: Option, + metadata: Option>, + object: Option, + tax_behavior: Option>, + tax_code: Option>>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ShippingRateBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "tax_behavior" => Deserialize::begin(&mut self.tax_behavior), + "tax_code" => Deserialize::begin(&mut self.tax_code), + "type" => Deserialize::begin(&mut self.type_), + + _ => ::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(), + object: Deserialize::default(), + tax_behavior: Deserialize::default(), + tax_code: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + active: self.active?, + created: self.created?, + delivery_estimate: self.delivery_estimate?, + display_name: self.display_name.take()?, + fixed_amount: self.fixed_amount.take()?, + id: self.id.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + tax_behavior: self.tax_behavior?, + tax_code: self.tax_code.take()?, + type_: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum ShippingRateObject { + ShippingRate, +} +impl ShippingRateObject { + pub fn as_str(self) -> &'static str { + use ShippingRateObject::*; + match self { + ShippingRate => "shipping_rate", + } + } +} + +impl std::str::FromStr for ShippingRateObject { + type Err = (); + fn from_str(s: &str) -> Result { + use ShippingRateObject::*; + match s { + "shipping_rate" => Ok(ShippingRate), + _ => Err(()), + } + } +} +impl std::fmt::Display for ShippingRateObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for ShippingRateObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for ShippingRateObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for ShippingRateObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ShippingRateObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ShippingRateObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ShippingRateObject { + fn deserialize>(deserializer: D) -> 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 ShippingRateObject")) + } +} impl stripe_types::Object for ShippingRate { type Id = stripe_shared::ShippingRateId; fn id(&self) -> &Self::Id { @@ -89,6 +305,22 @@ impl serde::Serialize for ShippingRateTaxBehavior { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ShippingRateTaxBehavior { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ShippingRateTaxBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ShippingRateTaxBehavior); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ShippingRateTaxBehavior { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -139,6 +371,22 @@ impl serde::Serialize for ShippingRateType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ShippingRateType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ShippingRateType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ShippingRateType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ShippingRateType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/shipping_rate_currency_option.rs b/generated/stripe_shared/src/shipping_rate_currency_option.rs index a1fcafacd..23aa359ab 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ShippingRateCurrencyOption { /// A non-negative integer in cents representing how much to charge. pub amount: i64, @@ -6,6 +8,95 @@ pub struct ShippingRateCurrencyOption { /// One of `inclusive`, `exclusive`, or `unspecified`. pub tax_behavior: ShippingRateCurrencyOptionTaxBehavior, } +#[doc(hidden)] +pub struct ShippingRateCurrencyOptionBuilder { + amount: Option, + tax_behavior: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ShippingRateCurrencyOptionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), tax_behavior: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { amount: self.amount?, tax_behavior: self.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 { + 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)] @@ -48,6 +139,7 @@ impl std::fmt::Debug for ShippingRateCurrencyOptionTaxBehavior { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ShippingRateCurrencyOptionTaxBehavior { fn serialize(&self, serializer: S) -> Result where @@ -56,6 +148,23 @@ impl serde::Serialize for ShippingRateCurrencyOptionTaxBehavior { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ShippingRateCurrencyOptionTaxBehavior { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(ShippingRateCurrencyOptionTaxBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ShippingRateCurrencyOptionTaxBehavior); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ShippingRateCurrencyOptionTaxBehavior { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/shipping_rate_delivery_estimate.rs b/generated/stripe_shared/src/shipping_rate_delivery_estimate.rs index 16875264f..0c1f4fc54 100644 --- a/generated/stripe_shared/src/shipping_rate_delivery_estimate.rs +++ b/generated/stripe_shared/src/shipping_rate_delivery_estimate.rs @@ -1,7 +1,98 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ShippingRateDeliveryEstimate { /// The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite. pub maximum: Option, /// The lower bound of the estimated range. If empty, represents no lower bound. pub minimum: Option, } +#[doc(hidden)] +pub struct ShippingRateDeliveryEstimateBuilder { + maximum: Option>, + minimum: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ShippingRateDeliveryEstimateBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { maximum: Deserialize::default(), minimum: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { maximum: self.maximum?, minimum: self.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 { + 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..a28e8e75d 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,101 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ShippingRateDeliveryEstimateBound { /// A unit of time. pub unit: ShippingRateDeliveryEstimateBoundUnit, /// Must be greater than 0. pub value: i64, } +#[doc(hidden)] +pub struct ShippingRateDeliveryEstimateBoundBuilder { + unit: Option, + value: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ShippingRateDeliveryEstimateBoundBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { unit: Deserialize::default(), value: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { unit: self.unit?, value: self.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 { + 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 { @@ -52,6 +143,7 @@ impl std::fmt::Debug for ShippingRateDeliveryEstimateBoundUnit { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ShippingRateDeliveryEstimateBoundUnit { fn serialize(&self, serializer: S) -> Result where @@ -60,6 +152,23 @@ impl serde::Serialize for ShippingRateDeliveryEstimateBoundUnit { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ShippingRateDeliveryEstimateBoundUnit { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(ShippingRateDeliveryEstimateBoundUnit::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ShippingRateDeliveryEstimateBoundUnit); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ShippingRateDeliveryEstimateBoundUnit { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/shipping_rate_fixed_amount.rs b/generated/stripe_shared/src/shipping_rate_fixed_amount.rs index 8259a0bbf..93c72c4db 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ShippingRateFixedAmount { /// A non-negative integer in cents representing how much to charge. pub amount: i64, @@ -7,7 +9,6 @@ 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, @@ -15,3 +16,110 @@ pub struct ShippingRateFixedAmount { >, >, } +#[doc(hidden)] +pub struct ShippingRateFixedAmountBuilder { + amount: Option, + currency: Option, + currency_options: Option< + Option< + std::collections::HashMap< + stripe_types::Currency, + stripe_shared::ShippingRateCurrencyOption, + >, + >, + >, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ShippingRateFixedAmountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + currency: Deserialize::default(), + currency_options: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + currency: self.currency?, + currency_options: self.currency_options.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..30ac32dfe 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Source { - #[serde(skip_serializing_if = "Option::is_none")] pub ach_credit_transfer: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub ach_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub acss_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub alipay: Option, /// 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, - #[serde(skip_serializing_if = "Option::is_none")] pub au_becs_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bancontact: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub card_present: Option, /// 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, /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -44,43 +37,32 @@ pub struct Source { pub currency: Option, /// 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, - #[serde(skip_serializing_if = "Option::is_none")] pub eps: Option, /// 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, /// Unique identifier for the object. pub id: stripe_shared::SourceId, - #[serde(skip_serializing_if = "Option::is_none")] pub ideal: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub klarna: Option, /// 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>, - #[serde(skip_serializing_if = "Option::is_none")] pub multibanco: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: SourceObject, /// Information about the owner of the payment instrument that may be used or required by particular source types. pub owner: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub p24: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub receiver: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub redirect: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_credit_transfer: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_debit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sofort: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub source_order: Option, /// Extra information about a source. /// This will appear on your customer's statement every time you charge the source. @@ -88,22 +70,365 @@ 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, /// 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(feature = "serde", 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, - #[serde(skip_serializing_if = "Option::is_none")] pub wechat: Option, } +#[doc(hidden)] +pub struct SourceBuilder { + ach_credit_transfer: Option>, + ach_debit: Option>, + acss_debit: Option>, + alipay: Option>, + amount: Option>, + au_becs_debit: Option>, + bancontact: Option>, + card: Option>, + card_present: Option>, + client_secret: Option, + code_verification: Option>, + created: Option, + currency: Option>, + customer: Option>, + eps: Option>, + flow: Option, + giropay: Option>, + id: Option, + ideal: Option>, + klarna: Option>, + livemode: Option, + metadata: Option>>, + multibanco: Option>, + object: Option, + owner: Option>, + p24: Option>, + receiver: Option>, + redirect: Option>, + sepa_credit_transfer: Option>, + sepa_debit: Option>, + sofort: Option>, + source_order: Option>, + statement_descriptor: Option>, + status: Option, + three_d_secure: Option>, + type_: Option, + usage: Option>, + wechat: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + ach_credit_transfer: self.ach_credit_transfer.take()?, + ach_debit: self.ach_debit.take()?, + acss_debit: self.acss_debit.take()?, + alipay: self.alipay.take()?, + amount: self.amount?, + au_becs_debit: self.au_becs_debit.take()?, + bancontact: self.bancontact.take()?, + card: self.card.take()?, + card_present: self.card_present.take()?, + client_secret: self.client_secret.take()?, + code_verification: self.code_verification.take()?, + created: self.created?, + currency: self.currency?, + customer: self.customer.take()?, + eps: self.eps.take()?, + flow: self.flow.take()?, + giropay: self.giropay.take()?, + id: self.id.take()?, + ideal: self.ideal.take()?, + klarna: self.klarna.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + multibanco: self.multibanco.take()?, + object: self.object?, + owner: self.owner.take()?, + p24: self.p24.take()?, + receiver: self.receiver.take()?, + redirect: self.redirect.take()?, + sepa_credit_transfer: self.sepa_credit_transfer.take()?, + sepa_debit: self.sepa_debit.take()?, + sofort: self.sofort.take()?, + source_order: self.source_order.take()?, + statement_descriptor: self.statement_descriptor.take()?, + status: self.status.take()?, + three_d_secure: self.three_d_secure.take()?, + type_: self.type_?, + usage: self.usage.take()?, + wechat: self.wechat.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum SourceObject { + Source, +} +impl SourceObject { + pub fn as_str(self) -> &'static str { + use SourceObject::*; + match self { + Source => "source", + } + } +} + +impl std::str::FromStr for SourceObject { + type Err = (); + fn from_str(s: &str) -> Result { + use SourceObject::*; + match s { + "source" => Ok(Source), + _ => Err(()), + } + } +} +impl std::fmt::Display for SourceObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for SourceObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for SourceObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for SourceObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SourceObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SourceObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for SourceObject { + fn deserialize>(deserializer: D) -> 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 SourceObject")) + } +} /// 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. @@ -200,6 +525,7 @@ impl std::fmt::Debug for SourceType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SourceType { fn serialize(&self, serializer: S) -> Result where @@ -208,11 +534,27 @@ impl serde::Serialize for SourceType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SourceType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SourceType::from_str(s).unwrap_or(SourceType::Unknown)); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SourceType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SourceType { fn deserialize>(deserializer: D) -> Result { 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)) } } impl stripe_types::Object for Source { diff --git a/generated/stripe_shared/src/source_code_verification_flow.rs b/generated/stripe_shared/src/source_code_verification_flow.rs index ebaa0cc38..d80e7faf3 100644 --- a/generated/stripe_shared/src/source_code_verification_flow.rs +++ b/generated/stripe_shared/src/source_code_verification_flow.rs @@ -1,7 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct SourceCodeVerificationFlowBuilder { + attempts_remaining: Option, + status: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceCodeVerificationFlowBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { attempts_remaining: Deserialize::default(), status: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + attempts_remaining: self.attempts_remaining?, + status: self.status.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..389677756 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,118 @@ 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, /// List of items constituting the order. pub items: Option>, - #[serde(skip_serializing_if = "Option::is_none")] pub shipping: Option, } +#[doc(hidden)] +pub struct SourceOrderBuilder { + amount: Option, + currency: Option, + email: Option>, + items: Option>>, + shipping: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceOrderBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount: self.amount?, + currency: self.currency?, + email: self.email.take()?, + items: self.items.take()?, + shipping: self.shipping.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..e8ffce7d4 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceOrderItem { /// The amount (price) for this order item. pub amount: Option, @@ -11,9 +13,123 @@ pub struct SourceOrderItem { pub parent: Option, /// 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, /// The type of this order item. Must be `sku`, `tax`, or `shipping`. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: Option, } +#[doc(hidden)] +pub struct SourceOrderItemBuilder { + amount: Option>, + currency: Option>, + description: Option>, + parent: Option>, + quantity: Option>, + type_: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceOrderItemBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + amount: self.amount?, + currency: self.currency?, + description: self.description.take()?, + parent: self.parent.take()?, + quantity: self.quantity?, + type_: self.type_.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..0bc3f2ded 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceOwner { /// Owner's address. pub address: Option, @@ -25,3 +27,128 @@ pub struct SourceOwner { /// They cannot be set or mutated. pub verified_phone: Option, } +#[doc(hidden)] +pub struct SourceOwnerBuilder { + address: Option>, + email: Option>, + name: Option>, + phone: Option>, + verified_address: Option>, + verified_email: Option>, + verified_name: Option>, + verified_phone: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceOwnerBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + address: self.address.take()?, + email: self.email.take()?, + name: self.name.take()?, + phone: self.phone.take()?, + verified_address: self.verified_address.take()?, + verified_email: self.verified_email.take()?, + verified_name: self.verified_name.take()?, + verified_phone: self.verified_phone.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..73280d056 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,126 @@ pub struct SourceReceiverFlow { /// Type of refund attribute status, one of `missing`, `requested`, or `available`. pub refund_attributes_status: String, } +#[doc(hidden)] +pub struct SourceReceiverFlowBuilder { + address: Option>, + amount_charged: Option, + amount_received: Option, + amount_returned: Option, + refund_attributes_method: Option, + refund_attributes_status: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceReceiverFlowBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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) + } + + _ => ::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 { + Some(Self::Out { + address: self.address.take()?, + amount_charged: self.amount_charged?, + amount_received: self.amount_received?, + amount_returned: self.amount_returned?, + refund_attributes_method: self.refund_attributes_method.take()?, + refund_attributes_status: self.refund_attributes_status.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..013902f34 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,108 @@ pub struct SourceRedirectFlow { /// The URL provided to you to redirect a customer to as part of a `redirect` authentication flow. pub url: String, } +#[doc(hidden)] +pub struct SourceRedirectFlowBuilder { + failure_reason: Option>, + return_url: Option, + status: Option, + url: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceRedirectFlowBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + failure_reason: self.failure_reason.take()?, + return_url: self.return_url.take()?, + status: self.status.take()?, + url: self.url.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..0830c9e84 100644 --- a/generated/stripe_shared/src/source_transaction.rs +++ b/generated/stripe_shared/src/source_transaction.rs @@ -2,37 +2,267 @@ /// 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTransaction { - #[serde(skip_serializing_if = "Option::is_none")] pub ach_credit_transfer: Option, /// 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, /// 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, /// 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")] + /// String representing the object's type. Objects of the same type share the same value. + pub object: SourceTransactionObject, pub paper_check: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sepa_credit_transfer: Option, /// 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(feature = "serde", serde(rename = "type"))] pub type_: SourceTransactionType, } +#[doc(hidden)] +pub struct SourceTransactionBuilder { + ach_credit_transfer: Option>, + amount: Option, + chf_credit_transfer: Option>, + created: Option, + currency: Option, + gbp_credit_transfer: Option>, + id: Option, + livemode: Option, + object: Option, + paper_check: Option>, + sepa_credit_transfer: Option>, + source: Option, + status: Option, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTransactionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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_), + + _ => ::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(), + object: 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 { + Some(Self::Out { + ach_credit_transfer: self.ach_credit_transfer.take()?, + amount: self.amount?, + chf_credit_transfer: self.chf_credit_transfer.take()?, + created: self.created?, + currency: self.currency?, + gbp_credit_transfer: self.gbp_credit_transfer.take()?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + paper_check: self.paper_check.take()?, + sepa_credit_transfer: self.sepa_credit_transfer.take()?, + source: self.source.take()?, + status: self.status.take()?, + type_: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum SourceTransactionObject { + SourceTransaction, +} +impl SourceTransactionObject { + pub fn as_str(self) -> &'static str { + use SourceTransactionObject::*; + match self { + SourceTransaction => "source_transaction", + } + } +} + +impl std::str::FromStr for SourceTransactionObject { + type Err = (); + fn from_str(s: &str) -> Result { + use SourceTransactionObject::*; + match s { + "source_transaction" => Ok(SourceTransaction), + _ => Err(()), + } + } +} +impl std::fmt::Display for SourceTransactionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for SourceTransactionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for SourceTransactionObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for SourceTransactionObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SourceTransactionObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SourceTransactionObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for SourceTransactionObject { + fn deserialize>(deserializer: D) -> 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 SourceTransactionObject")) + } +} /// The type of source this transaction is attached to. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -117,6 +347,7 @@ impl std::fmt::Debug for SourceTransactionType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SourceTransactionType { fn serialize(&self, serializer: S) -> Result where @@ -125,11 +356,28 @@ impl serde::Serialize for SourceTransactionType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SourceTransactionType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(SourceTransactionType::from_str(s).unwrap_or(SourceTransactionType::Unknown)); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SourceTransactionType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SourceTransactionType { fn deserialize>(deserializer: D) -> Result { 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)) } } impl stripe_types::Object for SourceTransaction { 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..7ecc8c9e8 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,118 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTransactionAchCreditTransferData { /// Customer data associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub customer_data: Option, /// Bank account fingerprint associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option, /// Last 4 digits of the account number associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option, /// Routing number associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub routing_number: Option, } +#[doc(hidden)] +pub struct SourceTransactionAchCreditTransferDataBuilder { + customer_data: Option>, + fingerprint: Option>, + last4: Option>, + routing_number: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTransactionAchCreditTransferDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + customer_data: self.customer_data.take()?, + fingerprint: self.fingerprint.take()?, + last4: self.last4.take()?, + routing_number: self.routing_number.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..73510e991 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,129 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTransactionChfCreditTransferData { /// Reference associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub reference: Option, /// Sender's country address. - #[serde(skip_serializing_if = "Option::is_none")] pub sender_address_country: Option, /// Sender's line 1 address. - #[serde(skip_serializing_if = "Option::is_none")] pub sender_address_line1: Option, /// Sender's bank account IBAN. - #[serde(skip_serializing_if = "Option::is_none")] pub sender_iban: Option, /// Sender's name. - #[serde(skip_serializing_if = "Option::is_none")] pub sender_name: Option, } +#[doc(hidden)] +pub struct SourceTransactionChfCreditTransferDataBuilder { + reference: Option>, + sender_address_country: Option>, + sender_address_line1: Option>, + sender_iban: Option>, + sender_name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTransactionChfCreditTransferDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + reference: self.reference.take()?, + sender_address_country: self.sender_address_country.take()?, + sender_address_line1: self.sender_address_line1.take()?, + sender_iban: self.sender_iban.take()?, + sender_name: self.sender_name.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..9e833704c 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,143 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// 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, /// Last 4 digits of sender account number associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option, /// Sender entered arbitrary information about the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub reference: Option, /// Sender account number associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub sender_account_number: Option, /// Sender name associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub sender_name: Option, /// Sender sort code associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub sender_sort_code: Option, } +#[doc(hidden)] +pub struct SourceTransactionGbpCreditTransferDataBuilder { + fingerprint: Option>, + funding_method: Option>, + last4: Option>, + reference: Option>, + sender_account_number: Option>, + sender_name: Option>, + sender_sort_code: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTransactionGbpCreditTransferDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + fingerprint: self.fingerprint.take()?, + funding_method: self.funding_method.take()?, + last4: self.last4.take()?, + reference: self.reference.take()?, + sender_account_number: self.sender_account_number.take()?, + sender_name: self.sender_name.take()?, + sender_sort_code: self.sender_sort_code.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..53f629a60 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,102 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// Comma-separated list of invoice IDs associated with the paper check. - #[serde(skip_serializing_if = "Option::is_none")] pub invoices: Option, } +#[doc(hidden)] +pub struct SourceTransactionPaperCheckDataBuilder { + available_at: Option>, + invoices: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTransactionPaperCheckDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { available_at: Deserialize::default(), invoices: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + available_at: self.available_at.take()?, + invoices: self.invoices.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..30a79104f 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,111 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTransactionSepaCreditTransferData { /// Reference associated with the transfer. - #[serde(skip_serializing_if = "Option::is_none")] pub reference: Option, /// Sender's bank account IBAN. - #[serde(skip_serializing_if = "Option::is_none")] pub sender_iban: Option, /// Sender's name. - #[serde(skip_serializing_if = "Option::is_none")] pub sender_name: Option, } +#[doc(hidden)] +pub struct SourceTransactionSepaCreditTransferDataBuilder { + reference: Option>, + sender_iban: Option>, + sender_name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTransactionSepaCreditTransferDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + reference: Deserialize::default(), + sender_iban: Deserialize::default(), + sender_name: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + reference: self.reference.take()?, + sender_iban: self.sender_iban.take()?, + sender_name: self.sender_name.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..b9cb42389 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,148 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeAchCreditTransfer { - #[serde(skip_serializing_if = "Option::is_none")] pub account_number: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bank_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_type: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_routing_number: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub routing_number: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub swift_code: Option, } +#[doc(hidden)] +pub struct SourceTypeAchCreditTransferBuilder { + account_number: Option>, + bank_name: Option>, + fingerprint: Option>, + refund_account_holder_name: Option>, + refund_account_holder_type: Option>, + refund_routing_number: Option>, + routing_number: Option>, + swift_code: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeAchCreditTransferBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + account_number: self.account_number.take()?, + bank_name: self.bank_name.take()?, + fingerprint: self.fingerprint.take()?, + refund_account_holder_name: self.refund_account_holder_name.take()?, + refund_account_holder_type: self.refund_account_holder_type.take()?, + refund_routing_number: self.refund_routing_number.take()?, + routing_number: self.routing_number.take()?, + swift_code: self.swift_code.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..5abf839ca 100644 --- a/generated/stripe_shared/src/source_type_ach_debit.rs +++ b/generated/stripe_shared/src/source_type_ach_debit.rs @@ -1,16 +1,127 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeAchDebit { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub country: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub routing_number: Option, - #[serde(rename = "type")] - #[serde(skip_serializing_if = "Option::is_none")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: Option, } +#[doc(hidden)] +pub struct SourceTypeAchDebitBuilder { + bank_name: Option>, + country: Option>, + fingerprint: Option>, + last4: Option>, + routing_number: Option>, + type_: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeAchDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + bank_name: self.bank_name.take()?, + country: self.country.take()?, + fingerprint: self.fingerprint.take()?, + last4: self.last4.take()?, + routing_number: self.routing_number.take()?, + type_: self.type_.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..213616380 100644 --- a/generated/stripe_shared/src/source_type_acss_debit.rs +++ b/generated/stripe_shared/src/source_type_acss_debit.rs @@ -1,23 +1,158 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeAcssDebit { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_address_city: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bank_address_line_1: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bank_address_line_2: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bank_address_postal_code: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bank_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub category: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub country: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub routing_number: Option, } +#[doc(hidden)] +pub struct SourceTypeAcssDebitBuilder { + bank_address_city: Option>, + bank_address_line_1: Option>, + bank_address_line_2: Option>, + bank_address_postal_code: Option>, + bank_name: Option>, + category: Option>, + country: Option>, + fingerprint: Option>, + last4: Option>, + routing_number: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeAcssDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank_address_city: self.bank_address_city.take()?, + bank_address_line_1: self.bank_address_line_1.take()?, + bank_address_line_2: self.bank_address_line_2.take()?, + bank_address_postal_code: self.bank_address_postal_code.take()?, + bank_name: self.bank_name.take()?, + category: self.category.take()?, + country: self.country.take()?, + fingerprint: self.fingerprint.take()?, + last4: self.last4.take()?, + routing_number: self.routing_number.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..5a25c0029 100644 --- a/generated/stripe_shared/src/source_type_alipay.rs +++ b/generated/stripe_shared/src/source_type_alipay.rs @@ -1,9 +1,110 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeAlipay { - #[serde(skip_serializing_if = "Option::is_none")] pub data_string: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub native_url: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option, } +#[doc(hidden)] +pub struct SourceTypeAlipayBuilder { + data_string: Option>, + native_url: Option>, + statement_descriptor: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeAlipayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + data_string: Deserialize::default(), + native_url: Deserialize::default(), + statement_descriptor: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + data_string: self.data_string.take()?, + native_url: self.native_url.take()?, + statement_descriptor: self.statement_descriptor.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..443233c12 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,108 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeAuBecsDebit { - #[serde(skip_serializing_if = "Option::is_none")] pub bsb_number: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option, } +#[doc(hidden)] +pub struct SourceTypeAuBecsDebitBuilder { + bsb_number: Option>, + fingerprint: Option>, + last4: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeAuBecsDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bsb_number: Deserialize::default(), + fingerprint: Deserialize::default(), + last4: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + bsb_number: self.bsb_number.take()?, + fingerprint: self.fingerprint.take()?, + last4: self.last4.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..9fc164daf 100644 --- a/generated/stripe_shared/src/source_type_bancontact.rs +++ b/generated/stripe_shared/src/source_type_bancontact.rs @@ -1,15 +1,130 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeBancontact { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_code: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bank_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bic: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub iban_last4: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub preferred_language: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option, } +#[doc(hidden)] +pub struct SourceTypeBancontactBuilder { + bank_code: Option>, + bank_name: Option>, + bic: Option>, + iban_last4: Option>, + preferred_language: Option>, + statement_descriptor: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeBancontactBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank_code: self.bank_code.take()?, + bank_name: self.bank_name.take()?, + bic: self.bic.take()?, + iban_last4: self.iban_last4.take()?, + preferred_language: self.preferred_language.take()?, + statement_descriptor: self.statement_descriptor.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..78a38a3fa 100644 --- a/generated/stripe_shared/src/source_type_card.rs +++ b/generated/stripe_shared/src/source_type_card.rs @@ -1,37 +1,196 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeCard { - #[serde(skip_serializing_if = "Option::is_none")] pub address_line1_check: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub address_zip_check: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub brand: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub country: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cvc_check: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_last4: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub exp_month: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub exp_year: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub funding: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub iin: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub issuer: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub three_d_secure: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub tokenization_method: Option, } +#[doc(hidden)] +pub struct SourceTypeCardBuilder { + address_line1_check: Option>, + address_zip_check: Option>, + brand: Option>, + country: Option>, + cvc_check: Option>, + description: Option>, + dynamic_last4: Option>, + exp_month: Option>, + exp_year: Option>, + fingerprint: Option>, + funding: Option>, + iin: Option>, + issuer: Option>, + last4: Option>, + name: Option>, + three_d_secure: Option>, + tokenization_method: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeCardBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + address_line1_check: self.address_line1_check.take()?, + address_zip_check: self.address_zip_check.take()?, + brand: self.brand.take()?, + country: self.country.take()?, + cvc_check: self.cvc_check.take()?, + description: self.description.take()?, + dynamic_last4: self.dynamic_last4.take()?, + exp_month: self.exp_month?, + exp_year: self.exp_year?, + fingerprint: self.fingerprint.take()?, + funding: self.funding.take()?, + iin: self.iin.take()?, + issuer: self.issuer.take()?, + last4: self.last4.take()?, + name: self.name.take()?, + three_d_secure: self.three_d_secure.take()?, + tokenization_method: self.tokenization_method.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..d47e4d199 100644 --- a/generated/stripe_shared/src/source_type_card_present.rs +++ b/generated/stripe_shared/src/source_type_card_present.rs @@ -1,55 +1,276 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeCardPresent { - #[serde(skip_serializing_if = "Option::is_none")] pub application_cryptogram: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub application_preferred_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub authorization_code: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub authorization_response_code: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub brand: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub country: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cvm_type: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub data_type: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub dedicated_file_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub emv_auth_data: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub evidence_customer_signature: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub evidence_transaction_certificate: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub exp_month: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub exp_year: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub funding: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub iin: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub issuer: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pos_device_id: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pos_entry_mode: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub read_method: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub reader: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub terminal_verification_results: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub transaction_status_information: Option, } +#[doc(hidden)] +pub struct SourceTypeCardPresentBuilder { + application_cryptogram: Option>, + application_preferred_name: Option>, + authorization_code: Option>, + authorization_response_code: Option>, + brand: Option>, + country: Option>, + cvm_type: Option>, + data_type: Option>, + dedicated_file_name: Option>, + description: Option>, + emv_auth_data: Option>, + evidence_customer_signature: Option>, + evidence_transaction_certificate: Option>, + exp_month: Option>, + exp_year: Option>, + fingerprint: Option>, + funding: Option>, + iin: Option>, + issuer: Option>, + last4: Option>, + pos_device_id: Option>, + pos_entry_mode: Option>, + read_method: Option>, + reader: Option>, + terminal_verification_results: Option>, + transaction_status_information: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeCardPresentBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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) + } + + _ => ::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 { + Some(Self::Out { + application_cryptogram: self.application_cryptogram.take()?, + application_preferred_name: self.application_preferred_name.take()?, + authorization_code: self.authorization_code.take()?, + authorization_response_code: self.authorization_response_code.take()?, + brand: self.brand.take()?, + country: self.country.take()?, + cvm_type: self.cvm_type.take()?, + data_type: self.data_type.take()?, + dedicated_file_name: self.dedicated_file_name.take()?, + description: self.description.take()?, + emv_auth_data: self.emv_auth_data.take()?, + evidence_customer_signature: self.evidence_customer_signature.take()?, + evidence_transaction_certificate: self.evidence_transaction_certificate.take()?, + exp_month: self.exp_month?, + exp_year: self.exp_year?, + fingerprint: self.fingerprint.take()?, + funding: self.funding.take()?, + iin: self.iin.take()?, + issuer: self.issuer.take()?, + last4: self.last4.take()?, + pos_device_id: self.pos_device_id.take()?, + pos_entry_mode: self.pos_entry_mode.take()?, + read_method: self.read_method.take()?, + reader: self.reader.take()?, + terminal_verification_results: self.terminal_verification_results.take()?, + transaction_status_information: self.transaction_status_information.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..124f646cd 100644 --- a/generated/stripe_shared/src/source_type_eps.rs +++ b/generated/stripe_shared/src/source_type_eps.rs @@ -1,7 +1,101 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeEps { - #[serde(skip_serializing_if = "Option::is_none")] pub reference: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option, } +#[doc(hidden)] +pub struct SourceTypeEpsBuilder { + reference: Option>, + statement_descriptor: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeEpsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { reference: Deserialize::default(), statement_descriptor: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + reference: self.reference.take()?, + statement_descriptor: self.statement_descriptor.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..6c0d1d695 100644 --- a/generated/stripe_shared/src/source_type_giropay.rs +++ b/generated/stripe_shared/src/source_type_giropay.rs @@ -1,11 +1,116 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeGiropay { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_code: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bank_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bic: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option, } +#[doc(hidden)] +pub struct SourceTypeGiropayBuilder { + bank_code: Option>, + bank_name: Option>, + bic: Option>, + statement_descriptor: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeGiropayBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank_code: self.bank_code.take()?, + bank_name: self.bank_name.take()?, + bic: self.bic.take()?, + statement_descriptor: self.statement_descriptor.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..ff6e288b7 100644 --- a/generated/stripe_shared/src/source_type_ideal.rs +++ b/generated/stripe_shared/src/source_type_ideal.rs @@ -1,11 +1,116 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeIdeal { - #[serde(skip_serializing_if = "Option::is_none")] pub bank: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bic: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub iban_last4: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option, } +#[doc(hidden)] +pub struct SourceTypeIdealBuilder { + bank: Option>, + bic: Option>, + iban_last4: Option>, + statement_descriptor: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeIdealBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank: self.bank.take()?, + bic: self.bic.take()?, + iban_last4: self.iban_last4.take()?, + statement_descriptor: self.statement_descriptor.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..e15d89744 100644 --- a/generated/stripe_shared/src/source_type_klarna.rs +++ b/generated/stripe_shared/src/source_type_klarna.rs @@ -1,55 +1,292 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeKlarna { - #[serde(skip_serializing_if = "Option::is_none")] pub background_image_url: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub client_token: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub first_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub last_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub locale: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub logo_url: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub page_title: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_later_asset_urls_descriptive: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_later_asset_urls_standard: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_later_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_later_redirect_url: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_now_asset_urls_descriptive: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_now_asset_urls_standard: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_now_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_now_redirect_url: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_over_time_asset_urls_descriptive: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_over_time_asset_urls_standard: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_over_time_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub pay_over_time_redirect_url: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub payment_method_categories: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub purchase_country: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub purchase_type: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub redirect_url: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub shipping_delay: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub shipping_first_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub shipping_last_name: Option, } +#[doc(hidden)] +pub struct SourceTypeKlarnaBuilder { + background_image_url: Option>, + client_token: Option>, + first_name: Option>, + last_name: Option>, + locale: Option>, + logo_url: Option>, + page_title: Option>, + pay_later_asset_urls_descriptive: Option>, + pay_later_asset_urls_standard: Option>, + pay_later_name: Option>, + pay_later_redirect_url: Option>, + pay_now_asset_urls_descriptive: Option>, + pay_now_asset_urls_standard: Option>, + pay_now_name: Option>, + pay_now_redirect_url: Option>, + pay_over_time_asset_urls_descriptive: Option>, + pay_over_time_asset_urls_standard: Option>, + pay_over_time_name: Option>, + pay_over_time_redirect_url: Option>, + payment_method_categories: Option>, + purchase_country: Option>, + purchase_type: Option>, + redirect_url: Option>, + shipping_delay: Option>, + shipping_first_name: Option>, + shipping_last_name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeKlarnaBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + background_image_url: self.background_image_url.take()?, + client_token: self.client_token.take()?, + first_name: self.first_name.take()?, + last_name: self.last_name.take()?, + locale: self.locale.take()?, + logo_url: self.logo_url.take()?, + page_title: self.page_title.take()?, + pay_later_asset_urls_descriptive: self.pay_later_asset_urls_descriptive.take()?, + pay_later_asset_urls_standard: self.pay_later_asset_urls_standard.take()?, + pay_later_name: self.pay_later_name.take()?, + pay_later_redirect_url: self.pay_later_redirect_url.take()?, + pay_now_asset_urls_descriptive: self.pay_now_asset_urls_descriptive.take()?, + pay_now_asset_urls_standard: self.pay_now_asset_urls_standard.take()?, + pay_now_name: self.pay_now_name.take()?, + pay_now_redirect_url: self.pay_now_redirect_url.take()?, + pay_over_time_asset_urls_descriptive: self + .pay_over_time_asset_urls_descriptive + .take()?, + pay_over_time_asset_urls_standard: self.pay_over_time_asset_urls_standard.take()?, + pay_over_time_name: self.pay_over_time_name.take()?, + pay_over_time_redirect_url: self.pay_over_time_redirect_url.take()?, + payment_method_categories: self.payment_method_categories.take()?, + purchase_country: self.purchase_country.take()?, + purchase_type: self.purchase_type.take()?, + redirect_url: self.redirect_url.take()?, + shipping_delay: self.shipping_delay?, + shipping_first_name: self.shipping_first_name.take()?, + shipping_last_name: self.shipping_last_name.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..cf23d5721 100644 --- a/generated/stripe_shared/src/source_type_multibanco.rs +++ b/generated/stripe_shared/src/source_type_multibanco.rs @@ -1,23 +1,191 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeMultibanco { - #[serde(skip_serializing_if = "Option::is_none")] pub entity: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub reference: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_city: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_country: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_line1: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_line2: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_postal_code: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_state: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_iban: Option, } +#[doc(hidden)] +pub struct SourceTypeMultibancoBuilder { + entity: Option>, + reference: Option>, + refund_account_holder_address_city: Option>, + refund_account_holder_address_country: Option>, + refund_account_holder_address_line1: Option>, + refund_account_holder_address_line2: Option>, + refund_account_holder_address_postal_code: Option>, + refund_account_holder_address_state: Option>, + refund_account_holder_name: Option>, + refund_iban: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeMultibancoBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + entity: self.entity.take()?, + reference: self.reference.take()?, + refund_account_holder_address_city: self + .refund_account_holder_address_city + .take()?, + refund_account_holder_address_country: self + .refund_account_holder_address_country + .take()?, + refund_account_holder_address_line1: self + .refund_account_holder_address_line1 + .take()?, + refund_account_holder_address_line2: self + .refund_account_holder_address_line2 + .take()?, + refund_account_holder_address_postal_code: self + .refund_account_holder_address_postal_code + .take()?, + refund_account_holder_address_state: self + .refund_account_holder_address_state + .take()?, + refund_account_holder_name: self.refund_account_holder_name.take()?, + refund_iban: self.refund_iban.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..2cd0a7a16 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeP24 { - #[serde(skip_serializing_if = "Option::is_none")] pub reference: Option, } +#[doc(hidden)] +pub struct SourceTypeP24Builder { + reference: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeP24Builder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { reference: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { reference: self.reference.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..9e44f88ee 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,197 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeSepaCreditTransfer { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bic: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub iban: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_city: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_country: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_line1: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_line2: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_postal_code: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_address_state: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_account_holder_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_iban: Option, } +#[doc(hidden)] +pub struct SourceTypeSepaCreditTransferBuilder { + bank_name: Option>, + bic: Option>, + iban: Option>, + refund_account_holder_address_city: Option>, + refund_account_holder_address_country: Option>, + refund_account_holder_address_line1: Option>, + refund_account_holder_address_line2: Option>, + refund_account_holder_address_postal_code: Option>, + refund_account_holder_address_state: Option>, + refund_account_holder_name: Option>, + refund_iban: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeSepaCreditTransferBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank_name: self.bank_name.take()?, + bic: self.bic.take()?, + iban: self.iban.take()?, + refund_account_holder_address_city: self + .refund_account_holder_address_city + .take()?, + refund_account_holder_address_country: self + .refund_account_holder_address_country + .take()?, + refund_account_holder_address_line1: self + .refund_account_holder_address_line1 + .take()?, + refund_account_holder_address_line2: self + .refund_account_holder_address_line2 + .take()?, + refund_account_holder_address_postal_code: self + .refund_account_holder_address_postal_code + .take()?, + refund_account_holder_address_state: self + .refund_account_holder_address_state + .take()?, + refund_account_holder_name: self.refund_account_holder_name.take()?, + refund_iban: self.refund_iban.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..bc0505e48 100644 --- a/generated/stripe_shared/src/source_type_sepa_debit.rs +++ b/generated/stripe_shared/src/source_type_sepa_debit.rs @@ -1,17 +1,132 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeSepaDebit { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_code: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub branch_code: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub country: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub mandate_reference: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub mandate_url: Option, } +#[doc(hidden)] +pub struct SourceTypeSepaDebitBuilder { + bank_code: Option>, + branch_code: Option>, + country: Option>, + fingerprint: Option>, + last4: Option>, + mandate_reference: Option>, + mandate_url: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeSepaDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank_code: self.bank_code.take()?, + branch_code: self.branch_code.take()?, + country: self.country.take()?, + fingerprint: self.fingerprint.take()?, + last4: self.last4.take()?, + mandate_reference: self.mandate_reference.take()?, + mandate_url: self.mandate_url.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..b0b6a7b4b 100644 --- a/generated/stripe_shared/src/source_type_sofort.rs +++ b/generated/stripe_shared/src/source_type_sofort.rs @@ -1,17 +1,136 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeSofort { - #[serde(skip_serializing_if = "Option::is_none")] pub bank_code: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bank_name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub bic: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub country: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub iban_last4: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub preferred_language: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option, } +#[doc(hidden)] +pub struct SourceTypeSofortBuilder { + bank_code: Option>, + bank_name: Option>, + bic: Option>, + country: Option>, + iban_last4: Option>, + preferred_language: Option>, + statement_descriptor: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeSofortBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + bank_code: self.bank_code.take()?, + bank_name: self.bank_name.take()?, + bic: self.bic.take()?, + country: self.country.take()?, + iban_last4: self.iban_last4.take()?, + preferred_language: self.preferred_language.take()?, + statement_descriptor: self.statement_descriptor.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..0b7d5a1b3 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,214 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeThreeDSecure { - #[serde(skip_serializing_if = "Option::is_none")] pub address_line1_check: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub address_zip_check: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub authenticated: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub brand: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub card: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub country: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub customer: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cvc_check: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub dynamic_last4: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub exp_month: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub exp_year: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub fingerprint: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub funding: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub iin: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub issuer: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub last4: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub name: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub three_d_secure: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub tokenization_method: Option, } +#[doc(hidden)] +pub struct SourceTypeThreeDSecureBuilder { + address_line1_check: Option>, + address_zip_check: Option>, + authenticated: Option>, + brand: Option>, + card: Option>, + country: Option>, + customer: Option>, + cvc_check: Option>, + description: Option>, + dynamic_last4: Option>, + exp_month: Option>, + exp_year: Option>, + fingerprint: Option>, + funding: Option>, + iin: Option>, + issuer: Option>, + last4: Option>, + name: Option>, + three_d_secure: Option>, + tokenization_method: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeThreeDSecureBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + address_line1_check: self.address_line1_check.take()?, + address_zip_check: self.address_zip_check.take()?, + authenticated: self.authenticated?, + brand: self.brand.take()?, + card: self.card.take()?, + country: self.country.take()?, + customer: self.customer.take()?, + cvc_check: self.cvc_check.take()?, + description: self.description.take()?, + dynamic_last4: self.dynamic_last4.take()?, + exp_month: self.exp_month?, + exp_year: self.exp_year?, + fingerprint: self.fingerprint.take()?, + funding: self.funding.take()?, + iin: self.iin.take()?, + issuer: self.issuer.take()?, + last4: self.last4.take()?, + name: self.name.take()?, + three_d_secure: self.three_d_secure.take()?, + tokenization_method: self.tokenization_method.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..c2aa4aab0 100644 --- a/generated/stripe_shared/src/source_type_wechat.rs +++ b/generated/stripe_shared/src/source_type_wechat.rs @@ -1,9 +1,110 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SourceTypeWechat { - #[serde(skip_serializing_if = "Option::is_none")] pub prepay_id: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub qr_code_url: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option, } +#[doc(hidden)] +pub struct SourceTypeWechatBuilder { + prepay_id: Option>, + qr_code_url: Option>, + statement_descriptor: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SourceTypeWechatBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + prepay_id: self.prepay_id.take()?, + qr_code_url: self.qr_code_url.take()?, + statement_descriptor: self.statement_descriptor.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..c61033694 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Subscription { /// ID of the Connect Application that created the subscription. pub application: Option>, @@ -61,7 +63,6 @@ pub struct Subscription { pub default_source: Option>, /// 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>, /// 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. @@ -84,6 +85,8 @@ pub struct Subscription { pub metadata: std::collections::HashMap, /// Specifies the approximate timestamp on which any pending invoice items will be billed according to the schedule provided at `pending_invoice_item_interval`. pub next_pending_invoice_item_invoice: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: SubscriptionObject, /// The account (if any) the charge was made on behalf of for charges associated with this subscription. /// See the Connect documentation for details. pub on_behalf_of: Option>, @@ -137,6 +140,411 @@ pub struct Subscription { /// If the subscription has a trial, the beginning of that trial. pub trial_start: Option, } +#[doc(hidden)] +pub struct SubscriptionBuilder { + application: Option>>, + application_fee_percent: Option>, + automatic_tax: Option, + billing_cycle_anchor: Option, + billing_cycle_anchor_config: + Option>, + billing_thresholds: Option>, + cancel_at: Option>, + cancel_at_period_end: Option, + canceled_at: Option>, + cancellation_details: Option>, + collection_method: Option, + created: Option, + currency: Option, + current_period_end: Option, + current_period_start: Option, + customer: Option>, + days_until_due: Option>, + default_payment_method: Option>>, + default_source: Option>>, + default_tax_rates: Option>>, + description: Option>, + discount: Option>, + ended_at: Option>, + id: Option, + items: Option>, + latest_invoice: Option>>, + livemode: Option, + metadata: Option>, + next_pending_invoice_item_invoice: Option>, + object: Option, + on_behalf_of: Option>>, + pause_collection: Option>, + payment_settings: Option>, + pending_invoice_item_interval: + Option>, + pending_setup_intent: Option>>, + pending_update: Option>, + schedule: Option>>, + start_date: Option, + status: Option, + test_clock: Option>>, + transfer_data: Option>, + trial_end: Option>, + trial_settings: Option>, + trial_start: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_cycle_anchor_config" => { + Deserialize::begin(&mut self.billing_cycle_anchor_config) + } + "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) + } + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + application: Deserialize::default(), + application_fee_percent: Deserialize::default(), + automatic_tax: Deserialize::default(), + billing_cycle_anchor: Deserialize::default(), + billing_cycle_anchor_config: 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(), + object: 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 { + Some(Self::Out { + application: self.application.take()?, + application_fee_percent: self.application_fee_percent?, + automatic_tax: self.automatic_tax.take()?, + billing_cycle_anchor: self.billing_cycle_anchor?, + billing_cycle_anchor_config: self.billing_cycle_anchor_config?, + billing_thresholds: self.billing_thresholds?, + cancel_at: self.cancel_at?, + cancel_at_period_end: self.cancel_at_period_end?, + canceled_at: self.canceled_at?, + cancellation_details: self.cancellation_details.take()?, + collection_method: self.collection_method?, + created: self.created?, + currency: self.currency?, + current_period_end: self.current_period_end?, + current_period_start: self.current_period_start?, + customer: self.customer.take()?, + days_until_due: self.days_until_due?, + default_payment_method: self.default_payment_method.take()?, + default_source: self.default_source.take()?, + default_tax_rates: self.default_tax_rates.take()?, + description: self.description.take()?, + discount: self.discount.take()?, + ended_at: self.ended_at?, + id: self.id.take()?, + items: self.items.take()?, + latest_invoice: self.latest_invoice.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + next_pending_invoice_item_invoice: self.next_pending_invoice_item_invoice?, + object: self.object?, + on_behalf_of: self.on_behalf_of.take()?, + pause_collection: self.pause_collection?, + payment_settings: self.payment_settings.take()?, + pending_invoice_item_interval: self.pending_invoice_item_interval?, + pending_setup_intent: self.pending_setup_intent.take()?, + pending_update: self.pending_update.take()?, + schedule: self.schedule.take()?, + start_date: self.start_date?, + status: self.status?, + test_clock: self.test_clock.take()?, + transfer_data: self.transfer_data.take()?, + trial_end: self.trial_end?, + trial_settings: self.trial_settings?, + trial_start: self.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 { + 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_cycle_anchor_config" => { + b.billing_cycle_anchor_config = 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)?) + } + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum SubscriptionObject { + Subscription, +} +impl SubscriptionObject { + pub fn as_str(self) -> &'static str { + use SubscriptionObject::*; + match self { + Subscription => "subscription", + } + } +} + +impl std::str::FromStr for SubscriptionObject { + type Err = (); + fn from_str(s: &str) -> Result { + use SubscriptionObject::*; + match s { + "subscription" => Ok(Subscription), + _ => Err(()), + } + } +} +impl std::fmt::Display for SubscriptionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for SubscriptionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for SubscriptionObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for SubscriptionObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SubscriptionObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for SubscriptionObject { + fn deserialize>(deserializer: D) -> 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 SubscriptionObject")) + } +} /// Possible values are `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `canceled`, or `unpaid`. /// /// @@ -212,6 +620,7 @@ impl std::fmt::Debug for SubscriptionStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SubscriptionStatus { fn serialize(&self, serializer: S) -> Result where @@ -220,6 +629,22 @@ impl serde::Serialize for SubscriptionStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SubscriptionStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SubscriptionStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SubscriptionStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -280,6 +705,22 @@ impl serde::Serialize for SubscriptionCollectionMethod { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SubscriptionCollectionMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionCollectionMethod::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SubscriptionCollectionMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SubscriptionCollectionMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/subscription_automatic_tax.rs b/generated/stripe_shared/src/subscription_automatic_tax.rs index 4328f2c5f..48eebff1e 100644 --- a/generated/stripe_shared/src/subscription_automatic_tax.rs +++ b/generated/stripe_shared/src/subscription_automatic_tax.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SubscriptionAutomaticTax { /// Whether Stripe automatically computes tax on this subscription. pub enabled: bool, @@ -7,3 +9,92 @@ pub struct SubscriptionAutomaticTax { /// The tax transaction is returned in the report of the connected account. pub liability: Option, } +#[doc(hidden)] +pub struct SubscriptionAutomaticTaxBuilder { + enabled: Option, + liability: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionAutomaticTaxBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "liability" => Deserialize::begin(&mut self.liability), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default(), liability: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.enabled?, liability: self.liability.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "liability" => b.liability = 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..52d7347f2 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SubscriptionBillingThresholds { /// Monetary threshold that triggers the subscription to create an invoice pub amount_gte: Option, @@ -7,3 +9,102 @@ 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, } +#[doc(hidden)] +pub struct SubscriptionBillingThresholdsBuilder { + amount_gte: Option>, + reset_billing_cycle_anchor: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionBillingThresholdsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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) + } + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount_gte: Deserialize::default(), + reset_billing_cycle_anchor: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount_gte: self.amount_gte?, + reset_billing_cycle_anchor: self.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 { + 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..ec323187b 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, } +#[doc(hidden)] +pub struct SubscriptionDetailsDataBuilder { + metadata: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionDetailsDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { metadata: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { metadata: self.metadata.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..947d800c6 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -13,10 +15,11 @@ pub struct SubscriptionItem { /// 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 representing the object's type. Objects of the same type share the same value. + pub object: SubscriptionItemObject, 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, /// The `subscription` this `subscription_item` belongs to. pub subscription: String, @@ -24,6 +27,211 @@ pub struct SubscriptionItem { /// When set, the `default_tax_rates` on the subscription do not apply to this `subscription_item`. pub tax_rates: Option>, } +#[doc(hidden)] +pub struct SubscriptionItemBuilder { + billing_thresholds: Option>, + created: Option, + id: Option, + metadata: Option>, + object: Option, + plan: Option, + price: Option, + quantity: Option>, + subscription: Option, + tax_rates: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionItemBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + billing_thresholds: Deserialize::default(), + created: Deserialize::default(), + id: Deserialize::default(), + metadata: Deserialize::default(), + object: Deserialize::default(), + plan: Deserialize::default(), + price: Deserialize::default(), + quantity: Deserialize::default(), + subscription: Deserialize::default(), + tax_rates: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + billing_thresholds: self.billing_thresholds?, + created: self.created?, + id: self.id.take()?, + metadata: self.metadata.take()?, + object: self.object?, + plan: self.plan.take()?, + price: self.price.take()?, + quantity: self.quantity?, + subscription: self.subscription.take()?, + tax_rates: self.tax_rates.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum SubscriptionItemObject { + SubscriptionItem, +} +impl SubscriptionItemObject { + pub fn as_str(self) -> &'static str { + use SubscriptionItemObject::*; + match self { + SubscriptionItem => "subscription_item", + } + } +} + +impl std::str::FromStr for SubscriptionItemObject { + type Err = (); + fn from_str(s: &str) -> Result { + use SubscriptionItemObject::*; + match s { + "subscription_item" => Ok(SubscriptionItem), + _ => Err(()), + } + } +} +impl std::fmt::Display for SubscriptionItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for SubscriptionItemObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for SubscriptionItemObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for SubscriptionItemObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionItemObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SubscriptionItemObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for SubscriptionItemObject { + fn deserialize>(deserializer: D) -> 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 SubscriptionItemObject")) + } +} 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..e3db0015b 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SubscriptionItemBillingThresholds { /// Usage threshold that triggers the subscription to create an invoice pub usage_gte: Option, } +#[doc(hidden)] +pub struct SubscriptionItemBillingThresholdsBuilder { + usage_gte: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionItemBillingThresholdsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { usage_gte: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { usage_gte: self.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 { + 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..b32eeb82f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SubscriptionPaymentMethodOptionsCard { - #[serde(skip_serializing_if = "Option::is_none")] pub mandate_options: Option, /// Selected network to process this Subscription on. /// Depends on the available networks of the card attached to the Subscription. @@ -11,6 +12,108 @@ 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, } +#[doc(hidden)] +pub struct SubscriptionPaymentMethodOptionsCardBuilder { + mandate_options: Option>, + network: Option>, + request_three_d_secure: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionPaymentMethodOptionsCardBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + mandate_options: self.mandate_options.take()?, + network: self.network?, + request_three_d_secure: self.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 { + 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. @@ -78,6 +181,7 @@ impl std::fmt::Debug for SubscriptionPaymentMethodOptionsCardNetwork { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SubscriptionPaymentMethodOptionsCardNetwork { fn serialize(&self, serializer: S) -> Result where @@ -86,6 +190,25 @@ impl serde::Serialize for SubscriptionPaymentMethodOptionsCardNetwork { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SubscriptionPaymentMethodOptionsCardNetwork { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SubscriptionPaymentMethodOptionsCardNetwork::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SubscriptionPaymentMethodOptionsCardNetwork); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SubscriptionPaymentMethodOptionsCardNetwork { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -140,6 +263,7 @@ impl std::fmt::Debug for SubscriptionPaymentMethodOptionsCardRequestThreeDSecure f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SubscriptionPaymentMethodOptionsCardRequestThreeDSecure { fn serialize(&self, serializer: S) -> Result where @@ -148,6 +272,27 @@ impl serde::Serialize for SubscriptionPaymentMethodOptionsCardRequestThreeDSecur serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SubscriptionPaymentMethodOptionsCardRequestThreeDSecure { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SubscriptionPaymentMethodOptionsCardRequestThreeDSecure::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SubscriptionPaymentMethodOptionsCardRequestThreeDSecure); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SubscriptionPaymentMethodOptionsCardRequestThreeDSecure { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..653e27d81 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SubscriptionPendingInvoiceItemInterval { /// Specifies invoicing frequency. Either `day`, `week`, `month` or `year`. pub interval: SubscriptionPendingInvoiceItemIntervalInterval, @@ -7,6 +9,95 @@ pub struct SubscriptionPendingInvoiceItemInterval { /// Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). pub interval_count: u64, } +#[doc(hidden)] +pub struct SubscriptionPendingInvoiceItemIntervalBuilder { + interval: Option, + interval_count: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionPendingInvoiceItemIntervalBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { interval: Deserialize::default(), interval_count: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { interval: self.interval?, interval_count: self.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 { + 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 { @@ -51,6 +142,7 @@ impl std::fmt::Debug for SubscriptionPendingInvoiceItemIntervalInterval { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SubscriptionPendingInvoiceItemIntervalInterval { fn serialize(&self, serializer: S) -> Result where @@ -59,6 +151,25 @@ impl serde::Serialize for SubscriptionPendingInvoiceItemIntervalInterval { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SubscriptionPendingInvoiceItemIntervalInterval { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SubscriptionPendingInvoiceItemIntervalInterval::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SubscriptionPendingInvoiceItemIntervalInterval); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SubscriptionPendingInvoiceItemIntervalInterval { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/subscription_schedule.rs b/generated/stripe_shared/src/subscription_schedule.rs index 7672ad33d..532f2db88 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SubscriptionSchedule { /// ID of the Connect Application that created the schedule. pub application: Option>, @@ -30,6 +32,8 @@ pub struct SubscriptionSchedule { /// 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>, + /// String representing the object's type. Objects of the same type share the same value. + pub object: SubscriptionScheduleObject, /// Configuration for the subscription schedule's phases. pub phases: Vec, /// Time at which the subscription schedule was released. Measured in seconds since the Unix epoch. @@ -45,6 +49,251 @@ pub struct SubscriptionSchedule { /// ID of the test clock this subscription schedule belongs to. pub test_clock: Option>, } +#[doc(hidden)] +pub struct SubscriptionScheduleBuilder { + application: Option>>, + canceled_at: Option>, + completed_at: Option>, + created: Option, + current_phase: Option>, + customer: Option>, + default_settings: Option, + end_behavior: Option, + id: Option, + livemode: Option, + metadata: Option>>, + object: Option, + phases: Option>, + released_at: Option>, + released_subscription: Option>, + status: Option, + subscription: Option>>, + test_clock: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionScheduleBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + application: self.application.take()?, + canceled_at: self.canceled_at?, + completed_at: self.completed_at?, + created: self.created?, + current_phase: self.current_phase?, + customer: self.customer.take()?, + default_settings: self.default_settings.take()?, + end_behavior: self.end_behavior?, + id: self.id.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + phases: self.phases.take()?, + released_at: self.released_at?, + released_subscription: self.released_subscription.take()?, + status: self.status?, + subscription: self.subscription.take()?, + test_clock: self.test_clock.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum SubscriptionScheduleObject { + SubscriptionSchedule, +} +impl SubscriptionScheduleObject { + pub fn as_str(self) -> &'static str { + use SubscriptionScheduleObject::*; + match self { + SubscriptionSchedule => "subscription_schedule", + } + } +} + +impl std::str::FromStr for SubscriptionScheduleObject { + type Err = (); + fn from_str(s: &str) -> Result { + use SubscriptionScheduleObject::*; + match s { + "subscription_schedule" => Ok(SubscriptionSchedule), + _ => Err(()), + } + } +} +impl std::fmt::Display for SubscriptionScheduleObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for SubscriptionScheduleObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for SubscriptionScheduleObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for SubscriptionScheduleObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionScheduleObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SubscriptionScheduleObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for SubscriptionScheduleObject { + fn deserialize>(deserializer: D) -> 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 SubscriptionScheduleObject")) + } +} /// 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). @@ -94,6 +343,7 @@ impl std::fmt::Debug for SubscriptionScheduleStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SubscriptionScheduleStatus { fn serialize(&self, serializer: S) -> Result where @@ -102,6 +352,22 @@ impl serde::Serialize for SubscriptionScheduleStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SubscriptionScheduleStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(SubscriptionScheduleStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SubscriptionScheduleStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SubscriptionScheduleStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -168,6 +434,23 @@ impl serde::Serialize for SubscriptionScheduleEndBehavior { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SubscriptionScheduleEndBehavior { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(SubscriptionScheduleEndBehavior::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SubscriptionScheduleEndBehavior); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SubscriptionScheduleEndBehavior { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..d12fbbfc7 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,112 @@ /// 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SubscriptionScheduleAddInvoiceItem { /// ID of the price used to generate the invoice item. pub price: stripe_types::Expandable, /// The quantity of the invoice item. pub quantity: Option, /// 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>, } +#[doc(hidden)] +pub struct SubscriptionScheduleAddInvoiceItemBuilder { + price: Option>, + quantity: Option>, + tax_rates: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionScheduleAddInvoiceItemBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + price: Deserialize::default(), + quantity: Deserialize::default(), + tax_rates: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + price: self.price.take()?, + quantity: self.quantity?, + tax_rates: self.tax_rates.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..4a1d38221 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -11,10 +13,125 @@ pub struct SubscriptionScheduleConfigurationItem { /// ID of the price to which the customer should be subscribed. pub price: stripe_types::Expandable, /// Quantity of the plan to which the customer should be subscribed. - #[serde(skip_serializing_if = "Option::is_none")] pub quantity: Option, /// 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>, } +#[doc(hidden)] +pub struct SubscriptionScheduleConfigurationItemBuilder { + billing_thresholds: Option>, + metadata: Option>>, + plan: Option>, + price: Option>, + quantity: Option>, + tax_rates: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionScheduleConfigurationItemBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + billing_thresholds: self.billing_thresholds?, + metadata: self.metadata.take()?, + plan: self.plan.take()?, + price: self.price.take()?, + quantity: self.quantity?, + tax_rates: self.tax_rates.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..c3b3ab30b 100644 --- a/generated/stripe_shared/src/subscription_schedule_current_phase.rs +++ b/generated/stripe_shared/src/subscription_schedule_current_phase.rs @@ -1,7 +1,98 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct SubscriptionScheduleCurrentPhaseBuilder { + end_date: Option, + start_date: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionScheduleCurrentPhaseBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { end_date: Deserialize::default(), start_date: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { end_date: self.end_date?, start_date: self.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 { + 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..bb9af8e2e 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// 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, - #[serde(skip_serializing_if = "Option::is_none")] pub automatic_tax: Option, /// 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>, /// 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>, /// 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,201 @@ pub struct SubscriptionSchedulePhaseConfiguration { /// When the trial ends within the phase. pub trial_end: Option, } +#[doc(hidden)] +pub struct SubscriptionSchedulePhaseConfigurationBuilder { + add_invoice_items: Option>, + application_fee_percent: Option>, + automatic_tax: Option>, + billing_cycle_anchor: Option>, + billing_thresholds: Option>, + collection_method: Option>, + coupon: Option>>, + currency: Option, + default_payment_method: Option>>, + default_tax_rates: Option>>, + description: Option>, + end_date: Option, + invoice_settings: Option>, + items: Option>, + metadata: Option>>, + on_behalf_of: Option>>, + proration_behavior: Option, + start_date: Option, + transfer_data: Option>, + trial_end: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionSchedulePhaseConfigurationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + add_invoice_items: self.add_invoice_items.take()?, + application_fee_percent: self.application_fee_percent?, + automatic_tax: self.automatic_tax.take()?, + billing_cycle_anchor: self.billing_cycle_anchor?, + billing_thresholds: self.billing_thresholds?, + collection_method: self.collection_method?, + coupon: self.coupon.take()?, + currency: self.currency?, + default_payment_method: self.default_payment_method.take()?, + default_tax_rates: self.default_tax_rates.take()?, + description: self.description.take()?, + end_date: self.end_date?, + invoice_settings: self.invoice_settings.take()?, + items: self.items.take()?, + metadata: self.metadata.take()?, + on_behalf_of: self.on_behalf_of.take()?, + proration_behavior: self.proration_behavior?, + start_date: self.start_date?, + transfer_data: self.transfer_data.take()?, + trial_end: self.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 { + 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. @@ -98,6 +293,7 @@ impl std::fmt::Debug for SubscriptionSchedulePhaseConfigurationBillingCycleAncho f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SubscriptionSchedulePhaseConfigurationBillingCycleAnchor { fn serialize(&self, serializer: S) -> Result where @@ -106,6 +302,29 @@ impl serde::Serialize for SubscriptionSchedulePhaseConfigurationBillingCycleAnch serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SubscriptionSchedulePhaseConfigurationBillingCycleAnchor { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SubscriptionSchedulePhaseConfigurationBillingCycleAnchor::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + SubscriptionSchedulePhaseConfigurationBillingCycleAnchor +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SubscriptionSchedulePhaseConfigurationBillingCycleAnchor { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -157,6 +376,7 @@ impl std::fmt::Debug for SubscriptionSchedulePhaseConfigurationCollectionMethod f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SubscriptionSchedulePhaseConfigurationCollectionMethod { fn serialize(&self, serializer: S) -> Result where @@ -165,6 +385,27 @@ impl serde::Serialize for SubscriptionSchedulePhaseConfigurationCollectionMethod serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SubscriptionSchedulePhaseConfigurationCollectionMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SubscriptionSchedulePhaseConfigurationCollectionMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SubscriptionSchedulePhaseConfigurationCollectionMethod); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SubscriptionSchedulePhaseConfigurationCollectionMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -218,6 +459,7 @@ impl std::fmt::Debug for SubscriptionSchedulePhaseConfigurationProrationBehavior f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SubscriptionSchedulePhaseConfigurationProrationBehavior { fn serialize(&self, serializer: S) -> Result where @@ -226,6 +468,27 @@ impl serde::Serialize for SubscriptionSchedulePhaseConfigurationProrationBehavio serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SubscriptionSchedulePhaseConfigurationProrationBehavior { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SubscriptionSchedulePhaseConfigurationProrationBehavior::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SubscriptionSchedulePhaseConfigurationProrationBehavior); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SubscriptionSchedulePhaseConfigurationProrationBehavior { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..36fb36fb5 100644 --- a/generated/stripe_shared/src/subscription_schedules_resource_default_settings.rs +++ b/generated/stripe_shared/src/subscription_schedules_resource_default_settings.rs @@ -1,9 +1,10 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, - #[serde(skip_serializing_if = "Option::is_none")] pub automatic_tax: Option, /// Possible values are `phase_start` or `automatic`. @@ -30,6 +31,150 @@ pub struct SubscriptionSchedulesResourceDefaultSettings { /// 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, } +#[doc(hidden)] +pub struct SubscriptionSchedulesResourceDefaultSettingsBuilder { + application_fee_percent: Option>, + automatic_tax: + Option>, + billing_cycle_anchor: Option, + billing_thresholds: Option>, + collection_method: Option>, + default_payment_method: Option>>, + description: Option>, + invoice_settings: Option, + on_behalf_of: Option>>, + transfer_data: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionSchedulesResourceDefaultSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + application_fee_percent: self.application_fee_percent?, + automatic_tax: self.automatic_tax.take()?, + billing_cycle_anchor: self.billing_cycle_anchor?, + billing_thresholds: self.billing_thresholds?, + collection_method: self.collection_method?, + default_payment_method: self.default_payment_method.take()?, + description: self.description.take()?, + invoice_settings: self.invoice_settings.take()?, + on_behalf_of: self.on_behalf_of.take()?, + transfer_data: self.transfer_data.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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. @@ -71,6 +216,7 @@ impl std::fmt::Debug for SubscriptionSchedulesResourceDefaultSettingsBillingCycl f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor { fn serialize(&self, serializer: S) -> Result where @@ -79,6 +225,29 @@ impl serde::Serialize for SubscriptionSchedulesResourceDefaultSettingsBillingCyc serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SubscriptionSchedulesResourceDefaultSettingsBillingCycleAnchor { @@ -132,6 +301,7 @@ impl std::fmt::Debug for SubscriptionSchedulesResourceDefaultSettingsCollectionM f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SubscriptionSchedulesResourceDefaultSettingsCollectionMethod { fn serialize(&self, serializer: S) -> Result where @@ -140,6 +310,29 @@ impl serde::Serialize for SubscriptionSchedulesResourceDefaultSettingsCollection serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SubscriptionSchedulesResourceDefaultSettingsCollectionMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SubscriptionSchedulesResourceDefaultSettingsCollectionMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + SubscriptionSchedulesResourceDefaultSettingsCollectionMethod +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SubscriptionSchedulesResourceDefaultSettingsCollectionMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..7778cb17b 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,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SubscriptionSchedulesResourceDefaultSettingsAutomaticTax { /// Whether Stripe automatically computes tax on invoices created during this phase. pub enabled: bool, @@ -7,3 +9,94 @@ pub struct SubscriptionSchedulesResourceDefaultSettingsAutomaticTax { /// The tax transaction is returned in the report of the connected account. pub liability: Option, } +#[doc(hidden)] +pub struct SubscriptionSchedulesResourceDefaultSettingsAutomaticTaxBuilder { + enabled: Option, + liability: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionSchedulesResourceDefaultSettingsAutomaticTaxBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "liability" => Deserialize::begin(&mut self.liability), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default(), liability: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.enabled?, liability: self.liability.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "liability" => b.liability = 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..ee20fec4a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,95 @@ pub struct SubscriptionTransferData { /// The account where funds from the payment will be transferred to upon payment success. pub destination: stripe_types::Expandable, } +#[doc(hidden)] +pub struct SubscriptionTransferDataBuilder { + amount_percent: Option>, + destination: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionTransferDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount_percent: Deserialize::default(), destination: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount_percent: self.amount_percent?, + destination: self.destination.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 index f1b2614f9..1a241814a 100644 --- a/generated/stripe_shared/src/subscriptions_resource_billing_cycle_anchor_config.rs +++ b/generated/stripe_shared/src/subscriptions_resource_billing_cycle_anchor_config.rs @@ -1,4 +1,6 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SubscriptionsResourceBillingCycleAnchorConfig { /// The day of the month of the billing_cycle_anchor. pub day_of_month: i64, @@ -11,3 +13,113 @@ pub struct SubscriptionsResourceBillingCycleAnchorConfig { /// The second of the minute of the billing_cycle_anchor. pub second: Option, } +#[doc(hidden)] +pub struct SubscriptionsResourceBillingCycleAnchorConfigBuilder { + day_of_month: Option, + hour: Option>, + minute: Option>, + month: Option>, + second: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for SubscriptionsResourceBillingCycleAnchorConfig { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionsResourceBillingCycleAnchorConfigBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: SubscriptionsResourceBillingCycleAnchorConfigBuilder::deser_default(), + })) + } + } + + impl MapBuilder for SubscriptionsResourceBillingCycleAnchorConfigBuilder { + type Out = SubscriptionsResourceBillingCycleAnchorConfig; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "day_of_month" => Deserialize::begin(&mut self.day_of_month), + "hour" => Deserialize::begin(&mut self.hour), + "minute" => Deserialize::begin(&mut self.minute), + "month" => Deserialize::begin(&mut self.month), + "second" => Deserialize::begin(&mut self.second), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + day_of_month: Deserialize::default(), + hour: Deserialize::default(), + minute: Deserialize::default(), + month: Deserialize::default(), + second: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + day_of_month: self.day_of_month?, + hour: self.hour?, + minute: self.minute?, + month: self.month?, + second: self.second?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + self.builder.key(k) + } + + fn finish(&mut self) -> Result<()> { + *self.out = self.builder.take_out(); + Ok(()) + } + } + + impl ObjectDeser for SubscriptionsResourceBillingCycleAnchorConfig { + type Builder = SubscriptionsResourceBillingCycleAnchorConfigBuilder; + } + + impl FromValueOpt for SubscriptionsResourceBillingCycleAnchorConfig { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = SubscriptionsResourceBillingCycleAnchorConfigBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "day_of_month" => b.day_of_month = Some(FromValueOpt::from_value(v)?), + "hour" => b.hour = Some(FromValueOpt::from_value(v)?), + "minute" => b.minute = Some(FromValueOpt::from_value(v)?), + "month" => b.month = Some(FromValueOpt::from_value(v)?), + "second" => b.second = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; diff --git a/generated/stripe_shared/src/subscriptions_resource_pause_collection.rs b/generated/stripe_shared/src/subscriptions_resource_pause_collection.rs index 0ff0713ff..a1213c8d5 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SubscriptionsResourcePauseCollection { /// The payment collection behavior for this subscription while paused. /// One of `keep_as_draft`, `mark_uncollectible`, or `void`. @@ -8,6 +10,95 @@ pub struct SubscriptionsResourcePauseCollection { /// The time after which the subscription will resume collecting payments. pub resumes_at: Option, } +#[doc(hidden)] +pub struct SubscriptionsResourcePauseCollectionBuilder { + behavior: Option, + resumes_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionsResourcePauseCollectionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { behavior: Deserialize::default(), resumes_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { behavior: self.behavior?, resumes_at: self.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 { + 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)] @@ -50,6 +141,7 @@ impl std::fmt::Debug for SubscriptionsResourcePauseCollectionBehavior { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SubscriptionsResourcePauseCollectionBehavior { fn serialize(&self, serializer: S) -> Result where @@ -58,6 +150,25 @@ impl serde::Serialize for SubscriptionsResourcePauseCollectionBehavior { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SubscriptionsResourcePauseCollectionBehavior { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SubscriptionsResourcePauseCollectionBehavior::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SubscriptionsResourcePauseCollectionBehavior); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SubscriptionsResourcePauseCollectionBehavior { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..d91549d48 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, @@ -13,3 +15,118 @@ 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, } +#[doc(hidden)] +pub struct SubscriptionsResourcePaymentMethodOptionsBuilder { + acss_debit: Option>, + bancontact: Option>, + card: Option>, + customer_balance: Option>, + konbini: Option>, + us_bank_account: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionsResourcePaymentMethodOptionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + acss_debit: self.acss_debit?, + bancontact: self.bancontact?, + card: self.card.take()?, + customer_balance: self.customer_balance.take()?, + konbini: self.konbini?, + us_bank_account: self.us_bank_account.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..754ae3d7f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SubscriptionsResourcePaymentSettings { /// Payment-method-specific configuration to provide to invoices created by the subscription. pub payment_method_options: Option, @@ -10,6 +12,117 @@ pub struct SubscriptionsResourcePaymentSettings { pub save_default_payment_method: Option, } +#[doc(hidden)] +pub struct SubscriptionsResourcePaymentSettingsBuilder { + payment_method_options: + Option>, + payment_method_types: + Option>>, + save_default_payment_method: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionsResourcePaymentSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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) + } + + _ => ::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 { + Some(Self::Out { + payment_method_options: self.payment_method_options.take()?, + payment_method_types: self.payment_method_types.take()?, + save_default_payment_method: self.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 { + 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)] @@ -125,6 +238,7 @@ impl std::fmt::Debug for SubscriptionsResourcePaymentSettingsPaymentMethodTypes f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SubscriptionsResourcePaymentSettingsPaymentMethodTypes { fn serialize(&self, serializer: S) -> Result where @@ -133,12 +247,32 @@ impl serde::Serialize for SubscriptionsResourcePaymentSettingsPaymentMethodTypes serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SubscriptionsResourcePaymentSettingsPaymentMethodTypes { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SubscriptionsResourcePaymentSettingsPaymentMethodTypes::from_str(s) + .unwrap_or(SubscriptionsResourcePaymentSettingsPaymentMethodTypes::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(SubscriptionsResourcePaymentSettingsPaymentMethodTypes); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SubscriptionsResourcePaymentSettingsPaymentMethodTypes { fn deserialize>(deserializer: D) -> Result { 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)) } } /// Either `off`, or `on_subscription`. @@ -180,6 +314,7 @@ impl std::fmt::Debug for SubscriptionsResourcePaymentSettingsSaveDefaultPaymentM f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod { fn serialize(&self, serializer: S) -> Result where @@ -188,6 +323,29 @@ impl serde::Serialize for SubscriptionsResourcePaymentSettingsSaveDefaultPayment serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SubscriptionsResourcePaymentSettingsSaveDefaultPaymentMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/subscriptions_resource_pending_update.rs b/generated/stripe_shared/src/subscriptions_resource_pending_update.rs index ef129a0dc..a6bfd7521 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,117 @@ pub struct SubscriptionsResourcePendingUpdate { /// See [Using trial periods on subscriptions](https://stripe.com/docs/billing/subscriptions/trials) to learn more. pub trial_from_plan: Option, } +#[doc(hidden)] +pub struct SubscriptionsResourcePendingUpdateBuilder { + billing_cycle_anchor: Option>, + expires_at: Option, + subscription_items: Option>>, + trial_end: Option>, + trial_from_plan: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionsResourcePendingUpdateBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + billing_cycle_anchor: self.billing_cycle_anchor?, + expires_at: self.expires_at?, + subscription_items: self.subscription_items.take()?, + trial_end: self.trial_end?, + trial_from_plan: self.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 { + 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..3593250b9 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,99 @@ /// Defines how a subscription behaves when a free trial ends. -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct SubscriptionsTrialsResourceEndBehaviorBuilder { + missing_payment_method: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionsTrialsResourceEndBehaviorBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { missing_payment_method: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { missing_payment_method: self.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 { + 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 { @@ -45,6 +135,7 @@ impl std::fmt::Debug for SubscriptionsTrialsResourceEndBehaviorMissingPaymentMet f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for SubscriptionsTrialsResourceEndBehaviorMissingPaymentMethod { fn serialize(&self, serializer: S) -> Result where @@ -53,6 +144,29 @@ impl serde::Serialize for SubscriptionsTrialsResourceEndBehaviorMissingPaymentMe serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for SubscriptionsTrialsResourceEndBehaviorMissingPaymentMethod { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + SubscriptionsTrialsResourceEndBehaviorMissingPaymentMethod::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + SubscriptionsTrialsResourceEndBehaviorMissingPaymentMethod +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for SubscriptionsTrialsResourceEndBehaviorMissingPaymentMethod { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..7f17f096f 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct SubscriptionsTrialsResourceTrialSettings { pub end_behavior: stripe_shared::SubscriptionsTrialsResourceEndBehavior, } +#[doc(hidden)] +pub struct SubscriptionsTrialsResourceTrialSettingsBuilder { + end_behavior: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: SubscriptionsTrialsResourceTrialSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { end_behavior: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { end_behavior: self.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 { + 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..81a8d2e31 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxCode { /// A detailed description of which types of products the tax code represents. pub description: String, @@ -9,6 +11,177 @@ pub struct TaxCode { pub id: stripe_shared::TaxCodeId, /// A short name for the tax code. pub name: String, + /// String representing the object's type. Objects of the same type share the same value. + pub object: TaxCodeObject, +} +#[doc(hidden)] +pub struct TaxCodeBuilder { + description: Option, + id: Option, + name: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxCodeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + description: Deserialize::default(), + id: Deserialize::default(), + name: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + description: self.description.take()?, + id: self.id.take()?, + name: self.name.take()?, + object: self.object?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TaxCodeObject { + TaxCode, +} +impl TaxCodeObject { + pub fn as_str(self) -> &'static str { + use TaxCodeObject::*; + match self { + TaxCode => "tax_code", + } + } +} + +impl std::str::FromStr for TaxCodeObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TaxCodeObject::*; + match s { + "tax_code" => Ok(TaxCode), + _ => Err(()), + } + } +} +impl std::fmt::Display for TaxCodeObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TaxCodeObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TaxCodeObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TaxCodeObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxCodeObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxCodeObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TaxCodeObject { + fn deserialize>(deserializer: D) -> 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 TaxCodeObject")) + } } impl stripe_types::Object for TaxCode { type Id = stripe_shared::TaxCodeId; diff --git a/generated/stripe_shared/src/tax_deducted_at_source.rs b/generated/stripe_shared/src/tax_deducted_at_source.rs index 9e9fd08f7..b0028714e 100644 --- a/generated/stripe_shared/src/tax_deducted_at_source.rs +++ b/generated/stripe_shared/src/tax_deducted_at_source.rs @@ -1,7 +1,11 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxDeductedAtSource { /// Unique identifier for the object. pub id: stripe_shared::TaxDeductedAtSourceId, + /// String representing the object's type. Objects of the same type share the same value. + pub object: TaxDeductedAtSourceObject, /// The end of the invoicing period. /// This TDS applies to Stripe fees collected during this invoicing period. pub period_end: stripe_types::Timestamp, @@ -11,6 +15,188 @@ pub struct TaxDeductedAtSource { /// The TAN that was supplied to Stripe when TDS was assessed pub tax_deduction_account_number: String, } +#[doc(hidden)] +pub struct TaxDeductedAtSourceBuilder { + id: Option, + object: Option, + period_end: Option, + period_start: Option, + tax_deduction_account_number: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxDeductedAtSourceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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) + } + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + id: Deserialize::default(), + object: Deserialize::default(), + period_end: Deserialize::default(), + period_start: Deserialize::default(), + tax_deduction_account_number: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + id: self.id.take()?, + object: self.object?, + period_end: self.period_end?, + period_start: self.period_start?, + tax_deduction_account_number: self.tax_deduction_account_number.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TaxDeductedAtSourceObject { + TaxDeductedAtSource, +} +impl TaxDeductedAtSourceObject { + pub fn as_str(self) -> &'static str { + use TaxDeductedAtSourceObject::*; + match self { + TaxDeductedAtSource => "tax_deducted_at_source", + } + } +} + +impl std::str::FromStr for TaxDeductedAtSourceObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TaxDeductedAtSourceObject::*; + match s { + "tax_deducted_at_source" => Ok(TaxDeductedAtSource), + _ => Err(()), + } + } +} +impl std::fmt::Display for TaxDeductedAtSourceObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TaxDeductedAtSourceObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TaxDeductedAtSourceObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TaxDeductedAtSourceObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxDeductedAtSourceObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxDeductedAtSourceObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TaxDeductedAtSourceObject { + fn deserialize>(deserializer: D) -> 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 TaxDeductedAtSourceObject")) + } +} 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 index 79a1ffa55..51c1f8572 100644 --- a/generated/stripe_shared/src/tax_i_ds_owner.rs +++ b/generated/stripe_shared/src/tax_i_ds_owner.rs @@ -1,18 +1,122 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxIDsOwner { /// The account being referenced when `type` is `account`. - #[serde(skip_serializing_if = "Option::is_none")] pub account: Option>, /// The Connect Application being referenced when `type` is `application`. - #[serde(skip_serializing_if = "Option::is_none")] pub application: Option>, /// The customer being referenced when `type` is `customer`. - #[serde(skip_serializing_if = "Option::is_none")] pub customer: Option>, /// Type of owner referenced. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: TaxIDsOwnerType, } +#[doc(hidden)] +pub struct TaxIDsOwnerBuilder { + account: Option>>, + application: Option>>, + customer: Option>>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::Value; + use miniserde::{make_place, Deserialize, Result}; + use stripe_types::miniserde_helpers::FromValueOpt; + use stripe_types::{MapBuilder, ObjectDeser}; + + make_place!(Place); + + impl Deserialize for TaxIDsOwner { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxIDsOwnerBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { + out: &mut self.out, + builder: TaxIDsOwnerBuilder::deser_default(), + })) + } + } + + impl MapBuilder for TaxIDsOwnerBuilder { + type Out = TaxIDsOwner; + fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> { + Ok(match k { + "account" => Deserialize::begin(&mut self.account), + "application" => Deserialize::begin(&mut self.application), + "customer" => Deserialize::begin(&mut self.customer), + "type" => Deserialize::begin(&mut self.type_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + account: Deserialize::default(), + application: Deserialize::default(), + customer: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + account: self.account.take()?, + application: self.application.take()?, + customer: self.customer.take()?, + type_: self.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 TaxIDsOwner { + type Builder = TaxIDsOwnerBuilder; + } + + impl FromValueOpt for TaxIDsOwner { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + let mut b = TaxIDsOwnerBuilder::deser_default(); + for (k, v) in obj { + match k.as_str() { + "account" => b.account = Some(FromValueOpt::from_value(v)?), + "application" => b.application = 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 owner referenced. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TaxIDsOwnerType { @@ -57,6 +161,7 @@ impl std::fmt::Debug for TaxIDsOwnerType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxIDsOwnerType { fn serialize(&self, serializer: S) -> Result where @@ -65,6 +170,22 @@ impl serde::Serialize for TaxIDsOwnerType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxIDsOwnerType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxIDsOwnerType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxIDsOwnerType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxIDsOwnerType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/tax_id.rs b/generated/stripe_shared/src/tax_id.rs index d8bceb5c0..df003c960 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxId { /// Two-letter ISO code representing the country of the tax ID. pub country: Option, @@ -16,18 +18,218 @@ 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: TaxIdObject, /// The account or customer the tax ID belongs to. - #[serde(skip_serializing_if = "Option::is_none")] pub owner: Option, /// 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(feature = "serde", serde(rename = "type"))] pub type_: TaxIdType, /// Value of the tax ID. pub value: String, /// Tax ID verification information. pub verification: Option, } +#[doc(hidden)] +pub struct TaxIdBuilder { + country: Option>, + created: Option, + customer: Option>>, + id: Option, + livemode: Option, + object: Option, + owner: Option>, + type_: Option, + value: Option, + verification: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxIdBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "owner" => Deserialize::begin(&mut self.owner), + "type" => Deserialize::begin(&mut self.type_), + "value" => Deserialize::begin(&mut self.value), + "verification" => Deserialize::begin(&mut self.verification), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + country: Deserialize::default(), + created: Deserialize::default(), + customer: Deserialize::default(), + id: Deserialize::default(), + livemode: Deserialize::default(), + object: Deserialize::default(), + owner: Deserialize::default(), + type_: Deserialize::default(), + value: Deserialize::default(), + verification: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + country: self.country.take()?, + created: self.created?, + customer: self.customer.take()?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + owner: self.owner.take()?, + type_: self.type_?, + value: self.value.take()?, + verification: self.verification.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "owner" => b.owner = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TaxIdObject { + TaxId, +} +impl TaxIdObject { + pub fn as_str(self) -> &'static str { + use TaxIdObject::*; + match self { + TaxId => "tax_id", + } + } +} + +impl std::str::FromStr for TaxIdObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TaxIdObject::*; + match s { + "tax_id" => Ok(TaxId), + _ => Err(()), + } + } +} +impl std::fmt::Display for TaxIdObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TaxIdObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TaxIdObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TaxIdObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxIdObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxIdObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TaxIdObject { + fn deserialize>(deserializer: D) -> 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 TaxIdObject")) + } +} /// 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)] @@ -262,6 +464,7 @@ impl std::fmt::Debug for TaxIdType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxIdType { fn serialize(&self, serializer: S) -> Result where @@ -270,6 +473,22 @@ impl serde::Serialize for TaxIdType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxIdType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxIdType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxIdType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxIdType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/tax_id_verification.rs b/generated/stripe_shared/src/tax_id_verification.rs index 2b50c88d2..9b5d8f537 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TaxIdVerification { /// Verification status, one of `pending`, `verified`, `unverified`, or `unavailable`. pub status: TaxIdVerificationStatus, @@ -7,6 +9,106 @@ pub struct TaxIdVerification { /// Verified name. pub verified_name: Option, } +#[doc(hidden)] +pub struct TaxIdVerificationBuilder { + status: Option, + verified_address: Option>, + verified_name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxIdVerificationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + status: Deserialize::default(), + verified_address: Deserialize::default(), + verified_name: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + status: self.status?, + verified_address: self.verified_address.take()?, + verified_name: self.verified_name.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -51,6 +153,7 @@ impl std::fmt::Debug for TaxIdVerificationStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxIdVerificationStatus { fn serialize(&self, serializer: S) -> Result where @@ -59,6 +162,22 @@ impl serde::Serialize for TaxIdVerificationStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxIdVerificationStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxIdVerificationStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxIdVerificationStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxIdVerificationStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/tax_rate.rs b/generated/stripe_shared/src/tax_rate.rs index d45339be6..7d9b2d330 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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. @@ -38,6 +40,8 @@ pub struct TaxRate { /// 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>, + /// String representing the object's type. Objects of the same type share the same value. + pub object: TaxRateObject, /// Tax rate percentage out of 100. /// For tax calculations with automatic_tax[enabled]=true, this percentage includes the statutory tax rate of non-taxable jurisdictions. pub percentage: f64, @@ -47,6 +51,172 @@ pub struct TaxRate { /// The high-level tax type, such as `vat` or `sales_tax`. pub tax_type: Option, } +#[doc(hidden)] +pub struct TaxRateBuilder { + active: Option, + country: Option>, + created: Option, + description: Option>, + display_name: Option, + effective_percentage: Option>, + id: Option, + inclusive: Option, + jurisdiction: Option>, + jurisdiction_level: Option>, + livemode: Option, + metadata: Option>>, + object: Option, + percentage: Option, + state: Option>, + tax_type: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TaxRateBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + Ok(Box::new(Builder { out: &mut self.out, builder: TaxRateBuilder::deser_default() })) + } + } + + 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), + "jurisdiction_level" => Deserialize::begin(&mut self.jurisdiction_level), + "livemode" => Deserialize::begin(&mut self.livemode), + "metadata" => Deserialize::begin(&mut self.metadata), + "object" => Deserialize::begin(&mut self.object), + "percentage" => Deserialize::begin(&mut self.percentage), + "state" => Deserialize::begin(&mut self.state), + "tax_type" => Deserialize::begin(&mut self.tax_type), + + _ => ::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(), + jurisdiction_level: Deserialize::default(), + livemode: Deserialize::default(), + metadata: Deserialize::default(), + object: Deserialize::default(), + percentage: Deserialize::default(), + state: Deserialize::default(), + tax_type: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + active: self.active?, + country: self.country.take()?, + created: self.created?, + description: self.description.take()?, + display_name: self.display_name.take()?, + effective_percentage: self.effective_percentage?, + id: self.id.take()?, + inclusive: self.inclusive?, + jurisdiction: self.jurisdiction.take()?, + jurisdiction_level: self.jurisdiction_level?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + percentage: self.percentage?, + state: self.state.take()?, + tax_type: self.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 TaxRate { + type Builder = TaxRateBuilder; + } + + impl FromValueOpt for TaxRate { + fn from_value(v: Value) -> Option { + 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)?), + "jurisdiction_level" => { + b.jurisdiction_level = Some(FromValueOpt::from_value(v)?) + } + "livemode" => b.livemode = Some(FromValueOpt::from_value(v)?), + "metadata" => b.metadata = Some(FromValueOpt::from_value(v)?), + "object" => b.object = 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() + } + } +}; /// The level of the jurisdiction that imposes this tax rate. /// Will be `null` for manually defined tax rates. #[derive(Copy, Clone, Eq, PartialEq)] @@ -98,6 +268,7 @@ impl std::fmt::Debug for TaxRateJurisdictionLevel { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TaxRateJurisdictionLevel { fn serialize(&self, serializer: S) -> Result where @@ -106,6 +277,22 @@ impl serde::Serialize for TaxRateJurisdictionLevel { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxRateJurisdictionLevel { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxRateJurisdictionLevel::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxRateJurisdictionLevel); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxRateJurisdictionLevel { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -114,6 +301,73 @@ impl<'de> serde::Deserialize<'de> for TaxRateJurisdictionLevel { .map_err(|_| serde::de::Error::custom("Unknown value for TaxRateJurisdictionLevel")) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TaxRateObject { + TaxRate, +} +impl TaxRateObject { + pub fn as_str(self) -> &'static str { + use TaxRateObject::*; + match self { + TaxRate => "tax_rate", + } + } +} + +impl std::str::FromStr for TaxRateObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TaxRateObject::*; + match s { + "tax_rate" => Ok(TaxRate), + _ => Err(()), + } + } +} +impl std::fmt::Display for TaxRateObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TaxRateObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TaxRateObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TaxRateObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxRateObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxRateObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TaxRateObject { + fn deserialize>(deserializer: D) -> 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 TaxRateObject")) + } +} impl stripe_types::Object for TaxRate { type Id = stripe_shared::TaxRateId; fn id(&self) -> &Self::Id { @@ -203,10 +457,26 @@ impl serde::Serialize for TaxRateTaxType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TaxRateTaxType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TaxRateTaxType::from_str(s).unwrap_or(TaxRateTaxType::Unknown)); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TaxRateTaxType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TaxRateTaxType { fn deserialize>(deserializer: D) -> Result { 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)) } } diff --git a/generated/stripe_shared/src/test_helpers_test_clock.rs b/generated/stripe_shared/src/test_helpers_test_clock.rs index af1af728e..c3c00ec71 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TestHelpersTestClock { /// Time at which the object was created. Measured in seconds since the Unix epoch. pub created: stripe_types::Timestamp, @@ -17,9 +19,204 @@ pub struct TestHelpersTestClock { pub livemode: bool, /// The custom name supplied at creation. pub name: Option, + /// String representing the object's type. Objects of the same type share the same value. + pub object: TestHelpersTestClockObject, /// The status of the Test Clock. pub status: TestHelpersTestClockStatus, } +#[doc(hidden)] +pub struct TestHelpersTestClockBuilder { + created: Option, + deletes_after: Option, + frozen_time: Option, + id: Option, + livemode: Option, + name: Option>, + object: Option, + status: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TestHelpersTestClockBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "status" => Deserialize::begin(&mut self.status), + + _ => ::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(), + object: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + created: self.created?, + deletes_after: self.deletes_after?, + frozen_time: self.frozen_time?, + id: self.id.take()?, + livemode: self.livemode?, + name: self.name.take()?, + object: self.object?, + status: self.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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "status" => b.status = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TestHelpersTestClockObject { + TestHelpersTestClock, +} +impl TestHelpersTestClockObject { + pub fn as_str(self) -> &'static str { + use TestHelpersTestClockObject::*; + match self { + TestHelpersTestClock => "test_helpers.test_clock", + } + } +} + +impl std::str::FromStr for TestHelpersTestClockObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TestHelpersTestClockObject::*; + match s { + "test_helpers.test_clock" => Ok(TestHelpersTestClock), + _ => Err(()), + } + } +} +impl std::fmt::Display for TestHelpersTestClockObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TestHelpersTestClockObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TestHelpersTestClockObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TestHelpersTestClockObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TestHelpersTestClockObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TestHelpersTestClockObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TestHelpersTestClockObject { + fn deserialize>(deserializer: D) -> 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 TestHelpersTestClockObject")) + } +} /// The status of the Test Clock. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TestHelpersTestClockStatus { @@ -61,6 +258,7 @@ impl std::fmt::Debug for TestHelpersTestClockStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TestHelpersTestClockStatus { fn serialize(&self, serializer: S) -> Result where @@ -69,6 +267,22 @@ impl serde::Serialize for TestHelpersTestClockStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TestHelpersTestClockStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TestHelpersTestClockStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TestHelpersTestClockStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TestHelpersTestClockStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/three_d_secure_details.rs b/generated/stripe_shared/src/three_d_secure_details.rs index b61bbeab4..f6a133f8e 100644 --- a/generated/stripe_shared/src/three_d_secure_details.rs +++ b/generated/stripe_shared/src/three_d_secure_details.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ThreeDSecureDetails { /// For authenticated transactions: how the customer was authenticated by /// the issuing bank. @@ -17,6 +19,127 @@ pub struct ThreeDSecureDetails { /// The version of 3D Secure that was used. pub version: Option, } +#[doc(hidden)] +pub struct ThreeDSecureDetailsBuilder { + authentication_flow: Option>, + electronic_commerce_indicator: Option>, + result: Option>, + result_reason: Option>, + transaction_id: Option>, + version: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ThreeDSecureDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "electronic_commerce_indicator" => { + Deserialize::begin(&mut self.electronic_commerce_indicator) + } + "result" => Deserialize::begin(&mut self.result), + "result_reason" => Deserialize::begin(&mut self.result_reason), + "transaction_id" => Deserialize::begin(&mut self.transaction_id), + "version" => Deserialize::begin(&mut self.version), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + authentication_flow: Deserialize::default(), + electronic_commerce_indicator: Deserialize::default(), + result: Deserialize::default(), + result_reason: Deserialize::default(), + transaction_id: Deserialize::default(), + version: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + authentication_flow: self.authentication_flow?, + electronic_commerce_indicator: self.electronic_commerce_indicator?, + result: self.result?, + result_reason: self.result_reason?, + transaction_id: self.transaction_id.take()?, + version: self.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 { + 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)?) + } + "electronic_commerce_indicator" => { + b.electronic_commerce_indicator = Some(FromValueOpt::from_value(v)?) + } + "result" => b.result = Some(FromValueOpt::from_value(v)?), + "result_reason" => b.result_reason = Some(FromValueOpt::from_value(v)?), + "transaction_id" => b.transaction_id = 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)] @@ -56,6 +179,7 @@ impl std::fmt::Debug for ThreeDSecureDetailsAuthenticationFlow { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ThreeDSecureDetailsAuthenticationFlow { fn serialize(&self, serializer: S) -> Result where @@ -64,6 +188,23 @@ impl serde::Serialize for ThreeDSecureDetailsAuthenticationFlow { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ThreeDSecureDetailsAuthenticationFlow { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(ThreeDSecureDetailsAuthenticationFlow::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsAuthenticationFlow); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsAuthenticationFlow { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -121,6 +262,7 @@ impl std::fmt::Debug for ThreeDSecureDetailsElectronicCommerceIndicator { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ThreeDSecureDetailsElectronicCommerceIndicator { fn serialize(&self, serializer: S) -> Result where @@ -129,6 +271,25 @@ impl serde::Serialize for ThreeDSecureDetailsElectronicCommerceIndicator { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ThreeDSecureDetailsElectronicCommerceIndicator { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + ThreeDSecureDetailsElectronicCommerceIndicator::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsElectronicCommerceIndicator); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsElectronicCommerceIndicator { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -190,6 +351,7 @@ impl std::fmt::Debug for ThreeDSecureDetailsResult { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ThreeDSecureDetailsResult { fn serialize(&self, serializer: S) -> Result where @@ -198,6 +360,22 @@ impl serde::Serialize for ThreeDSecureDetailsResult { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ThreeDSecureDetailsResult { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ThreeDSecureDetailsResult::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsResult); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsResult { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -260,6 +438,7 @@ impl std::fmt::Debug for ThreeDSecureDetailsResultReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ThreeDSecureDetailsResultReason { fn serialize(&self, serializer: S) -> Result where @@ -268,6 +447,23 @@ impl serde::Serialize for ThreeDSecureDetailsResultReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ThreeDSecureDetailsResultReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(ThreeDSecureDetailsResultReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsResultReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsResultReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -318,6 +514,7 @@ impl std::fmt::Debug for ThreeDSecureDetailsVersion { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ThreeDSecureDetailsVersion { fn serialize(&self, serializer: S) -> Result where @@ -326,6 +523,22 @@ impl serde::Serialize for ThreeDSecureDetailsVersion { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ThreeDSecureDetailsVersion { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(ThreeDSecureDetailsVersion::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsVersion); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsVersion { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..18d8ee245 100644 --- a/generated/stripe_shared/src/three_d_secure_details_charge.rs +++ b/generated/stripe_shared/src/three_d_secure_details_charge.rs @@ -1,4 +1,6 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ThreeDSecureDetailsCharge { /// For authenticated transactions: how the customer was authenticated by /// the issuing bank. @@ -10,7 +12,6 @@ pub struct ThreeDSecureDetailsCharge { pub exemption_indicator: Option, /// 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, /// Indicates the outcome of 3D Secure authentication. pub result: Option, @@ -23,6 +24,144 @@ pub struct ThreeDSecureDetailsCharge { /// The version of 3D Secure that was used. pub version: Option, } +#[doc(hidden)] +pub struct ThreeDSecureDetailsChargeBuilder { + authentication_flow: Option>, + electronic_commerce_indicator: + Option>, + exemption_indicator: Option>, + exemption_indicator_applied: Option>, + result: Option>, + result_reason: Option>, + transaction_id: Option>, + version: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ThreeDSecureDetailsChargeBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "electronic_commerce_indicator" => { + Deserialize::begin(&mut self.electronic_commerce_indicator) + } + "exemption_indicator" => Deserialize::begin(&mut self.exemption_indicator), + "exemption_indicator_applied" => { + Deserialize::begin(&mut self.exemption_indicator_applied) + } + "result" => Deserialize::begin(&mut self.result), + "result_reason" => Deserialize::begin(&mut self.result_reason), + "transaction_id" => Deserialize::begin(&mut self.transaction_id), + "version" => Deserialize::begin(&mut self.version), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + authentication_flow: Deserialize::default(), + electronic_commerce_indicator: Deserialize::default(), + exemption_indicator: Deserialize::default(), + exemption_indicator_applied: Deserialize::default(), + result: Deserialize::default(), + result_reason: Deserialize::default(), + transaction_id: Deserialize::default(), + version: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + authentication_flow: self.authentication_flow?, + electronic_commerce_indicator: self.electronic_commerce_indicator?, + exemption_indicator: self.exemption_indicator?, + exemption_indicator_applied: self.exemption_indicator_applied?, + result: self.result?, + result_reason: self.result_reason?, + transaction_id: self.transaction_id.take()?, + version: self.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 { + 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)?) + } + "electronic_commerce_indicator" => { + b.electronic_commerce_indicator = Some(FromValueOpt::from_value(v)?) + } + "exemption_indicator" => { + b.exemption_indicator = Some(FromValueOpt::from_value(v)?) + } + "exemption_indicator_applied" => { + b.exemption_indicator_applied = Some(FromValueOpt::from_value(v)?) + } + "result" => b.result = Some(FromValueOpt::from_value(v)?), + "result_reason" => b.result_reason = Some(FromValueOpt::from_value(v)?), + "transaction_id" => b.transaction_id = 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)] @@ -62,6 +201,7 @@ impl std::fmt::Debug for ThreeDSecureDetailsChargeAuthenticationFlow { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ThreeDSecureDetailsChargeAuthenticationFlow { fn serialize(&self, serializer: S) -> Result where @@ -70,6 +210,25 @@ impl serde::Serialize for ThreeDSecureDetailsChargeAuthenticationFlow { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ThreeDSecureDetailsChargeAuthenticationFlow { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + ThreeDSecureDetailsChargeAuthenticationFlow::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsChargeAuthenticationFlow); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsChargeAuthenticationFlow { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -129,6 +288,7 @@ impl std::fmt::Debug for ThreeDSecureDetailsChargeElectronicCommerceIndicator { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ThreeDSecureDetailsChargeElectronicCommerceIndicator { fn serialize(&self, serializer: S) -> Result where @@ -137,6 +297,25 @@ impl serde::Serialize for ThreeDSecureDetailsChargeElectronicCommerceIndicator { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ThreeDSecureDetailsChargeElectronicCommerceIndicator { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + ThreeDSecureDetailsChargeElectronicCommerceIndicator::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsChargeElectronicCommerceIndicator); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsChargeElectronicCommerceIndicator { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -186,6 +365,7 @@ impl std::fmt::Debug for ThreeDSecureDetailsChargeExemptionIndicator { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ThreeDSecureDetailsChargeExemptionIndicator { fn serialize(&self, serializer: S) -> Result where @@ -194,6 +374,25 @@ impl serde::Serialize for ThreeDSecureDetailsChargeExemptionIndicator { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ThreeDSecureDetailsChargeExemptionIndicator { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + ThreeDSecureDetailsChargeExemptionIndicator::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsChargeExemptionIndicator); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsChargeExemptionIndicator { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -255,6 +454,7 @@ impl std::fmt::Debug for ThreeDSecureDetailsChargeResult { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ThreeDSecureDetailsChargeResult { fn serialize(&self, serializer: S) -> Result where @@ -263,6 +463,23 @@ impl serde::Serialize for ThreeDSecureDetailsChargeResult { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ThreeDSecureDetailsChargeResult { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(ThreeDSecureDetailsChargeResult::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsChargeResult); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsChargeResult { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -326,6 +543,7 @@ impl std::fmt::Debug for ThreeDSecureDetailsChargeResultReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ThreeDSecureDetailsChargeResultReason { fn serialize(&self, serializer: S) -> Result where @@ -334,6 +552,23 @@ impl serde::Serialize for ThreeDSecureDetailsChargeResultReason { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ThreeDSecureDetailsChargeResultReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(ThreeDSecureDetailsChargeResultReason::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsChargeResultReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsChargeResultReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -384,6 +619,7 @@ impl std::fmt::Debug for ThreeDSecureDetailsChargeVersion { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ThreeDSecureDetailsChargeVersion { fn serialize(&self, serializer: S) -> Result where @@ -392,6 +628,23 @@ impl serde::Serialize for ThreeDSecureDetailsChargeVersion { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ThreeDSecureDetailsChargeVersion { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(ThreeDSecureDetailsChargeVersion::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ThreeDSecureDetailsChargeVersion); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ThreeDSecureDetailsChargeVersion { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/three_d_secure_usage.rs b/generated/stripe_shared/src/three_d_secure_usage.rs index c2869dd18..c42415ad4 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct ThreeDSecureUsage { /// Whether 3D Secure is supported on this card. pub supported: bool, } +#[doc(hidden)] +pub struct ThreeDSecureUsageBuilder { + supported: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ThreeDSecureUsageBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { supported: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { supported: self.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 { + 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..36fdaa418 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Topup { /// Amount transferred. pub amount: i64, @@ -34,6 +36,8 @@ pub struct Topup { /// 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 representing the object's type. Objects of the same type share the same value. + pub object: TopupObject, /// The source field is deprecated. It might not always be present in the API response. pub source: Option, /// Extra information about a top-up. @@ -45,6 +49,244 @@ pub struct Topup { /// A string that identifies this top-up as part of a group. pub transfer_group: Option, } +#[doc(hidden)] +pub struct TopupBuilder { + amount: Option, + balance_transaction: + Option>>, + created: Option, + currency: Option, + description: Option>, + expected_availability_date: Option>, + failure_code: Option>, + failure_message: Option>, + id: Option, + livemode: Option, + metadata: Option>, + object: Option, + source: Option>, + statement_descriptor: Option>, + status: Option, + transfer_group: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TopupBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: Deserialize::default(), + source: Deserialize::default(), + statement_descriptor: Deserialize::default(), + status: Deserialize::default(), + transfer_group: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + balance_transaction: self.balance_transaction.take()?, + created: self.created?, + currency: self.currency?, + description: self.description.take()?, + expected_availability_date: self.expected_availability_date?, + failure_code: self.failure_code.take()?, + failure_message: self.failure_message.take()?, + id: self.id.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + source: self.source.take()?, + statement_descriptor: self.statement_descriptor.take()?, + status: self.status?, + transfer_group: self.transfer_group.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TopupObject { + Topup, +} +impl TopupObject { + pub fn as_str(self) -> &'static str { + use TopupObject::*; + match self { + Topup => "topup", + } + } +} + +impl std::str::FromStr for TopupObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TopupObject::*; + match s { + "topup" => Ok(Topup), + _ => Err(()), + } + } +} +impl std::fmt::Display for TopupObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TopupObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TopupObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TopupObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TopupObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TopupObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TopupObject { + fn deserialize>(deserializer: D) -> 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 TopupObject")) + } +} /// The status of the top-up is either `canceled`, `failed`, `pending`, `reversed`, or `succeeded`. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TopupStatus { @@ -92,6 +334,7 @@ impl std::fmt::Debug for TopupStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TopupStatus { fn serialize(&self, serializer: S) -> Result where @@ -100,6 +343,22 @@ impl serde::Serialize for TopupStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TopupStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TopupStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TopupStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TopupStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/transfer.rs b/generated/stripe_shared/src/transfer.rs index ac70f0ce6..1afb45c1b 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, /// 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>, /// Unique identifier for the object. pub id: stripe_shared::TransferId, @@ -38,6 +39,8 @@ pub struct Transfer { /// 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 representing the object's type. Objects of the same type share the same value. + pub object: TransferObject, /// A list of reversals that have been applied to the transfer. pub reversals: stripe_types::List, /// Whether the transfer has been fully reversed. @@ -47,12 +50,252 @@ pub struct Transfer { /// If null, the transfer was funded from the available balance. pub source_transaction: Option>, /// 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, /// 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, } +#[doc(hidden)] +pub struct TransferBuilder { + amount: Option, + amount_reversed: Option, + balance_transaction: + Option>>, + created: Option, + currency: Option, + description: Option>, + destination: Option>>, + destination_payment: Option>>, + id: Option, + livemode: Option, + metadata: Option>, + object: Option, + reversals: Option>, + reversed: Option, + source_transaction: Option>>, + source_type: Option>, + transfer_group: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TransferBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + amount: self.amount?, + amount_reversed: self.amount_reversed?, + balance_transaction: self.balance_transaction.take()?, + created: self.created?, + currency: self.currency?, + description: self.description.take()?, + destination: self.destination.take()?, + destination_payment: self.destination_payment.take()?, + id: self.id.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + reversals: self.reversals.take()?, + reversed: self.reversed?, + source_transaction: self.source_transaction.take()?, + source_type: self.source_type.take()?, + transfer_group: self.transfer_group.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TransferObject { + Transfer, +} +impl TransferObject { + pub fn as_str(self) -> &'static str { + use TransferObject::*; + match self { + Transfer => "transfer", + } + } +} + +impl std::str::FromStr for TransferObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TransferObject::*; + match s { + "transfer" => Ok(Transfer), + _ => Err(()), + } + } +} +impl std::fmt::Display for TransferObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TransferObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TransferObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TransferObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TransferObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TransferObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TransferObject { + fn deserialize>(deserializer: D) -> 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 TransferObject")) + } +} 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..6326c7816 100644 --- a/generated/stripe_shared/src/transfer_data.rs +++ b/generated/stripe_shared/src/transfer_data.rs @@ -1,13 +1,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// 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, } +#[doc(hidden)] +pub struct TransferDataBuilder { + amount: Option>, + destination: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TransferDataBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount: Deserialize::default(), destination: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { amount: self.amount?, destination: self.destination.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..86f85e215 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TransferReversal { /// Amount, in cents (or local equivalent). pub amount: i64, @@ -31,11 +33,223 @@ pub struct TransferReversal { /// 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>, + /// String representing the object's type. Objects of the same type share the same value. + pub object: TransferReversalObject, /// ID of the refund responsible for the transfer reversal. pub source_refund: Option>, /// ID of the transfer that was reversed. pub transfer: stripe_types::Expandable, } +#[doc(hidden)] +pub struct TransferReversalBuilder { + amount: Option, + balance_transaction: + Option>>, + created: Option, + currency: Option, + destination_payment_refund: Option>>, + id: Option, + metadata: Option>>, + object: Option, + source_refund: Option>>, + transfer: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TransferReversalBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "source_refund" => Deserialize::begin(&mut self.source_refund), + "transfer" => Deserialize::begin(&mut self.transfer), + + _ => ::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(), + object: Deserialize::default(), + source_refund: Deserialize::default(), + transfer: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + balance_transaction: self.balance_transaction.take()?, + created: self.created?, + currency: self.currency?, + destination_payment_refund: self.destination_payment_refund.take()?, + id: self.id.take()?, + metadata: self.metadata.take()?, + object: self.object?, + source_refund: self.source_refund.take()?, + transfer: self.transfer.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TransferReversalObject { + TransferReversal, +} +impl TransferReversalObject { + pub fn as_str(self) -> &'static str { + use TransferReversalObject::*; + match self { + TransferReversal => "transfer_reversal", + } + } +} + +impl std::str::FromStr for TransferReversalObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TransferReversalObject::*; + match s { + "transfer_reversal" => Ok(TransferReversal), + _ => Err(()), + } + } +} +impl std::fmt::Display for TransferReversalObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TransferReversalObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TransferReversalObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TransferReversalObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TransferReversalObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TransferReversalObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TransferReversalObject { + fn deserialize>(deserializer: D) -> 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 TransferReversalObject")) + } +} 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..88fde2fae 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,113 @@ 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, /// 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, } +#[doc(hidden)] +pub struct TransferScheduleBuilder { + delay_days: Option, + interval: Option, + monthly_anchor: Option>, + weekly_anchor: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TransferScheduleBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + delay_days: self.delay_days?, + interval: self.interval.take()?, + monthly_anchor: self.monthly_anchor?, + weekly_anchor: self.weekly_anchor.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..147d62c6d 100644 --- a/generated/stripe_shared/src/transform_quantity.rs +++ b/generated/stripe_shared/src/transform_quantity.rs @@ -1,10 +1,101 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TransformQuantity { /// Divide usage by this number. pub divide_by: i64, /// After division, either round the result `up` or `down`. pub round: TransformQuantityRound, } +#[doc(hidden)] +pub struct TransformQuantityBuilder { + divide_by: Option, + round: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TransformQuantityBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { divide_by: Deserialize::default(), round: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { divide_by: self.divide_by?, round: self.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 { + 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 { @@ -43,6 +134,7 @@ impl std::fmt::Debug for TransformQuantityRound { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TransformQuantityRound { fn serialize(&self, serializer: S) -> Result where @@ -51,6 +143,22 @@ impl serde::Serialize for TransformQuantityRound { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TransformQuantityRound { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TransformQuantityRound::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TransformQuantityRound); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TransformQuantityRound { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/transform_usage.rs b/generated/stripe_shared/src/transform_usage.rs index 4b27d3e7d..ec92cdcce 100644 --- a/generated/stripe_shared/src/transform_usage.rs +++ b/generated/stripe_shared/src/transform_usage.rs @@ -1,10 +1,101 @@ -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TransformUsage { /// Divide usage by this number. pub divide_by: i64, /// After division, either round the result `up` or `down`. pub round: TransformUsageRound, } +#[doc(hidden)] +pub struct TransformUsageBuilder { + divide_by: Option, + round: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TransformUsageBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { divide_by: Deserialize::default(), round: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { divide_by: self.divide_by?, round: self.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 { + 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 { @@ -43,6 +134,7 @@ impl std::fmt::Debug for TransformUsageRound { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TransformUsageRound { fn serialize(&self, serializer: S) -> Result where @@ -51,6 +143,22 @@ impl serde::Serialize for TransformUsageRound { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TransformUsageRound { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TransformUsageRound::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TransformUsageRound); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TransformUsageRound { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/us_bank_account_networks.rs b/generated/stripe_shared/src/us_bank_account_networks.rs index 987f23aea..66979468d 100644 --- a/generated/stripe_shared/src/us_bank_account_networks.rs +++ b/generated/stripe_shared/src/us_bank_account_networks.rs @@ -1,10 +1,101 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct UsBankAccountNetworks { /// The preferred network. pub preferred: Option, /// All supported networks. pub supported: Vec, } +#[doc(hidden)] +pub struct UsBankAccountNetworksBuilder { + preferred: Option>, + supported: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: UsBankAccountNetworksBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { preferred: Deserialize::default(), supported: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { preferred: self.preferred.take()?, supported: self.supported.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -43,6 +134,7 @@ impl std::fmt::Debug for UsBankAccountNetworksSupported { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for UsBankAccountNetworksSupported { fn serialize(&self, serializer: S) -> Result where @@ -51,6 +143,22 @@ impl serde::Serialize for UsBankAccountNetworksSupported { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for UsBankAccountNetworksSupported { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(UsBankAccountNetworksSupported::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(UsBankAccountNetworksSupported); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for UsBankAccountNetworksSupported { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_shared/src/usage_record_summary.rs b/generated/stripe_shared/src/usage_record_summary.rs index 2b9343648..52e6f8aa3 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct UsageRecordSummary { /// Unique identifier for the object. pub id: stripe_shared::UsageRecordSummaryId, @@ -6,12 +8,202 @@ pub struct UsageRecordSummary { pub invoice: Option, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: UsageRecordSummaryObject, pub period: stripe_shared::Period, /// The ID of the subscription item this summary is describing. pub subscription_item: String, /// The total usage within this usage period. pub total_usage: i64, } +#[doc(hidden)] +pub struct UsageRecordSummaryBuilder { + id: Option, + invoice: Option>, + livemode: Option, + object: Option, + period: Option, + subscription_item: Option, + total_usage: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: UsageRecordSummaryBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "period" => Deserialize::begin(&mut self.period), + "subscription_item" => Deserialize::begin(&mut self.subscription_item), + "total_usage" => Deserialize::begin(&mut self.total_usage), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + id: Deserialize::default(), + invoice: Deserialize::default(), + livemode: Deserialize::default(), + object: Deserialize::default(), + period: Deserialize::default(), + subscription_item: Deserialize::default(), + total_usage: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + id: self.id.take()?, + invoice: self.invoice.take()?, + livemode: self.livemode?, + object: self.object?, + period: self.period?, + subscription_item: self.subscription_item.take()?, + total_usage: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum UsageRecordSummaryObject { + UsageRecordSummary, +} +impl UsageRecordSummaryObject { + pub fn as_str(self) -> &'static str { + use UsageRecordSummaryObject::*; + match self { + UsageRecordSummary => "usage_record_summary", + } + } +} + +impl std::str::FromStr for UsageRecordSummaryObject { + type Err = (); + fn from_str(s: &str) -> Result { + use UsageRecordSummaryObject::*; + match s { + "usage_record_summary" => Ok(UsageRecordSummary), + _ => Err(()), + } + } +} +impl std::fmt::Display for UsageRecordSummaryObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for UsageRecordSummaryObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for UsageRecordSummaryObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for UsageRecordSummaryObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(UsageRecordSummaryObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(UsageRecordSummaryObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for UsageRecordSummaryObject { + fn deserialize>(deserializer: D) -> 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 UsageRecordSummaryObject")) + } +} impl stripe_types::Object for UsageRecordSummary { type Id = stripe_shared::UsageRecordSummaryId; fn id(&self) -> &Self::Id { diff --git a/generated/stripe_terminal/Cargo.toml b/generated/stripe_terminal/Cargo.toml index 04def9be3..313d54194 100644 --- a/generated/stripe_terminal/Cargo.toml +++ b/generated/stripe_terminal/Cargo.toml @@ -16,8 +16,9 @@ path = "src/mod.rs" [dependencies] serde.workspace = true -smol_str.workspace = true serde_json.workspace = true +smol_str.workspace = true +miniserde.workspace = true stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +serde = ["stripe_types/serde","stripe_shared/serde"] 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..b0b6e6105 100644 --- a/generated/stripe_terminal/src/deleted_terminal_configuration.rs +++ b/generated/stripe_terminal/src/deleted_terminal_configuration.rs @@ -1,9 +1,180 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedTerminalConfigurationObject, +} +#[doc(hidden)] +pub struct DeletedTerminalConfigurationBuilder { + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedTerminalConfigurationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deleted: self.deleted?, id: self.id.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedTerminalConfigurationObject { + TerminalConfiguration, +} +impl DeletedTerminalConfigurationObject { + pub fn as_str(self) -> &'static str { + use DeletedTerminalConfigurationObject::*; + match self { + TerminalConfiguration => "terminal.configuration", + } + } +} + +impl std::str::FromStr for DeletedTerminalConfigurationObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedTerminalConfigurationObject::*; + match s { + "terminal.configuration" => Ok(TerminalConfiguration), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedTerminalConfigurationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedTerminalConfigurationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedTerminalConfigurationObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedTerminalConfigurationObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(DeletedTerminalConfigurationObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedTerminalConfigurationObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedTerminalConfigurationObject { + fn deserialize>(deserializer: D) -> 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 DeletedTerminalConfigurationObject") + }) + } } impl stripe_types::Object for DeletedTerminalConfiguration { type Id = stripe_terminal::TerminalConfigurationId; diff --git a/generated/stripe_terminal/src/deleted_terminal_location.rs b/generated/stripe_terminal/src/deleted_terminal_location.rs index e60106201..7fd2388cc 100644 --- a/generated/stripe_terminal/src/deleted_terminal_location.rs +++ b/generated/stripe_terminal/src/deleted_terminal_location.rs @@ -1,9 +1,179 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedTerminalLocationObject, +} +#[doc(hidden)] +pub struct DeletedTerminalLocationBuilder { + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedTerminalLocationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deleted: self.deleted?, id: self.id.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedTerminalLocationObject { + TerminalLocation, +} +impl DeletedTerminalLocationObject { + pub fn as_str(self) -> &'static str { + use DeletedTerminalLocationObject::*; + match self { + TerminalLocation => "terminal.location", + } + } +} + +impl std::str::FromStr for DeletedTerminalLocationObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedTerminalLocationObject::*; + match s { + "terminal.location" => Ok(TerminalLocation), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedTerminalLocationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedTerminalLocationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedTerminalLocationObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedTerminalLocationObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DeletedTerminalLocationObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedTerminalLocationObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedTerminalLocationObject { + fn deserialize>(deserializer: D) -> 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 DeletedTerminalLocationObject") + }) + } } impl stripe_types::Object for DeletedTerminalLocation { type Id = stripe_terminal::TerminalLocationId; diff --git a/generated/stripe_terminal/src/deleted_terminal_reader.rs b/generated/stripe_terminal/src/deleted_terminal_reader.rs index 9143214e1..46f07260e 100644 --- a/generated/stripe_terminal/src/deleted_terminal_reader.rs +++ b/generated/stripe_terminal/src/deleted_terminal_reader.rs @@ -1,9 +1,178 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: DeletedTerminalReaderObject, +} +#[doc(hidden)] +pub struct DeletedTerminalReaderBuilder { + deleted: Option, + id: Option, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: DeletedTerminalReaderBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + deleted: Deserialize::default(), + id: Deserialize::default(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deleted: self.deleted?, id: self.id.take()?, object: self.object? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum DeletedTerminalReaderObject { + TerminalReader, +} +impl DeletedTerminalReaderObject { + pub fn as_str(self) -> &'static str { + use DeletedTerminalReaderObject::*; + match self { + TerminalReader => "terminal.reader", + } + } +} + +impl std::str::FromStr for DeletedTerminalReaderObject { + type Err = (); + fn from_str(s: &str) -> Result { + use DeletedTerminalReaderObject::*; + match s { + "terminal.reader" => Ok(TerminalReader), + _ => Err(()), + } + } +} +impl std::fmt::Display for DeletedTerminalReaderObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for DeletedTerminalReaderObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for DeletedTerminalReaderObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for DeletedTerminalReaderObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(DeletedTerminalReaderObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(DeletedTerminalReaderObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for DeletedTerminalReaderObject { + fn deserialize>(deserializer: D) -> 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 DeletedTerminalReaderObject")) + } } impl stripe_types::Object for DeletedTerminalReader { type Id = stripe_terminal::TerminalReaderId; diff --git a/generated/stripe_terminal/src/mod.rs b/generated/stripe_terminal/src/mod.rs index 854cc8cf1..7f0c40749 100644 --- a/generated/stripe_terminal/src/mod.rs +++ b/generated/stripe_terminal/src/mod.rs @@ -7,6 +7,8 @@ //! for requests mentioned in the `Terminal` section of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_terminal; + +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..c700d787d 100644 --- a/generated/stripe_terminal/src/terminal_configuration/requests.rs +++ b/generated/stripe_terminal/src/terminal_configuration/requests.rs @@ -82,12 +82,88 @@ impl<'a> RetrieveTerminalConfiguration<'a> { client.get_query(&format!("/terminal/configurations/{configuration}"), self) } } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(untagged))] pub enum RetrieveTerminalConfigurationReturned { TerminalConfiguration(stripe_terminal::TerminalConfiguration), DeletedTerminalConfiguration(stripe_terminal::DeletedTerminalConfiguration), } + +#[derive(Default)] +pub struct RetrieveTerminalConfigurationReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +const _: () = { + use 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, + builder: RetrieveTerminalConfigurationReturnedBuilder, + } + + impl Deserialize for RetrieveTerminalConfigurationReturned { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 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 { + 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 CreateTerminalConfiguration<'a> { /// An object containing device type specific settings for BBPOS WisePOS E readers @@ -205,12 +281,88 @@ impl<'a> UpdateTerminalConfiguration<'a> { ) } } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(untagged))] pub enum UpdateTerminalConfigurationReturned { TerminalConfiguration(stripe_terminal::TerminalConfiguration), DeletedTerminalConfiguration(stripe_terminal::DeletedTerminalConfiguration), } + +#[derive(Default)] +pub struct UpdateTerminalConfigurationReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +const _: () = { + use 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, + builder: UpdateTerminalConfigurationReturnedBuilder, + } + + impl Deserialize for UpdateTerminalConfigurationReturned { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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, 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..b8e1e4d43 100644 --- a/generated/stripe_terminal/src/terminal_configuration/types.rs +++ b/generated/stripe_terminal/src/terminal_configuration/types.rs @@ -1,9 +1,10 @@ /// A Configurations object represents how features should be configured for terminal readers. /// /// For more details see <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TerminalConfiguration { - #[serde(skip_serializing_if = "Option::is_none")] pub bbpos_wisepos_e: Option, /// Unique identifier for the object. @@ -12,14 +13,213 @@ pub struct TerminalConfiguration { pub is_account_default: Option, /// 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")] + /// String representing the object's type. Objects of the same type share the same value. + pub object: TerminalConfigurationObject, pub offline: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub tipping: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub verifone_p400: Option, } +#[doc(hidden)] +pub struct TerminalConfigurationBuilder { + bbpos_wisepos_e: Option< + Option, + >, + id: Option, + is_account_default: Option>, + livemode: Option, + object: Option, + offline: + Option>, + tipping: Option>, + verifone_p400: Option< + Option, + >, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TerminalConfigurationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "offline" => Deserialize::begin(&mut self.offline), + "tipping" => Deserialize::begin(&mut self.tipping), + "verifone_p400" => Deserialize::begin(&mut self.verifone_p400), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bbpos_wisepos_e: Deserialize::default(), + id: Deserialize::default(), + is_account_default: Deserialize::default(), + livemode: Deserialize::default(), + object: Deserialize::default(), + offline: Deserialize::default(), + tipping: Deserialize::default(), + verifone_p400: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + bbpos_wisepos_e: self.bbpos_wisepos_e.take()?, + id: self.id.take()?, + is_account_default: self.is_account_default?, + livemode: self.livemode?, + object: self.object?, + offline: self.offline?, + tipping: self.tipping.take()?, + verifone_p400: self.verifone_p400.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TerminalConfigurationObject { + TerminalConfiguration, +} +impl TerminalConfigurationObject { + pub fn as_str(self) -> &'static str { + use TerminalConfigurationObject::*; + match self { + TerminalConfiguration => "terminal.configuration", + } + } +} + +impl std::str::FromStr for TerminalConfigurationObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TerminalConfigurationObject::*; + match s { + "terminal.configuration" => Ok(TerminalConfiguration), + _ => Err(()), + } + } +} +impl std::fmt::Display for TerminalConfigurationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TerminalConfigurationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TerminalConfigurationObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TerminalConfigurationObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TerminalConfigurationObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TerminalConfigurationObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TerminalConfigurationObject { + fn deserialize>(deserializer: D) -> 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 TerminalConfigurationObject")) + } +} 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..d7ce783ac 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,113 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TerminalConfigurationConfigurationResourceCurrencySpecificConfig { /// Fixed amounts displayed when collecting a tip - #[serde(skip_serializing_if = "Option::is_none")] pub fixed_amounts: Option>, /// Percentages displayed when collecting a tip - #[serde(skip_serializing_if = "Option::is_none")] pub percentages: Option>, /// 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, } +#[doc(hidden)] +pub struct TerminalConfigurationConfigurationResourceCurrencySpecificConfigBuilder { + fixed_amounts: Option>>, + percentages: Option>>, + smart_tip_threshold: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TerminalConfigurationConfigurationResourceCurrencySpecificConfigBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + fixed_amounts: Deserialize::default(), + percentages: Deserialize::default(), + smart_tip_threshold: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + fixed_amounts: self.fixed_amounts.take()?, + percentages: self.percentages.take()?, + smart_tip_threshold: self.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 { + 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..1089ce791 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, } +#[doc(hidden)] +pub struct TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfigBuilder { + splashscreen: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TerminalConfigurationConfigurationResourceDeviceTypeSpecificConfigBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { splashscreen: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { splashscreen: self.splashscreen.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..72b9a06f4 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,96 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TerminalConfigurationConfigurationResourceOfflineConfig { /// Determines whether to allow transactions to be collected while reader is offline. /// Defaults to false. pub enabled: Option, } +#[doc(hidden)] +pub struct TerminalConfigurationConfigurationResourceOfflineConfigBuilder { + enabled: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TerminalConfigurationConfigurationResourceOfflineConfigBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { enabled: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { enabled: self.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 { + 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..60a8ec10f 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,216 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TerminalConfigurationConfigurationResourceTipping { - #[serde(skip_serializing_if = "Option::is_none")] pub aud: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cad: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub chf: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub czk: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub dkk: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub eur: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub gbp: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub hkd: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub myr: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub nok: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub nzd: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sek: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub sgd: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub usd: Option, } +#[doc(hidden)] +pub struct TerminalConfigurationConfigurationResourceTippingBuilder { + aud: Option< + Option, + >, + cad: Option< + Option, + >, + chf: Option< + Option, + >, + czk: Option< + Option, + >, + dkk: Option< + Option, + >, + eur: Option< + Option, + >, + gbp: Option< + Option, + >, + hkd: Option< + Option, + >, + myr: Option< + Option, + >, + nok: Option< + Option, + >, + nzd: Option< + Option, + >, + sek: Option< + Option, + >, + sgd: Option< + Option, + >, + usd: Option< + Option, + >, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TerminalConfigurationConfigurationResourceTippingBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + aud: self.aud.take()?, + cad: self.cad.take()?, + chf: self.chf.take()?, + czk: self.czk.take()?, + dkk: self.dkk.take()?, + eur: self.eur.take()?, + gbp: self.gbp.take()?, + hkd: self.hkd.take()?, + myr: self.myr.take()?, + nok: self.nok.take()?, + nzd: self.nzd.take()?, + sek: self.sek.take()?, + sgd: self.sgd.take()?, + usd: self.usd.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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/types.rs b/generated/stripe_terminal/src/terminal_connection_token/types.rs index 4b10b55db..b0f4f9922 100644 --- a/generated/stripe_terminal/src/terminal_connection_token/types.rs +++ b/generated/stripe_terminal/src/terminal_connection_token/types.rs @@ -3,13 +3,185 @@ /// Related guide: [Fleet management](https://stripe.com/docs/terminal/fleet/locations) /// /// For more details see <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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 representing the object's type. Objects of the same type share the same value. + pub object: TerminalConnectionTokenObject, /// Your application should pass this token to the Stripe Terminal SDK. pub secret: String, } +#[doc(hidden)] +pub struct TerminalConnectionTokenBuilder { + location: Option>, + object: Option, + secret: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TerminalConnectionTokenBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "secret" => Deserialize::begin(&mut self.secret), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + location: Deserialize::default(), + object: Deserialize::default(), + secret: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + location: self.location.take()?, + object: self.object?, + secret: self.secret.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + "secret" => b.secret = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TerminalConnectionTokenObject { + TerminalConnectionToken, +} +impl TerminalConnectionTokenObject { + pub fn as_str(self) -> &'static str { + use TerminalConnectionTokenObject::*; + match self { + TerminalConnectionToken => "terminal.connection_token", + } + } +} + +impl std::str::FromStr for TerminalConnectionTokenObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TerminalConnectionTokenObject::*; + match s { + "terminal.connection_token" => Ok(TerminalConnectionToken), + _ => Err(()), + } + } +} +impl std::fmt::Display for TerminalConnectionTokenObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TerminalConnectionTokenObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TerminalConnectionTokenObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TerminalConnectionTokenObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TerminalConnectionTokenObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TerminalConnectionTokenObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TerminalConnectionTokenObject { + fn deserialize>(deserializer: D) -> 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 TerminalConnectionTokenObject") + }) + } +} diff --git a/generated/stripe_terminal/src/terminal_location/requests.rs b/generated/stripe_terminal/src/terminal_location/requests.rs index 137fb10ce..b17f417af 100644 --- a/generated/stripe_terminal/src/terminal_location/requests.rs +++ b/generated/stripe_terminal/src/terminal_location/requests.rs @@ -79,12 +79,88 @@ impl<'a> RetrieveTerminalLocation<'a> { client.get_query(&format!("/terminal/locations/{location}"), self) } } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(untagged))] pub enum RetrieveTerminalLocationReturned { TerminalLocation(stripe_terminal::TerminalLocation), DeletedTerminalLocation(stripe_terminal::DeletedTerminalLocation), } + +#[derive(Default)] +pub struct RetrieveTerminalLocationReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +const _: () = { + use 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, + builder: RetrieveTerminalLocationReturnedBuilder, + } + + impl Deserialize for RetrieveTerminalLocationReturned { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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. @@ -209,9 +285,84 @@ impl<'a> UpdateTerminalLocation<'a> { 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(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(untagged))] pub enum UpdateTerminalLocationReturned { TerminalLocation(stripe_terminal::TerminalLocation), DeletedTerminalLocation(stripe_terminal::DeletedTerminalLocation), } + +#[derive(Default)] +pub struct UpdateTerminalLocationReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +const _: () = { + use 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, + builder: UpdateTerminalLocationReturnedBuilder, + } + + impl Deserialize for UpdateTerminalLocationReturned { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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; + } +}; diff --git a/generated/stripe_terminal/src/terminal_location/types.rs b/generated/stripe_terminal/src/terminal_location/types.rs index d7762ef3a..2c9289040 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// The display name of the location. pub display_name: String, @@ -18,6 +19,198 @@ pub struct TerminalLocation { /// 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 representing the object's type. Objects of the same type share the same value. + pub object: TerminalLocationObject, +} +#[doc(hidden)] +pub struct TerminalLocationBuilder { + address: Option, + configuration_overrides: Option>, + display_name: Option, + id: Option, + livemode: Option, + metadata: Option>, + object: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TerminalLocationBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + + _ => ::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(), + object: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + address: self.address.take()?, + configuration_overrides: self.configuration_overrides.take()?, + display_name: self.display_name.take()?, + id: self.id.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = Some(FromValueOpt::from_value(v)?), + + _ => {} + } + } + b.take_out() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TerminalLocationObject { + TerminalLocation, +} +impl TerminalLocationObject { + pub fn as_str(self) -> &'static str { + use TerminalLocationObject::*; + match self { + TerminalLocation => "terminal.location", + } + } +} + +impl std::str::FromStr for TerminalLocationObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TerminalLocationObject::*; + match s { + "terminal.location" => Ok(TerminalLocation), + _ => Err(()), + } + } +} +impl std::fmt::Display for TerminalLocationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TerminalLocationObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TerminalLocationObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TerminalLocationObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TerminalLocationObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TerminalLocationObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TerminalLocationObject { + fn deserialize>(deserializer: D) -> 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 TerminalLocationObject")) + } } impl stripe_types::Object for TerminalLocation { type Id = stripe_terminal::TerminalLocationId; diff --git a/generated/stripe_terminal/src/terminal_reader/requests.rs b/generated/stripe_terminal/src/terminal_reader/requests.rs index 97b961716..394efa89c 100644 --- a/generated/stripe_terminal/src/terminal_reader/requests.rs +++ b/generated/stripe_terminal/src/terminal_reader/requests.rs @@ -87,12 +87,88 @@ impl<'a> RetrieveTerminalReader<'a> { client.get_query(&format!("/terminal/readers/{reader}"), self) } } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(untagged))] pub enum RetrieveTerminalReaderReturned { TerminalReader(stripe_terminal::TerminalReader), DeletedTerminalReader(stripe_terminal::DeletedTerminalReader), } + +#[derive(Default)] +pub struct RetrieveTerminalReaderReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +const _: () = { + use 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, + builder: RetrieveTerminalReaderReturnedBuilder, + } + + impl Deserialize for RetrieveTerminalReaderReturned { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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. @@ -159,12 +235,88 @@ impl<'a> UpdateTerminalReader<'a> { client.send_form(&format!("/terminal/readers/{reader}"), self, http_types::Method::Post) } } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(untagged)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(untagged))] pub enum UpdateTerminalReaderReturned { TerminalReader(stripe_terminal::TerminalReader), DeletedTerminalReader(stripe_terminal::DeletedTerminalReader), } + +#[derive(Default)] +pub struct UpdateTerminalReaderReturnedBuilder { + inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner, +} + +const _: () = { + use 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, + builder: UpdateTerminalReaderReturnedBuilder, + } + + impl Deserialize for UpdateTerminalReaderReturned { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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 CancelActionTerminalReader<'a> { /// Specifies which fields in the response should be expanded. @@ -248,7 +400,7 @@ impl<'a> ProcessPaymentIntentTerminalReader<'a> { ) } } -#[derive(Copy, Clone, Debug, serde::Serialize)] +#[derive(Clone, Debug, serde::Serialize)] pub struct ProcessSetupIntentTerminalReader<'a> { /// Customer Consent Collected pub customer_consent_collected: bool, @@ -257,7 +409,8 @@ pub struct ProcessSetupIntentTerminalReader<'a> { pub expand: Option<&'a [&'a str]>, /// Configuration overrides #[serde(skip_serializing_if = "Option::is_none")] - pub process_config: Option<&'a serde_json::Value>, + #[serde(with = "stripe_types::with_serde_json_opt")] + pub process_config: Option, /// SetupIntent ID pub setup_intent: &'a str, } @@ -429,6 +582,16 @@ impl serde::Serialize for SetReaderDisplayTerminalReaderType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for SetReaderDisplayTerminalReaderType { + fn deserialize>(deserializer: D) -> 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 SetReaderDisplayTerminalReaderType") + }) + } +} impl<'a> SetReaderDisplayTerminalReader<'a> { /// Sets reader display to show cart details. pub fn send( @@ -537,6 +700,16 @@ impl serde::Serialize for PresentPaymentMethodTerminalReaderType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for PresentPaymentMethodTerminalReaderType { + fn deserialize>(deserializer: D) -> 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 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. diff --git a/generated/stripe_terminal/src/terminal_reader/types.rs b/generated/stripe_terminal/src/terminal_reader/types.rs index 8f2edbcd7..ed85a1c9a 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 <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TerminalReader { /// The most recent action performed by the reader. pub action: Option, @@ -24,11 +26,226 @@ pub struct TerminalReader { /// 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 representing the object's type. Objects of the same type share the same value. + pub object: TerminalReaderObject, /// Serial number of the reader. pub serial_number: String, /// The networking status of the reader. pub status: Option, } +#[doc(hidden)] +pub struct TerminalReaderBuilder { + action: Option>, + device_sw_version: Option>, + device_type: Option, + id: Option, + ip_address: Option>, + label: Option, + livemode: Option, + location: Option>>, + metadata: Option>, + object: Option, + serial_number: Option, + status: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TerminalReaderBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "serial_number" => Deserialize::begin(&mut self.serial_number), + "status" => Deserialize::begin(&mut self.status), + + _ => ::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(), + object: Deserialize::default(), + serial_number: Deserialize::default(), + status: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + action: self.action.take()?, + device_sw_version: self.device_sw_version.take()?, + device_type: self.device_type?, + id: self.id.take()?, + ip_address: self.ip_address.take()?, + label: self.label.take()?, + livemode: self.livemode?, + location: self.location.take()?, + metadata: self.metadata.take()?, + object: self.object?, + serial_number: self.serial_number.take()?, + status: self.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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TerminalReaderObject { + TerminalReader, +} +impl TerminalReaderObject { + pub fn as_str(self) -> &'static str { + use TerminalReaderObject::*; + match self { + TerminalReader => "terminal.reader", + } + } +} + +impl std::str::FromStr for TerminalReaderObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TerminalReaderObject::*; + match s { + "terminal.reader" => Ok(TerminalReader), + _ => Err(()), + } + } +} +impl std::fmt::Display for TerminalReaderObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TerminalReaderObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TerminalReaderObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TerminalReaderObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TerminalReaderObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TerminalReaderObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TerminalReaderObject { + fn deserialize>(deserializer: D) -> 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 TerminalReaderObject")) + } +} impl stripe_types::Object for TerminalReader { type Id = stripe_terminal::TerminalReaderId; fn id(&self) -> &Self::Id { @@ -93,6 +310,22 @@ impl serde::Serialize for TerminalReaderDeviceType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TerminalReaderDeviceType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TerminalReaderDeviceType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TerminalReaderDeviceType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TerminalReaderDeviceType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -146,6 +379,22 @@ impl serde::Serialize for TerminalReaderStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TerminalReaderStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TerminalReaderStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TerminalReaderStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TerminalReaderStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..8a23a0af6 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,108 @@ pub struct TerminalReaderReaderResourceCart { /// A positive integer in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). pub total: i64, } +#[doc(hidden)] +pub struct TerminalReaderReaderResourceCartBuilder { + currency: Option, + line_items: Option>, + tax: Option>, + total: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TerminalReaderReaderResourceCartBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + currency: self.currency?, + line_items: self.line_items.take()?, + tax: self.tax?, + total: self.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 { + 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..3db1cf91d 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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,103 @@ pub struct TerminalReaderReaderResourceLineItem { /// The quantity of the line item. pub quantity: u64, } +#[doc(hidden)] +pub struct TerminalReaderReaderResourceLineItemBuilder { + amount: Option, + description: Option, + quantity: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TerminalReaderReaderResourceLineItemBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + amount: Deserialize::default(), + description: Deserialize::default(), + quantity: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + description: self.description.take()?, + quantity: self.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 { + 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..f4e2fb984 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,98 @@ /// 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TerminalReaderReaderResourceProcessConfig { /// Override showing a tipping selection screen on this transaction. - #[serde(skip_serializing_if = "Option::is_none")] pub skip_tipping: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub tipping: Option, } +#[doc(hidden)] +pub struct TerminalReaderReaderResourceProcessConfigBuilder { + skip_tipping: Option>, + tipping: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TerminalReaderReaderResourceProcessConfigBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { skip_tipping: Deserialize::default(), tipping: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { skip_tipping: self.skip_tipping?, tipping: self.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 { + 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..487de68f1 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,103 @@ /// Represents a reader action to process a payment intent -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TerminalReaderReaderResourceProcessPaymentIntentAction { /// Most recent PaymentIntent processed by the reader. pub payment_intent: stripe_types::Expandable, - #[serde(skip_serializing_if = "Option::is_none")] pub process_config: Option, } +#[doc(hidden)] +pub struct TerminalReaderReaderResourceProcessPaymentIntentActionBuilder { + payment_intent: Option>, + process_config: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TerminalReaderReaderResourceProcessPaymentIntentActionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { payment_intent: Deserialize::default(), process_config: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + payment_intent: self.payment_intent.take()?, + process_config: self.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 { + 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..88e25eb22 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,85 @@ /// 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TerminalReaderReaderResourceProcessSetupConfig {} +#[doc(hidden)] +pub struct TerminalReaderReaderResourceProcessSetupConfigBuilder {} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TerminalReaderReaderResourceProcessSetupConfigBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self {} + } + + fn take_out(&mut self) -> Option { + 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 { + 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..6072ce8d8 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,114 @@ /// Represents a reader action to process a setup intent -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, - #[serde(skip_serializing_if = "Option::is_none")] pub process_config: Option, /// Most recent SetupIntent processed by the reader. pub setup_intent: stripe_types::Expandable, } +#[doc(hidden)] +pub struct TerminalReaderReaderResourceProcessSetupIntentActionBuilder { + generated_card: Option>, + process_config: Option>, + setup_intent: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TerminalReaderReaderResourceProcessSetupIntentActionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + generated_card: Deserialize::default(), + process_config: Deserialize::default(), + setup_intent: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + generated_card: self.generated_card.take()?, + process_config: self.process_config?, + setup_intent: self.setup_intent.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..d903653dd 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,160 @@ /// Represents an action performed by the reader -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TerminalReaderReaderResourceReaderAction { /// Failure code, only set if status is `failed`. pub failure_code: Option, /// Detailed failure message, only set if status is `failed`. pub failure_message: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub process_payment_intent: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub process_setup_intent: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub refund_payment: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub set_reader_display: Option, /// Status of the action performed by the reader. pub status: TerminalReaderReaderResourceReaderActionStatus, /// Type of action performed by the reader. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: TerminalReaderReaderResourceReaderActionType, } +#[doc(hidden)] +pub struct TerminalReaderReaderResourceReaderActionBuilder { + failure_code: Option>, + failure_message: Option>, + process_payment_intent: + Option>, + process_setup_intent: + Option>, + refund_payment: + Option>, + set_reader_display: + Option>, + status: Option, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TerminalReaderReaderResourceReaderActionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + failure_code: self.failure_code.take()?, + failure_message: self.failure_message.take()?, + process_payment_intent: self.process_payment_intent.take()?, + process_setup_intent: self.process_setup_intent.take()?, + refund_payment: self.refund_payment.take()?, + set_reader_display: self.set_reader_display.take()?, + status: self.status?, + type_: self.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 { + 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 { @@ -63,6 +196,7 @@ impl std::fmt::Debug for TerminalReaderReaderResourceReaderActionStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TerminalReaderReaderResourceReaderActionStatus { fn serialize(&self, serializer: S) -> Result where @@ -71,6 +205,25 @@ impl serde::Serialize for TerminalReaderReaderResourceReaderActionStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TerminalReaderReaderResourceReaderActionStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TerminalReaderReaderResourceReaderActionStatus::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TerminalReaderReaderResourceReaderActionStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TerminalReaderReaderResourceReaderActionStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -126,6 +279,7 @@ impl std::fmt::Debug for TerminalReaderReaderResourceReaderActionType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TerminalReaderReaderResourceReaderActionType { fn serialize(&self, serializer: S) -> Result where @@ -134,6 +288,25 @@ impl serde::Serialize for TerminalReaderReaderResourceReaderActionType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TerminalReaderReaderResourceReaderActionType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TerminalReaderReaderResourceReaderActionType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TerminalReaderReaderResourceReaderActionType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TerminalReaderReaderResourceReaderActionType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..bd4b29a29 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,158 @@ /// Represents a reader action to refund a payment -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TerminalReaderReaderResourceRefundPaymentAction { /// The amount being refunded. - #[serde(skip_serializing_if = "Option::is_none")] pub amount: Option, /// Charge that is being refunded. - #[serde(skip_serializing_if = "Option::is_none")] pub charge: Option>, /// 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>, /// Payment intent that is being refunded. - #[serde(skip_serializing_if = "Option::is_none")] pub payment_intent: Option>, /// The reason for the refund. - #[serde(skip_serializing_if = "Option::is_none")] pub reason: Option, /// Unique identifier for the refund object. - #[serde(skip_serializing_if = "Option::is_none")] pub refund: Option>, /// 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, /// 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, } +#[doc(hidden)] +pub struct TerminalReaderReaderResourceRefundPaymentActionBuilder { + amount: Option>, + charge: Option>>, + metadata: Option>>, + payment_intent: Option>>, + reason: Option>, + refund: Option>>, + refund_application_fee: Option>, + reverse_transfer: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TerminalReaderReaderResourceRefundPaymentActionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + amount: self.amount?, + charge: self.charge.take()?, + metadata: self.metadata.take()?, + payment_intent: self.payment_intent.take()?, + reason: self.reason?, + refund: self.refund.take()?, + refund_application_fee: self.refund_application_fee?, + reverse_transfer: self.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 { + 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 { @@ -73,6 +194,7 @@ impl std::fmt::Debug for TerminalReaderReaderResourceRefundPaymentActionReason { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TerminalReaderReaderResourceRefundPaymentActionReason { fn serialize(&self, serializer: S) -> Result where @@ -81,6 +203,27 @@ impl serde::Serialize for TerminalReaderReaderResourceRefundPaymentActionReason serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TerminalReaderReaderResourceRefundPaymentActionReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TerminalReaderReaderResourceRefundPaymentActionReason::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TerminalReaderReaderResourceRefundPaymentActionReason); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TerminalReaderReaderResourceRefundPaymentActionReason { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..f2841436c 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,103 @@ /// Represents a reader action to set the reader display -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TerminalReaderReaderResourceSetReaderDisplayAction { /// Cart object to be displayed by the reader. pub cart: Option, /// Type of information to be displayed by the reader. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: TerminalReaderReaderResourceSetReaderDisplayActionType, } +#[doc(hidden)] +pub struct TerminalReaderReaderResourceSetReaderDisplayActionBuilder { + cart: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TerminalReaderReaderResourceSetReaderDisplayActionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { cart: Deserialize::default(), type_: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { cart: self.cart.take()?, type_: self.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 { + 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 { @@ -42,6 +133,7 @@ impl std::fmt::Debug for TerminalReaderReaderResourceSetReaderDisplayActionType f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TerminalReaderReaderResourceSetReaderDisplayActionType { fn serialize(&self, serializer: S) -> Result where @@ -50,6 +142,27 @@ impl serde::Serialize for TerminalReaderReaderResourceSetReaderDisplayActionType serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TerminalReaderReaderResourceSetReaderDisplayActionType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TerminalReaderReaderResourceSetReaderDisplayActionType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TerminalReaderReaderResourceSetReaderDisplayActionType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TerminalReaderReaderResourceSetReaderDisplayActionType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..4b800a885 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct TerminalReaderReaderResourceTippingConfigBuilder { + amount_eligible: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TerminalReaderReaderResourceTippingConfigBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { amount_eligible: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { amount_eligible: self.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 { + 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/Cargo.toml b/generated/stripe_treasury/Cargo.toml index 7595a426f..bde37e3c2 100644 --- a/generated/stripe_treasury/Cargo.toml +++ b/generated/stripe_treasury/Cargo.toml @@ -16,8 +16,9 @@ path = "src/mod.rs" [dependencies] serde.workspace = true -smol_str.workspace = true serde_json.workspace = true +smol_str.workspace = true +miniserde.workspace = true stripe_types = {path = "../../stripe_types"} http-types.workspace = true @@ -28,6 +29,7 @@ stripe_shared = {path = "../../generated/stripe_shared"} [features] +serde = ["stripe_types/serde","stripe_shared/serde"] 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..38d0acef9 100644 --- a/generated/stripe_treasury/src/inbound_transfers.rs +++ b/generated/stripe_treasury/src/inbound_transfers.rs @@ -1,13 +1,115 @@ /// For more details see <>. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InboundTransfers { pub billing_details: stripe_treasury::TreasurySharedResourceBillingDetails, /// The type of the payment method used in the InboundTransfer. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: InboundTransfersType, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option, } +#[doc(hidden)] +pub struct InboundTransfersBuilder { + billing_details: Option, + type_: Option, + us_bank_account: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InboundTransfersBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + billing_details: Deserialize::default(), + type_: Deserialize::default(), + us_bank_account: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + billing_details: self.billing_details.take()?, + type_: self.type_?, + us_bank_account: self.us_bank_account.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -43,6 +145,7 @@ impl std::fmt::Debug for InboundTransfersType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InboundTransfersType { fn serialize(&self, serializer: S) -> Result where @@ -51,6 +154,22 @@ impl serde::Serialize for InboundTransfersType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InboundTransfersType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(InboundTransfersType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(InboundTransfersType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InboundTransfersType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..1407aa574 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,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct InboundTransfersPaymentMethodDetailsUsBankAccount { /// Account holder type: individual or company. pub account_holder_type: @@ -17,6 +19,129 @@ pub struct InboundTransfersPaymentMethodDetailsUsBankAccount { /// Routing number of the bank account. pub routing_number: Option, } +#[doc(hidden)] +pub struct InboundTransfersPaymentMethodDetailsUsBankAccountBuilder { + account_holder_type: + Option>, + account_type: Option>, + bank_name: Option>, + fingerprint: Option>, + last4: Option>, + network: Option, + routing_number: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: InboundTransfersPaymentMethodDetailsUsBankAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + account_holder_type: self.account_holder_type?, + account_type: self.account_type?, + bank_name: self.bank_name.take()?, + fingerprint: self.fingerprint.take()?, + last4: self.last4.take()?, + network: self.network?, + routing_number: self.routing_number.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -55,6 +180,7 @@ impl std::fmt::Debug for InboundTransfersPaymentMethodDetailsUsBankAccountAccoun f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType { fn serialize(&self, serializer: S) -> Result where @@ -63,6 +189,29 @@ impl serde::Serialize for InboundTransfersPaymentMethodDetailsUsBankAccountAccou serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType { @@ -110,6 +259,7 @@ impl std::fmt::Debug for InboundTransfersPaymentMethodDetailsUsBankAccountAccoun f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InboundTransfersPaymentMethodDetailsUsBankAccountAccountType { fn serialize(&self, serializer: S) -> Result where @@ -118,6 +268,29 @@ impl serde::Serialize for InboundTransfersPaymentMethodDetailsUsBankAccountAccou serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InboundTransfersPaymentMethodDetailsUsBankAccountAccountType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + InboundTransfersPaymentMethodDetailsUsBankAccountAccountType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + InboundTransfersPaymentMethodDetailsUsBankAccountAccountType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InboundTransfersPaymentMethodDetailsUsBankAccountAccountType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -164,6 +337,7 @@ impl std::fmt::Debug for InboundTransfersPaymentMethodDetailsUsBankAccountNetwor f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for InboundTransfersPaymentMethodDetailsUsBankAccountNetwork { fn serialize(&self, serializer: S) -> Result where @@ -172,6 +346,29 @@ impl serde::Serialize for InboundTransfersPaymentMethodDetailsUsBankAccountNetwo serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for InboundTransfersPaymentMethodDetailsUsBankAccountNetwork { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + InboundTransfersPaymentMethodDetailsUsBankAccountNetwork::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + InboundTransfersPaymentMethodDetailsUsBankAccountNetwork +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for InboundTransfersPaymentMethodDetailsUsBankAccountNetwork { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_treasury/src/mod.rs b/generated/stripe_treasury/src/mod.rs index e99ca40d7..422d66272 100644 --- a/generated/stripe_treasury/src/mod.rs +++ b/generated/stripe_treasury/src/mod.rs @@ -7,6 +7,8 @@ //! for requests mentioned in the `Treasury` section of the [Stripe API docs](https://stripe.com/docs/api) extern crate self as stripe_treasury; + +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..4c94be7a3 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,122 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct OutboundPaymentsPaymentMethodDetails { pub billing_details: stripe_treasury::TreasurySharedResourceBillingDetails, - #[serde(skip_serializing_if = "Option::is_none")] pub financial_account: Option, /// The type of the payment method used in the OutboundPayment. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: OutboundPaymentsPaymentMethodDetailsType, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option, } +#[doc(hidden)] +pub struct OutboundPaymentsPaymentMethodDetailsBuilder { + billing_details: Option, + financial_account: + Option>, + type_: Option, + us_bank_account: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: OutboundPaymentsPaymentMethodDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + billing_details: self.billing_details.take()?, + financial_account: self.financial_account.take()?, + type_: self.type_?, + us_bank_account: self.us_bank_account.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -48,6 +155,7 @@ impl std::fmt::Debug for OutboundPaymentsPaymentMethodDetailsType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for OutboundPaymentsPaymentMethodDetailsType { fn serialize(&self, serializer: S) -> Result where @@ -56,6 +164,24 @@ impl serde::Serialize for OutboundPaymentsPaymentMethodDetailsType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for OutboundPaymentsPaymentMethodDetailsType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + OutboundPaymentsPaymentMethodDetailsType::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(OutboundPaymentsPaymentMethodDetailsType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for OutboundPaymentsPaymentMethodDetailsType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..14f56ba02 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,103 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct OutboundPaymentsPaymentMethodDetailsFinancialAccount { /// Token of the FinancialAccount. pub id: String, /// The rails used to send funds. pub network: OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork, } +#[doc(hidden)] +pub struct OutboundPaymentsPaymentMethodDetailsFinancialAccountBuilder { + id: Option, + network: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: OutboundPaymentsPaymentMethodDetailsFinancialAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { id: Deserialize::default(), network: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { id: self.id.take()?, network: self.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 { + 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 { @@ -40,6 +133,7 @@ impl std::fmt::Debug for OutboundPaymentsPaymentMethodDetailsFinancialAccountNet f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork { fn serialize(&self, serializer: S) -> Result where @@ -48,6 +142,29 @@ impl serde::Serialize for OutboundPaymentsPaymentMethodDetailsFinancialAccountNe serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for OutboundPaymentsPaymentMethodDetailsFinancialAccountNetwork { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..a9b912530 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,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct OutboundPaymentsPaymentMethodDetailsUsBankAccount { /// Account holder type: individual or company. pub account_holder_type: @@ -17,6 +19,129 @@ pub struct OutboundPaymentsPaymentMethodDetailsUsBankAccount { /// Routing number of the bank account. pub routing_number: Option, } +#[doc(hidden)] +pub struct OutboundPaymentsPaymentMethodDetailsUsBankAccountBuilder { + account_holder_type: + Option>, + account_type: Option>, + bank_name: Option>, + fingerprint: Option>, + last4: Option>, + network: Option, + routing_number: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: OutboundPaymentsPaymentMethodDetailsUsBankAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + account_holder_type: self.account_holder_type?, + account_type: self.account_type?, + bank_name: self.bank_name.take()?, + fingerprint: self.fingerprint.take()?, + last4: self.last4.take()?, + network: self.network?, + routing_number: self.routing_number.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -55,6 +180,7 @@ impl std::fmt::Debug for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccoun f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType { fn serialize(&self, serializer: S) -> Result where @@ -63,6 +189,29 @@ impl serde::Serialize for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccou serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountHolderType { @@ -110,6 +259,7 @@ impl std::fmt::Debug for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccoun f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType { fn serialize(&self, serializer: S) -> Result where @@ -118,6 +268,29 @@ impl serde::Serialize for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccou serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for OutboundPaymentsPaymentMethodDetailsUsBankAccountAccountType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -167,6 +340,7 @@ impl std::fmt::Debug for OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwor f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork { fn serialize(&self, serializer: S) -> Result where @@ -175,6 +349,29 @@ impl serde::Serialize for OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwo serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for OutboundPaymentsPaymentMethodDetailsUsBankAccountNetwork { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..15f1b3712 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,115 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct OutboundTransfersPaymentMethodDetails { pub billing_details: stripe_treasury::TreasurySharedResourceBillingDetails, /// The type of the payment method used in the OutboundTransfer. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: OutboundTransfersPaymentMethodDetailsType, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option, } +#[doc(hidden)] +pub struct OutboundTransfersPaymentMethodDetailsBuilder { + billing_details: Option, + type_: Option, + us_bank_account: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: OutboundTransfersPaymentMethodDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + billing_details: Deserialize::default(), + type_: Deserialize::default(), + us_bank_account: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + billing_details: self.billing_details.take()?, + type_: self.type_?, + us_bank_account: self.us_bank_account.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -43,6 +145,7 @@ impl std::fmt::Debug for OutboundTransfersPaymentMethodDetailsType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for OutboundTransfersPaymentMethodDetailsType { fn serialize(&self, serializer: S) -> Result where @@ -51,6 +154,24 @@ impl serde::Serialize for OutboundTransfersPaymentMethodDetailsType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for OutboundTransfersPaymentMethodDetailsType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + OutboundTransfersPaymentMethodDetailsType::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(OutboundTransfersPaymentMethodDetailsType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for OutboundTransfersPaymentMethodDetailsType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..09b4be78c 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,4 +1,6 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct OutboundTransfersPaymentMethodDetailsUsBankAccount { /// Account holder type: individual or company. pub account_holder_type: @@ -17,6 +19,129 @@ pub struct OutboundTransfersPaymentMethodDetailsUsBankAccount { /// Routing number of the bank account. pub routing_number: Option, } +#[doc(hidden)] +pub struct OutboundTransfersPaymentMethodDetailsUsBankAccountBuilder { + account_holder_type: + Option>, + account_type: Option>, + bank_name: Option>, + fingerprint: Option>, + last4: Option>, + network: Option, + routing_number: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: OutboundTransfersPaymentMethodDetailsUsBankAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + account_holder_type: self.account_holder_type?, + account_type: self.account_type?, + bank_name: self.bank_name.take()?, + fingerprint: self.fingerprint.take()?, + last4: self.last4.take()?, + network: self.network?, + routing_number: self.routing_number.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -55,6 +180,7 @@ impl std::fmt::Debug for OutboundTransfersPaymentMethodDetailsUsBankAccountAccou f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for OutboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType { fn serialize(&self, serializer: S) -> Result where @@ -63,6 +189,31 @@ impl serde::Serialize for OutboundTransfersPaymentMethodDetailsUsBankAccountAcco serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for OutboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + OutboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + OutboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for OutboundTransfersPaymentMethodDetailsUsBankAccountAccountHolderType { @@ -110,6 +261,7 @@ impl std::fmt::Debug for OutboundTransfersPaymentMethodDetailsUsBankAccountAccou f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for OutboundTransfersPaymentMethodDetailsUsBankAccountAccountType { fn serialize(&self, serializer: S) -> Result where @@ -118,6 +270,29 @@ impl serde::Serialize for OutboundTransfersPaymentMethodDetailsUsBankAccountAcco serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for OutboundTransfersPaymentMethodDetailsUsBankAccountAccountType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + OutboundTransfersPaymentMethodDetailsUsBankAccountAccountType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + OutboundTransfersPaymentMethodDetailsUsBankAccountAccountType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for OutboundTransfersPaymentMethodDetailsUsBankAccountAccountType { @@ -169,6 +344,7 @@ impl std::fmt::Debug for OutboundTransfersPaymentMethodDetailsUsBankAccountNetwo f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for OutboundTransfersPaymentMethodDetailsUsBankAccountNetwork { fn serialize(&self, serializer: S) -> Result where @@ -177,6 +353,29 @@ impl serde::Serialize for OutboundTransfersPaymentMethodDetailsUsBankAccountNetw serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for OutboundTransfersPaymentMethodDetailsUsBankAccountNetwork { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + OutboundTransfersPaymentMethodDetailsUsBankAccountNetwork::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + OutboundTransfersPaymentMethodDetailsUsBankAccountNetwork +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for OutboundTransfersPaymentMethodDetailsUsBankAccountNetwork { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..2cf8a867b 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,101 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct ReceivedPaymentMethodDetailsFinancialAccountBuilder { + id: Option, + network: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: ReceivedPaymentMethodDetailsFinancialAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { id: Deserialize::default(), network: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { id: self.id.take()?, network: self.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 { + 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 { @@ -40,6 +131,7 @@ impl std::fmt::Debug for ReceivedPaymentMethodDetailsFinancialAccountNetwork { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for ReceivedPaymentMethodDetailsFinancialAccountNetwork { fn serialize(&self, serializer: S) -> Result where @@ -48,6 +140,25 @@ impl serde::Serialize for ReceivedPaymentMethodDetailsFinancialAccountNetwork { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for ReceivedPaymentMethodDetailsFinancialAccountNetwork { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + ReceivedPaymentMethodDetailsFinancialAccountNetwork::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(ReceivedPaymentMethodDetailsFinancialAccountNetwork); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for ReceivedPaymentMethodDetailsFinancialAccountNetwork { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_treasury/src/treasury_credit_reversal/types.rs b/generated/stripe_treasury/src/treasury_credit_reversal/types.rs index 21eff098f..7cb081fdf 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryCreditReversal { /// Amount (in cents) transferred. pub amount: i64, @@ -22,6 +24,8 @@ pub struct TreasuryCreditReversal { pub metadata: std::collections::HashMap, /// The rails used to reverse the funds. pub network: TreasuryCreditReversalNetwork, + /// String representing the object's type. Objects of the same type share the same value. + pub object: TreasuryCreditReversalObject, /// The ReceivedCredit being reversed. pub received_credit: String, /// Status of the CreditReversal @@ -30,6 +34,167 @@ pub struct TreasuryCreditReversal { /// The Transaction associated with this object. pub transaction: Option>, } +#[doc(hidden)] +pub struct TreasuryCreditReversalBuilder { + amount: Option, + created: Option, + currency: Option, + financial_account: Option, + hosted_regulatory_receipt_url: Option>, + id: Option, + livemode: Option, + metadata: Option>, + network: Option, + object: Option, + received_credit: Option, + status: Option, + status_transitions: Option, + transaction: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryCreditReversalBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: Deserialize::default(), + received_credit: Deserialize::default(), + status: Deserialize::default(), + status_transitions: Deserialize::default(), + transaction: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + created: self.created?, + currency: self.currency?, + financial_account: self.financial_account.take()?, + hosted_regulatory_receipt_url: self.hosted_regulatory_receipt_url.take()?, + id: self.id.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + network: self.network?, + object: self.object?, + received_credit: self.received_credit.take()?, + status: self.status?, + status_transitions: self.status_transitions?, + transaction: self.transaction.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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 { @@ -68,6 +233,7 @@ impl std::fmt::Debug for TreasuryCreditReversalNetwork { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryCreditReversalNetwork { fn serialize(&self, serializer: S) -> Result where @@ -76,6 +242,22 @@ impl serde::Serialize for TreasuryCreditReversalNetwork { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryCreditReversalNetwork { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryCreditReversalNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryCreditReversalNetwork); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryCreditReversalNetwork { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -85,6 +267,74 @@ impl<'de> serde::Deserialize<'de> for TreasuryCreditReversalNetwork { }) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TreasuryCreditReversalObject { + TreasuryCreditReversal, +} +impl TreasuryCreditReversalObject { + pub fn as_str(self) -> &'static str { + use TreasuryCreditReversalObject::*; + match self { + TreasuryCreditReversal => "treasury.credit_reversal", + } + } +} + +impl std::str::FromStr for TreasuryCreditReversalObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TreasuryCreditReversalObject::*; + match s { + "treasury.credit_reversal" => Ok(TreasuryCreditReversal), + _ => Err(()), + } + } +} +impl std::fmt::Display for TreasuryCreditReversalObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TreasuryCreditReversalObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TreasuryCreditReversalObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TreasuryCreditReversalObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryCreditReversalObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryCreditReversalObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TreasuryCreditReversalObject { + fn deserialize>(deserializer: D) -> 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 TreasuryCreditReversalObject")) + } +} impl stripe_types::Object for TreasuryCreditReversal { type Id = stripe_treasury::TreasuryCreditReversalId; fn id(&self) -> &Self::Id { @@ -140,6 +390,22 @@ impl serde::Serialize for TreasuryCreditReversalStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryCreditReversalStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryCreditReversalStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryCreditReversalStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryCreditReversalStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_treasury/src/treasury_debit_reversal/requests.rs b/generated/stripe_treasury/src/treasury_debit_reversal/requests.rs index a02d734dd..707e13680 100644 --- a/generated/stripe_treasury/src/treasury_debit_reversal/requests.rs +++ b/generated/stripe_treasury/src/treasury_debit_reversal/requests.rs @@ -89,6 +89,16 @@ impl serde::Serialize for ListTreasuryDebitReversalResolution { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ListTreasuryDebitReversalResolution { + fn deserialize>(deserializer: D) -> 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 ListTreasuryDebitReversalResolution") + }) + } +} /// Only return DebitReversals for a given status. #[derive(Copy, Clone, Eq, PartialEq)] pub enum ListTreasuryDebitReversalStatus { @@ -138,6 +148,16 @@ impl serde::Serialize for ListTreasuryDebitReversalStatus { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ListTreasuryDebitReversalStatus { + fn deserialize>(deserializer: D) -> 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 ListTreasuryDebitReversalStatus") + }) + } +} impl<'a> ListTreasuryDebitReversal<'a> { /// Returns a list of DebitReversals. pub fn send( diff --git a/generated/stripe_treasury/src/treasury_debit_reversal/types.rs b/generated/stripe_treasury/src/treasury_debit_reversal/types.rs index 62ec67342..c717dae3a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryDebitReversal { /// Amount (in cents) transferred. pub amount: i64, @@ -25,6 +27,8 @@ pub struct TreasuryDebitReversal { pub metadata: std::collections::HashMap, /// The rails used to reverse the funds. pub network: TreasuryDebitReversalNetwork, + /// String representing the object's type. Objects of the same type share the same value. + pub object: TreasuryDebitReversalObject, /// The ReceivedDebit being reversed. pub received_debit: String, /// Status of the DebitReversal @@ -33,6 +37,173 @@ pub struct TreasuryDebitReversal { /// The Transaction associated with this object. pub transaction: Option>, } +#[doc(hidden)] +pub struct TreasuryDebitReversalBuilder { + amount: Option, + created: Option, + currency: Option, + financial_account: Option>, + hosted_regulatory_receipt_url: Option>, + id: Option, + linked_flows: + Option>, + livemode: Option, + metadata: Option>, + network: Option, + object: Option, + received_debit: Option, + status: Option, + status_transitions: Option, + transaction: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryDebitReversalBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: Deserialize::default(), + received_debit: Deserialize::default(), + status: Deserialize::default(), + status_transitions: Deserialize::default(), + transaction: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + created: self.created?, + currency: self.currency?, + financial_account: self.financial_account.take()?, + hosted_regulatory_receipt_url: self.hosted_regulatory_receipt_url.take()?, + id: self.id.take()?, + linked_flows: self.linked_flows.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + network: self.network?, + object: self.object?, + received_debit: self.received_debit.take()?, + status: self.status?, + status_transitions: self.status_transitions?, + transaction: self.transaction.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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 { @@ -71,6 +242,7 @@ impl std::fmt::Debug for TreasuryDebitReversalNetwork { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryDebitReversalNetwork { fn serialize(&self, serializer: S) -> Result where @@ -79,6 +251,22 @@ impl serde::Serialize for TreasuryDebitReversalNetwork { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryDebitReversalNetwork { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryDebitReversalNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryDebitReversalNetwork); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryDebitReversalNetwork { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -87,6 +275,74 @@ impl<'de> serde::Deserialize<'de> for TreasuryDebitReversalNetwork { .map_err(|_| serde::de::Error::custom("Unknown value for TreasuryDebitReversalNetwork")) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TreasuryDebitReversalObject { + TreasuryDebitReversal, +} +impl TreasuryDebitReversalObject { + pub fn as_str(self) -> &'static str { + use TreasuryDebitReversalObject::*; + match self { + TreasuryDebitReversal => "treasury.debit_reversal", + } + } +} + +impl std::str::FromStr for TreasuryDebitReversalObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TreasuryDebitReversalObject::*; + match s { + "treasury.debit_reversal" => Ok(TreasuryDebitReversal), + _ => Err(()), + } + } +} +impl std::fmt::Display for TreasuryDebitReversalObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TreasuryDebitReversalObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TreasuryDebitReversalObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TreasuryDebitReversalObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryDebitReversalObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryDebitReversalObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TreasuryDebitReversalObject { + fn deserialize>(deserializer: D) -> 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 TreasuryDebitReversalObject")) + } +} /// Status of the DebitReversal #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryDebitReversalStatus { @@ -128,6 +384,7 @@ impl std::fmt::Debug for TreasuryDebitReversalStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryDebitReversalStatus { fn serialize(&self, serializer: S) -> Result where @@ -136,6 +393,22 @@ impl serde::Serialize for TreasuryDebitReversalStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryDebitReversalStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryDebitReversalStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryDebitReversalStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryDebitReversalStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_treasury/src/treasury_financial_account/requests.rs b/generated/stripe_treasury/src/treasury_financial_account/requests.rs index a30f0be40..3a50329d7 100644 --- a/generated/stripe_treasury/src/treasury_financial_account/requests.rs +++ b/generated/stripe_treasury/src/treasury_financial_account/requests.rs @@ -358,6 +358,20 @@ impl serde::Serialize for CreateTreasuryFinancialAccountPlatformRestrictionsInbo serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTreasuryFinancialAccountPlatformRestrictionsInboundFlows +{ + fn deserialize>(deserializer: D) -> 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 CreateTreasuryFinancialAccountPlatformRestrictionsInboundFlows", + ) + }) + } +} /// Restricts all outbound money movement. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTreasuryFinancialAccountPlatformRestrictionsOutboundFlows { @@ -404,6 +418,20 @@ impl serde::Serialize for CreateTreasuryFinancialAccountPlatformRestrictionsOutb serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTreasuryFinancialAccountPlatformRestrictionsOutboundFlows +{ + fn deserialize>(deserializer: D) -> 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 CreateTreasuryFinancialAccountPlatformRestrictionsOutboundFlows", + ) + }) + } +} impl<'a> CreateTreasuryFinancialAccount<'a> { /// Creates a new FinancialAccount. For now, each connected account can only have one FinancialAccount. pub fn send( @@ -686,6 +714,20 @@ impl serde::Serialize for UpdateTreasuryFinancialAccountPlatformRestrictionsInbo serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateTreasuryFinancialAccountPlatformRestrictionsInboundFlows +{ + fn deserialize>(deserializer: D) -> 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 UpdateTreasuryFinancialAccountPlatformRestrictionsInboundFlows", + ) + }) + } +} /// Restricts all outbound money movement. #[derive(Copy, Clone, Eq, PartialEq)] pub enum UpdateTreasuryFinancialAccountPlatformRestrictionsOutboundFlows { @@ -732,6 +774,20 @@ impl serde::Serialize for UpdateTreasuryFinancialAccountPlatformRestrictionsOutb serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for UpdateTreasuryFinancialAccountPlatformRestrictionsOutboundFlows +{ + fn deserialize>(deserializer: D) -> 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 UpdateTreasuryFinancialAccountPlatformRestrictionsOutboundFlows", + ) + }) + } +} impl<'a> UpdateTreasuryFinancialAccount<'a> { /// Updates the details of a FinancialAccount. pub fn send( diff --git a/generated/stripe_treasury/src/treasury_financial_account/types.rs b/generated/stripe_treasury/src/treasury_financial_account/types.rs index 0bbcf92ad..f6bb42d29 100644 --- a/generated/stripe_treasury/src/treasury_financial_account/types.rs +++ b/generated/stripe_treasury/src/treasury_financial_account/types.rs @@ -1,16 +1,16 @@ /// 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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>, 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, /// The set of credentials that resolve to a FinancialAccount. pub financial_addresses: @@ -22,15 +22,14 @@ pub struct TreasuryFinancialAccount { /// 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>, + /// String representing the object's type. Objects of the same type share the same value. + pub object: TreasuryFinancialAccountObject, /// The array of paths to pending Features in the Features hash. - #[serde(skip_serializing_if = "Option::is_none")] pub pending_features: Option>, /// The set of functionalities that the platform can restrict on the FinancialAccount. - #[serde(skip_serializing_if = "Option::is_none")] pub platform_restrictions: Option, /// The array of paths to restricted Features in the Features hash. - #[serde(skip_serializing_if = "Option::is_none")] pub restricted_features: Option>, /// The enum specifying what state the account is in. pub status: TreasuryFinancialAccountStatus, @@ -39,6 +38,250 @@ pub struct TreasuryFinancialAccount { /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. pub supported_currencies: Vec, } +#[doc(hidden)] +pub struct TreasuryFinancialAccountBuilder { + active_features: Option>>, + balance: Option, + country: Option, + created: Option, + features: Option>, + financial_addresses: + Option>, + id: Option, + livemode: Option, + metadata: Option>>, + object: Option, + pending_features: Option>>, + platform_restrictions: + Option>, + restricted_features: Option>>, + status: Option, + status_details: Option, + supported_currencies: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryFinancialAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + active_features: self.active_features.take()?, + balance: self.balance.take()?, + country: self.country.take()?, + created: self.created?, + features: self.features.take()?, + financial_addresses: self.financial_addresses.take()?, + id: self.id.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + pending_features: self.pending_features.take()?, + platform_restrictions: self.platform_restrictions?, + restricted_features: self.restricted_features.take()?, + status: self.status?, + status_details: self.status_details.take()?, + supported_currencies: self.supported_currencies.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TreasuryFinancialAccountObject { + TreasuryFinancialAccount, +} +impl TreasuryFinancialAccountObject { + pub fn as_str(self) -> &'static str { + use TreasuryFinancialAccountObject::*; + match self { + TreasuryFinancialAccount => "treasury.financial_account", + } + } +} + +impl std::str::FromStr for TreasuryFinancialAccountObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TreasuryFinancialAccountObject::*; + match s { + "treasury.financial_account" => Ok(TreasuryFinancialAccount), + _ => Err(()), + } + } +} +impl std::fmt::Display for TreasuryFinancialAccountObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TreasuryFinancialAccountObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TreasuryFinancialAccountObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TreasuryFinancialAccountObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryFinancialAccountObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountObject { + fn deserialize>(deserializer: D) -> 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 TreasuryFinancialAccountObject") + }) + } +} /// The enum specifying what state the account is in. #[derive(Copy, Clone, Eq, PartialEq)] pub enum TreasuryFinancialAccountStatus { @@ -77,6 +320,7 @@ impl std::fmt::Debug for TreasuryFinancialAccountStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryFinancialAccountStatus { fn serialize(&self, serializer: S) -> Result where @@ -85,6 +329,22 @@ impl serde::Serialize for TreasuryFinancialAccountStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryFinancialAccountStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryFinancialAccountStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -162,6 +422,7 @@ impl std::fmt::Debug for TreasuryFinancialAccountArray { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryFinancialAccountArray { fn serialize(&self, serializer: S) -> Result where @@ -170,6 +431,22 @@ impl serde::Serialize for TreasuryFinancialAccountArray { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryFinancialAccountArray { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryFinancialAccountArray::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountArray); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountArray { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_treasury/src/treasury_financial_account_features.rs b/generated/stripe_treasury/src/treasury_financial_account_features.rs index 3a461ef13..8934f8dd6 100644 --- a/generated/stripe_treasury/src/treasury_financial_account_features.rs +++ b/generated/stripe_treasury/src/treasury_financial_account_features.rs @@ -1,24 +1,230 @@ /// 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)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryFinancialAccountFeatures { - #[serde(skip_serializing_if = "Option::is_none")] pub card_issuing: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub deposit_insurance: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub financial_addresses: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub inbound_transfers: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub intra_stripe_flows: Option, - #[serde(skip_serializing_if = "Option::is_none")] + /// String representing the object's type. Objects of the same type share the same value. + pub object: TreasuryFinancialAccountFeaturesObject, pub outbound_payments: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub outbound_transfers: Option, } +#[doc(hidden)] +pub struct TreasuryFinancialAccountFeaturesBuilder { + card_issuing: Option>, + deposit_insurance: + Option>, + financial_addresses: Option< + Option, + >, + inbound_transfers: + Option>, + intra_stripe_flows: + Option>, + object: Option, + outbound_payments: + Option>, + outbound_transfers: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryFinancialAccountFeaturesBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "outbound_payments" => Deserialize::begin(&mut self.outbound_payments), + "outbound_transfers" => Deserialize::begin(&mut self.outbound_transfers), + + _ => ::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(), + object: Deserialize::default(), + outbound_payments: Deserialize::default(), + outbound_transfers: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + card_issuing: self.card_issuing.take()?, + deposit_insurance: self.deposit_insurance.take()?, + financial_addresses: self.financial_addresses.take()?, + inbound_transfers: self.inbound_transfers.take()?, + intra_stripe_flows: self.intra_stripe_flows.take()?, + object: self.object?, + outbound_payments: self.outbound_payments.take()?, + outbound_transfers: self.outbound_transfers.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?) + } + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TreasuryFinancialAccountFeaturesObject { + TreasuryFinancialAccountFeatures, +} +impl TreasuryFinancialAccountFeaturesObject { + pub fn as_str(self) -> &'static str { + use TreasuryFinancialAccountFeaturesObject::*; + match self { + TreasuryFinancialAccountFeatures => "treasury.financial_account_features", + } + } +} + +impl std::str::FromStr for TreasuryFinancialAccountFeaturesObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TreasuryFinancialAccountFeaturesObject::*; + match s { + "treasury.financial_account_features" => Ok(TreasuryFinancialAccountFeatures), + _ => Err(()), + } + } +} +impl std::fmt::Display for TreasuryFinancialAccountFeaturesObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TreasuryFinancialAccountFeaturesObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TreasuryFinancialAccountFeaturesObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TreasuryFinancialAccountFeaturesObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryFinancialAccountFeaturesObject::from_str(s).map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountFeaturesObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountFeaturesObject { + fn deserialize>(deserializer: D) -> 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 TreasuryFinancialAccountFeaturesObject") + }) + } +} 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..79c5c82d8 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryFinancialAccountsResourceAbaRecord { /// The name of the person or business that owns the bank account. pub account_holder_name: String, @@ -12,3 +14,117 @@ pub struct TreasuryFinancialAccountsResourceAbaRecord { /// Routing number for the account. pub routing_number: String, } +#[doc(hidden)] +pub struct TreasuryFinancialAccountsResourceAbaRecordBuilder { + account_holder_name: Option, + account_number: Option>, + account_number_last4: Option, + bank_name: Option, + routing_number: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryFinancialAccountsResourceAbaRecordBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + account_holder_name: self.account_holder_name.take()?, + account_number: self.account_number.take()?, + account_number_last4: self.account_number_last4.take()?, + bank_name: self.bank_name.take()?, + routing_number: self.routing_number.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..b797ca6af 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,5 +1,7 @@ /// Toggle settings for enabling/disabling the ABA address feature -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryFinancialAccountsResourceAbaToggleSettings { /// Whether the FinancialAccount should have the Feature. pub requested: bool, @@ -9,6 +11,107 @@ pub struct TreasuryFinancialAccountsResourceAbaToggleSettings { pub status_details: Vec, } +#[doc(hidden)] +pub struct TreasuryFinancialAccountsResourceAbaToggleSettingsBuilder { + requested: Option, + status: Option, + status_details: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryFinancialAccountsResourceAbaToggleSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + requested: Deserialize::default(), + status: Deserialize::default(), + status_details: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + requested: self.requested?, + status: self.status?, + status_details: self.status_details.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -50,6 +153,7 @@ impl std::fmt::Debug for TreasuryFinancialAccountsResourceAbaToggleSettingsStatu f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryFinancialAccountsResourceAbaToggleSettingsStatus { fn serialize(&self, serializer: S) -> Result where @@ -58,6 +162,29 @@ impl serde::Serialize for TreasuryFinancialAccountsResourceAbaToggleSettingsStat serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryFinancialAccountsResourceAbaToggleSettingsStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryFinancialAccountsResourceAbaToggleSettingsStatus::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + TreasuryFinancialAccountsResourceAbaToggleSettingsStatus +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourceAbaToggleSettingsStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..4ab9fb1ce 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,5 +1,7 @@ /// Toggle settings for enabling/disabling an ACH specific feature -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryFinancialAccountsResourceAchToggleSettings { /// Whether the FinancialAccount should have the Feature. pub requested: bool, @@ -9,6 +11,107 @@ pub struct TreasuryFinancialAccountsResourceAchToggleSettings { pub status_details: Vec, } +#[doc(hidden)] +pub struct TreasuryFinancialAccountsResourceAchToggleSettingsBuilder { + requested: Option, + status: Option, + status_details: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryFinancialAccountsResourceAchToggleSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + requested: Deserialize::default(), + status: Deserialize::default(), + status_details: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + requested: self.requested?, + status: self.status?, + status_details: self.status_details.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -50,6 +153,7 @@ impl std::fmt::Debug for TreasuryFinancialAccountsResourceAchToggleSettingsStatu f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryFinancialAccountsResourceAchToggleSettingsStatus { fn serialize(&self, serializer: S) -> Result where @@ -58,6 +162,29 @@ impl serde::Serialize for TreasuryFinancialAccountsResourceAchToggleSettingsStat serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryFinancialAccountsResourceAchToggleSettingsStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryFinancialAccountsResourceAchToggleSettingsStatus::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + TreasuryFinancialAccountsResourceAchToggleSettingsStatus +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourceAchToggleSettingsStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..bd40eccd1 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryFinancialAccountsResourceBalance { /// Funds the user can spend right now. pub cash: std::collections::HashMap, @@ -8,3 +10,103 @@ 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, } +#[doc(hidden)] +pub struct TreasuryFinancialAccountsResourceBalanceBuilder { + cash: Option>, + inbound_pending: Option>, + outbound_pending: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryFinancialAccountsResourceBalanceBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + cash: Deserialize::default(), + inbound_pending: Deserialize::default(), + outbound_pending: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + cash: self.cash.take()?, + inbound_pending: self.inbound_pending.take()?, + outbound_pending: self.outbound_pending.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..2850c53b7 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,98 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryFinancialAccountsResourceClosedStatusDetails { /// The array that contains reasons for a FinancialAccount closure. pub reasons: Vec, } +#[doc(hidden)] +pub struct TreasuryFinancialAccountsResourceClosedStatusDetailsBuilder { + reasons: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryFinancialAccountsResourceClosedStatusDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { reasons: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { reasons: self.reasons.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -44,6 +134,7 @@ impl std::fmt::Debug for TreasuryFinancialAccountsResourceClosedStatusDetailsRea f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryFinancialAccountsResourceClosedStatusDetailsReasons { fn serialize(&self, serializer: S) -> Result where @@ -52,6 +143,29 @@ impl serde::Serialize for TreasuryFinancialAccountsResourceClosedStatusDetailsRe serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryFinancialAccountsResourceClosedStatusDetailsReasons { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryFinancialAccountsResourceClosedStatusDetailsReasons::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + TreasuryFinancialAccountsResourceClosedStatusDetailsReasons +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourceClosedStatusDetailsReasons { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..66372a155 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,119 @@ /// FinancialAddresses contain identifying information that resolves to a FinancialAccount. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryFinancialAccountsResourceFinancialAddress { - #[serde(skip_serializing_if = "Option::is_none")] pub aba: Option, /// The list of networks that the address supports - #[serde(skip_serializing_if = "Option::is_none")] pub supported_networks: Option>, /// The type of financial address - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: TreasuryFinancialAccountsResourceFinancialAddressType, } +#[doc(hidden)] +pub struct TreasuryFinancialAccountsResourceFinancialAddressBuilder { + aba: Option>, + supported_networks: + Option>>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryFinancialAccountsResourceFinancialAddressBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + aba: Deserialize::default(), + supported_networks: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + aba: self.aba.take()?, + supported_networks: self.supported_networks.take()?, + type_: self.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 { + 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 { @@ -49,6 +152,7 @@ impl std::fmt::Debug for TreasuryFinancialAccountsResourceFinancialAddressSuppor f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryFinancialAccountsResourceFinancialAddressSupportedNetworks { fn serialize(&self, serializer: S) -> Result where @@ -57,6 +161,29 @@ impl serde::Serialize for TreasuryFinancialAccountsResourceFinancialAddressSuppo serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryFinancialAccountsResourceFinancialAddressSupportedNetworks { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryFinancialAccountsResourceFinancialAddressSupportedNetworks::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + TreasuryFinancialAccountsResourceFinancialAddressSupportedNetworks +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourceFinancialAddressSupportedNetworks { @@ -101,6 +228,7 @@ impl std::fmt::Debug for TreasuryFinancialAccountsResourceFinancialAddressType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryFinancialAccountsResourceFinancialAddressType { fn serialize(&self, serializer: S) -> Result where @@ -109,6 +237,27 @@ impl serde::Serialize for TreasuryFinancialAccountsResourceFinancialAddressType serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryFinancialAccountsResourceFinancialAddressType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryFinancialAccountsResourceFinancialAddressType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountsResourceFinancialAddressType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourceFinancialAddressType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..179b90370 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,94 @@ /// Settings related to Financial Addresses features on a Financial Account -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryFinancialAccountsResourceFinancialAddressesFeatures { - #[serde(skip_serializing_if = "Option::is_none")] pub aba: Option, } +#[doc(hidden)] +pub struct TreasuryFinancialAccountsResourceFinancialAddressesFeaturesBuilder { + aba: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryFinancialAccountsResourceFinancialAddressesFeaturesBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { aba: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { aba: self.aba.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..9b89c5234 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryFinancialAccountsResourceInboundTransfers { - #[serde(skip_serializing_if = "Option::is_none")] pub ach: Option, } +#[doc(hidden)] +pub struct TreasuryFinancialAccountsResourceInboundTransfersBuilder { + ach: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryFinancialAccountsResourceInboundTransfersBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { ach: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { ach: self.ach.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..ee6be0f65 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,101 @@ /// Settings related to Outbound Payments features on a Financial Account -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryFinancialAccountsResourceOutboundPayments { - #[serde(skip_serializing_if = "Option::is_none")] pub ach: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub us_domestic_wire: Option, } +#[doc(hidden)] +pub struct TreasuryFinancialAccountsResourceOutboundPaymentsBuilder { + ach: Option>, + us_domestic_wire: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryFinancialAccountsResourceOutboundPaymentsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { ach: Deserialize::default(), us_domestic_wire: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + ach: self.ach.take()?, + us_domestic_wire: self.us_domestic_wire.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..02ebdb491 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,101 @@ /// OutboundTransfers contains outbound transfers features for a FinancialAccount. -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryFinancialAccountsResourceOutboundTransfers { - #[serde(skip_serializing_if = "Option::is_none")] pub ach: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub us_domestic_wire: Option, } +#[doc(hidden)] +pub struct TreasuryFinancialAccountsResourceOutboundTransfersBuilder { + ach: Option>, + us_domestic_wire: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryFinancialAccountsResourceOutboundTransfersBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { ach: Deserialize::default(), us_domestic_wire: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + ach: self.ach.take()?, + us_domestic_wire: self.us_domestic_wire.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..15d60a8e3 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,109 @@ /// 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryFinancialAccountsResourcePlatformRestrictions { /// Restricts all inbound money movement. pub inbound_flows: Option, /// Restricts all outbound money movement. pub outbound_flows: Option, } +#[doc(hidden)] +pub struct TreasuryFinancialAccountsResourcePlatformRestrictionsBuilder { + inbound_flows: + Option>, + outbound_flows: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryFinancialAccountsResourcePlatformRestrictionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { inbound_flows: Deserialize::default(), outbound_flows: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + inbound_flows: self.inbound_flows?, + outbound_flows: self.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 { + 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 { @@ -44,6 +142,7 @@ impl std::fmt::Debug for TreasuryFinancialAccountsResourcePlatformRestrictionsIn f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryFinancialAccountsResourcePlatformRestrictionsInboundFlows { fn serialize(&self, serializer: S) -> Result where @@ -52,6 +151,29 @@ impl serde::Serialize for TreasuryFinancialAccountsResourcePlatformRestrictionsI serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryFinancialAccountsResourcePlatformRestrictionsInboundFlows { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryFinancialAccountsResourcePlatformRestrictionsInboundFlows::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + TreasuryFinancialAccountsResourcePlatformRestrictionsInboundFlows +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourcePlatformRestrictionsInboundFlows { @@ -99,6 +221,7 @@ impl std::fmt::Debug for TreasuryFinancialAccountsResourcePlatformRestrictionsOu f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryFinancialAccountsResourcePlatformRestrictionsOutboundFlows { fn serialize(&self, serializer: S) -> Result where @@ -107,6 +230,29 @@ impl serde::Serialize for TreasuryFinancialAccountsResourcePlatformRestrictionsO serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryFinancialAccountsResourcePlatformRestrictionsOutboundFlows { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryFinancialAccountsResourcePlatformRestrictionsOutboundFlows::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + TreasuryFinancialAccountsResourcePlatformRestrictionsOutboundFlows +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for 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..3d786441c 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryFinancialAccountsResourceStatusDetails { /// Details related to the closure of this FinancialAccount pub closed: Option, } +#[doc(hidden)] +pub struct TreasuryFinancialAccountsResourceStatusDetailsBuilder { + closed: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryFinancialAccountsResourceStatusDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { closed: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { closed: self.closed.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..5977b1e16 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,5 +1,7 @@ /// Toggle settings for enabling/disabling a feature -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryFinancialAccountsResourceToggleSettings { /// Whether the FinancialAccount should have the Feature. pub requested: bool, @@ -9,6 +11,107 @@ pub struct TreasuryFinancialAccountsResourceToggleSettings { pub status_details: Vec, } +#[doc(hidden)] +pub struct TreasuryFinancialAccountsResourceToggleSettingsBuilder { + requested: Option, + status: Option, + status_details: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryFinancialAccountsResourceToggleSettingsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + requested: Deserialize::default(), + status: Deserialize::default(), + status_details: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + requested: self.requested?, + status: self.status?, + status_details: self.status_details.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -50,6 +153,7 @@ impl std::fmt::Debug for TreasuryFinancialAccountsResourceToggleSettingsStatus { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryFinancialAccountsResourceToggleSettingsStatus { fn serialize(&self, serializer: S) -> Result where @@ -58,6 +162,27 @@ impl serde::Serialize for TreasuryFinancialAccountsResourceToggleSettingsStatus serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryFinancialAccountsResourceToggleSettingsStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryFinancialAccountsResourceToggleSettingsStatus::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryFinancialAccountsResourceToggleSettingsStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourceToggleSettingsStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..e20eebe3f 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,120 @@ /// Additional details on the FinancialAccount Features information. -#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, /// The `platform_restrictions` that are restricting this Feature. - #[serde(skip_serializing_if = "Option::is_none")] pub restriction: Option, } +#[doc(hidden)] +pub struct TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsBuilder { + code: Option, + resolution: + Option>, + restriction: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + code: Deserialize::default(), + resolution: Deserialize::default(), + restriction: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + code: self.code?, + resolution: self.resolution?, + restriction: self.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 { + 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 { @@ -69,6 +174,7 @@ impl std::fmt::Debug for TreasuryFinancialAccountsResourceTogglesSettingStatusDe f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsCode { fn serialize(&self, serializer: S) -> Result where @@ -77,6 +183,29 @@ impl serde::Serialize for TreasuryFinancialAccountsResourceTogglesSettingStatusD serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsCode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsCode::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsCode +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsCode { @@ -127,6 +256,7 @@ impl std::fmt::Debug for TreasuryFinancialAccountsResourceTogglesSettingStatusDe f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsResolution { fn serialize(&self, serializer: S) -> Result where @@ -135,6 +265,31 @@ impl serde::Serialize for TreasuryFinancialAccountsResourceTogglesSettingStatusD serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsResolution +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsResolution::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsResolution +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsResolution { @@ -182,6 +337,7 @@ impl std::fmt::Debug for TreasuryFinancialAccountsResourceTogglesSettingStatusDe f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsRestriction { fn serialize(&self, serializer: S) -> Result where @@ -190,6 +346,31 @@ impl serde::Serialize for TreasuryFinancialAccountsResourceTogglesSettingStatusD serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsRestriction +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsRestriction::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + TreasuryFinancialAccountsResourceTogglesSettingStatusDetailsRestriction +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for 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..b84e58b00 100644 --- a/generated/stripe_treasury/src/treasury_inbound_transfer/requests.rs +++ b/generated/stripe_treasury/src/treasury_inbound_transfer/requests.rs @@ -179,6 +179,14 @@ impl serde::Serialize for FailTreasuryInboundTransferFailureDetailsCode { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for FailTreasuryInboundTransferFailureDetailsCode { + fn deserialize>(deserializer: D) -> Result { + use std::str::FromStr; + let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; + Ok(Self::from_str(&s).unwrap_or(Self::Unknown)) + } +} impl<'a> FailTreasuryInboundTransfer<'a> { /// Transitions a test mode created InboundTransfer to the `failed` status. /// The InboundTransfer must already be in the `processing` state. diff --git a/generated/stripe_treasury/src/treasury_inbound_transfer/types.rs b/generated/stripe_treasury/src/treasury_inbound_transfer/types.rs index 81965670f..62d39afc9 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryInboundTransfer { /// Amount (in cents) transferred. pub amount: i64, @@ -28,6 +30,8 @@ pub struct TreasuryInboundTransfer { /// 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 representing the object's type. Objects of the same type share the same value. + pub object: TreasuryInboundTransferObject, /// The origin payment method to be debited for an InboundTransfer. pub origin_payment_method: String, /// Details about the PaymentMethod for an InboundTransfer. @@ -47,6 +51,278 @@ pub struct TreasuryInboundTransfer { /// The Transaction associated with this object. pub transaction: Option>, } +#[doc(hidden)] +pub struct TreasuryInboundTransferBuilder { + amount: Option, + cancelable: Option, + created: Option, + currency: Option, + description: Option>, + failure_details: + Option>, + financial_account: Option, + hosted_regulatory_receipt_url: Option>, + id: Option, + linked_flows: + Option, + livemode: Option, + metadata: Option>, + object: Option, + origin_payment_method: Option, + origin_payment_method_details: Option>, + returned: Option>, + statement_descriptor: Option, + status: Option, + status_transitions: Option< + stripe_treasury::TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitions, + >, + transaction: Option>>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryInboundTransferBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + amount: self.amount?, + cancelable: self.cancelable?, + created: self.created?, + currency: self.currency?, + description: self.description.take()?, + failure_details: self.failure_details?, + financial_account: self.financial_account.take()?, + hosted_regulatory_receipt_url: self.hosted_regulatory_receipt_url.take()?, + id: self.id.take()?, + linked_flows: self.linked_flows.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + origin_payment_method: self.origin_payment_method.take()?, + origin_payment_method_details: self.origin_payment_method_details.take()?, + returned: self.returned?, + statement_descriptor: self.statement_descriptor.take()?, + status: self.status?, + status_transitions: self.status_transitions?, + transaction: self.transaction.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TreasuryInboundTransferObject { + TreasuryInboundTransfer, +} +impl TreasuryInboundTransferObject { + pub fn as_str(self) -> &'static str { + use TreasuryInboundTransferObject::*; + match self { + TreasuryInboundTransfer => "treasury.inbound_transfer", + } + } +} + +impl std::str::FromStr for TreasuryInboundTransferObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TreasuryInboundTransferObject::*; + match s { + "treasury.inbound_transfer" => Ok(TreasuryInboundTransfer), + _ => Err(()), + } + } +} +impl std::fmt::Display for TreasuryInboundTransferObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TreasuryInboundTransferObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TreasuryInboundTransferObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TreasuryInboundTransferObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryInboundTransferObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryInboundTransferObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TreasuryInboundTransferObject { + fn deserialize>(deserializer: D) -> 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 TreasuryInboundTransferObject") + }) + } +} impl stripe_types::Object for TreasuryInboundTransfer { type Id = stripe_treasury::TreasuryInboundTransferId; fn id(&self) -> &Self::Id { @@ -105,6 +381,22 @@ impl serde::Serialize for TreasuryInboundTransferStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryInboundTransferStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryInboundTransferStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryInboundTransferStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryInboundTransferStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..fc67f9f87 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryInboundTransfersResourceFailureDetails { /// Reason for the failure. pub code: TreasuryInboundTransfersResourceFailureDetailsCode, } +#[doc(hidden)] +pub struct TreasuryInboundTransfersResourceFailureDetailsBuilder { + code: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryInboundTransfersResourceFailureDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { code: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { code: self.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 { + 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] @@ -78,6 +166,7 @@ impl std::fmt::Debug for TreasuryInboundTransfersResourceFailureDetailsCode { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryInboundTransfersResourceFailureDetailsCode { fn serialize(&self, serializer: S) -> Result where @@ -86,11 +175,29 @@ impl serde::Serialize for TreasuryInboundTransfersResourceFailureDetailsCode { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryInboundTransfersResourceFailureDetailsCode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryInboundTransfersResourceFailureDetailsCode::from_str(s) + .unwrap_or(TreasuryInboundTransfersResourceFailureDetailsCode::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryInboundTransfersResourceFailureDetailsCode); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryInboundTransfersResourceFailureDetailsCode { fn deserialize>(deserializer: D) -> Result { 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)) } } 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..fcb8fe9d7 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] 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, } +#[doc(hidden)] +pub struct TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlowsBuilder { + received_debit: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryInboundTransfersResourceInboundTransferResourceLinkedFlowsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { received_debit: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { received_debit: self.received_debit.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..f715f9a07 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,116 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitions { /// Timestamp describing when an InboundTransfer changed status to `canceled`. - #[serde(skip_serializing_if = "Option::is_none")] pub canceled_at: Option, /// Timestamp describing when an InboundTransfer changed status to `failed`. pub failed_at: Option, /// Timestamp describing when an InboundTransfer changed status to `succeeded`. pub succeeded_at: Option, } +#[doc(hidden)] +pub struct TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitionsBuilder { + canceled_at: Option>, + failed_at: Option>, + succeeded_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option< + TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitions, + >, + builder: TreasuryInboundTransfersResourceInboundTransferResourceStatusTransitionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + canceled_at: Deserialize::default(), + failed_at: Deserialize::default(), + succeeded_at: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + canceled_at: self.canceled_at?, + failed_at: self.failed_at?, + succeeded_at: self.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 { + 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..b966ab6b4 100644 --- a/generated/stripe_treasury/src/treasury_outbound_payment/requests.rs +++ b/generated/stripe_treasury/src/treasury_outbound_payment/requests.rs @@ -222,6 +222,20 @@ impl serde::Serialize for ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDe serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode +{ + fn deserialize>(deserializer: D) -> 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 ReturnOutboundPaymentTreasuryOutboundPaymentReturnedDetailsCode", + ) + }) + } +} impl<'a> ReturnOutboundPaymentTreasuryOutboundPayment<'a> { /// Transitions a test mode created OutboundPayment to the `returned` status. /// The OutboundPayment must already be in the `processing` state. @@ -437,6 +451,20 @@ impl serde::Serialize for CreateTreasuryOutboundPaymentDestinationPaymentMethodD serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataType +{ + fn deserialize>(deserializer: D) -> 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 CreateTreasuryOutboundPaymentDestinationPaymentMethodDataType", + ) + }) + } +} /// Required hash if type is set to `us_bank_account`. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccount<'a> { @@ -518,6 +546,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountHolderType +{ + fn deserialize>(deserializer: D) -> 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 CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountHolderType")) + } +} /// Account type: checkings or savings. Defaults to checking if omitted. #[derive(Copy, Clone, Eq, PartialEq)] pub enum CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountType { @@ -572,6 +610,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountType +{ + fn deserialize>(deserializer: D) -> 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 CreateTreasuryOutboundPaymentDestinationPaymentMethodDataUsBankAccountAccountType")) + } +} /// Payment method-specific configuration for this OutboundPayment. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateTreasuryOutboundPaymentDestinationPaymentMethodOptions { @@ -654,6 +702,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTreasuryOutboundPaymentDestinationPaymentMethodOptionsUsBankAccountNetwork +{ + fn deserialize>(deserializer: D) -> 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 CreateTreasuryOutboundPaymentDestinationPaymentMethodOptionsUsBankAccountNetwork")) + } +} /// End user details. #[derive(Copy, Clone, Debug, serde::Serialize)] pub struct CreateTreasuryOutboundPaymentEndUserDetails<'a> { diff --git a/generated/stripe_treasury/src/treasury_outbound_payment/types.rs b/generated/stripe_treasury/src/treasury_outbound_payment/types.rs index 4c59edc33..f407f16e8 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryOutboundPayment { /// Amount (in cents) transferred. pub amount: i64, @@ -41,6 +43,8 @@ pub struct TreasuryOutboundPayment { /// 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 representing the object's type. Objects of the same type share the same value. + pub object: TreasuryOutboundPaymentObject, /// Details about a returned OutboundPayment. Only set when the status is `returned`. pub returned_details: Option, /// The description that appears on the receiving end for an OutboundPayment (for example, bank statement for external bank transfer). @@ -55,6 +59,293 @@ pub struct TreasuryOutboundPayment { /// The Transaction associated with this object. pub transaction: stripe_types::Expandable, } +#[doc(hidden)] +pub struct TreasuryOutboundPaymentBuilder { + amount: Option, + cancelable: Option, + created: Option, + currency: Option, + customer: Option>, + description: Option>, + destination_payment_method: Option>, + destination_payment_method_details: + Option>, + end_user_details: Option< + Option< + stripe_treasury::TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetails, + >, + >, + expected_arrival_date: Option, + financial_account: Option, + hosted_regulatory_receipt_url: Option>, + id: Option, + livemode: Option, + metadata: Option>, + object: Option, + returned_details: + Option>, + statement_descriptor: Option, + status: Option, + status_transitions: Option< + stripe_treasury::TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitions, + >, + transaction: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryOutboundPaymentBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + amount: self.amount?, + cancelable: self.cancelable?, + created: self.created?, + currency: self.currency?, + customer: self.customer.take()?, + description: self.description.take()?, + destination_payment_method: self.destination_payment_method.take()?, + destination_payment_method_details: self + .destination_payment_method_details + .take()?, + end_user_details: self.end_user_details.take()?, + expected_arrival_date: self.expected_arrival_date?, + financial_account: self.financial_account.take()?, + hosted_regulatory_receipt_url: self.hosted_regulatory_receipt_url.take()?, + id: self.id.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + returned_details: self.returned_details.take()?, + statement_descriptor: self.statement_descriptor.take()?, + status: self.status?, + status_transitions: self.status_transitions?, + transaction: self.transaction.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TreasuryOutboundPaymentObject { + TreasuryOutboundPayment, +} +impl TreasuryOutboundPaymentObject { + pub fn as_str(self) -> &'static str { + use TreasuryOutboundPaymentObject::*; + match self { + TreasuryOutboundPayment => "treasury.outbound_payment", + } + } +} + +impl std::str::FromStr for TreasuryOutboundPaymentObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TreasuryOutboundPaymentObject::*; + match s { + "treasury.outbound_payment" => Ok(TreasuryOutboundPayment), + _ => Err(()), + } + } +} +impl std::fmt::Display for TreasuryOutboundPaymentObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TreasuryOutboundPaymentObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TreasuryOutboundPaymentObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TreasuryOutboundPaymentObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryOutboundPaymentObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryOutboundPaymentObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TreasuryOutboundPaymentObject { + fn deserialize>(deserializer: D) -> 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 TreasuryOutboundPaymentObject") + }) + } +} impl stripe_types::Object for TreasuryOutboundPayment { type Id = stripe_treasury::TreasuryOutboundPaymentId; fn id(&self) -> &Self::Id { @@ -116,6 +407,22 @@ impl serde::Serialize for TreasuryOutboundPaymentStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryOutboundPaymentStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryOutboundPaymentStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryOutboundPaymentStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryOutboundPaymentStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..0ffbcd569 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetails { /// IP address of the user initiating the OutboundPayment. /// Set if `present` is set to `true`. @@ -9,3 +11,92 @@ pub struct TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetails /// Otherwise, `false`. pub present: bool, } +#[doc(hidden)] +pub struct TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetailsBuilder { + ip_address: Option>, + present: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryOutboundPaymentsResourceOutboundPaymentResourceEndUserDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { ip_address: Deserialize::default(), present: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { ip_address: self.ip_address.take()?, present: self.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 { + 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..7c2f18f8c 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitions { /// Timestamp describing when an OutboundPayment changed status to `canceled`. pub canceled_at: Option, @@ -9,3 +11,113 @@ pub struct TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransiti /// Timestamp describing when an OutboundPayment changed status to `returned`. pub returned_at: Option, } +#[doc(hidden)] +pub struct TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitionsBuilder { + canceled_at: Option>, + failed_at: Option>, + posted_at: Option>, + returned_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option< + TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitions, + >, + builder: TreasuryOutboundPaymentsResourceOutboundPaymentResourceStatusTransitionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + canceled_at: self.canceled_at?, + failed_at: self.failed_at?, + posted_at: self.posted_at?, + returned_at: self.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 { + 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..23025cbcd 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,101 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryOutboundPaymentsResourceReturnedStatus { /// Reason for the return. pub code: TreasuryOutboundPaymentsResourceReturnedStatusCode, /// The Transaction associated with this object. pub transaction: stripe_types::Expandable, } +#[doc(hidden)] +pub struct TreasuryOutboundPaymentsResourceReturnedStatusBuilder { + code: Option, + transaction: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryOutboundPaymentsResourceReturnedStatusBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { code: Deserialize::default(), transaction: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { code: self.code?, transaction: self.transaction.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -67,6 +158,7 @@ impl std::fmt::Debug for TreasuryOutboundPaymentsResourceReturnedStatusCode { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryOutboundPaymentsResourceReturnedStatusCode { fn serialize(&self, serializer: S) -> Result where @@ -75,6 +167,25 @@ impl serde::Serialize for TreasuryOutboundPaymentsResourceReturnedStatusCode { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryOutboundPaymentsResourceReturnedStatusCode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryOutboundPaymentsResourceReturnedStatusCode::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryOutboundPaymentsResourceReturnedStatusCode); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryOutboundPaymentsResourceReturnedStatusCode { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_treasury/src/treasury_outbound_transfer/requests.rs b/generated/stripe_treasury/src/treasury_outbound_transfer/requests.rs index a5f1ac540..558b6067f 100644 --- a/generated/stripe_treasury/src/treasury_outbound_transfer/requests.rs +++ b/generated/stripe_treasury/src/treasury_outbound_transfer/requests.rs @@ -218,6 +218,16 @@ impl serde::Serialize for ReturnOutboundTransferTreasuryOutboundTransferReturned serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for ReturnOutboundTransferTreasuryOutboundTransferReturnedDetailsCode +{ + fn deserialize>(deserializer: D) -> 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 ReturnOutboundTransferTreasuryOutboundTransferReturnedDetailsCode")) + } +} impl<'a> ReturnOutboundTransferTreasuryOutboundTransfer<'a> { /// Transitions a test mode created OutboundTransfer to the `returned` status. /// The OutboundTransfer must already be in the `processing` state. @@ -362,6 +372,16 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork +{ + fn deserialize>(deserializer: D) -> 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 CreateTreasuryOutboundTransferDestinationPaymentMethodOptionsUsBankAccountNetwork")) + } +} impl<'a> CreateTreasuryOutboundTransfer<'a> { /// Creates an OutboundTransfer. pub fn send( diff --git a/generated/stripe_treasury/src/treasury_outbound_transfer/types.rs b/generated/stripe_treasury/src/treasury_outbound_transfer/types.rs index 08415c713..f2054d97a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryOutboundTransfer { /// Amount (in cents) transferred. pub amount: i64, @@ -33,6 +35,8 @@ pub struct TreasuryOutboundTransfer { /// 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 representing the object's type. Objects of the same type share the same value. + pub object: TreasuryOutboundTransferObject, /// Details about a returned OutboundTransfer. Only set when the status is `returned`. pub returned_details: Option, /// Information about the OutboundTransfer to be sent to the recipient account. @@ -46,6 +50,277 @@ pub struct TreasuryOutboundTransfer { /// The Transaction associated with this object. pub transaction: stripe_types::Expandable, } +#[doc(hidden)] +pub struct TreasuryOutboundTransferBuilder { + amount: Option, + cancelable: Option, + created: Option, + currency: Option, + description: Option>, + destination_payment_method: Option>, + destination_payment_method_details: + Option, + expected_arrival_date: Option, + financial_account: Option, + hosted_regulatory_receipt_url: Option>, + id: Option, + livemode: Option, + metadata: Option>, + object: Option, + returned_details: + Option>, + statement_descriptor: Option, + status: Option, + status_transitions: Option, + transaction: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryOutboundTransferBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "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), + + _ => ::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(), + object: 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 { + Some(Self::Out { + amount: self.amount?, + cancelable: self.cancelable?, + created: self.created?, + currency: self.currency?, + description: self.description.take()?, + destination_payment_method: self.destination_payment_method.take()?, + destination_payment_method_details: self + .destination_payment_method_details + .take()?, + expected_arrival_date: self.expected_arrival_date?, + financial_account: self.financial_account.take()?, + hosted_regulatory_receipt_url: self.hosted_regulatory_receipt_url.take()?, + id: self.id.take()?, + livemode: self.livemode?, + metadata: self.metadata.take()?, + object: self.object?, + returned_details: self.returned_details.take()?, + statement_descriptor: self.statement_descriptor.take()?, + status: self.status?, + status_transitions: self.status_transitions?, + transaction: self.transaction.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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() + } + } +}; +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TreasuryOutboundTransferObject { + TreasuryOutboundTransfer, +} +impl TreasuryOutboundTransferObject { + pub fn as_str(self) -> &'static str { + use TreasuryOutboundTransferObject::*; + match self { + TreasuryOutboundTransfer => "treasury.outbound_transfer", + } + } +} + +impl std::str::FromStr for TreasuryOutboundTransferObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TreasuryOutboundTransferObject::*; + match s { + "treasury.outbound_transfer" => Ok(TreasuryOutboundTransfer), + _ => Err(()), + } + } +} +impl std::fmt::Display for TreasuryOutboundTransferObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TreasuryOutboundTransferObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TreasuryOutboundTransferObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TreasuryOutboundTransferObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryOutboundTransferObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryOutboundTransferObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TreasuryOutboundTransferObject { + fn deserialize>(deserializer: D) -> 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 TreasuryOutboundTransferObject") + }) + } +} impl stripe_types::Object for TreasuryOutboundTransfer { type Id = stripe_treasury::TreasuryOutboundTransferId; fn id(&self) -> &Self::Id { @@ -107,6 +382,22 @@ impl serde::Serialize for TreasuryOutboundTransferStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryOutboundTransferStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryOutboundTransferStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryOutboundTransferStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryOutboundTransferStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..6b82a73e2 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,101 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryOutboundTransfersResourceReturnedDetails { /// Reason for the return. pub code: TreasuryOutboundTransfersResourceReturnedDetailsCode, /// The Transaction associated with this object. pub transaction: stripe_types::Expandable, } +#[doc(hidden)] +pub struct TreasuryOutboundTransfersResourceReturnedDetailsBuilder { + code: Option, + transaction: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryOutboundTransfersResourceReturnedDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { code: Deserialize::default(), transaction: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { code: self.code?, transaction: self.transaction.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -67,6 +158,7 @@ impl std::fmt::Debug for TreasuryOutboundTransfersResourceReturnedDetailsCode { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryOutboundTransfersResourceReturnedDetailsCode { fn serialize(&self, serializer: S) -> Result where @@ -75,6 +167,25 @@ impl serde::Serialize for TreasuryOutboundTransfersResourceReturnedDetailsCode { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryOutboundTransfersResourceReturnedDetailsCode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryOutboundTransfersResourceReturnedDetailsCode::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryOutboundTransfersResourceReturnedDetailsCode); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryOutboundTransfersResourceReturnedDetailsCode { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..77b04cb31 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryOutboundTransfersResourceStatusTransitions { /// Timestamp describing when an OutboundTransfer changed status to `canceled` pub canceled_at: Option, @@ -9,3 +11,108 @@ pub struct TreasuryOutboundTransfersResourceStatusTransitions { /// Timestamp describing when an OutboundTransfer changed status to `returned` pub returned_at: Option, } +#[doc(hidden)] +pub struct TreasuryOutboundTransfersResourceStatusTransitionsBuilder { + canceled_at: Option>, + failed_at: Option>, + posted_at: Option>, + returned_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryOutboundTransfersResourceStatusTransitionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + canceled_at: self.canceled_at?, + failed_at: self.failed_at?, + posted_at: self.posted_at?, + returned_at: self.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 { + 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..ff22d924d 100644 --- a/generated/stripe_treasury/src/treasury_received_credit/requests.rs +++ b/generated/stripe_treasury/src/treasury_received_credit/requests.rs @@ -102,6 +102,18 @@ impl serde::Serialize for ListTreasuryReceivedCreditLinkedFlowsSourceFlowType { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ListTreasuryReceivedCreditLinkedFlowsSourceFlowType { + fn deserialize>(deserializer: D) -> 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 ListTreasuryReceivedCreditLinkedFlowsSourceFlowType", + ) + }) + } +} impl<'a> ListTreasuryReceivedCredit<'a> { /// Returns a list of ReceivedCredits. pub fn send( @@ -236,6 +248,20 @@ impl serde::Serialize for CreateTreasuryReceivedCreditInitiatingPaymentMethodDet serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTreasuryReceivedCreditInitiatingPaymentMethodDetailsType +{ + fn deserialize>(deserializer: D) -> 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 CreateTreasuryReceivedCreditInitiatingPaymentMethodDetailsType", + ) + }) + } +} /// Optional fields for `us_bank_account`. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateTreasuryReceivedCreditInitiatingPaymentMethodDetailsUsBankAccount<'a> { @@ -300,6 +326,16 @@ impl serde::Serialize for CreateTreasuryReceivedCreditNetwork { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTreasuryReceivedCreditNetwork { + fn deserialize>(deserializer: D) -> 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 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. diff --git a/generated/stripe_treasury/src/treasury_received_credit/types.rs b/generated/stripe_treasury/src/treasury_received_credit/types.rs index c9cf74773..d1d4b746e 100644 --- a/generated/stripe_treasury/src/treasury_received_credit/types.rs +++ b/generated/stripe_treasury/src/treasury_received_credit/types.rs @@ -1,6 +1,8 @@ /// 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryReceivedCredit { /// Amount (in cents) transferred. pub amount: i64, @@ -26,6 +28,8 @@ pub linked_flows: stripe_treasury::TreasuryReceivedCreditsResourceLinkedFlows, pub livemode: bool, /// The rails used to send the funds. pub network: TreasuryReceivedCreditNetwork, + /// String representing the object's type. Objects of the same type share the same value. +pub object: TreasuryReceivedCreditObject, /// Details describing when a ReceivedCredit may be reversed. pub reversal_details: Option, /// Status of the ReceivedCredit. @@ -36,6 +40,180 @@ pub status: stripe_treasury::TreasuryReceivedCreditStatus, pub transaction: Option>, } +#[doc(hidden)] +pub struct TreasuryReceivedCreditBuilder { + amount: Option, +created: Option, +currency: Option, +description: Option, +failure_code: Option>, +financial_account: Option>, +hosted_regulatory_receipt_url: Option>, +id: Option, +initiating_payment_method_details: Option, +linked_flows: Option, +livemode: Option, +network: Option, +object: Option, +reversal_details: Option>, +status: Option, +transaction: Option>>, + +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryReceivedCreditBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "reversal_details" => Deserialize::begin(&mut self.reversal_details), + "status" => Deserialize::begin(&mut self.status), + "transaction" => Deserialize::begin(&mut self.transaction), + + _ => ::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(), + object: Deserialize::default(), + reversal_details: Deserialize::default(), + status: Deserialize::default(), + transaction: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + created: self.created?, + currency: self.currency?, + description: self.description.take()?, + failure_code: self.failure_code?, + financial_account: self.financial_account.take()?, + hosted_regulatory_receipt_url: self.hosted_regulatory_receipt_url.take()?, + id: self.id.take()?, + initiating_payment_method_details: self.initiating_payment_method_details.take()?, + linked_flows: self.linked_flows.take()?, + livemode: self.livemode?, + network: self.network?, + object: self.object?, + reversal_details: self.reversal_details?, + status: self.status?, + transaction: self.transaction.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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)] @@ -78,6 +256,7 @@ impl std::fmt::Debug for TreasuryReceivedCreditFailureCode { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryReceivedCreditFailureCode { fn serialize(&self, serializer: S) -> Result where @@ -86,6 +265,23 @@ impl serde::Serialize for TreasuryReceivedCreditFailureCode { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryReceivedCreditFailureCode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(TreasuryReceivedCreditFailureCode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryReceivedCreditFailureCode); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryReceivedCreditFailureCode { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -139,6 +335,7 @@ impl std::fmt::Debug for TreasuryReceivedCreditNetwork { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryReceivedCreditNetwork { fn serialize(&self, serializer: S) -> Result where @@ -147,6 +344,22 @@ impl serde::Serialize for TreasuryReceivedCreditNetwork { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryReceivedCreditNetwork { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryReceivedCreditNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryReceivedCreditNetwork); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryReceivedCreditNetwork { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -156,6 +369,74 @@ impl<'de> serde::Deserialize<'de> for TreasuryReceivedCreditNetwork { }) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TreasuryReceivedCreditObject { + TreasuryReceivedCredit, +} +impl TreasuryReceivedCreditObject { + pub fn as_str(self) -> &'static str { + use TreasuryReceivedCreditObject::*; + match self { + TreasuryReceivedCredit => "treasury.received_credit", + } + } +} + +impl std::str::FromStr for TreasuryReceivedCreditObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TreasuryReceivedCreditObject::*; + match s { + "treasury.received_credit" => Ok(TreasuryReceivedCredit), + _ => Err(()), + } + } +} +impl std::fmt::Display for TreasuryReceivedCreditObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TreasuryReceivedCreditObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TreasuryReceivedCreditObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TreasuryReceivedCreditObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryReceivedCreditObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryReceivedCreditObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TreasuryReceivedCreditObject { + fn deserialize>(deserializer: D) -> 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 TreasuryReceivedCreditObject")) + } +} impl stripe_types::Object for TreasuryReceivedCredit { type Id = stripe_treasury::TreasuryReceivedCreditId; fn id(&self) -> &Self::Id { @@ -208,6 +489,22 @@ impl serde::Serialize for TreasuryReceivedCreditStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryReceivedCreditStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryReceivedCreditStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryReceivedCreditStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryReceivedCreditStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..ca88fe471 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryReceivedCreditsResourceLinkedFlows { /// The CreditReversal created as a result of this ReceivedCredit being reversed. pub credit_reversal: Option, @@ -16,3 +18,125 @@ pub struct TreasuryReceivedCreditsResourceLinkedFlows { /// The type of flow that originated the ReceivedCredit (for example, `outbound_payment`). pub source_flow_type: Option, } +#[doc(hidden)] +pub struct TreasuryReceivedCreditsResourceLinkedFlowsBuilder { + credit_reversal: Option>, + issuing_authorization: Option>, + issuing_transaction: Option>, + source_flow: Option>, + source_flow_details: + Option>, + source_flow_type: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryReceivedCreditsResourceLinkedFlowsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + credit_reversal: self.credit_reversal.take()?, + issuing_authorization: self.issuing_authorization.take()?, + issuing_transaction: self.issuing_transaction.take()?, + source_flow: self.source_flow.take()?, + source_flow_details: self.source_flow_details.take()?, + source_flow_type: self.source_flow_type.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..97a9f3ce4 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryReceivedCreditsResourceReversalDetails { /// Time before which a ReceivedCredit can be reversed. pub deadline: Option, /// Set if a ReceivedCredit cannot be reversed. pub restricted_reason: Option, } +#[doc(hidden)] +pub struct TreasuryReceivedCreditsResourceReversalDetailsBuilder { + deadline: Option>, + restricted_reason: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryReceivedCreditsResourceReversalDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deadline: Deserialize::default(), restricted_reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deadline: self.deadline?, restricted_reason: self.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 { + 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 { @@ -52,6 +144,7 @@ impl std::fmt::Debug for TreasuryReceivedCreditsResourceReversalDetailsRestricte f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryReceivedCreditsResourceReversalDetailsRestrictedReason { fn serialize(&self, serializer: S) -> Result where @@ -60,6 +153,29 @@ impl serde::Serialize for TreasuryReceivedCreditsResourceReversalDetailsRestrict serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryReceivedCreditsResourceReversalDetailsRestrictedReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryReceivedCreditsResourceReversalDetailsRestrictedReason::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + TreasuryReceivedCreditsResourceReversalDetailsRestrictedReason +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for 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..2b4546646 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,119 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryReceivedCreditsResourceSourceFlowsDetails { - #[serde(skip_serializing_if = "Option::is_none")] pub credit_reversal: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub outbound_payment: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub payout: Option, /// The type of the source flow that originated the ReceivedCredit. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: TreasuryReceivedCreditsResourceSourceFlowsDetailsType, } +#[doc(hidden)] +pub struct TreasuryReceivedCreditsResourceSourceFlowsDetailsBuilder { + credit_reversal: Option>, + outbound_payment: Option>, + payout: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryReceivedCreditsResourceSourceFlowsDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + credit_reversal: self.credit_reversal.take()?, + outbound_payment: self.outbound_payment.take()?, + payout: self.payout.take()?, + type_: self.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 { + 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 { @@ -54,6 +158,7 @@ impl std::fmt::Debug for TreasuryReceivedCreditsResourceSourceFlowsDetailsType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryReceivedCreditsResourceSourceFlowsDetailsType { fn serialize(&self, serializer: S) -> Result where @@ -62,6 +167,27 @@ impl serde::Serialize for TreasuryReceivedCreditsResourceSourceFlowsDetailsType serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryReceivedCreditsResourceSourceFlowsDetailsType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryReceivedCreditsResourceSourceFlowsDetailsType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryReceivedCreditsResourceSourceFlowsDetailsType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryReceivedCreditsResourceSourceFlowsDetailsType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..d25e98e87 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryReceivedCreditsResourceStatusTransitions { /// Timestamp describing when the CreditReversal changed status to `posted` pub posted_at: Option, } +#[doc(hidden)] +pub struct TreasuryReceivedCreditsResourceStatusTransitionsBuilder { + posted_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryReceivedCreditsResourceStatusTransitionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { posted_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { posted_at: self.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 { + 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..fbad3383a 100644 --- a/generated/stripe_treasury/src/treasury_received_debit/requests.rs +++ b/generated/stripe_treasury/src/treasury_received_debit/requests.rs @@ -169,6 +169,20 @@ impl serde::Serialize for CreateTreasuryReceivedDebitInitiatingPaymentMethodDeta serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> + for CreateTreasuryReceivedDebitInitiatingPaymentMethodDetailsType +{ + fn deserialize>(deserializer: D) -> 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 CreateTreasuryReceivedDebitInitiatingPaymentMethodDetailsType", + ) + }) + } +} /// Optional fields for `us_bank_account`. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] pub struct CreateTreasuryReceivedDebitInitiatingPaymentMethodDetailsUsBankAccount<'a> { @@ -230,6 +244,16 @@ impl serde::Serialize for CreateTreasuryReceivedDebitNetwork { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for CreateTreasuryReceivedDebitNetwork { + fn deserialize>(deserializer: D) -> 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 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. diff --git a/generated/stripe_treasury/src/treasury_received_debit/types.rs b/generated/stripe_treasury/src/treasury_received_debit/types.rs index fe061ab9b..fd2c64eca 100644 --- a/generated/stripe_treasury/src/treasury_received_debit/types.rs +++ b/generated/stripe_treasury/src/treasury_received_debit/types.rs @@ -1,6 +1,8 @@ /// 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryReceivedDebit { /// Amount (in cents) transferred. pub amount: i64, @@ -20,13 +22,14 @@ pub financial_account: Option, pub hosted_regulatory_receipt_url: Option, /// Unique identifier for the object. pub id: stripe_treasury::TreasuryReceivedDebitId, -#[serde(skip_serializing_if = "Option::is_none")] pub initiating_payment_method_details: Option, 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, + /// String representing the object's type. Objects of the same type share the same value. +pub object: TreasuryReceivedDebitObject, /// Details describing when a ReceivedDebit might be reversed. pub reversal_details: Option, /// Status of the ReceivedDebit. @@ -37,6 +40,180 @@ pub status: stripe_treasury::TreasuryReceivedDebitStatus, pub transaction: Option>, } +#[doc(hidden)] +pub struct TreasuryReceivedDebitBuilder { + amount: Option, +created: Option, +currency: Option, +description: Option, +failure_code: Option>, +financial_account: Option>, +hosted_regulatory_receipt_url: Option>, +id: Option, +initiating_payment_method_details: Option>, +linked_flows: Option, +livemode: Option, +network: Option, +object: Option, +reversal_details: Option>, +status: Option, +transaction: Option>>, + +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryReceivedDebitBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "reversal_details" => Deserialize::begin(&mut self.reversal_details), + "status" => Deserialize::begin(&mut self.status), + "transaction" => Deserialize::begin(&mut self.transaction), + + _ => ::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(), + object: Deserialize::default(), + reversal_details: Deserialize::default(), + status: Deserialize::default(), + transaction: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + created: self.created?, + currency: self.currency?, + description: self.description.take()?, + failure_code: self.failure_code?, + financial_account: self.financial_account.take()?, + hosted_regulatory_receipt_url: self.hosted_regulatory_receipt_url.take()?, + id: self.id.take()?, + initiating_payment_method_details: self.initiating_payment_method_details.take()?, + linked_flows: self.linked_flows.take()?, + livemode: self.livemode?, + network: self.network?, + object: self.object?, + reversal_details: self.reversal_details?, + status: self.status?, + transaction: self.transaction.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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)?), + "object" => b.object = 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)] @@ -82,6 +259,7 @@ impl std::fmt::Debug for TreasuryReceivedDebitFailureCode { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryReceivedDebitFailureCode { fn serialize(&self, serializer: S) -> Result where @@ -90,6 +268,23 @@ impl serde::Serialize for TreasuryReceivedDebitFailureCode { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryReceivedDebitFailureCode { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(TreasuryReceivedDebitFailureCode::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryReceivedDebitFailureCode); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryReceivedDebitFailureCode { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -140,6 +335,7 @@ impl std::fmt::Debug for TreasuryReceivedDebitNetwork { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryReceivedDebitNetwork { fn serialize(&self, serializer: S) -> Result where @@ -148,6 +344,22 @@ impl serde::Serialize for TreasuryReceivedDebitNetwork { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryReceivedDebitNetwork { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryReceivedDebitNetwork::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryReceivedDebitNetwork); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryReceivedDebitNetwork { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -156,6 +368,74 @@ impl<'de> serde::Deserialize<'de> for TreasuryReceivedDebitNetwork { .map_err(|_| serde::de::Error::custom("Unknown value for TreasuryReceivedDebitNetwork")) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TreasuryReceivedDebitObject { + TreasuryReceivedDebit, +} +impl TreasuryReceivedDebitObject { + pub fn as_str(self) -> &'static str { + use TreasuryReceivedDebitObject::*; + match self { + TreasuryReceivedDebit => "treasury.received_debit", + } + } +} + +impl std::str::FromStr for TreasuryReceivedDebitObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TreasuryReceivedDebitObject::*; + match s { + "treasury.received_debit" => Ok(TreasuryReceivedDebit), + _ => Err(()), + } + } +} +impl std::fmt::Display for TreasuryReceivedDebitObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TreasuryReceivedDebitObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TreasuryReceivedDebitObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TreasuryReceivedDebitObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryReceivedDebitObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryReceivedDebitObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TreasuryReceivedDebitObject { + fn deserialize>(deserializer: D) -> 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 TreasuryReceivedDebitObject")) + } +} impl stripe_types::Object for TreasuryReceivedDebit { type Id = stripe_treasury::TreasuryReceivedDebitId; fn id(&self) -> &Self::Id { @@ -208,6 +488,22 @@ impl serde::Serialize for TreasuryReceivedDebitStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryReceivedDebitStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryReceivedDebitStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryReceivedDebitStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryReceivedDebitStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; 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..2dbf23341 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,95 @@ -#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryReceivedDebitsResourceDebitReversalLinkedFlows { /// Set if there is an Issuing dispute associated with the DebitReversal. pub issuing_dispute: Option, } +#[doc(hidden)] +pub struct TreasuryReceivedDebitsResourceDebitReversalLinkedFlowsBuilder { + issuing_dispute: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryReceivedDebitsResourceDebitReversalLinkedFlowsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { issuing_dispute: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { issuing_dispute: self.issuing_dispute.take()? }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..a6e4a1545 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryReceivedDebitsResourceLinkedFlows { /// The DebitReversal created as a result of this ReceivedDebit being reversed. pub debit_reversal: Option, @@ -9,3 +11,112 @@ 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, } +#[doc(hidden)] +pub struct TreasuryReceivedDebitsResourceLinkedFlowsBuilder { + debit_reversal: Option>, + inbound_transfer: Option>, + issuing_authorization: Option>, + issuing_transaction: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryReceivedDebitsResourceLinkedFlowsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { + debit_reversal: self.debit_reversal.take()?, + inbound_transfer: self.inbound_transfer.take()?, + issuing_authorization: self.issuing_authorization.take()?, + issuing_transaction: self.issuing_transaction.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..5234ece1a 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryReceivedDebitsResourceReversalDetails { /// Time before which a ReceivedDebit can be reversed. pub deadline: Option, /// Set if a ReceivedDebit can't be reversed. pub restricted_reason: Option, } +#[doc(hidden)] +pub struct TreasuryReceivedDebitsResourceReversalDetailsBuilder { + deadline: Option>, + restricted_reason: + Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryReceivedDebitsResourceReversalDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { deadline: Deserialize::default(), restricted_reason: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { deadline: self.deadline?, restricted_reason: self.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 { + 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 { @@ -52,6 +144,7 @@ impl std::fmt::Debug for TreasuryReceivedDebitsResourceReversalDetailsRestricted f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryReceivedDebitsResourceReversalDetailsRestrictedReason { fn serialize(&self, serializer: S) -> Result where @@ -60,6 +153,29 @@ impl serde::Serialize for TreasuryReceivedDebitsResourceReversalDetailsRestricte serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryReceivedDebitsResourceReversalDetailsRestrictedReason { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor + for crate::Place +{ + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryReceivedDebitsResourceReversalDetailsRestrictedReason::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + TreasuryReceivedDebitsResourceReversalDetailsRestrictedReason +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for 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..75237add8 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryReceivedDebitsResourceStatusTransitions { /// Timestamp describing when the DebitReversal changed status to `completed`. pub completed_at: Option, } +#[doc(hidden)] +pub struct TreasuryReceivedDebitsResourceStatusTransitionsBuilder { + completed_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryReceivedDebitsResourceStatusTransitionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { completed_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { completed_at: self.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 { + 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..286388b9d 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasurySharedResourceBillingDetails { pub address: stripe_shared::Address, /// Email address. @@ -6,3 +8,103 @@ pub struct TreasurySharedResourceBillingDetails { /// Full name. pub name: Option, } +#[doc(hidden)] +pub struct TreasurySharedResourceBillingDetailsBuilder { + address: Option, + email: Option>, + name: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasurySharedResourceBillingDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + address: Deserialize::default(), + email: Deserialize::default(), + name: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + address: self.address.take()?, + email: self.email.take()?, + name: self.name.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..03daef179 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,150 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetails { /// Set when `type` is `balance`. - #[serde(skip_serializing_if = "Option::is_none")] pub balance: Option< TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance, >, pub billing_details: stripe_treasury::TreasurySharedResourceBillingDetails, - #[serde(skip_serializing_if = "Option::is_none")] pub financial_account: Option, /// 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, /// Polymorphic type matching the originating money movement's source. /// This can be an external account, a Stripe balance, or a FinancialAccount. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType, - #[serde(skip_serializing_if = "Option::is_none")] pub us_bank_account: Option, } +#[doc(hidden)] +pub struct TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBuilder { + balance: Option>, +billing_details: Option, +financial_account: Option>, +issuing_card: Option>, +type_: Option, +us_bank_account: Option>, + +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBuilder, +} + + impl Visitor + for Place< + TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetails, + > + { + fn map(&mut self) -> Result> { + 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), + + _ => ::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 { + Some(Self::Out { balance: self.balance?, +billing_details: self.billing_details.take()?, +financial_account: self.financial_account.take()?, +issuing_card: self.issuing_card.take()?, +type_: self.type_?, +us_bank_account: self.us_bank_account.take()?, + }) + } +} + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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 { @@ -62,6 +186,7 @@ impl std::fmt::Debug f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance { @@ -72,6 +197,30 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +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(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsBalance { @@ -135,6 +284,7 @@ impl std::fmt::Debug f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType { @@ -145,6 +295,30 @@ impl serde::Serialize serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize + for TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType +{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +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(()) + } +} + +stripe_types::impl_from_val_with_from_str!( + TreasurySharedResourceInitiatingPaymentMethodDetailsInitiatingPaymentMethodDetailsType +); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for 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..56e9b4c23 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccount { /// Bank name. pub bank_name: Option, @@ -7,3 +9,103 @@ pub struct TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccount { /// The routing number for the bank account. pub routing_number: Option, } +#[doc(hidden)] +pub struct TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccountBuilder { + bank_name: Option>, + last4: Option>, + routing_number: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasurySharedResourceInitiatingPaymentMethodDetailsUsBankAccountBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + bank_name: Deserialize::default(), + last4: Deserialize::default(), + routing_number: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + bank_name: self.bank_name.take()?, + last4: self.last4.take()?, + routing_number: self.routing_number.take()?, + }) + } + } + + impl<'a> Map for Builder<'a> { + fn key(&mut self, k: &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 { + 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..6a9db3047 100644 --- a/generated/stripe_treasury/src/treasury_transaction/requests.rs +++ b/generated/stripe_treasury/src/treasury_transaction/requests.rs @@ -95,6 +95,16 @@ impl serde::Serialize for ListTreasuryTransactionOrderBy { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ListTreasuryTransactionOrderBy { + fn deserialize>(deserializer: D) -> 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 ListTreasuryTransactionOrderBy") + }) + } +} /// A filter for the `status_transitions.posted_at` timestamp. /// When using this filter, `status=posted` and `order_by=posted_at` must also be specified. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] diff --git a/generated/stripe_treasury/src/treasury_transaction/types.rs b/generated/stripe_treasury/src/treasury_transaction/types.rs index 33e551d9a..00efcea7e 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryTransaction { /// Amount (in cents) transferred. pub amount: i64, @@ -26,11 +28,177 @@ pub struct TreasuryTransaction { pub id: stripe_treasury::TreasuryTransactionId, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: TreasuryTransactionObject, /// Status of the Transaction. pub status: stripe_treasury::TreasuryTransactionStatus, pub status_transitions: stripe_treasury::TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitions, } +#[doc(hidden)] +pub struct TreasuryTransactionBuilder { + amount: Option, + balance_impact: Option, + created: Option, + currency: Option, + description: Option, + entries: Option>>, + financial_account: Option, + flow: Option>, + flow_details: Option>, + flow_type: Option, + id: Option, + livemode: Option, + object: Option, + status: Option, + status_transitions: Option< + stripe_treasury::TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitions, + >, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryTransactionBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "status" => Deserialize::begin(&mut self.status), + "status_transitions" => Deserialize::begin(&mut self.status_transitions), + + _ => ::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(), + object: Deserialize::default(), + status: Deserialize::default(), + status_transitions: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + amount: self.amount?, + balance_impact: self.balance_impact?, + created: self.created?, + currency: self.currency?, + description: self.description.take()?, + entries: self.entries.take()?, + financial_account: self.financial_account.take()?, + flow: self.flow.take()?, + flow_details: self.flow_details.take()?, + flow_type: self.flow_type?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + status: self.status?, + status_transitions: self.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 { + 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)?), + "object" => b.object = 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 { @@ -90,6 +258,7 @@ impl std::fmt::Debug for TreasuryTransactionFlowType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryTransactionFlowType { fn serialize(&self, serializer: S) -> Result where @@ -98,6 +267,22 @@ impl serde::Serialize for TreasuryTransactionFlowType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryTransactionFlowType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryTransactionFlowType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryTransactionFlowType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryTransactionFlowType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -106,6 +291,74 @@ impl<'de> serde::Deserialize<'de> for TreasuryTransactionFlowType { .map_err(|_| serde::de::Error::custom("Unknown value for TreasuryTransactionFlowType")) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TreasuryTransactionObject { + TreasuryTransaction, +} +impl TreasuryTransactionObject { + pub fn as_str(self) -> &'static str { + use TreasuryTransactionObject::*; + match self { + TreasuryTransaction => "treasury.transaction", + } + } +} + +impl std::str::FromStr for TreasuryTransactionObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TreasuryTransactionObject::*; + match s { + "treasury.transaction" => Ok(TreasuryTransaction), + _ => Err(()), + } + } +} +impl std::fmt::Display for TreasuryTransactionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TreasuryTransactionObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TreasuryTransactionObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TreasuryTransactionObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryTransactionObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryTransactionObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TreasuryTransactionObject { + fn deserialize>(deserializer: D) -> 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 TreasuryTransactionObject")) + } +} impl stripe_types::Object for TreasuryTransaction { type Id = stripe_treasury::TreasuryTransactionId; fn id(&self) -> &Self::Id { @@ -161,6 +414,22 @@ impl serde::Serialize for TreasuryTransactionStatus { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryTransactionStatus { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryTransactionStatus::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryTransactionStatus); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryTransactionStatus { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/generated/stripe_treasury/src/treasury_transaction_entry/requests.rs b/generated/stripe_treasury/src/treasury_transaction_entry/requests.rs index 5e1cbf5d3..87028b938 100644 --- a/generated/stripe_treasury/src/treasury_transaction_entry/requests.rs +++ b/generated/stripe_treasury/src/treasury_transaction_entry/requests.rs @@ -93,6 +93,16 @@ impl serde::Serialize for ListTreasuryTransactionEntryOrderBy { serializer.serialize_str(self.as_str()) } } +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for ListTreasuryTransactionEntryOrderBy { + fn deserialize>(deserializer: D) -> 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 ListTreasuryTransactionEntryOrderBy") + }) + } +} impl<'a> ListTreasuryTransactionEntry<'a> { /// Retrieves a list of TransactionEntry objects. pub fn send( diff --git a/generated/stripe_treasury/src/treasury_transaction_entry/types.rs b/generated/stripe_treasury/src/treasury_transaction_entry/types.rs index 920eb0631..87e981bf5 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryTransactionEntry { pub balance_impact: stripe_treasury::TreasuryTransactionsResourceBalanceImpact, /// Time at which the object was created. Measured in seconds since the Unix epoch. @@ -21,12 +23,164 @@ pub struct TreasuryTransactionEntry { pub id: stripe_treasury::TreasuryTransactionEntryId, /// 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, + /// String representing the object's type. Objects of the same type share the same value. + pub object: TreasuryTransactionEntryObject, /// The Transaction associated with this object. pub transaction: stripe_types::Expandable, /// The specific money movement that generated the TransactionEntry. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: TreasuryTransactionEntryType, } +#[doc(hidden)] +pub struct TreasuryTransactionEntryBuilder { + balance_impact: Option, + created: Option, + currency: Option, + effective_at: Option, + financial_account: Option, + flow: Option>, + flow_details: Option>, + flow_type: Option, + id: Option, + livemode: Option, + object: Option, + transaction: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryTransactionEntryBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + "object" => Deserialize::begin(&mut self.object), + "transaction" => Deserialize::begin(&mut self.transaction), + "type" => Deserialize::begin(&mut self.type_), + + _ => ::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(), + object: Deserialize::default(), + transaction: Deserialize::default(), + type_: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + balance_impact: self.balance_impact?, + created: self.created?, + currency: self.currency?, + effective_at: self.effective_at?, + financial_account: self.financial_account.take()?, + flow: self.flow.take()?, + flow_details: self.flow_details.take()?, + flow_type: self.flow_type?, + id: self.id.take()?, + livemode: self.livemode?, + object: self.object?, + transaction: self.transaction.take()?, + type_: self.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 { + 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)?), + "object" => b.object = 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 { @@ -86,6 +240,7 @@ impl std::fmt::Debug for TreasuryTransactionEntryFlowType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryTransactionEntryFlowType { fn serialize(&self, serializer: S) -> Result where @@ -94,6 +249,23 @@ impl serde::Serialize for TreasuryTransactionEntryFlowType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryTransactionEntryFlowType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = + Some(TreasuryTransactionEntryFlowType::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryTransactionEntryFlowType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryTransactionEntryFlowType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; @@ -103,6 +275,75 @@ impl<'de> serde::Deserialize<'de> for TreasuryTransactionEntryFlowType { }) } } +/// String representing the object's type. Objects of the same type share the same value. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum TreasuryTransactionEntryObject { + TreasuryTransactionEntry, +} +impl TreasuryTransactionEntryObject { + pub fn as_str(self) -> &'static str { + use TreasuryTransactionEntryObject::*; + match self { + TreasuryTransactionEntry => "treasury.transaction_entry", + } + } +} + +impl std::str::FromStr for TreasuryTransactionEntryObject { + type Err = (); + fn from_str(s: &str) -> Result { + use TreasuryTransactionEntryObject::*; + match s { + "treasury.transaction_entry" => Ok(TreasuryTransactionEntry), + _ => Err(()), + } + } +} +impl std::fmt::Display for TreasuryTransactionEntryObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} + +impl std::fmt::Debug for TreasuryTransactionEntryObject { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.write_str(self.as_str()) + } +} +#[cfg(feature = "serde")] +impl serde::Serialize for TreasuryTransactionEntryObject { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(self.as_str()) + } +} +impl miniserde::Deserialize for TreasuryTransactionEntryObject { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some(TreasuryTransactionEntryObject::from_str(s).map_err(|_| miniserde::Error)?); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryTransactionEntryObject); +#[cfg(feature = "serde")] +impl<'de> serde::Deserialize<'de> for TreasuryTransactionEntryObject { + fn deserialize>(deserializer: D) -> 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 TreasuryTransactionEntryObject") + }) + } +} /// The specific money movement that generated the TransactionEntry. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] @@ -199,6 +440,7 @@ impl std::fmt::Debug for TreasuryTransactionEntryType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryTransactionEntryType { fn serialize(&self, serializer: S) -> Result where @@ -207,11 +449,30 @@ impl serde::Serialize for TreasuryTransactionEntryType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryTransactionEntryType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryTransactionEntryType::from_str(s) + .unwrap_or(TreasuryTransactionEntryType::Unknown), + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryTransactionEntryType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryTransactionEntryType { fn deserialize>(deserializer: D) -> Result { 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)) } } impl stripe_types::Object for TreasuryTransactionEntry { 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..516f9054d 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,103 @@ -#[derive(Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize)] +#[derive(Copy, Clone, Debug, Default)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitions { /// Timestamp describing when the Transaction changed status to `posted`. pub posted_at: Option, /// Timestamp describing when the Transaction changed status to `void`. pub void_at: Option, } +#[doc(hidden)] +pub struct TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitionsBuilder { + posted_at: Option>, + void_at: Option>, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option< + TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitions, + >, + builder: TreasuryTransactionsResourceAbstractTransactionResourceStatusTransitionsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { posted_at: Deserialize::default(), void_at: Deserialize::default() } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { posted_at: self.posted_at?, void_at: self.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 { + 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..eeb7b3aa2 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(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryTransactionsResourceBalanceImpact { /// The change made to funds the user can spend right now. pub cash: i64, @@ -8,3 +10,103 @@ 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, } +#[doc(hidden)] +pub struct TreasuryTransactionsResourceBalanceImpactBuilder { + cash: Option, + inbound_pending: Option, + outbound_pending: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryTransactionsResourceBalanceImpactBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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), + + _ => ::ignore(), + }) + } + + fn deser_default() -> Self { + Self { + cash: Deserialize::default(), + inbound_pending: Deserialize::default(), + outbound_pending: Deserialize::default(), + } + } + + fn take_out(&mut self) -> Option { + Some(Self::Out { + cash: self.cash?, + inbound_pending: self.inbound_pending?, + outbound_pending: self.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 { + 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..f073554dc 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,151 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct TreasuryTransactionsResourceFlowDetails { - #[serde(skip_serializing_if = "Option::is_none")] pub credit_reversal: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub debit_reversal: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub inbound_transfer: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub issuing_authorization: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub outbound_payment: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub outbound_transfer: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub received_credit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub received_debit: Option, /// Type of the flow that created the Transaction. Set to the same value as `flow_type`. - #[serde(rename = "type")] + #[cfg_attr(feature = "serde", serde(rename = "type"))] pub type_: TreasuryTransactionsResourceFlowDetailsType, } +#[doc(hidden)] +pub struct TreasuryTransactionsResourceFlowDetailsBuilder { + credit_reversal: Option>, + debit_reversal: Option>, + inbound_transfer: Option>, + issuing_authorization: Option>, + outbound_payment: Option>, + outbound_transfer: Option>, + received_credit: Option>, + received_debit: Option>, + type_: Option, +} + +#[allow(unused_variables, clippy::match_single_binding, clippy::single_match)] +const _: () = { + use miniserde::de::{Map, Visitor}; + use miniserde::json::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) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct Builder<'a> { + out: &'a mut Option, + builder: TreasuryTransactionsResourceFlowDetailsBuilder, + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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_), + + _ => ::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 { + Some(Self::Out { + credit_reversal: self.credit_reversal.take()?, + debit_reversal: self.debit_reversal.take()?, + inbound_transfer: self.inbound_transfer.take()?, + issuing_authorization: self.issuing_authorization.take()?, + outbound_payment: self.outbound_payment.take()?, + outbound_transfer: self.outbound_transfer.take()?, + received_credit: self.received_credit.take()?, + received_debit: self.received_debit.take()?, + type_: self.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 { + 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 { @@ -79,6 +205,7 @@ impl std::fmt::Debug for TreasuryTransactionsResourceFlowDetailsType { f.write_str(self.as_str()) } } +#[cfg(feature = "serde")] impl serde::Serialize for TreasuryTransactionsResourceFlowDetailsType { fn serialize(&self, serializer: S) -> Result where @@ -87,6 +214,25 @@ impl serde::Serialize for TreasuryTransactionsResourceFlowDetailsType { serializer.serialize_str(self.as_str()) } } +impl miniserde::Deserialize for TreasuryTransactionsResourceFlowDetailsType { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } +} + +impl miniserde::de::Visitor for crate::Place { + fn string(&mut self, s: &str) -> miniserde::Result<()> { + use std::str::FromStr; + self.out = Some( + TreasuryTransactionsResourceFlowDetailsType::from_str(s) + .map_err(|_| miniserde::Error)?, + ); + Ok(()) + } +} + +stripe_types::impl_from_val_with_from_str!(TreasuryTransactionsResourceFlowDetailsType); +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for TreasuryTransactionsResourceFlowDetailsType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; diff --git a/openapi/fixtures.json b/openapi/fixtures.json new file mode 100644 index 000000000..7bd4ef384 --- /dev/null +++ b/openapi/fixtures.json @@ -0,0 +1,4379 @@ +{ + "resources": { + "account": { + "business_profile": { + "annual_revenue": null, + "estimated_worker_count": null, + "mcc": null, + "name": null, + "product_description": null, + "support_address": null, + "support_email": null, + "support_phone": null, + "support_url": null, + "url": null + }, + "business_type": null, + "capabilities": { + "card_payments": "active", + "transfers": "active" + }, + "charges_enabled": false, + "controller": { + "type": "account" + }, + "country": "US", + "created": 1234567890, + "default_currency": "usd", + "details_submitted": false, + "email": "site@stripe.com", + "external_accounts": { + "data": [], + "has_more": false, + "object": "list", + "url": "/v1/accounts/acct_1OPouMJN5vQBdWEx/external_accounts" + }, + "future_requirements": { + "alternatives": [], + "current_deadline": null, + "currently_due": [], + "disabled_reason": null, + "errors": [], + "eventually_due": [], + "past_due": [], + "pending_verification": [] + }, + "id": "acct_1OPouMJN5vQBdWEx", + "metadata": {}, + "object": "account", + "payouts_enabled": false, + "requirements": { + "alternatives": [], + "current_deadline": null, + "currently_due": [ + "business_profile.product_description", + "business_profile.support_phone", + "business_profile.url", + "external_account", + "tos_acceptance.date", + "tos_acceptance.ip" + ], + "disabled_reason": "requirements.past_due", + "errors": [], + "eventually_due": [ + "business_profile.product_description", + "business_profile.support_phone", + "business_profile.url", + "external_account", + "tos_acceptance.date", + "tos_acceptance.ip" + ], + "past_due": [], + "pending_verification": [] + }, + "settings": { + "bacs_debit_payments": { + "display_name": null, + "service_user_number": null + }, + "branding": { + "icon": null, + "logo": null, + "primary_color": null, + "secondary_color": null + }, + "card_issuing": { + "tos_acceptance": { + "date": null, + "ip": null + } + }, + "card_payments": { + "decline_on": { + "avs_failure": true, + "cvc_failure": true + }, + "statement_descriptor_prefix": null, + "statement_descriptor_prefix_kana": null, + "statement_descriptor_prefix_kanji": null + }, + "dashboard": { + "display_name": null, + "timezone": "Etc/UTC" + }, + "payments": { + "statement_descriptor": null, + "statement_descriptor_kana": null, + "statement_descriptor_kanji": null + }, + "payouts": { + "debit_negative_balances": true, + "schedule": { + "delay_days": 2, + "interval": "daily" + }, + "statement_descriptor": null + }, + "sepa_debit_payments": {} + }, + "tos_acceptance": { + "date": null, + "ip": null, + "user_agent": null + }, + "type": "standard" + }, + "account_link": { + "created": 1234567890, + "expires_at": 1234567890, + "object": "account_link", + "url": "https://pakrym-manage-mydev.dev.stripe.me/setup/s/acct_1OPouMJN5vQBdWEx/A70LFGX6VXGE" + }, + "account_session": { + "account": "acct_1OPousKxBrsRi89x", + "client_secret": "_PEHTFHffpUcokiSVrrc6TERNdA8300TQ5tgKincvQQYRY0v", + "components": { + "account_onboarding": { + "enabled": false, + "features": {} + }, + "payment_details": { + "enabled": false, + "features": { + "capture_payments": true, + "dispute_management": true, + "refund_management": true + } + }, + "payments": { + "enabled": false, + "features": { + "capture_payments": true, + "dispute_management": true, + "refund_management": true + } + }, + "payouts": { + "enabled": false, + "features": { + "edit_payout_schedule": false, + "instant_payouts": false, + "standard_payouts": false + } + } + }, + "expires_at": 1234567890, + "livemode": false, + "object": "account_session" + }, + "apple_pay_domain": { + "created": 1234567890, + "domain_name": "example.com", + "id": "apwc_1OPoujJN5vQBdWExuvzAhTDs", + "livemode": true, + "object": "apple_pay_domain" + }, + "application_fee": { + "account": "acct_1OPouMJN5vQBdWEx", + "amount": 100, + "amount_refunded": 0, + "application": "ca_PEHTxk3gWAWtTbzqUoOxfbLUkWTusmur", + "balance_transaction": "txn_1OPoueJN5vQBdWEx8dhHMVqh", + "charge": "ch_1OPoueJN5vQBdWEx5AWizjSY", + "created": 1234567890, + "currency": "usd", + "id": "fee_1OPounJN5vQBdWExWgwi95uU", + "livemode": false, + "object": "application_fee", + "originating_transaction": null, + "refunded": false, + "refunds": { + "data": [], + "has_more": false, + "object": "list", + "url": "/v1/application_fees/fee_1OPounJN5vQBdWExWgwi95uU/refunds" + } + }, + "apps.secret": { + "created": 1234567890, + "expires_at": 1234567890, + "id": "appsecret_5110QzMIZ0005GiEH1m0419O8KAxCG", + "livemode": false, + "name": "test-secret", + "object": "apps.secret", + "scope": { + "type": "account" + } + }, + "balance": { + "available": [ + { + "amount": 0, + "currency": "usd", + "source_types": { + "card": 0 + } + } + ], + "connect_reserved": [ + { + "amount": 0, + "currency": "usd" + } + ], + "livemode": false, + "object": "balance", + "pending": [ + { + "amount": 0, + "currency": "usd", + "source_types": { + "card": 0 + } + } + ] + }, + "balance_transaction": { + "amount": 100, + "available_on": 1234567890, + "created": 1234567890, + "currency": "usd", + "description": "My First Test Charge (created for API docs)", + "exchange_rate": null, + "fee": 0, + "fee_details": [], + "id": "txn_1OPoueJN5vQBdWEx8dhHMVqh", + "net": 100, + "object": "balance_transaction", + "reporting_category": "charge", + "source": "ch_1OPoueJN5vQBdWExHvNS496R", + "status": "available", + "type": "charge" + }, + "bank_account": { + "account_holder_name": "Jane Austen", + "account_holder_type": "individual", + "account_type": null, + "bank_name": "STRIPE TEST BANK", + "country": "US", + "currency": "usd", + "customer": null, + "fingerprint": "1JWtPxqbdX5Gamtz", + "id": "ba_1OPoumJN5vQBdWExwmpTeNeE", + "last4": "6789", + "metadata": {}, + "object": "bank_account", + "routing_number": "110000000", + "status": "new" + }, + "billing_portal.configuration": { + "active": true, + "application": null, + "business_profile": { + "headline": null, + "privacy_policy_url": "https://example.com/privacy", + "terms_of_service_url": "https://example.com/terms" + }, + "created": 1234567890, + "default_return_url": null, + "features": { + "customer_update": { + "allowed_updates": [ + "email", + "tax_id" + ], + "enabled": true + }, + "invoice_history": { + "enabled": true + }, + "payment_method_update": { + "enabled": false + }, + "subscription_cancel": { + "cancellation_reason": { + "enabled": false, + "options": [] + }, + "enabled": false, + "mode": "at_period_end", + "proration_behavior": "none" + }, + "subscription_pause": { + "enabled": false + }, + "subscription_update": { + "default_allowed_updates": [], + "enabled": false, + "proration_behavior": "none" + } + }, + "id": "bpc_1OPouvJN5vQBdWEx6dSG6gsf", + "is_default": true, + "livemode": true, + "login_page": { + "enabled": false, + "url": null + }, + "metadata": null, + "object": "billing_portal.configuration", + "updated": 1234567890 + }, + "billing_portal.session": { + "configuration": "bpc_1OPouvJN5vQBdWEx9IJMn3wL", + "created": 1234567890, + "customer": "cus_PEHTIoPSgT0tXQ", + "flow": null, + "id": "bps_1OPouvJN5vQBdWEx4sx4lucn", + "livemode": true, + "locale": null, + "object": "billing_portal.session", + "on_behalf_of": null, + "return_url": "https://example.com/account", + "url": "https://pakrym-customer_portal-mydev.dev.stripe.me/session/{SESSION_SECRET}" + }, + "capability": { + "account": "acct_1OPouMJN5vQBdWEx", + "future_requirements": { + "alternatives": [], + "current_deadline": null, + "currently_due": [], + "disabled_reason": null, + "errors": [], + "eventually_due": [], + "past_due": [], + "pending_verification": [] + }, + "id": "card_payments", + "object": "capability", + "requested": true, + "requested_at": 1234567890, + "requirements": { + "alternatives": [], + "current_deadline": null, + "currently_due": [], + "disabled_reason": null, + "errors": [], + "eventually_due": [], + "past_due": [], + "pending_verification": [] + }, + "status": "inactive" + }, + "card": { + "address_city": null, + "address_country": null, + "address_line1": null, + "address_line1_check": null, + "address_line2": null, + "address_state": null, + "address_zip": null, + "address_zip_check": null, + "brand": "Visa", + "country": "US", + "customer": null, + "cvc_check": "pass", + "dynamic_last4": null, + "exp_month": 8, + "exp_year": 2024, + "fingerprint": "r40d4vOgg3VecDJF", + "funding": "credit", + "id": "card_1OPoudJN5vQBdWExoijT3YAB", + "last4": "4242", + "metadata": {}, + "name": "Jenny Rosen", + "object": "card", + "tokenization_method": null + }, + "cash_balance": { + "available": { + "eur": 10000 + }, + "customer": "cus_PEHTIoPSgT0tXQ", + "livemode": false, + "object": "cash_balance", + "settings": { + "reconciliation_mode": "automatic", + "using_merchant_default": true + } + }, + "charge": { + "amount": 100, + "amount_captured": 0, + "amount_refunded": 0, + "application": null, + "application_fee": null, + "application_fee_amount": null, + "balance_transaction": "txn_1OPoueJN5vQBdWEx8dhHMVqh", + "billing_details": { + "address": { + "city": null, + "country": null, + "line1": null, + "line2": null, + "postal_code": null, + "state": null + }, + "email": null, + "name": "Jenny Rosen", + "phone": null + }, + "calculated_statement_descriptor": null, + "captured": false, + "created": 1234567890, + "currency": "usd", + "customer": null, + "description": "My First Test Charge (created for API docs)", + "disputed": false, + "failure_balance_transaction": null, + "failure_code": null, + "failure_message": null, + "fraud_details": {}, + "id": "ch_1OPoueJN5vQBdWEx5AWizjSY", + "invoice": null, + "livemode": false, + "metadata": {}, + "object": "charge", + "on_behalf_of": null, + "outcome": null, + "paid": true, + "payment_intent": null, + "payment_method": "card_1OPoudJN5vQBdWExSTD9mIPF", + "payment_method_details": { + "card": { + "amount_authorized": null, + "brand": "visa", + "checks": { + "address_line1_check": null, + "address_postal_code_check": null, + "cvc_check": "pass" + }, + "country": "US", + "exp_month": 8, + "exp_year": 2024, + "extended_authorization": { + "status": "disabled" + }, + "fingerprint": "r40d4vOgg3VecDJF", + "funding": "credit", + "incremental_authorization": { + "status": "unavailable" + }, + "installments": null, + "last4": "4242", + "mandate": null, + "multicapture": { + "status": "unavailable" + }, + "network": "visa", + "network_token": { + "used": false + }, + "overcapture": { + "maximum_amount_capturable": 100, + "status": "unavailable" + }, + "three_d_secure": null, + "wallet": null + }, + "type": "card" + }, + "receipt_email": null, + "receipt_number": null, + "receipt_url": "https://pakrym-manage-mydev.dev.stripe.me/receipts/payment/CAcaFwoVYWNjdF8xT1BvdU1KTjV2UUJkV0V4KL3JkawGMgZvNmQ3SW46LCKn_twcP-jc9phNH9BfAtUKJcNs5Gy9n0cn7wNp9IWz2coUhEmAKuyETwtJ", + "refunded": false, + "refunds": { + "data": [], + "has_more": false, + "object": "list", + "url": "/v1/charges/ch_1OPoueJN5vQBdWEx5AWizjSY/refunds" + }, + "review": null, + "shipping": null, + "source_transfer": null, + "statement_descriptor": null, + "statement_descriptor_suffix": null, + "status": "succeeded", + "transfer_data": null, + "transfer_group": null + }, + "checkout.session": { + "after_expiration": null, + "allow_promotion_codes": null, + "amount_subtotal": null, + "amount_total": null, + "automatic_tax": { + "enabled": false, + "liability": null, + "status": null + }, + "billing_address_collection": null, + "cancel_url": "https://example.com/cancel", + "client_reference_id": null, + "client_secret": null, + "consent": null, + "consent_collection": null, + "created": 1234567890, + "currency": null, + "currency_conversion": null, + "custom_fields": [], + "custom_text": { + "after_submit": null, + "shipping_address": null, + "submit": null, + "terms_of_service_acceptance": null + }, + "customer": null, + "customer_creation": null, + "customer_details": { + "address": null, + "email": "example@example.com", + "name": null, + "phone": null, + "tax_exempt": "none", + "tax_ids": null + }, + "customer_email": null, + "expires_at": 1234567890, + "id": "cs_test_a12et9VnHfV9NETJktvuOmVoyrOB40recOCQWiVNeDlBe4IqxEIRNi1Qdf", + "invoice": null, + "invoice_creation": null, + "livemode": false, + "locale": null, + "metadata": {}, + "mode": "payment", + "object": "checkout.session", + "payment_intent": "pi_1OPougJN5vQBdWEx8s2Dj0YR", + "payment_link": null, + "payment_method_collection": null, + "payment_method_configuration_details": null, + "payment_method_options": {}, + "payment_method_types": [ + "card" + ], + "payment_status": "unpaid", + "phone_number_collection": { + "enabled": false + }, + "recovered_from": null, + "setup_intent": null, + "shipping_address_collection": null, + "shipping_cost": null, + "shipping_details": null, + "shipping_options": [], + "status": "open", + "submit_type": null, + "subscription": null, + "success_url": "https://example.com/success", + "total_details": null, + "ui_mode": "hosted", + "url": "https://checkout.stripe.com/pay/c/cs_test_a12et9VnHfV9NETJktvuOmVoyrOB40recOCQWiVNeDlBe4IqxEIRNi1Qdf" + }, + "climate.order": { + "amount_fees": 300, + "amount_subtotal": 10000, + "amount_total": 10300, + "beneficiary": { + "public_name": "Frontier Climate" + }, + "canceled_at": 1234567890, + "cancellation_reason": null, + "certificate": null, + "confirmed_at": 1234567890, + "created": 1234567890, + "currency": "usd", + "delayed_at": 1234567890, + "delivered_at": 1234567890, + "delivery_details": [], + "expected_delivery_year": 2027, + "id": "climorder_1OPouwJN5vQBdWExXDtawOMl", + "livemode": false, + "metadata": {}, + "metric_tons": "10", + "object": "climate.order", + "product": "climsku_frontier_offtake_portfolio_2027", + "product_substituted_at": 1234567890, + "status": "open" + }, + "climate.product": { + "created": 1234567890, + "current_prices_per_metric_ton": { + "usd": { + "amount_fees": 1650, + "amount_subtotal": 55000, + "amount_total": 56650 + } + }, + "delivery_year": 2027, + "id": "climsku_frontier_offtake_portfolio_2027", + "livemode": false, + "metric_tons_available": "1000000", + "name": "Frontier's 2027 offtake portfolio", + "object": "climate.product", + "suppliers": [ + { + "id": "climsup_charm_industrial", + "info_url": "https://frontierclimate.com/portfolio/charm-industrial", + "livemode": false, + "locations": [ + { + "city": "San Francisco", + "country": "US", + "latitude": 37.7749, + "longitude": -122.4194, + "region": "CA" + } + ], + "name": "Charm Industrial", + "object": "climate.supplier", + "removal_pathway": "biomass_carbon_removal_and_storage" + }, + { + "id": "climsup_carbon_capture_inc", + "info_url": "https://frontierclimate.com/portfolio/carboncapture-inc", + "livemode": false, + "locations": [ + { + "city": "Los Angeles", + "country": "US", + "latitude": 34.0549, + "longitude": -118.2426, + "region": "CA" + } + ], + "name": "CarbonCapture Inc.", + "object": "climate.supplier", + "removal_pathway": "direct_air_capture" + }, + { + "id": "climsup_heirloom", + "info_url": "https://frontierclimate.com/portfolio/heirloom", + "livemode": false, + "locations": [ + { + "city": "Brisbane", + "country": "US", + "latitude": 37.6808, + "longitude": -122.4, + "region": "CA" + } + ], + "name": "Heirloom", + "object": "climate.supplier", + "removal_pathway": "direct_air_capture" + }, + { + "id": "climsup_lithos", + "info_url": "https://frontierclimate.com/portfolio/lithos", + "livemode": false, + "locations": [ + { + "city": "San Francisco", + "country": "US", + "latitude": 37.7749, + "longitude": -122.4194, + "region": "CA" + } + ], + "name": "Lithos", + "object": "climate.supplier", + "removal_pathway": "enhanced_weathering" + } + ] + }, + "climate.supplier": { + "id": "climsup_charm_industrial", + "info_url": "https://frontierclimate.com/portfolio/charm-industrial", + "livemode": false, + "locations": [ + { + "city": "San Francisco", + "country": "US", + "latitude": 37.7749, + "longitude": -122.4194, + "region": "CA" + } + ], + "name": "Charm Industrial", + "object": "climate.supplier", + "removal_pathway": "biomass_carbon_removal_and_storage" + }, + "country_spec": { + "default_currency": "usd", + "id": "US", + "object": "country_spec", + "supported_bank_account_currencies": { + "usd": [ + "US" + ] + }, + "supported_payment_currencies": [ + "...", + "aed", + "afn", + "usd" + ], + "supported_payment_methods": [ + "ach", + "card", + "stripe" + ], + "supported_transfer_countries": [ + "AE", + "AG", + "AL", + "AM", + "AO", + "AR", + "AT", + "AU", + "AZ", + "BA", + "BD", + "BE", + "BG", + "BH", + "BJ", + "BN", + "BO", + "BS", + "BT", + "BW", + "CA", + "CH", + "CI", + "CL", + "CO", + "CR", + "CY", + "CZ", + "DE", + "DK", + "DO", + "DZ", + "EC", + "EE", + "EG", + "ES", + "ET", + "FI", + "FR", + "GA", + "GB", + "GH", + "GM", + "GR", + "GT", + "GY", + "HK", + "HR", + "HU", + "ID", + "IE", + "IL", + "IS", + "IT", + "JM", + "JO", + "JP", + "KE", + "KH", + "KR", + "KW", + "KZ", + "LA", + "LC", + "LI", + "LK", + "LT", + "LU", + "LV", + "MA", + "MC", + "MD", + "MG", + "MK", + "MN", + "MO", + "MT", + "MU", + "MX", + "MY", + "MZ", + "NA", + "NE", + "NG", + "NL", + "NO", + "NZ", + "OM", + "PA", + "PE", + "PH", + "PK", + "PL", + "PT", + "PY", + "QA", + "RO", + "RS", + "RW", + "SA", + "SE", + "SG", + "SI", + "SK", + "SM", + "SN", + "SV", + "TH", + "TN", + "TR", + "TT", + "TW", + "TZ", + "US", + "UY", + "UZ", + "VN", + "ZA" + ], + "verification_fields": { + "company": { + "additional": [], + "minimum": [ + "business_profile.mcc", + "business_profile.name", + "business_profile.product_description", + "business_profile.url", + "business_type", + "company.address.city", + "company.address.line1", + "company.address.postal_code", + "company.address.state", + "company.name", + "company.owners_provided", + "company.phone", + "company.tax_id", + "external_account", + "owners.address.city", + "owners.address.line1", + "owners.address.postal_code", + "owners.address.state", + "owners.dob.day", + "owners.dob.month", + "owners.dob.year", + "owners.email", + "owners.first_name", + "owners.last_name", + "owners.phone", + "representative.address.city", + "representative.address.line1", + "representative.address.postal_code", + "representative.address.state", + "representative.dob.day", + "representative.dob.month", + "representative.dob.year", + "representative.email", + "representative.first_name", + "representative.id_number", + "representative.last_name", + "representative.phone", + "representative.relationship.title", + "representative.ssn_last_4", + "representative.verification.document", + "settings.card_payments.statement_descriptor_prefix", + "settings.payments.statement_descriptor", + "tos_acceptance.date", + "tos_acceptance.ip" + ] + }, + "individual": { + "additional": [], + "minimum": [ + "business_profile.mcc", + "business_profile.name", + "business_profile.product_description", + "business_profile.url", + "business_type", + "company.address.city", + "company.address.line1", + "company.address.postal_code", + "company.address.state", + "company.name", + "company.tax_id", + "external_account", + "individual.address.city", + "individual.address.line1", + "individual.address.postal_code", + "individual.address.state", + "individual.dob.day", + "individual.dob.month", + "individual.dob.year", + "individual.email", + "individual.first_name", + "individual.id_number", + "individual.last_name", + "individual.phone", + "individual.ssn_last_4", + "individual.verification.document", + "settings.card_payments.statement_descriptor_prefix", + "settings.payments.statement_descriptor", + "tos_acceptance.date", + "tos_acceptance.ip" + ] + } + } + }, + "coupon": { + "amount_off": null, + "created": 1234567890, + "currency": "usd", + "duration": "repeating", + "duration_in_months": 3, + "id": "Z4OV52SU", + "livemode": false, + "max_redemptions": null, + "metadata": {}, + "name": "25.5% off", + "object": "coupon", + "percent_off": 25.5, + "redeem_by": 1234567890, + "times_redeemed": 0, + "valid": true + }, + "credit_note": { + "amount": 1690, + "amount_shipping": 0, + "created": 1234567890, + "currency": "usd", + "customer": "cus_PEHTIoPSgT0tXQ", + "customer_balance_transaction": null, + "discount_amount": 0, + "discount_amounts": [], + "effective_at": 1234567890, + "id": "cn_1OPouvJN5vQBdWExIhfxzf67", + "invoice": "in_1OPouvJN5vQBdWExRyU1EhWP", + "lines": { + "data": [ + { + "amount": 1190, + "amount_excluding_tax": 1190, + "description": "My First Invoice Item (created for API docs)", + "discount_amount": 0, + "discount_amounts": [], + "id": "cnli_1OPouvJN5vQBdWExsUfSIvWE", + "invoice_line_item": "il_1OPouvJN5vQBdWExpk2vqZBx", + "livemode": false, + "object": "credit_note_line_item", + "quantity": 1, + "tax_amounts": [ + { + "amount": 190, + "inclusive": false, + "tax_rate": "txr_1OPouvJN5vQBdWExvkEZYzsQ", + "taxability_reason": null, + "taxable_amount": 1000 + } + ], + "tax_rates": [ + { + "active": true, + "country": "DE", + "created": 1703175373, + "description": "VAT Germany", + "display_name": "VAT", + "effective_percentage": null, + "id": "txr_1OPouvJN5vQBdWExvkEZYzsQ", + "inclusive": false, + "jurisdiction": "DE", + "jurisdiction_level": null, + "livemode": false, + "metadata": {}, + "object": "tax_rate", + "percentage": 19, + "state": null, + "tax_type": "vat" + } + ], + "type": "invoice_line_item", + "unit_amount": null, + "unit_amount_decimal": null, + "unit_amount_excluding_tax": "1190" + }, + { + "amount": 500, + "amount_excluding_tax": 500, + "description": "Service credit", + "discount_amount": 0, + "discount_amounts": [], + "id": "cnli_1OPouvJN5vQBdWExbjtBWlPg", + "livemode": false, + "object": "credit_note_line_item", + "quantity": 1, + "tax_amounts": [], + "tax_rates": [], + "type": "custom_line_item", + "unit_amount": 500, + "unit_amount_decimal": "500", + "unit_amount_excluding_tax": "500" + } + ], + "has_more": false, + "object": "list", + "url": "/v1/credit_notes/cn_1OPouvJN5vQBdWExIhfxzf67/lines" + }, + "livemode": false, + "memo": null, + "metadata": {}, + "number": "ABCD-1234-CN-01", + "object": "credit_note", + "out_of_band_amount": null, + "pdf": "https://pakrym-manage-mydev.dev.stripe.me/credit_notes/acct_1OPouMJN5vQBdWEx/cnst_123456789/pdf?s=ap", + "reason": null, + "refund": null, + "shipping_cost": null, + "status": "issued", + "subtotal": 1690, + "subtotal_excluding_tax": 1690, + "tax_amounts": [ + { + "amount": 190, + "inclusive": false, + "tax_rate": "txr_1OPouvJN5vQBdWExvkEZYzsQ", + "taxability_reason": null, + "taxable_amount": 1000 + } + ], + "total": 1690, + "total_excluding_tax": null, + "type": "pre_payment", + "voided_at": 1234567890 + }, + "credit_note_line_item": { + "amount": 1000, + "amount_excluding_tax": 1000, + "description": "My First Invoice Item (created for API docs)", + "discount_amount": 0, + "discount_amounts": [], + "id": "cnli_1OPouvJN5vQBdWExkO30YEXZ", + "invoice_line_item": "il_1OPouvJN5vQBdWEx4xnltBII", + "livemode": false, + "object": "credit_note_line_item", + "quantity": 1, + "tax_amounts": [], + "tax_rates": [], + "type": "invoice_line_item", + "unit_amount": null, + "unit_amount_decimal": null, + "unit_amount_excluding_tax": "1000" + }, + "customer": { + "address": null, + "balance": 0, + "created": 1234567890, + "currency": "usd", + "default_source": null, + "delinquent": false, + "description": null, + "discount": null, + "email": null, + "id": "cus_PEHTtYpY7elppN", + "invoice_prefix": "B4749BD", + "invoice_settings": { + "custom_fields": null, + "default_payment_method": null, + "footer": null, + "rendering_options": null + }, + "livemode": false, + "metadata": {}, + "name": null, + "next_invoice_sequence": 1, + "object": "customer", + "phone": null, + "preferred_locales": [], + "shipping": null, + "tax_exempt": "none", + "test_clock": null + }, + "customer_balance_transaction": { + "amount": -500, + "created": 1234567890, + "credit_note": null, + "currency": "usd", + "customer": "cus_PEHTIoPSgT0tXQ", + "description": null, + "ending_balance": -500, + "id": "cbtxn_1OPoulJN5vQBdWExjRxTJd1t", + "invoice": null, + "livemode": false, + "metadata": null, + "object": "customer_balance_transaction", + "type": "adjustment" + }, + "customer_cash_balance_transaction": { + "created": 1234567890, + "currency": "eur", + "customer": "cus_PEHTIoPSgT0tXQ", + "ending_balance": 10000, + "funded": { + "bank_transfer": { + "eu_bank_transfer": { + "bic": "BANKDEAAXXX", + "iban_last4": "7089", + "sender_name": "Sample Business GmbH" + }, + "reference": "Payment for Invoice 629C465-155", + "type": "eu_bank_transfer" + } + }, + "id": "ccsbtxn_1OPoulJN5vQBdWExFSnWlKPa", + "livemode": false, + "net_amount": 5000, + "object": "customer_cash_balance_transaction", + "type": "funded" + }, + "customer_session": { + "client_secret": "_PMG9cUABRpWoToRKwjVQsfVNtZ0oe5m5LuRYsgOe68eoLHh", + "components": { + "buy_button": { + "enabled": false + }, + "pricing_table": { + "enabled": true + } + }, + "created": 1234567890, + "customer": "cus_PMG9sZduVeoHej", + "expires_at": 1234567890, + "livemode": false, + "object": "customer_session" + }, + "deleted_account": { + "deleted": true, + "id": "acct_1OPouMJN5vQBdWEx", + "object": "account" + }, + "deleted_apple_pay_domain": { + "deleted": true, + "id": "apwc_1OPoujJN5vQBdWExuvzAhTDs", + "object": "apple_pay_domain" + }, + "deleted_coupon": { + "deleted": true, + "id": "Z4OV52SU", + "object": "coupon" + }, + "deleted_customer": { + "deleted": true, + "id": "cus_PEHTtYpY7elppN", + "object": "customer" + }, + "deleted_discount": { + "coupon": { + "amount_off": null, + "applies_to": { + "products": [] + }, + "created": 0, + "currency": null, + "currency_options": {}, + "duration": "forever", + "duration_in_months": null, + "id": "", + "livemode": false, + "max_redemptions": null, + "metadata": null, + "name": null, + "object": "coupon", + "percent_off": null, + "redeem_by": null, + "times_redeemed": 0, + "valid": false + }, + "deleted": true, + "id": "", + "object": "discount", + "start": 1234567890 + }, + "deleted_external_account": { + "deleted": true, + "id": "ba_1OPoumJN5vQBdWExwmpTeNeE", + "object": "bank_account" + }, + "deleted_invoice": { + "deleted": true, + "id": "in_1OPouhJN5vQBdWExQl3czOuP", + "object": "invoice" + }, + "deleted_invoiceitem": { + "deleted": true, + "id": "ii_1OPoulJN5vQBdWExKaAxodMb", + "object": "invoiceitem" + }, + "deleted_payment_source": { + "deleted": true, + "id": "ba_1OPoumJN5vQBdWExwmpTeNeE", + "object": "bank_account" + }, + "deleted_person": { + "deleted": true, + "id": "person_1OPouvJN5vQBdWEx4ogP6Lfq", + "object": "person" + }, + "deleted_plan": { + "deleted": true, + "id": "price_1OPouiJN5vQBdWExAQaqTooZ", + "object": "plan" + }, + "deleted_product": { + "deleted": true, + "id": "prod_PEHTfnvdJH6K0k", + "object": "product" + }, + "deleted_radar.value_list": { + "deleted": true, + "id": "rsl_1OPouuJN5vQBdWExWiMNdstK", + "object": "radar.value_list" + }, + "deleted_radar.value_list_item": { + "deleted": true, + "id": "rsli_1OPouuJN5vQBdWExu3DMfSOX", + "object": "radar.value_list_item" + }, + "deleted_subscription_item": { + "deleted": true, + "id": "si_PEHTIbRiA7RW9V", + "object": "subscription_item" + }, + "deleted_tax_id": { + "deleted": true, + "id": "txi_1OPouvJN5vQBdWExlr1piCRz", + "object": "tax_id" + }, + "deleted_terminal.configuration": { + "deleted": true, + "id": "tmc_ElVUAjF8xXG3hj", + "object": "terminal.configuration" + }, + "deleted_terminal.location": { + "deleted": true, + "id": "tml_NGBMEGFknv9VbAajaGp51lDl", + "object": "terminal.location" + }, + "deleted_terminal.reader": { + "deleted": true, + "id": "tmr_BKknTibEn0JgG9fJJXUV93Wy", + "object": "terminal.reader" + }, + "deleted_test_helpers.test_clock": { + "deleted": true, + "id": "clock_1OPoumJN5vQBdWEx6P81PQHY", + "object": "test_helpers.test_clock" + }, + "deleted_webhook_endpoint": { + "deleted": true, + "id": "we_1OPouqJN5vQBdWEx9Xl0KCo3", + "object": "webhook_endpoint" + }, + "discount": { + "checkout_session": null, + "coupon": { + "amount_off": null, + "created": 1703175364, + "currency": "usd", + "duration": "repeating", + "duration_in_months": 3, + "id": "Z4OV52SU", + "livemode": false, + "max_redemptions": null, + "metadata": {}, + "name": "25.5% off", + "object": "coupon", + "percent_off": 25.5, + "redeem_by": null, + "times_redeemed": 0, + "valid": true + }, + "customer": "cus_PEHTtYpY7elppN", + "end": 1234567890, + "id": "di_1OPoumJN5vQBdWExC4zKmgo8", + "invoice": null, + "invoice_item": null, + "object": "discount", + "promotion_code": null, + "start": 1234567890, + "subscription": null + }, + "dispute": { + "amount": 1000, + "balance_transactions": [], + "charge": "ch_1OPoueJN5vQBdWExHvNS496R", + "created": 1234567890, + "currency": "usd", + "evidence": { + "access_activity_log": null, + "billing_address": null, + "cancellation_policy": null, + "cancellation_policy_disclosure": null, + "cancellation_rebuttal": null, + "customer_communication": null, + "customer_email_address": null, + "customer_name": null, + "customer_purchase_ip": null, + "customer_signature": null, + "duplicate_charge_documentation": null, + "duplicate_charge_explanation": null, + "duplicate_charge_id": null, + "product_description": null, + "receipt": null, + "refund_policy": null, + "refund_policy_disclosure": null, + "refund_refusal_explanation": null, + "service_date": null, + "service_documentation": null, + "shipping_address": null, + "shipping_carrier": null, + "shipping_date": null, + "shipping_documentation": null, + "shipping_tracking_number": null, + "uncategorized_file": null, + "uncategorized_text": null + }, + "evidence_details": { + "due_by": 1704844799, + "has_evidence": false, + "past_due": false, + "submission_count": 0 + }, + "id": "dp_1OPoujJN5vQBdWExZXzZC5oN", + "is_charge_refundable": true, + "livemode": false, + "metadata": {}, + "object": "dispute", + "payment_intent": null, + "payment_method_details": { + "card": { + "brand": "visa", + "network_reason_code": "10.4" + }, + "type": "card" + }, + "reason": "general", + "status": "warning_needs_response" + }, + "ephemeral_key": { + "created": 1234567890, + "expires": 1234567890, + "id": "ephkey_1OPouuJN5vQBdWExzc5yUxlO", + "livemode": false, + "object": "ephemeral_key" + }, + "event": { + "api_version": null, + "created": 1234567890, + "data": { + "object": { + "active": true, + "aggregate_usage": null, + "amount": 2000, + "amount_decimal": "2000", + "billing_scheme": "per_unit", + "created": 1703175360, + "currency": "usd", + "id": "price_1OPouiJN5vQBdWExAQaqTooZ", + "interval": "month", + "interval_count": 1, + "livemode": false, + "metadata": {}, + "nickname": null, + "object": "plan", + "product": "prod_PEHTfnvdJH6K0k", + "tiers_mode": null, + "transform_usage": null, + "trial_period_days": null, + "usage_type": "licensed" + } + }, + "id": "evt_1OPouqJN5vQBdWExgxCYZfvK", + "livemode": false, + "object": "event", + "pending_webhooks": 0, + "request": { + "id": null, + "idempotency_key": null + }, + "type": "plan.created" + }, + "exchange_rate": { + "id": "rate_7573642d636164", + "object": "exchange_rate", + "rates": {} + }, + "external_account": { + "account_holder_name": "Jane Austen", + "account_holder_type": "individual", + "account_type": null, + "bank_name": "STRIPE TEST BANK", + "country": "US", + "currency": "usd", + "customer": null, + "fingerprint": "1JWtPxqbdX5Gamtz", + "id": "ba_1OPoumJN5vQBdWExwmpTeNeE", + "last4": "6789", + "metadata": {}, + "object": "bank_account", + "routing_number": "110000000", + "status": "new" + }, + "fee_refund": { + "amount": 100, + "balance_transaction": null, + "created": 1234567890, + "currency": "usd", + "fee": "fee_1OPounJN5vQBdWExWgwi95uU", + "id": "fr_1OPouoJN5vQBdWExfoD1ectq", + "metadata": {}, + "object": "fee_refund" + }, + "file": { + "created": 1234567890, + "expires_at": 1234567890, + "filename": "file_1OPouvJN5vQBdWExSL8Knl9d", + "id": "file_1OPouvJN5vQBdWExSL8Knl9d", + "links": { + "data": [ + { + "created": 1705015539, + "expired": false, + "expires_at": null, + "file": "file_1OXXd1D2qP7QtJeGUtVg07y2", + "id": "link_1OXXd1D2qP7QtJeG4PxdkQAI", + "livemode": false, + "metadata": {}, + "object": "file_link", + "url": "https://pakrym-upload-mydev.dev.stripe.me/links/MDB8YWNjdF8xT1hYY1VEMnFQN1F0SmVHfGZsX3Rlc3RfUzNDbHVhMWc0dEJuaWZVTFlQbXVSelhu00rmgafjqm" + }, + { + "created": 1706199800, + "expired": false, + "expires_at": null, + "file": "file_1OcVhzDy8zbvZdAPbMdtICx2", + "id": "link_1OcVi0Dy8zbvZdAPelDMzIr9", + "livemode": false, + "metadata": {}, + "object": "file_link", + "url": "https://pakrym-upload-mydev.dev.stripe.me/links/MDB8YWNjdF8xT2NWaGNEeTh6YnZaZEFQfGZsX3Rlc3RfSzFXUUhwdTVnTzJNcWFBMTVOYWl4ZE8500ozp8ilyy" + }, + { + "created": 1706199799, + "expired": false, + "expires_at": null, + "file": "file_1OcVhzDy8zbvZdAPbMdtICx2", + "id": "link_1OcVhzDy8zbvZdAPamJnikfg", + "livemode": false, + "metadata": {}, + "object": "file_link", + "url": "https://pakrym-upload-mydev.dev.stripe.me/links/MDB8YWNjdF8xT2NWaGNEeTh6YnZaZEFQfGZsX3Rlc3RfRjJLSVNGMTBoR1FmVldGN2JhV0FaeXVz009hUvBCR4" + } + ], + "has_more": false, + "object": "list", + "url": "/v1/file_links?file=file_1OPouvJN5vQBdWExSL8Knl9d" + }, + "object": "file", + "purpose": "dispute_evidence", + "size": 9863, + "title": null, + "type": "png", + "url": "https://pakrym-upload-mydev.dev.stripe.me/v1/files/file_1OPouvJN5vQBdWExSL8Knl9d/contents" + }, + "file_link": { + "created": 1234567890, + "expired": false, + "expires_at": 1234567890, + "file": "file_1OPouvJN5vQBdWExtMnVibvZ", + "id": "link_1OPouvJN5vQBdWEx8Hbtu72Q", + "livemode": false, + "metadata": {}, + "object": "file_link", + "url": "https://pakrym-upload-mydev.dev.stripe.me/links/MDB8YWNjdF8xT1BvdU1KTjV2UUJkV0V4fGZsX3Rlc3RfNkRjY2xBMFA1UlByQ0FiQzRWZk1Hd3B300VOpaJG5C" + }, + "financial_connections.account": { + "account_holder": { + "customer": "cus_PEHTIoPSgT0tXQ", + "type": "customer" + }, + "balance": null, + "balance_refresh": null, + "category": "cash", + "created": 1234567890, + "display_name": "Sample Checking Account", + "id": "fca_1OPouwJN5vQBdWExZJ9BIvU6", + "institution_name": "StripeBank", + "last4": "6789", + "livemode": false, + "object": "financial_connections.account", + "ownership": null, + "ownership_refresh": null, + "permissions": [], + "status": "active", + "subcategory": "checking", + "subscriptions": [], + "supported_payment_method_types": [ + "us_bank_account" + ], + "transaction_refresh": null + }, + "financial_connections.account_owner": { + "email": "nobody+janesmith@stripe.com", + "id": "fcaown_1OPouwJN5vQBdWEx0GENYe0S", + "name": "Jane Smith", + "object": "financial_connections.account_owner", + "ownership": "fcaowns_1OPouwJN5vQBdWExxKE8Bg4J", + "phone": "+1 555-555-5555", + "raw_address": "123 Main Street, Everytown USA", + "refreshed_at": 1234567890 + }, + "financial_connections.session": { + "account_holder": { + "customer": "cus_PEHTIoPSgT0tXQ", + "type": "customer" + }, + "accounts": { + "data": [], + "has_more": false, + "object": "list", + "url": "/v1/financial_connections/accounts" + }, + "client_secret": "fcsess_..._secret_...", + "id": "fcsess_1OPouvJN5vQBdWExDs9PPkmC", + "livemode": false, + "object": "financial_connections.session", + "permissions": [ + "balances", + "payment_method" + ], + "prefetch": [] + }, + "financial_connections.transaction": { + "account": "fca_1OPouwJN5vQBdWExhxva8Q8m", + "amount": 300, + "currency": "usd", + "description": "Rocket Rides", + "id": "fctxn_1OPouwJN5vQBdWExrPGADkLG", + "livemode": false, + "object": "financial_connections.transaction", + "status": "posted", + "status_transitions": { + "posted_at": 1703175374, + "void_at": null + }, + "transacted_at": 1234567890, + "transaction_refresh": "fctxnref_PEHT703aotlKawfHY2I61XWP", + "updated": 1234567890 + }, + "funding_instructions": { + "bank_transfer": { + "country": "DE", + "financial_addresses": [ + { + "iban": { + "account_holder_name": "Stripe Technology Europe Limited", + "bic": "SXPYDEHH", + "country": "DE", + "iban": "DE00000000000000000001" + }, + "supported_networks": [ + "sepa" + ], + "type": "iban" + } + ], + "type": "eu_bank_transfer" + }, + "currency": "eur", + "funding_type": "bank_transfer", + "livemode": false, + "object": "funding_instructions" + }, + "identity.verification_report": { + "created": 1234567890, + "document": { + "address": { + "city": "San Francisco", + "country": "US", + "line1": "1234 Main St.", + "state": "CA", + "zip": "94111" + }, + "error": null, + "expiration_date": { + "day": 1, + "month": 12, + "year": 2025 + }, + "files": [ + "file_PEHTDcVdS1FsitkFp1GIIfBV", + "file_PEHTLEOP6X1X7QoBzeaNVDVV" + ], + "first_name": "Jenny", + "issued_date": { + "day": 1, + "month": 12, + "year": 2020 + }, + "issuing_country": "US", + "last_name": "Rosen", + "status": "verified", + "type": "driving_license" + }, + "id": "vr_1OPouwJN5vQBdWExD3MD40Gc", + "livemode": false, + "object": "identity.verification_report", + "options": { + "document": {}, + "id_number": {} + }, + "type": "document", + "verification_session": "vs_1OPouwJN5vQBdWExbazjv0rx" + }, + "identity.verification_session": { + "client_secret": null, + "created": 1234567890, + "id": "vs_1OPouwJN5vQBdWExwnxAiDeP", + "last_error": null, + "last_verification_report": "vr_PEHTCbeksNcBl9s8mpoBQapA", + "livemode": false, + "metadata": {}, + "object": "identity.verification_session", + "options": { + "document": { + "require_matching_selfie": true + } + }, + "redaction": null, + "status": "verified", + "type": "document", + "url": null + }, + "invoice": { + "account_country": "US", + "account_name": null, + "account_tax_ids": null, + "amount_due": 1000, + "amount_paid": 0, + "amount_remaining": 1000, + "amount_shipping": 0, + "application": null, + "application_fee_amount": null, + "attempt_count": 0, + "attempted": false, + "auto_advance": false, + "automatic_tax": { + "enabled": false, + "liability": null, + "status": null + }, + "billing_reason": "manual", + "charge": null, + "collection_method": "charge_automatically", + "created": 1234567890, + "currency": "usd", + "custom_fields": null, + "customer": "cus_PEHTtYpY7elppN", + "customer_address": null, + "customer_email": null, + "customer_name": null, + "customer_phone": null, + "customer_shipping": null, + "customer_tax_exempt": "none", + "customer_tax_ids": [], + "default_payment_method": null, + "default_source": null, + "default_tax_rates": [], + "description": null, + "discount": null, + "discounts": [], + "due_date": 1234567890, + "effective_at": 1234567890, + "ending_balance": null, + "footer": null, + "from_invoice": null, + "hosted_invoice_url": null, + "id": "in_1OPouhJN5vQBdWExQl3czOuP", + "invoice_pdf": null, + "issuer": { + "type": "self" + }, + "last_finalization_error": null, + "latest_revision": null, + "lines": { + "data": [ + { + "amount": 1000, + "amount_excluding_tax": 1000, + "currency": "usd", + "description": "My First Invoice Item (created for API docs)", + "discount_amounts": [], + "discountable": true, + "discounts": [], + "id": "il_1OPougJN5vQBdWExuj8Ico7Q", + "invoice_item": "ii_1OPougJN5vQBdWExCVUz1PP9", + "livemode": false, + "metadata": {}, + "object": "line_item", + "period": { + "end": 1703175358, + "start": 1703175358 + }, + "price": { + "active": true, + "billing_scheme": "per_unit", + "created": 1703175358, + "currency": "usd", + "custom_unit_amount": null, + "id": "price_1OPougJN5vQBdWEx6kfkXDIL", + "livemode": false, + "lookup_key": null, + "metadata": {}, + "nickname": null, + "object": "price", + "product": "prod_PEHTfnvdJH6K0k", + "recurring": null, + "tax_behavior": "unspecified", + "tiers_mode": null, + "transform_quantity": null, + "type": "one_time", + "unit_amount": 1000, + "unit_amount_decimal": "1000" + }, + "proration": false, + "proration_details": { + "credited_items": null + }, + "quantity": 1, + "subscription": null, + "tax_amounts": [], + "tax_rates": [], + "type": "invoiceitem", + "unit_amount_excluding_tax": "1000" + } + ], + "has_more": false, + "object": "list", + "url": "/v1/invoices/in_1OPouhJN5vQBdWExQl3czOuP/lines" + }, + "livemode": false, + "metadata": {}, + "next_payment_attempt": 1234567890, + "number": null, + "object": "invoice", + "on_behalf_of": null, + "paid": false, + "paid_out_of_band": false, + "payment_intent": null, + "payment_settings": { + "default_mandate": null, + "payment_method_options": null, + "payment_method_types": null + }, + "period_end": 1234567890, + "period_start": 1234567890, + "post_payment_credit_notes_amount": 0, + "pre_payment_credit_notes_amount": 0, + "quote": null, + "receipt_number": null, + "rendering": null, + "shipping_cost": null, + "shipping_details": null, + "starting_balance": 0, + "statement_descriptor": null, + "status": "draft", + "status_transitions": { + "finalized_at": null, + "marked_uncollectible_at": null, + "paid_at": null, + "voided_at": null + }, + "subscription": null, + "subscription_details": { + "metadata": null + }, + "subtotal": 1000, + "subtotal_excluding_tax": 1000, + "tax": null, + "test_clock": null, + "total": 1000, + "total_discount_amounts": [], + "total_excluding_tax": 1000, + "total_tax_amounts": [], + "transfer_data": null, + "webhooks_delivered_at": 1234567890 + }, + "invoiceitem": { + "amount": 1000, + "currency": "usd", + "customer": "cus_PEHTtYpY7elppN", + "date": 1234567890, + "description": "My First Invoice Item (created for API docs)", + "discountable": true, + "discounts": [], + "id": "ii_1OPoulJN5vQBdWExKaAxodMb", + "invoice": null, + "livemode": false, + "metadata": {}, + "object": "invoiceitem", + "period": { + "end": 1703175363, + "start": 1703175363 + }, + "price": { + "active": true, + "billing_scheme": "per_unit", + "created": 1703175358, + "currency": "usd", + "custom_unit_amount": null, + "id": "price_1OPougJN5vQBdWEx6kfkXDIL", + "livemode": false, + "lookup_key": null, + "metadata": {}, + "nickname": null, + "object": "price", + "product": "prod_PEHTfnvdJH6K0k", + "recurring": null, + "tax_behavior": "unspecified", + "tiers_mode": null, + "transform_quantity": null, + "type": "one_time", + "unit_amount": 1000, + "unit_amount_decimal": "1000" + }, + "proration": false, + "quantity": 1, + "subscription": null, + "tax_rates": [], + "test_clock": null, + "unit_amount": 1000, + "unit_amount_decimal": "1000" + }, + "issuing.authorization": { + "amount": 0, + "amount_details": { + "atm_fee": null, + "cashback_amount": null + }, + "approved": true, + "authorization_method": "keyed_in", + "balance_transactions": [], + "card": { + "brand": "Visa", + "cancellation_reason": null, + "cardholder": { + "billing": { + "address": { + "city": "Beverly Hills", + "country": "US", + "line1": "123 Fake St", + "line2": "Apt 3", + "postal_code": "90210", + "state": "CA" + } + }, + "company": null, + "created": 1703175372, + "email": "jenny@example.com", + "id": "ich_1OPouuJN5vQBdWExwzpyb2cp", + "individual": null, + "livemode": false, + "metadata": {}, + "name": "Jenny Rosen", + "object": "issuing.cardholder", + "phone_number": "+18008675309", + "preferred_locales": [ + "en" + ], + "requirements": { + "disabled_reason": null, + "past_due": [] + }, + "spending_controls": { + "allowed_categories": [], + "blocked_categories": [], + "spending_limits": [], + "spending_limits_currency": null + }, + "status": "active", + "type": "individual" + }, + "created": 1703175372, + "currency": "usd", + "exp_month": 8, + "exp_year": 2024, + "id": "ic_1OPouuJN5vQBdWEx2BuUwQc3", + "last4": "4242", + "livemode": false, + "metadata": {}, + "object": "issuing.card", + "replaced_by": null, + "replacement_for": null, + "replacement_reason": null, + "shipping": null, + "spending_controls": { + "allowed_categories": null, + "blocked_categories": null, + "spending_limits": [], + "spending_limits_currency": null + }, + "status": "active", + "type": "physical", + "wallets": { + "apple_pay": { + "eligible": true, + "ineligible_reason": null + }, + "google_pay": { + "eligible": false, + "ineligible_reason": "missing_agreement" + }, + "primary_account_identifier": null + } + }, + "cardholder": null, + "created": 1234567890, + "currency": "usd", + "id": "iauth_1OPouuJN5vQBdWExzEwVqbW3", + "livemode": false, + "merchant_amount": 0, + "merchant_currency": "usd", + "merchant_data": { + "category": "taxicabs_limousines", + "category_code": "4121", + "city": "San Francisco", + "country": "US", + "name": "Rocket Rides", + "network_id": "1234567890", + "postal_code": "94107", + "state": "CA", + "terminal_id": null, + "url": null + }, + "metadata": {}, + "network_data": null, + "object": "issuing.authorization", + "pending_request": { + "amount": 700, + "amount_details": { + "atm_fee": null, + "cashback_amount": null + }, + "currency": "usd", + "is_amount_controllable": false, + "merchant_amount": 700, + "merchant_currency": "usd", + "network_risk_score": null + }, + "request_history": [], + "status": "pending", + "token": null, + "transactions": [], + "verification_data": { + "address_line1_check": "not_provided", + "address_postal_code_check": "match", + "authentication_exemption": null, + "cvc_check": "match", + "expiry_check": "match", + "postal_code": null, + "three_d_secure": { + "result": "authenticated" + } + }, + "wallet": null + }, + "issuing.card": { + "brand": "Visa", + "cancellation_reason": null, + "cardholder": { + "billing": { + "address": { + "city": "Beverly Hills", + "country": "US", + "line1": "123 Fake St", + "line2": "Apt 3", + "postal_code": "90210", + "state": "CA" + } + }, + "company": null, + "created": 1703175372, + "email": "jenny@example.com", + "id": "ich_1OPouuJN5vQBdWExwzpyb2cp", + "individual": null, + "livemode": false, + "metadata": {}, + "name": "Jenny Rosen", + "object": "issuing.cardholder", + "phone_number": "+18008675309", + "preferred_locales": [ + "en" + ], + "requirements": { + "disabled_reason": null, + "past_due": [] + }, + "spending_controls": { + "allowed_categories": [], + "blocked_categories": [], + "spending_limits": [], + "spending_limits_currency": null + }, + "status": "active", + "type": "individual" + }, + "created": 1234567890, + "currency": "usd", + "exp_month": 8, + "exp_year": 2024, + "id": "ic_1OPouuJN5vQBdWExIoXsQoxc", + "last4": "4242", + "livemode": false, + "metadata": {}, + "object": "issuing.card", + "replaced_by": null, + "replacement_for": null, + "replacement_reason": null, + "shipping": null, + "spending_controls": { + "allowed_categories": null, + "blocked_categories": null, + "spending_limits": [], + "spending_limits_currency": null + }, + "status": "active", + "type": "physical", + "wallets": { + "apple_pay": { + "eligible": true, + "ineligible_reason": null + }, + "google_pay": { + "eligible": false, + "ineligible_reason": "missing_agreement" + }, + "primary_account_identifier": null + } + }, + "issuing.cardholder": { + "billing": { + "address": { + "city": "Beverly Hills", + "country": "US", + "line1": "123 Fake St", + "line2": "Apt 3", + "postal_code": "90210", + "state": "CA" + } + }, + "company": null, + "created": 1234567890, + "email": "jenny@example.com", + "id": "ich_1OPouuJN5vQBdWExwzpyb2cp", + "individual": null, + "livemode": false, + "metadata": {}, + "name": "Jenny Rosen", + "object": "issuing.cardholder", + "phone_number": "+18008675309", + "preferred_locales": [ + "en" + ], + "requirements": { + "disabled_reason": null, + "past_due": [] + }, + "spending_controls": { + "allowed_categories": [], + "blocked_categories": [], + "spending_limits": [], + "spending_limits_currency": null + }, + "status": "active", + "type": "individual" + }, + "issuing.dispute": { + "amount": 100, + "created": 1234567890, + "currency": "usd", + "evidence": { + "fraudulent": { + "additional_documentation": null, + "explanation": "Fraud; card reported lost on 12/21/2023" + }, + "reason": "fraudulent" + }, + "id": "idp_1OPouuJN5vQBdWEx0fS3VE9m", + "livemode": false, + "metadata": {}, + "object": "issuing.dispute", + "status": "unsubmitted", + "transaction": "ipi_1OPouuJN5vQBdWExyOINiqR1" + }, + "issuing.settlement": { + "bin": "424242", + "clearing_date": 1703175372, + "created": 1234567890, + "currency": "usd", + "id": "ise_1OPouuJN5vQBdWExUSjMz9xA", + "interchange_fees": 44, + "livemode": false, + "metadata": {}, + "net_total": 3575, + "network": "visa", + "network_fees": 37, + "network_settlement_identifier": "1000633976", + "object": "issuing.settlement", + "settlement_service": "international", + "transaction_count": 2, + "transaction_volume": 3656 + }, + "issuing.token": { + "card": "ic_1OPouuJN5vQBdWExtrIXaPAW", + "created": 1234567890, + "device_fingerprint": null, + "id": "intok_1OPouuJN5vQBdWEx5hqkGy26", + "last4": "2424", + "livemode": false, + "network": "visa", + "network_updated_at": 1234567890, + "object": "issuing.token", + "status": "active", + "wallet_provider": "apple_pay" + }, + "issuing.transaction": { + "amount": -100, + "amount_details": { + "atm_fee": null, + "cashback_amount": null + }, + "authorization": "iauth_1OPouuJN5vQBdWExicfRiUm4", + "balance_transaction": null, + "card": "ic_1OPouuJN5vQBdWExtrIXaPAW", + "cardholder": "ich_1OPouuJN5vQBdWExwzpyb2cp", + "created": 1234567890, + "currency": "usd", + "dispute": null, + "id": "ipi_1OPouuJN5vQBdWEx9u49EzoG", + "livemode": false, + "merchant_amount": -100, + "merchant_currency": "usd", + "merchant_data": { + "category": "taxicabs_limousines", + "category_code": "4121", + "city": "San Francisco", + "country": "US", + "name": "Rocket Rides", + "network_id": "1234567890", + "postal_code": "94107", + "state": "CA", + "terminal_id": null, + "url": null + }, + "metadata": {}, + "network_data": { + "authorization_code": null, + "processing_date": "2023-12-21", + "transaction_id": null + }, + "object": "issuing.transaction", + "token": null, + "type": "capture", + "wallet": "apple_pay" + }, + "item": { + "amount_discount": 0, + "amount_subtotal": 0, + "amount_tax": 0, + "amount_total": 0, + "currency": "usd", + "description": "T-shirt", + "id": "li_1OPoumJN5vQBdWExEftIkrW0", + "object": "item", + "price": { + "active": true, + "billing_scheme": "per_unit", + "created": 1703175358, + "currency": "usd", + "custom_unit_amount": null, + "id": "price_1OPougJN5vQBdWEx6kfkXDIL", + "livemode": false, + "lookup_key": null, + "metadata": {}, + "nickname": null, + "object": "price", + "product": "prod_PEHTfnvdJH6K0k", + "recurring": null, + "tax_behavior": "unspecified", + "tiers_mode": null, + "transform_quantity": null, + "type": "one_time", + "unit_amount": 1000, + "unit_amount_decimal": "1000" + }, + "quantity": 1 + }, + "line_item": { + "amount": 1000, + "amount_excluding_tax": 1000, + "currency": "usd", + "description": "My First Invoice Item (created for API docs)", + "discount_amounts": [], + "discountable": true, + "discounts": [], + "id": "il_tmp_1OPoulJN5vQBdWExKaAxodMb", + "invoice_item": "ii_1OPoulJN5vQBdWExKaAxodMb", + "livemode": false, + "metadata": {}, + "object": "line_item", + "period": { + "end": 1703175363, + "start": 1703175363 + }, + "price": { + "active": true, + "billing_scheme": "per_unit", + "created": 1703175358, + "currency": "usd", + "custom_unit_amount": null, + "id": "price_1OPougJN5vQBdWEx6kfkXDIL", + "livemode": false, + "lookup_key": null, + "metadata": {}, + "nickname": null, + "object": "price", + "product": "prod_PEHTfnvdJH6K0k", + "recurring": null, + "tax_behavior": "unspecified", + "tiers_mode": null, + "transform_quantity": null, + "type": "one_time", + "unit_amount": 1000, + "unit_amount_decimal": "1000" + }, + "proration": false, + "proration_details": { + "credited_items": null + }, + "quantity": 1, + "subscription": null, + "tax_amounts": [], + "tax_rates": [], + "type": "invoiceitem", + "unit_amount_excluding_tax": "1000" + }, + "login_link": { + "created": 1234567890, + "object": "login_link", + "url": "https://pakrym-manage-mydev.dev.stripe.me/express/acct_1OPouMJN5vQBdWEx/KDbirv0KG5kK" + }, + "mandate": { + "customer_acceptance": { + "accepted_at": 123456789, + "online": { + "ip_address": "127.0.0.0", + "user_agent": "device" + }, + "type": "online" + }, + "id": "mandate_1OPoutJN5vQBdWExCvI7QJ24", + "livemode": false, + "multi_use": {}, + "object": "mandate", + "payment_method": "pm_123456789", + "payment_method_details": { + "sepa_debit": { + "reference": "123456789", + "url": "" + }, + "type": "sepa_debit" + }, + "status": "active", + "type": "multi_use" + }, + "payment_intent": { + "amount": 1099, + "amount_capturable": 0, + "amount_details": { + "tip": {} + }, + "amount_received": 0, + "application": null, + "application_fee_amount": null, + "automatic_payment_methods": null, + "canceled_at": 1234567890, + "cancellation_reason": null, + "capture_method": "automatic", + "client_secret": "pi_1OPougJN5vQBdWEx8s2Dj0YR_secret_XeXo8Ee1ITOJzjVWEtPoWG5ha", + "confirmation_method": "automatic", + "created": 1234567890, + "currency": "usd", + "customer": null, + "description": null, + "id": "pi_1OPougJN5vQBdWEx8s2Dj0YR", + "invoice": null, + "last_payment_error": null, + "latest_charge": null, + "livemode": false, + "metadata": {}, + "next_action": null, + "object": "payment_intent", + "on_behalf_of": null, + "payment_method": null, + "payment_method_configuration_details": null, + "payment_method_options": {}, + "payment_method_types": [ + "card" + ], + "processing": null, + "receipt_email": null, + "review": null, + "setup_future_usage": null, + "shipping": null, + "statement_descriptor": null, + "statement_descriptor_suffix": null, + "status": "requires_payment_method", + "transfer_data": null, + "transfer_group": null + }, + "payment_link": { + "active": true, + "after_completion": { + "hosted_confirmation": { + "custom_message": null + }, + "type": "hosted_confirmation" + }, + "allow_promotion_codes": false, + "application": null, + "application_fee_amount": null, + "application_fee_percent": null, + "automatic_tax": { + "enabled": false, + "liability": null + }, + "billing_address_collection": "auto", + "consent_collection": null, + "currency": "usd", + "custom_fields": [], + "custom_text": { + "after_submit": null, + "shipping_address": null, + "submit": null, + "terms_of_service_acceptance": null + }, + "customer_creation": "if_required", + "id": "plink_1OPoutJN5vQBdWExHKI59Qwy", + "inactive_message": null, + "invoice_creation": null, + "livemode": false, + "metadata": {}, + "object": "payment_link", + "on_behalf_of": null, + "payment_intent_data": null, + "payment_method_collection": "if_required", + "payment_method_types": null, + "phone_number_collection": { + "enabled": false + }, + "restrictions": null, + "shipping_address_collection": null, + "shipping_options": [], + "submit_type": "auto", + "subscription_data": null, + "tax_id_collection": { + "enabled": false + }, + "transfer_data": null, + "url": "https://pakrym-payment_links_ingress-mydev.dev.stripe.me/test_4gw3eYbvN3ixabe6oo" + }, + "payment_method": { + "billing_details": { + "address": { + "city": "San Francisco", + "country": "US", + "line1": "1234 Fake Street", + "line2": null, + "postal_code": "94102", + "state": "CA" + }, + "email": "jenny@example.com", + "name": null, + "phone": "+15555555555" + }, + "card": { + "brand": "visa", + "checks": { + "address_line1_check": null, + "address_postal_code_check": null, + "cvc_check": "pass" + }, + "country": "US", + "exp_month": 8, + "exp_year": 2024, + "fingerprint": "r40d4vOgg3VecDJF", + "funding": "credit", + "generated_from": null, + "last4": "4242", + "networks": { + "available": [ + "visa" + ], + "preferred": null + }, + "three_d_secure_usage": { + "supported": true + }, + "wallet": null + }, + "created": 1234567890, + "customer": null, + "id": "pm_1OPoukJN5vQBdWEx0hPok3pj", + "livemode": false, + "metadata": { + "order_id": "123456789" + }, + "object": "payment_method", + "type": "card" + }, + "payment_method_configuration": { + "acss_debit": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + }, + "active": true, + "affirm": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + }, + "afterpay_clearpay": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + }, + "alipay": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + }, + "apple_pay": { + "available": true, + "display_preference": { + "overridable": null, + "preference": "on", + "value": "on" + } + }, + "application": null, + "bancontact": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + }, + "blik": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + }, + "card": { + "available": true, + "display_preference": { + "overridable": null, + "preference": "on", + "value": "on" + } + }, + "cartes_bancaires": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + }, + "cashapp": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + }, + "customer_balance": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + }, + "eps": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + }, + "giropay": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + }, + "google_pay": { + "available": true, + "display_preference": { + "overridable": null, + "preference": "on", + "value": "on" + } + }, + "id": "pmc_1OPouxJN5vQBdWExE4OpJOVG", + "ideal": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + }, + "is_default": true, + "klarna": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + }, + "link": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + }, + "livemode": false, + "name": "Default", + "object": "payment_method_configuration", + "p24": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + }, + "parent": null, + "sepa_debit": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + }, + "sofort": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + }, + "us_bank_account": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + }, + "wechat_pay": { + "available": false, + "display_preference": { + "overridable": null, + "preference": "off", + "value": "off" + } + } + }, + "payment_method_domain": { + "apple_pay": { + "status": "active" + }, + "created": 1234567890, + "domain_name": "example.com", + "enabled": true, + "google_pay": { + "status": "active" + }, + "id": "pmd_1OPouyJN5vQBdWExgldeVH07", + "link": { + "status": "active" + }, + "livemode": false, + "object": "payment_method_domain", + "paypal": { + "status": "active" + } + }, + "payment_source": { + "business_profile": { + "annual_revenue": null, + "estimated_worker_count": null, + "mcc": null, + "name": null, + "product_description": null, + "support_address": null, + "support_email": null, + "support_phone": null, + "support_url": null, + "url": null + }, + "business_type": null, + "capabilities": { + "card_payments": "active", + "transfers": "active" + }, + "charges_enabled": false, + "controller": { + "type": "account" + }, + "country": "US", + "created": 1703175339, + "default_currency": "usd", + "details_submitted": false, + "email": "site@stripe.com", + "external_accounts": { + "data": [], + "has_more": false, + "object": "list", + "url": "/v1/accounts/acct_1OPouMJN5vQBdWEx/external_accounts" + }, + "future_requirements": { + "alternatives": [], + "current_deadline": null, + "currently_due": [], + "disabled_reason": null, + "errors": [], + "eventually_due": [], + "past_due": [], + "pending_verification": [] + }, + "id": "acct_1OPouMJN5vQBdWEx", + "metadata": {}, + "object": "account", + "payouts_enabled": false, + "requirements": { + "alternatives": [], + "current_deadline": null, + "currently_due": [ + "business_profile.product_description", + "business_profile.support_phone", + "business_profile.url", + "external_account", + "tos_acceptance.date", + "tos_acceptance.ip" + ], + "disabled_reason": "requirements.past_due", + "errors": [], + "eventually_due": [ + "business_profile.product_description", + "business_profile.support_phone", + "business_profile.url", + "external_account", + "tos_acceptance.date", + "tos_acceptance.ip" + ], + "past_due": [], + "pending_verification": [] + }, + "settings": { + "bacs_debit_payments": { + "display_name": null, + "service_user_number": null + }, + "branding": { + "icon": null, + "logo": null, + "primary_color": null, + "secondary_color": null + }, + "card_issuing": { + "tos_acceptance": { + "date": null, + "ip": null + } + }, + "card_payments": { + "decline_on": { + "avs_failure": true, + "cvc_failure": true + }, + "statement_descriptor_prefix": null, + "statement_descriptor_prefix_kana": null, + "statement_descriptor_prefix_kanji": null + }, + "dashboard": { + "display_name": null, + "timezone": "Etc/UTC" + }, + "payments": { + "statement_descriptor": null, + "statement_descriptor_kana": null, + "statement_descriptor_kanji": null + }, + "payouts": { + "debit_negative_balances": true, + "schedule": { + "delay_days": 2, + "interval": "daily" + }, + "statement_descriptor": null + }, + "sepa_debit_payments": {} + }, + "tos_acceptance": { + "date": null, + "ip": null, + "user_agent": null + }, + "type": "standard" + }, + "payout": { + "amount": 1100, + "arrival_date": 1234567890, + "automatic": true, + "balance_transaction": "txn_1OPoueJN5vQBdWEx8dhHMVqh", + "created": 1234567890, + "currency": "usd", + "description": "STRIPE PAYOUT", + "destination": "ba_1OPounJN5vQBdWExpcDZWbix", + "failure_balance_transaction": null, + "failure_code": null, + "failure_message": null, + "id": "po_1OPounJN5vQBdWExyK5eT2UD", + "livemode": false, + "metadata": {}, + "method": "standard", + "object": "payout", + "original_payout": null, + "reconciliation_status": "completed", + "reversed_by": null, + "source_type": "card", + "statement_descriptor": null, + "status": "in_transit", + "type": "bank_account" + }, + "person": { + "account": "acct_1OPouMJN5vQBdWEx", + "additional_tos_acceptances": { + "account": { + "date": null, + "ip": null, + "user_agent": null + } + }, + "created": 1234567890, + "dob": { + "day": null, + "month": null, + "year": null + }, + "first_name": null, + "future_requirements": { + "alternatives": [], + "currently_due": [], + "errors": [], + "eventually_due": [], + "past_due": [], + "pending_verification": [] + }, + "id": "person_1OPouvJN5vQBdWEx4ogP6Lfq", + "id_number_provided": false, + "last_name": null, + "metadata": {}, + "object": "person", + "relationship": { + "director": false, + "executive": false, + "legal_guardian": false, + "owner": false, + "percent_ownership": null, + "representative": false, + "title": null + }, + "requirements": { + "alternatives": [], + "currently_due": [], + "errors": [], + "eventually_due": [], + "past_due": [], + "pending_verification": [] + }, + "ssn_last_4_provided": false, + "verification": { + "additional_document": { + "back": null, + "details": null, + "details_code": null, + "front": null + }, + "details": null, + "details_code": null, + "document": { + "back": null, + "details": null, + "details_code": null, + "front": null + }, + "status": "unverified" + } + }, + "plan": { + "active": true, + "aggregate_usage": null, + "amount": 2000, + "amount_decimal": "2000", + "billing_scheme": "per_unit", + "created": 1234567890, + "currency": "usd", + "id": "price_1OPouiJN5vQBdWExAQaqTooZ", + "interval": "month", + "interval_count": 1, + "livemode": false, + "metadata": {}, + "nickname": null, + "object": "plan", + "product": "prod_PEHTfnvdJH6K0k", + "tiers_mode": null, + "transform_usage": null, + "trial_period_days": null, + "usage_type": "licensed" + }, + "price": { + "active": true, + "billing_scheme": "per_unit", + "created": 1234567890, + "currency": "usd", + "custom_unit_amount": null, + "id": "price_1OPouiJN5vQBdWExAQaqTooZ", + "livemode": false, + "lookup_key": null, + "metadata": {}, + "nickname": null, + "object": "price", + "product": "prod_PEHTfnvdJH6K0k", + "recurring": { + "aggregate_usage": null, + "interval": "month", + "interval_count": 1, + "usage_type": "licensed" + }, + "tax_behavior": "unspecified", + "tiers_mode": null, + "transform_quantity": null, + "type": "recurring", + "unit_amount": 2000, + "unit_amount_decimal": "2000" + }, + "product": { + "active": true, + "created": 1234567890, + "default_price": "price_1OPougJN5vQBdWExAuB7D8i5", + "description": "Comfortable gray cotton t-shirt", + "features": [], + "id": "prod_PEHTfnvdJH6K0k", + "images": [], + "livemode": false, + "metadata": {}, + "name": "T-shirt", + "object": "product", + "package_dimensions": null, + "shippable": null, + "statement_descriptor": null, + "tax_code": null, + "unit_label": null, + "updated": 1234567890, + "url": null + }, + "promotion_code": { + "active": false, + "code": "FALL20", + "coupon": { + "amount_off": null, + "created": 1703175364, + "currency": "usd", + "duration": "repeating", + "duration_in_months": 3, + "id": "Z4OV52SU", + "livemode": false, + "max_redemptions": null, + "metadata": {}, + "name": "25.5% off", + "object": "coupon", + "percent_off": 25.5, + "redeem_by": null, + "times_redeemed": 0, + "valid": true + }, + "created": 1234567890, + "customer": null, + "expires_at": 1234567890, + "id": "promo_1OPoumJN5vQBdWExho5DMMcC", + "livemode": false, + "max_redemptions": null, + "metadata": {}, + "object": "promotion_code", + "restrictions": { + "first_time_transaction": false, + "minimum_amount": null, + "minimum_amount_currency": null + }, + "times_redeemed": 0 + }, + "quote": { + "amount_subtotal": 0, + "amount_total": 0, + "application": null, + "application_fee_amount": null, + "application_fee_percent": null, + "automatic_tax": { + "enabled": false, + "liability": null, + "status": null + }, + "collection_method": "charge_automatically", + "computed": { + "recurring": null, + "upfront": { + "amount_subtotal": 0, + "amount_total": 0, + "total_details": { + "amount_discount": 0, + "amount_shipping": 0, + "amount_tax": 0 + } + } + }, + "created": 1234567890, + "currency": "usd", + "customer": "cus_PEHTIoPSgT0tXQ", + "default_tax_rates": [], + "description": null, + "discounts": [], + "expires_at": 1234567890, + "footer": null, + "from_quote": null, + "header": null, + "id": "qt_1OPoumJN5vQBdWExJFNWX8UZ", + "invoice": null, + "invoice_settings": { + "days_until_due": null, + "issuer": { + "type": "self" + } + }, + "livemode": false, + "metadata": {}, + "number": null, + "object": "quote", + "on_behalf_of": null, + "status": "draft", + "status_transitions": { + "accepted_at": null, + "canceled_at": null, + "finalized_at": null + }, + "subscription": null, + "subscription_data": { + "description": null, + "effective_date": null, + "metadata": null, + "trial_period_days": null + }, + "subscription_schedule": null, + "test_clock": null, + "total_details": { + "amount_discount": 0, + "amount_shipping": 0, + "amount_tax": 0 + }, + "transfer_data": null + }, + "radar.early_fraud_warning": { + "actionable": true, + "charge": "ch_1234", + "created": 1234567890, + "fraud_type": "misc", + "id": "issfr_1OPouuJN5vQBdWEx1nfPQnik", + "livemode": false, + "object": "radar.early_fraud_warning" + }, + "radar.value_list": { + "alias": "custom_ip_blocklist", + "created": 1234567890, + "created_by": "jenny@example.com", + "id": "rsl_1OPouuJN5vQBdWExWiMNdstK", + "item_type": "ip_address", + "list_items": { + "data": [], + "has_more": false, + "object": "list", + "url": "/v1/radar/value_list_items?value_list=rsl_1OPouuJN5vQBdWExWiMNdstK" + }, + "livemode": false, + "metadata": {}, + "name": "Custom IP Blocklist", + "object": "radar.value_list" + }, + "radar.value_list_item": { + "created": 1234567890, + "created_by": "jenny@example.com", + "id": "rsli_1OPouuJN5vQBdWExu3DMfSOX", + "livemode": false, + "object": "radar.value_list_item", + "value": "1.2.3.4", + "value_list": "rsl_1OPouuJN5vQBdWExHVJyCl0n" + }, + "refund": { + "amount": 100, + "balance_transaction": null, + "charge": "ch_1OPoueJN5vQBdWEx5AWizjSY", + "created": 1234567890, + "currency": "usd", + "destination_details": { + "card": { + "type": "reversal" + }, + "type": "card" + }, + "id": "re_1OPoujJN5vQBdWExUGBANu1j", + "metadata": {}, + "object": "refund", + "payment_intent": null, + "reason": null, + "receipt_number": null, + "source_transfer_reversal": null, + "status": "succeeded", + "transfer_reversal": null + }, + "reporting.report_run": { + "created": 1234567890, + "error": null, + "id": "frr_1OPouvJN5vQBdWExgodnLu30", + "livemode": true, + "object": "reporting.report_run", + "parameters": { + "interval_end": 1525132800, + "interval_start": 1522540800 + }, + "report_type": "balance.summary.1", + "result": { + "created": 1703175373, + "expires_at": 1734711373, + "filename": "file_1OPouvJN5vQBdWExuXVAIkHb", + "id": "file_1OPouvJN5vQBdWExuXVAIkHb", + "links": { + "data": [], + "has_more": false, + "object": "list", + "url": "/v1/file_links?file=file_1OPouvJN5vQBdWExuXVAIkHb" + }, + "object": "file", + "purpose": "finance_report_run", + "size": 16890, + "title": null, + "type": "csv", + "url": "https://pakrym-upload-mydev.dev.stripe.me/v1/files/file_1OPouvJN5vQBdWExuXVAIkHb/contents" + }, + "status": "succeeded", + "succeeded_at": 1234567890 + }, + "reporting.report_type": { + "data_available_end": 1234567890, + "data_available_start": 1234567890, + "default_columns": [ + "category", + "currency", + "description", + "net_amount" + ], + "id": "balance.summary.1", + "livemode": true, + "name": "Balance summary", + "object": "reporting.report_type", + "updated": 1234567890, + "version": 1 + }, + "review": { + "billing_zip": null, + "charge": "ch_1OPoueJN5vQBdWExHvNS496R", + "closed_reason": null, + "created": 1234567890, + "id": "prv_1OPouuJN5vQBdWExaP70CbXQ", + "ip_address": null, + "ip_address_location": null, + "livemode": false, + "object": "review", + "open": true, + "opened_reason": "rule", + "reason": "rule", + "session": null + }, + "scheduled_query_run": { + "created": 1234567890, + "data_load_time": 1234567890, + "file": { + "created": 1703175372, + "expires_at": null, + "filename": "path", + "id": "file_1OPouuJN5vQBdWExlKaWjdjo", + "links": { + "data": [], + "has_more": false, + "object": "list", + "url": "/v1/file_links?file=file_1OPouuJN5vQBdWExlKaWjdjo" + }, + "object": "file", + "purpose": "sigma_scheduled_query", + "size": 500, + "title": null, + "type": "csv", + "url": "https://pakrym-upload-mydev.dev.stripe.me/v1/files/file_1OPouuJN5vQBdWExlKaWjdjo/contents" + }, + "id": "sqr_1OPouvJN5vQBdWExYriJptnl", + "livemode": false, + "object": "scheduled_query_run", + "result_available_until": 1234567890, + "sql": "SELECT count(*) from charges", + "status": "completed", + "title": "Count all charges" + }, + "setup_attempt": { + "application": null, + "created": 1234567890, + "customer": null, + "flow_directions": null, + "id": "setatt_123456789012345678901234", + "livemode": false, + "object": "setup_attempt", + "on_behalf_of": null, + "payment_method": "card_1OPoudJN5vQBdWExSTD9mIPF", + "payment_method_details": { + "card": { + "brand": null, + "checks": null, + "country": null, + "exp_month": null, + "exp_year": null, + "fingerprint": null, + "funding": null, + "last4": null, + "network": null, + "three_d_secure": null, + "wallet": null + }, + "type": "card" + }, + "setup_error": null, + "setup_intent": "seti_1OPoutJN5vQBdWExijPulwWI", + "status": "succeeded", + "usage": "off_session" + }, + "setup_intent": { + "application": null, + "automatic_payment_methods": null, + "cancellation_reason": null, + "client_secret": "seti_1OPoutJN5vQBdWExijPulwWI_secret_PEHTJ4I4FBJxR6sDa0HTdK98RaYgSSc", + "created": 1234567890, + "customer": null, + "description": null, + "flow_directions": null, + "id": "seti_1OPoutJN5vQBdWExijPulwWI", + "last_setup_error": null, + "latest_attempt": null, + "livemode": false, + "mandate": null, + "metadata": {}, + "next_action": null, + "object": "setup_intent", + "on_behalf_of": null, + "payment_method": null, + "payment_method_configuration_details": null, + "payment_method_options": {}, + "payment_method_types": [ + "card" + ], + "single_use_mandate": null, + "status": "requires_payment_method", + "usage": "off_session" + }, + "shipping_rate": { + "active": true, + "created": 1234567890, + "delivery_estimate": null, + "display_name": "Ground shipping", + "fixed_amount": { + "amount": 500, + "currency": "usd" + }, + "id": "shr_1OPoutJN5vQBdWExTw0yZ1uf", + "livemode": false, + "metadata": {}, + "object": "shipping_rate", + "tax_behavior": "unspecified", + "tax_code": null, + "type": "fixed_amount" + }, + "source": { + "ach_credit_transfer": { + "account_number": "test_52796e3294dc", + "bank_name": "TEST BANK", + "fingerprint": "ecpwEzmBOSMOqQTL", + "routing_number": "110000000", + "swift_code": "TSTEZ122" + }, + "amount": null, + "client_secret": "src_client_secret_YKwbc23bbUEBnMfgjAmYdnp0", + "created": 1234567890, + "currency": "usd", + "flow": "receiver", + "id": "src_1OPoumJN5vQBdWExvde7Hv2e", + "livemode": false, + "metadata": {}, + "object": "source", + "owner": { + "address": null, + "email": "jenny.rosen@example.com", + "name": null, + "phone": null, + "verified_address": null, + "verified_email": null, + "verified_name": null, + "verified_phone": null + }, + "receiver": { + "address": "121042882-38381234567890123", + "amount_charged": 0, + "amount_received": 0, + "amount_returned": 0, + "refund_attributes_method": "email", + "refund_attributes_status": "missing" + }, + "statement_descriptor": null, + "status": "pending", + "type": "ach_credit_transfer", + "usage": "reusable" + }, + "source_mandate_notification": { + "amount": 2000, + "created": 1234567890, + "id": "srcmn_1OPoutJN5vQBdWExUwb0XtbS", + "livemode": false, + "object": "source_mandate_notification", + "reason": "debit_initiated", + "sepa_debit": { + "creditor_identifier": "TEST42ZZZ0000424242", + "last4": "3000", + "mandate_reference": "FFU45BAKH9LWLMM0" + }, + "source": { + "ach_credit_transfer": { + "account_number": "test_52796e3294dc", + "bank_name": "TEST BANK", + "fingerprint": "ecpwEzmBOSMOqQTL", + "routing_number": "110000000", + "swift_code": "TSTEZ122" + }, + "amount": null, + "client_secret": "src_client_secret_C1TZo7pymZMnlKUlzG3197O1", + "created": 1703175371, + "currency": "usd", + "flow": "receiver", + "id": "src_1OPoutJN5vQBdWEx9IQfUhAI", + "livemode": false, + "metadata": {}, + "object": "source", + "owner": { + "address": null, + "email": "jenny.rosen@example.com", + "name": null, + "phone": null, + "verified_address": null, + "verified_email": null, + "verified_name": null, + "verified_phone": null + }, + "receiver": { + "address": "121042882-38381234567890123", + "amount_charged": 0, + "amount_received": 0, + "amount_returned": 0, + "refund_attributes_method": "email", + "refund_attributes_status": "missing" + }, + "statement_descriptor": null, + "status": "pending", + "type": "ach_credit_transfer", + "usage": "reusable" + }, + "status": "submitted", + "type": "sepa_debit" + }, + "source_transaction": { + "ach_credit_transfer": {}, + "amount": 500, + "created": 1234567890, + "currency": "usd", + "id": "srctxn_1OPoutJN5vQBdWExDm1bbE6Z", + "livemode": false, + "object": "source_transaction", + "source": "src_1OPoumJN5vQBdWExvde7Hv2e", + "status": "succeeded", + "type": "ach_credit_transfer" + }, + "subscription": { + "application": null, + "application_fee_percent": null, + "automatic_tax": { + "enabled": false, + "liability": null + }, + "billing_cycle_anchor": 1234567890, + "billing_cycle_anchor_config": null, + "billing_thresholds": null, + "cancel_at": 1234567890, + "cancel_at_period_end": false, + "canceled_at": 1234567890, + "cancellation_details": { + "comment": null, + "feedback": null, + "reason": null + }, + "collection_method": "charge_automatically", + "created": 1234567890, + "currency": "usd", + "current_period_end": 1234567890, + "current_period_start": 1234567890, + "customer": "cus_PEHTIoPSgT0tXQ", + "days_until_due": null, + "default_payment_method": null, + "default_source": null, + "default_tax_rates": [], + "description": null, + "discount": null, + "ended_at": 1234567890, + "id": "sub_1OPouiJN5vQBdWExOgfg6t5C", + "items": { + "data": [ + { + "billing_thresholds": null, + "created": 1703175361, + "id": "si_PEHTru8PmLRCo3", + "metadata": {}, + "object": "subscription_item", + "price": { + "active": true, + "billing_scheme": "per_unit", + "created": 1703175360, + "currency": "usd", + "custom_unit_amount": null, + "id": "price_1OPouiJN5vQBdWExAQaqTooZ", + "livemode": false, + "lookup_key": null, + "metadata": {}, + "nickname": null, + "object": "price", + "product": "prod_PEHTfnvdJH6K0k", + "recurring": { + "aggregate_usage": null, + "interval": "month", + "interval_count": 1, + "usage_type": "licensed" + }, + "tax_behavior": "unspecified", + "tiers_mode": null, + "transform_quantity": null, + "type": "recurring", + "unit_amount": 2000, + "unit_amount_decimal": "2000" + }, + "quantity": 1, + "subscription": "sub_1OPouiJN5vQBdWExOgfg6t5C", + "tax_rates": [] + } + ], + "has_more": false, + "object": "list", + "url": "/v1/subscription_items?subscription=sub_1OPouiJN5vQBdWExOgfg6t5C" + }, + "latest_invoice": null, + "livemode": false, + "metadata": {}, + "next_pending_invoice_item_invoice": 1234567890, + "object": "subscription", + "on_behalf_of": null, + "pause_collection": null, + "payment_settings": { + "payment_method_options": null, + "payment_method_types": null, + "save_default_payment_method": null + }, + "pending_invoice_item_interval": null, + "pending_setup_intent": null, + "pending_update": null, + "schedule": null, + "start_date": 1234567890, + "status": "active", + "test_clock": null, + "transfer_data": null, + "trial_end": 1234567890, + "trial_settings": { + "end_behavior": { + "missing_payment_method": "create_invoice" + } + }, + "trial_start": 1234567890 + }, + "subscription_item": { + "billing_thresholds": null, + "created": 1703175363, + "id": "si_PEHTIbRiA7RW9V", + "metadata": {}, + "object": "subscription_item", + "price": { + "active": true, + "billing_scheme": "per_unit", + "created": 1703175360, + "currency": "usd", + "custom_unit_amount": null, + "id": "price_1OPouiJN5vQBdWExAQaqTooZ", + "livemode": false, + "lookup_key": null, + "metadata": {}, + "nickname": null, + "object": "price", + "product": "prod_PEHTfnvdJH6K0k", + "recurring": { + "aggregate_usage": null, + "interval": "month", + "interval_count": 1, + "usage_type": "licensed" + }, + "tax_behavior": "unspecified", + "tiers_mode": null, + "transform_quantity": null, + "type": "recurring", + "unit_amount": 2000, + "unit_amount_decimal": "2000" + }, + "quantity": 1, + "subscription": "sub_1OPoulJN5vQBdWExmDmopkQy", + "tax_rates": [] + }, + "subscription_schedule": { + "application": null, + "canceled_at": 1234567890, + "completed_at": 1234567890, + "created": 1234567890, + "current_phase": null, + "customer": "cus_PEHTtYpY7elppN", + "default_settings": { + "application_fee_percent": null, + "automatic_tax": { + "enabled": false, + "liability": null + }, + "billing_cycle_anchor": "automatic", + "billing_thresholds": null, + "collection_method": "charge_automatically", + "default_payment_method": null, + "description": null, + "invoice_settings": { + "days_until_due": null, + "issuer": { + "type": "self" + } + }, + "on_behalf_of": null, + "transfer_data": null + }, + "end_behavior": "release", + "id": "sub_sched_1OPoulJN5vQBdWEx2v9mIBvO", + "livemode": false, + "metadata": {}, + "object": "subscription_schedule", + "phases": [ + { + "add_invoice_items": [], + "application_fee_percent": null, + "billing_cycle_anchor": null, + "billing_thresholds": null, + "collection_method": null, + "coupon": null, + "currency": "usd", + "default_payment_method": null, + "default_tax_rates": [], + "description": null, + "end_date": 1735229763, + "invoice_settings": null, + "items": [ + { + "billing_thresholds": null, + "metadata": {}, + "price": "price_1OPouiJN5vQBdWExAQaqTooZ", + "quantity": 1, + "tax_rates": [] + } + ], + "metadata": {}, + "on_behalf_of": null, + "proration_behavior": "create_prorations", + "start_date": 1703780163, + "transfer_data": null, + "trial_end": null + } + ], + "released_at": 1234567890, + "released_subscription": null, + "status": "not_started", + "subscription": null, + "test_clock": null + }, + "tax.calculation": { + "amount_total": 1947, + "currency": "usd", + "customer": null, + "customer_details": { + "address": { + "city": "South San Francisco", + "country": "US", + "line1": "354 Oyster Point Blvd", + "line2": "", + "postal_code": "94080", + "state": "CA" + }, + "address_source": "shipping", + "ip_address": null, + "tax_ids": [], + "taxability_override": "none" + }, + "expires_at": 1234567890, + "id": "taxcalc_1OPouwJN5vQBdWExxLiHCl2k", + "livemode": false, + "object": "tax.calculation", + "shipping_cost": { + "amount": 300, + "amount_tax": 0, + "tax_behavior": "exclusive", + "tax_code": "txcd_92010001" + }, + "tax_amount_exclusive": 148, + "tax_amount_inclusive": 0, + "tax_breakdown": [ + { + "amount": 148, + "inclusive": false, + "tax_rate_details": { + "country": "US", + "percentage_decimal": "9.875", + "state": "CA", + "tax_type": "sales_tax" + }, + "taxability_reason": "standard_rated", + "taxable_amount": 1499 + }, + { + "amount": 0, + "inclusive": false, + "tax_rate_details": { + "country": "US", + "percentage_decimal": "0.0", + "state": "CA", + "tax_type": "sales_tax" + }, + "taxability_reason": "product_exempt", + "taxable_amount": 0 + } + ], + "tax_date": 1234567890 + }, + "tax.calculation_line_item": { + "amount": 1499, + "amount_tax": 148, + "id": "tax_li_PEHTRKid3aAj4P", + "livemode": false, + "object": "tax.calculation_line_item", + "product": null, + "quantity": 1, + "reference": "Pepperoni Pizza", + "tax_behavior": "exclusive", + "tax_code": "txcd_40060003" + }, + "tax.registration": { + "active_from": 1234567890, + "country": "US", + "country_options": { + "us": { + "state": "CA", + "type": "state_sales_tax" + } + }, + "created": 1234567890, + "expires_at": 1234567890, + "id": "taxreg_PEHTqoThMP4gyv", + "livemode": false, + "object": "tax.registration", + "status": "active" + }, + "tax.settings": { + "defaults": { + "tax_behavior": null, + "tax_code": "txcd_10000000" + }, + "head_office": { + "address": { + "city": null, + "country": "US", + "line1": null, + "line2": null, + "postal_code": null, + "state": "CA" + } + }, + "livemode": false, + "object": "tax.settings", + "status": "active", + "status_details": { + "active": {} + } + }, + "tax.transaction": { + "created": 1234567890, + "currency": "usd", + "customer": null, + "customer_details": { + "address": { + "city": "South San Francisco", + "country": "US", + "line1": "354 Oyster Point Blvd", + "line2": "", + "postal_code": "94080", + "state": "CA" + }, + "address_source": "shipping", + "ip_address": null, + "tax_ids": [], + "taxability_override": "none" + }, + "id": "tax_1OPouwJN5vQBdWExb4Vlgfcu", + "line_items": { + "data": [ + { + "amount": 1499, + "amount_tax": 148, + "id": "tax_li_PEHTRKid3aAj4P", + "livemode": false, + "metadata": null, + "object": "tax.transaction_line_item", + "product": null, + "quantity": 1, + "reference": "Pepperoni Pizza", + "reversal": null, + "tax_behavior": "exclusive", + "tax_code": "txcd_40060003", + "type": "transaction" + } + ], + "has_more": false, + "object": "list", + "url": "/v1/tax/transactions/tax_1OPouwJN5vQBdWExb4Vlgfcu/line_items" + }, + "livemode": false, + "metadata": null, + "object": "tax.transaction", + "reference": "myOrder_123", + "reversal": null, + "shipping_cost": { + "amount": 300, + "amount_tax": 0, + "tax_behavior": "exclusive", + "tax_code": "txcd_92010001" + }, + "tax_date": 1234567890, + "type": "transaction" + }, + "tax.transaction_line_item": { + "amount": 1499, + "amount_tax": 148, + "id": "tax_li_PEHTRKid3aAj4P", + "livemode": false, + "metadata": null, + "object": "tax.transaction_line_item", + "product": null, + "quantity": 1, + "reference": "Pepperoni Pizza", + "reversal": null, + "tax_behavior": "exclusive", + "tax_code": "txcd_40060003", + "type": "transaction" + }, + "tax_code": { + "description": "A physical good that can be moved or touched. Also known as tangible personal property.", + "id": "txcd_99999999", + "name": "General - Tangible Goods", + "object": "tax_code" + }, + "tax_id": { + "country": "DE", + "created": 1234567890, + "customer": "cus_PEHTIoPSgT0tXQ", + "id": "txi_1OPouvJN5vQBdWExlr1piCRz", + "livemode": false, + "object": "tax_id", + "type": "eu_vat", + "value": "DE123456789", + "verification": { + "status": "pending", + "verified_address": null, + "verified_name": null + } + }, + "tax_rate": { + "active": true, + "country": "DE", + "created": 1234567890, + "description": "VAT Germany", + "display_name": "VAT", + "effective_percentage": null, + "id": "txr_1OPoulJN5vQBdWExFxem94NU", + "inclusive": false, + "jurisdiction": "DE", + "livemode": false, + "metadata": {}, + "object": "tax_rate", + "percentage": 19, + "state": null, + "tax_type": "vat" + }, + "terminal.configuration": { + "bbpos_wisepos_e": { + "splashscreen": "file_1OPouuJN5vQBdWExsQRSvk0Q" + }, + "id": "tmc_ElVUAjF8xXG3hj", + "is_account_default": false, + "livemode": false, + "object": "terminal.configuration" + }, + "terminal.connection_token": { + "object": "terminal.connection_token", + "secret": "pst_test_EYaaCPF2R8lL8NK17UlpFtp" + }, + "terminal.location": { + "address": { + "city": "San Francisco", + "country": "US", + "line1": "1234 Fake Street", + "line2": null, + "postal_code": "94102", + "state": "CA" + }, + "display_name": "My First Store", + "id": "tml_NGBMEGFknv9VbAajaGp51lDl", + "livemode": false, + "metadata": {}, + "object": "terminal.location" + }, + "terminal.reader": { + "action": null, + "device_sw_version": null, + "device_type": "bbpos_wisepos_e", + "id": "tmr_BKknTibEn0JgG9fJJXUV93Wy", + "ip_address": "192.168.2.2", + "label": "Blue Rabbit", + "livemode": false, + "location": null, + "metadata": {}, + "object": "terminal.reader", + "serial_number": "123-456-789", + "status": "online" + }, + "test_helpers.test_clock": { + "created": 1234567890, + "deletes_after": 1234567890, + "frozen_time": 1234567890, + "id": "clock_1OPoumJN5vQBdWEx6P81PQHY", + "livemode": false, + "name": null, + "object": "test_helpers.test_clock", + "status": "ready" + }, + "token": { + "card": { + "address_city": null, + "address_country": null, + "address_line1": null, + "address_line1_check": null, + "address_line2": null, + "address_state": null, + "address_zip": null, + "address_zip_check": null, + "brand": "Visa", + "country": "US", + "cvc_check": "pass", + "dynamic_last4": null, + "exp_month": 8, + "exp_year": 2024, + "fingerprint": "r40d4vOgg3VecDJF", + "funding": "credit", + "id": "card_1OPoulJN5vQBdWExeqd0Lni6", + "last4": "4242", + "metadata": {}, + "name": null, + "object": "card", + "tokenization_method": null, + "wallet": null + }, + "client_ip": null, + "created": 1234567890, + "id": "tok_1OPoulJN5vQBdWExS6soPfIn", + "livemode": false, + "object": "token", + "type": "card", + "used": false + }, + "topup": { + "amount": 1000, + "balance_transaction": null, + "created": 1234567890, + "currency": "usd", + "description": "Top-up description", + "expected_availability_date": 123456789, + "failure_code": null, + "failure_message": null, + "id": "tu_1OPounJN5vQBdWExFC5ZOuYf", + "livemode": false, + "metadata": { + "order_id": "12345678" + }, + "object": "topup", + "source": null, + "statement_descriptor": null, + "status": "pending", + "transfer_group": null + }, + "transfer": { + "amount": 1100, + "amount_reversed": 0, + "balance_transaction": "txn_1OPoueJN5vQBdWEx8dhHMVqh", + "created": 1234567890, + "currency": "usd", + "description": null, + "destination": "acct_1OPouMJN5vQBdWEx", + "destination_payment": "py_PEHTHL4uD4U3Hv", + "id": "tr_1OPounJN5vQBdWExGHeyZqlt", + "livemode": false, + "metadata": {}, + "object": "transfer", + "reversals": { + "data": [], + "has_more": false, + "object": "list", + "url": "/v1/transfers/tr_1OPounJN5vQBdWExGHeyZqlt/reversals" + }, + "reversed": false, + "source_transaction": null, + "source_type": "card", + "transfer_group": null + }, + "transfer_reversal": { + "amount": 1100, + "balance_transaction": null, + "created": 1234567890, + "currency": "usd", + "destination_payment_refund": null, + "id": "trr_1OPounJN5vQBdWExmrkKTeuo", + "metadata": {}, + "object": "transfer_reversal", + "source_refund": null, + "transfer": "tr_1OPounJN5vQBdWExGHeyZqlt" + }, + "treasury.credit_reversal": { + "amount": 1000, + "created": 1234567890, + "currency": "usd", + "financial_account": "fa_1OPousJN5vQBdWEx4bT8ilJV", + "hosted_regulatory_receipt_url": "https://pakrym-agrippa-mydev.dev.stripe.me/regulatory-receipt/CBQaFwoVYWNjdF8xT1BvdU1KTjV2UUJkV0V4KM_JkawGMga8M0E_q486Nv0d0rrdNKVtgXmdjiQ9H6AyLkOWWj7S6Gc_skc7RdLmZGn9gzZ2bQuYuVUAeCuCc_M0fyz5iw", + "id": "credrev_1OPouxJN5vQBdWExm49he8ue", + "livemode": false, + "metadata": {}, + "network": "ach", + "object": "treasury.credit_reversal", + "received_credit": "rc_1OPouxJN5vQBdWExlRb8gNBH", + "status": "processing", + "status_transitions": { + "posted_at": null + }, + "transaction": "trxn_1OPousJN5vQBdWExS2LKXVAv" + }, + "treasury.debit_reversal": { + "amount": 1000, + "created": 1234567890, + "currency": "usd", + "financial_account": "fa_1OPousJN5vQBdWEx4bT8ilJV", + "hosted_regulatory_receipt_url": "https://pakrym-agrippa-mydev.dev.stripe.me/regulatory-receipt/CBQaFwoVYWNjdF8xT1BvdU1KTjV2UUJkV0V4KM_JkawGMgaMklxnLBk6Nv05uSgo_HpwZ6zRfImbuWdDwzGba8s70W9PPhVOTo3JaEXfDcpkaQ-OP_gJZnKjjRutxDLaIQ", + "id": "debrev_1OPouxJN5vQBdWExZrkJLF3z", + "linked_flows": null, + "livemode": false, + "metadata": {}, + "network": "ach", + "object": "treasury.debit_reversal", + "received_debit": "rd_1OPouxJN5vQBdWExmkiLsbaL", + "status": "processing", + "status_transitions": { + "completed_at": null + }, + "transaction": "trxn_1OPousJN5vQBdWExS2LKXVAv" + }, + "treasury.financial_account": { + "active_features": [ + "financial_addresses.aba", + "outbound_payments.ach", + "outbound_payments.us_domestic_wire" + ], + "balance": { + "cash": { + "usd": 0 + }, + "inbound_pending": { + "usd": 0 + }, + "outbound_pending": { + "usd": 0 + } + }, + "country": "US", + "created": 1234567890, + "financial_addresses": [ + { + "aba": { + "account_holder_name": "Jenny Rosen", + "account_number_last4": "7890", + "bank_name": "STRIPE TEST BANK", + "routing_number": "0000000001" + }, + "supported_networks": [ + "ach", + "us_domestic_wire" + ], + "type": "aba" + } + ], + "id": "fa_1OPousJN5vQBdWEx4bT8ilJV", + "livemode": true, + "metadata": null, + "object": "treasury.financial_account", + "pending_features": [], + "restricted_features": [], + "status": "open", + "status_details": { + "closed": null + }, + "supported_currencies": [ + "usd" + ] + }, + "treasury.financial_account_features": { + "card_issuing": { + "requested": true, + "status": "active", + "status_details": [] + }, + "deposit_insurance": { + "requested": true, + "status": "active", + "status_details": [] + }, + "financial_addresses": { + "aba": { + "requested": true, + "status": "active", + "status_details": [] + } + }, + "inbound_transfers": { + "ach": { + "requested": true, + "status": "active", + "status_details": [] + } + }, + "intra_stripe_flows": { + "requested": true, + "status": "active", + "status_details": [] + }, + "object": "treasury.financial_account_features", + "outbound_payments": { + "ach": { + "requested": true, + "status": "active", + "status_details": [] + }, + "us_domestic_wire": { + "requested": true, + "status": "active", + "status_details": [] + } + }, + "outbound_transfers": { + "ach": { + "requested": true, + "status": "active", + "status_details": [] + }, + "us_domestic_wire": { + "requested": true, + "status": "active", + "status_details": [] + } + } + }, + "treasury.inbound_transfer": { + "amount": 10000, + "cancelable": true, + "created": 1234567890, + "currency": "usd", + "description": "InboundTransfer from my external bank account", + "failure_details": null, + "financial_account": "fa_1OPousJN5vQBdWEx4bT8ilJV", + "hosted_regulatory_receipt_url": "https://pakrym-agrippa-mydev.dev.stripe.me/regulatory-receipt/CBQaFwoVYWNjdF8xT1BvdU1KTjV2UUJkV0V4KM_JkawGMgYOEtbDkck6Nv2qFp3js1PntieIqQDERWMh17q9c735bplptY1B0Am1liqX_copS8vzlwmXl-r1E2jHWIEMxg", + "id": "ibt_1OPouxJN5vQBdWExcKHR4iQ8", + "linked_flows": { + "received_debit": null + }, + "livemode": false, + "metadata": {}, + "object": "treasury.inbound_transfer", + "origin_payment_method": "pm_1OPouwJN5vQBdWExnzH1xIFm", + "origin_payment_method_details": { + "billing_details": { + "address": { + "city": "San Francisco", + "country": "US", + "line1": "1234 Fake Street", + "line2": null, + "postal_code": "94102", + "state": "CA" + }, + "email": null, + "name": "Jane Austen" + }, + "type": "us_bank_account", + "us_bank_account": { + "account_holder_type": "company", + "account_type": "checking", + "bank_name": "STRIPE TEST BANK", + "fingerprint": "oBMt5pBDd633Ahah", + "last4": "6789", + "network": "ach", + "routing_number": "110000000" + } + }, + "returned": false, + "statement_descriptor": "transfer", + "status": "processing", + "status_transitions": { + "failed_at": null, + "succeeded_at": null + }, + "transaction": "trxn_1OPousJN5vQBdWExS2LKXVAv" + }, + "treasury.outbound_payment": { + "amount": 10000, + "cancelable": false, + "created": 1234567890, + "currency": "usd", + "customer": null, + "description": "OutboundPayment to a 3rd party", + "destination_payment_method": null, + "destination_payment_method_details": { + "destination": "ba_1OPoumJN5vQBdWExwmpTeNeE", + "type": "us_bank_account" + }, + "end_user_details": { + "ip_address": null, + "present": false + }, + "expected_arrival_date": 1234567890, + "financial_account": "fa_1OPousJN5vQBdWEx4bT8ilJV", + "hosted_regulatory_receipt_url": "https://pakrym-agrippa-mydev.dev.stripe.me/regulatory-receipt/CBQaFwoVYWNjdF8xT1BvdU1KTjV2UUJkV0V4KM_JkawGMgaR9eFFZxA6Nf1Uo94Mpn-7Tsn_H3VUq5eU5VqUXb9OIEaCinxrEDg2YK6jwW9CYt3AXOyCohxB6swPKWTL", + "id": "obp_1OPouxJN5vQBdWExcfBNWRw2", + "livemode": false, + "metadata": {}, + "object": "treasury.outbound_payment", + "returned_details": null, + "statement_descriptor": "payment", + "status": "processing", + "status_transitions": { + "canceled_at": null, + "failed_at": null, + "posted_at": null, + "returned_at": null + }, + "transaction": "trxn_1OPousJN5vQBdWExS2LKXVAv" + }, + "treasury.outbound_transfer": { + "amount": 10000, + "cancelable": true, + "created": 1234567890, + "currency": "usd", + "description": "OutboundTransfer to my external bank account", + "destination_payment_method": "pm_1OPouwJN5vQBdWExnzH1xIFm", + "destination_payment_method_details": { + "billing_details": { + "address": { + "city": "San Francisco", + "country": "US", + "line1": "1234 Fake Street", + "line2": null, + "postal_code": "94102", + "state": "CA" + }, + "email": null, + "name": "Jane Austen" + }, + "type": "us_bank_account", + "us_bank_account": { + "account_holder_type": "company", + "account_type": "checking", + "bank_name": "STRIPE TEST BANK", + "fingerprint": "oBMt5pBDd633Ahah", + "last4": "6789", + "network": "ach", + "routing_number": "110000000" + } + }, + "expected_arrival_date": 1234567890, + "financial_account": "fa_1OPousJN5vQBdWEx4bT8ilJV", + "hosted_regulatory_receipt_url": "https://pakrym-agrippa-mydev.dev.stripe.me/regulatory-receipt/CBQaFwoVYWNjdF8xT1BvdU1KTjV2UUJkV0V4KM_JkawGMgbubL2Juz06Nv36NszL7bgMw-HdKdK3GPWOCnC-aVisnjcPYKMEC58GB1yGAIqB2xYannP_UefTP7OEMOIRww", + "id": "obt_1OPouxJN5vQBdWExpjuwR2Xd", + "livemode": false, + "metadata": {}, + "object": "treasury.outbound_transfer", + "returned_details": null, + "statement_descriptor": "transfer", + "status": "processing", + "status_transitions": { + "canceled_at": null, + "failed_at": null, + "posted_at": null, + "returned_at": null + }, + "transaction": "trxn_1OPousJN5vQBdWExS2LKXVAv" + }, + "treasury.received_credit": { + "amount": 1234, + "created": 1234567890, + "currency": "usd", + "description": "Stripe Test", + "failure_code": null, + "financial_account": "fa_1OPousJN5vQBdWEx4bT8ilJV", + "hosted_regulatory_receipt_url": "https://pakrym-agrippa-mydev.dev.stripe.me/regulatory-receipt/CBQaFwoVYWNjdF8xT1BvdU1KTjV2UUJkV0V4KM_JkawGMgbR9qpUOwI6Nv1M_-1yzVcQyDBD5fWzBOC5c8-OKRj3GCgQrKwMoQk7B_x6BQ8WbJAzeH1-MYa33PH-tXw38g", + "id": "rc_1OPouxJN5vQBdWExlRb8gNBH", + "initiating_payment_method_details": { + "billing_details": { + "address": { + "city": null, + "country": null, + "line1": null, + "line2": null, + "postal_code": null, + "state": null + }, + "email": null, + "name": "Jane Austen" + }, + "type": "us_bank_account", + "us_bank_account": { + "bank_name": "STRIPE TEST BANK", + "last4": "6789", + "routing_number": "110000000" + } + }, + "linked_flows": { + "credit_reversal": null, + "issuing_authorization": null, + "issuing_transaction": null, + "source_flow": null, + "source_flow_type": null + }, + "livemode": false, + "network": "ach", + "object": "treasury.received_credit", + "reversal_details": { + "deadline": 1703548800, + "restricted_reason": null + }, + "status": "succeeded", + "transaction": "trxn_1OPousJN5vQBdWExS2LKXVAv" + }, + "treasury.received_debit": { + "amount": 54321, + "created": 1234567890, + "currency": "usd", + "description": "Stripe Test", + "failure_code": null, + "financial_account": "fa_1OPousJN5vQBdWEx4bT8ilJV", + "hosted_regulatory_receipt_url": "https://pakrym-agrippa-mydev.dev.stripe.me/regulatory-receipt/CBQaFwoVYWNjdF8xT1BvdU1KTjV2UUJkV0V4KM_JkawGMgZqCQzu5wU6Nv3BettKOuxLU_e9_QIggyk_Iu_hjDWSPq7SWu9O0hf2ORmZ5RoneWewCsaDdCIgZuoDPI5FOA", + "id": "rd_1OPouxJN5vQBdWExcQ4JcpiH", + "initiating_payment_method_details": { + "billing_details": { + "address": { + "city": null, + "country": null, + "line1": null, + "line2": null, + "postal_code": null, + "state": null + }, + "email": null, + "name": "Jane Austen" + }, + "type": "us_bank_account", + "us_bank_account": { + "bank_name": "STRIPE TEST BANK", + "last4": "6789", + "routing_number": "110000000" + } + }, + "linked_flows": { + "debit_reversal": null, + "inbound_transfer": null, + "issuing_authorization": null, + "issuing_transaction": null + }, + "livemode": false, + "network": "ach", + "object": "treasury.received_debit", + "reversal_details": { + "deadline": 1703548800, + "restricted_reason": null + }, + "status": "succeeded", + "transaction": "trxn_1OPousJN5vQBdWExS2LKXVAv" + }, + "treasury.transaction": { + "amount": -100, + "balance_impact": { + "cash": -100, + "inbound_pending": 0, + "outbound_pending": 100 + }, + "created": 1234567890, + "currency": "usd", + "description": "Jane Austen (6789) | Outbound transfer | transfer", + "financial_account": "fa_1OPousJN5vQBdWEx4bT8ilJV", + "flow": "obt_1OPouxJN5vQBdWExpjuwR2Xd", + "flow_type": "outbound_transfer", + "id": "trxn_1OPousJN5vQBdWExS2LKXVAv", + "livemode": false, + "object": "treasury.transaction", + "status": "open", + "status_transitions": { + "posted_at": null, + "void_at": null + } + }, + "treasury.transaction_entry": { + "balance_impact": { + "cash": 0, + "inbound_pending": 0, + "outbound_pending": -1000 + }, + "created": 1234567890, + "currency": "usd", + "effective_at": 1234567890, + "financial_account": "fa_1OPousJN5vQBdWEx4bT8ilJV", + "flow": "obt_1OPouxJN5vQBdWExpjuwR2Xd", + "flow_type": "outbound_transfer", + "id": "trxne_1OPouxJN5vQBdWExvDiJTOkM", + "livemode": false, + "object": "treasury.transaction_entry", + "transaction": "trxn_1OPousJN5vQBdWExS2LKXVAv", + "type": "outbound_transfer" + }, + "usage_record": { + "id": "mbur_1OPoumJN5vQBdWExO39fivTh", + "livemode": false, + "object": "usage_record", + "quantity": 100, + "subscription_item": "si_PEHTB8PAPrlJ0Q", + "timestamp": 1234567890 + }, + "usage_record_summary": { + "id": "sis_1OPoumJN5vQBdWEx7TSOHJ9Q", + "invoice": "in_1OPoulJN5vQBdWExBI9AQC8z", + "livemode": false, + "object": "usage_record_summary", + "period": { + "end": 1703175364, + "start": 1700583364 + }, + "subscription_item": "si_PEHTi9FjaTNeBx", + "total_usage": 123 + }, + "webhook_endpoint": { + "api_version": null, + "application": null, + "created": 1234567890, + "description": "This is my webhook, I like it a lot", + "enabled_events": [ + "charge.failed", + "charge.succeeded" + ], + "id": "we_1OPouqJN5vQBdWEx9Xl0KCo3", + "livemode": false, + "metadata": {}, + "object": "webhook_endpoint", + "status": "enabled", + "url": "https://example.com/my/webhook/endpoint" + } + }, + "version": "v814" +} \ No newline at end of file diff --git a/openapi/objects.json b/openapi/objects.json new file mode 100644 index 000000000..7e36a4f15 --- /dev/null +++ b/openapi/objects.json @@ -0,0 +1,570 @@ +[ + { + "path": "account", + "import_type": "stripe_shared::Account" + }, + { + "path": "account_link", + "import_type": "stripe_connect::AccountLink" + }, + { + "path": "account_session", + "import_type": "stripe_connect::AccountSession" + }, + { + "path": "apple_pay_domain", + "import_type": "stripe_misc::ApplePayDomain" + }, + { + "path": "application", + "import_type": "stripe_shared::Application" + }, + { + "path": "application_fee", + "import_type": "stripe_shared::ApplicationFee" + }, + { + "path": "apps.secret", + "import_type": "stripe_connect::AppsSecret" + }, + { + "path": "balance", + "import_type": "stripe_core::Balance" + }, + { + "path": "balance_transaction", + "import_type": "stripe_shared::BalanceTransaction" + }, + { + "path": "bank_account", + "import_type": "stripe_shared::BankAccount" + }, + { + "path": "billing_portal.configuration", + "import_type": "stripe_billing::BillingPortalConfiguration" + }, + { + "path": "billing_portal.session", + "import_type": "stripe_billing::BillingPortalSession" + }, + { + "path": "capability", + "import_type": "stripe_shared::Capability" + }, + { + "path": "card", + "import_type": "stripe_shared::Card" + }, + { + "path": "cash_balance", + "import_type": "stripe_shared::CashBalance" + }, + { + "path": "charge", + "import_type": "stripe_shared::Charge" + }, + { + "path": "checkout.session", + "import_type": "stripe_checkout::CheckoutSession" + }, + { + "path": "climate.order", + "import_type": "stripe_misc::ClimateOrder" + }, + { + "path": "climate.product", + "import_type": "stripe_misc::ClimateProduct" + }, + { + "path": "climate.supplier", + "import_type": "stripe_misc::ClimateSupplier" + }, + { + "path": "connect_collection_transfer", + "import_type": "stripe_shared::ConnectCollectionTransfer" + }, + { + "path": "country_spec", + "import_type": "stripe_connect::CountrySpec" + }, + { + "path": "coupon", + "import_type": "stripe_shared::Coupon" + }, + { + "path": "credit_note", + "import_type": "stripe_shared::CreditNote" + }, + { + "path": "credit_note_line_item", + "import_type": "stripe_shared::CreditNoteLineItem" + }, + { + "path": "customer", + "import_type": "stripe_shared::Customer" + }, + { + "path": "customer_balance_transaction", + "import_type": "stripe_shared::CustomerBalanceTransaction" + }, + { + "path": "customer_cash_balance_transaction", + "import_type": "stripe_shared::CustomerCashBalanceTransaction" + }, + { + "path": "customer_session", + "import_type": "stripe_core::CustomerSession" + }, + { + "path": "deleted_account", + "import_type": "stripe_shared::DeletedAccount" + }, + { + "path": "deleted_apple_pay_domain", + "import_type": "stripe_misc::DeletedApplePayDomain" + }, + { + "path": "deleted_bank_account", + "import_type": "stripe_shared::DeletedBankAccount" + }, + { + "path": "deleted_card", + "import_type": "stripe_shared::DeletedCard" + }, + { + "path": "deleted_coupon", + "import_type": "stripe_shared::DeletedCoupon" + }, + { + "path": "deleted_customer", + "import_type": "stripe_shared::DeletedCustomer" + }, + { + "path": "deleted_discount", + "import_type": "stripe_shared::DeletedDiscount" + }, + { + "path": "deleted_invoice", + "import_type": "stripe_shared::DeletedInvoice" + }, + { + "path": "deleted_invoiceitem", + "import_type": "stripe_shared::DeletedInvoiceitem" + }, + { + "path": "deleted_person", + "import_type": "stripe_shared::DeletedPerson" + }, + { + "path": "deleted_plan", + "import_type": "stripe_shared::DeletedPlan" + }, + { + "path": "deleted_product", + "import_type": "stripe_shared::DeletedProduct" + }, + { + "path": "deleted_radar.value_list", + "import_type": "stripe_fraud::DeletedRadarValueList" + }, + { + "path": "deleted_radar.value_list_item", + "import_type": "stripe_fraud::DeletedRadarValueListItem" + }, + { + "path": "deleted_subscription_item", + "import_type": "stripe_shared::DeletedSubscriptionItem" + }, + { + "path": "deleted_tax_id", + "import_type": "stripe_shared::DeletedTaxId" + }, + { + "path": "deleted_terminal.configuration", + "import_type": "stripe_terminal::DeletedTerminalConfiguration" + }, + { + "path": "deleted_terminal.location", + "import_type": "stripe_terminal::DeletedTerminalLocation" + }, + { + "path": "deleted_terminal.reader", + "import_type": "stripe_terminal::DeletedTerminalReader" + }, + { + "path": "deleted_test_helpers.test_clock", + "import_type": "stripe_shared::DeletedTestHelpersTestClock" + }, + { + "path": "deleted_webhook_endpoint", + "import_type": "stripe_misc::DeletedWebhookEndpoint" + }, + { + "path": "discount", + "import_type": "stripe_shared::Discount" + }, + { + "path": "dispute", + "import_type": "stripe_shared::Dispute" + }, + { + "path": "ephemeral_key", + "import_type": "stripe_misc::EphemeralKey" + }, + { + "path": "event", + "import_type": "stripe_shared::Event" + }, + { + "path": "exchange_rate", + "import_type": "stripe_misc::ExchangeRate" + }, + { + "path": "fee_refund", + "import_type": "stripe_shared::ApplicationFeeRefund" + }, + { + "path": "file", + "import_type": "stripe_shared::File" + }, + { + "path": "file_link", + "import_type": "stripe_shared::FileLink" + }, + { + "path": "financial_connections.account", + "import_type": "stripe_misc::FinancialConnectionsAccount" + }, + { + "path": "financial_connections.account_owner", + "import_type": "stripe_misc::FinancialConnectionsAccountOwner" + }, + { + "path": "financial_connections.account_ownership", + "import_type": "stripe_misc::FinancialConnectionsAccountOwnership" + }, + { + "path": "financial_connections.session", + "import_type": "stripe_misc::FinancialConnectionsSession" + }, + { + "path": "financial_connections.transaction", + "import_type": "stripe_misc::FinancialConnectionsTransaction" + }, + { + "path": "funding_instructions", + "import_type": "stripe_shared::FundingInstructions" + }, + { + "path": "identity.verification_report", + "import_type": "stripe_misc::IdentityVerificationReport" + }, + { + "path": "identity.verification_session", + "import_type": "stripe_misc::IdentityVerificationSession" + }, + { + "path": "invoice", + "import_type": "stripe_shared::Invoice" + }, + { + "path": "invoiceitem", + "import_type": "stripe_shared::InvoiceItem" + }, + { + "path": "issuing.authorization", + "import_type": "stripe_shared::IssuingAuthorization" + }, + { + "path": "issuing.card", + "import_type": "stripe_shared::IssuingCard" + }, + { + "path": "issuing.cardholder", + "import_type": "stripe_shared::IssuingCardholder" + }, + { + "path": "issuing.dispute", + "import_type": "stripe_shared::IssuingDispute" + }, + { + "path": "issuing.token", + "import_type": "stripe_shared::IssuingToken" + }, + { + "path": "issuing.transaction", + "import_type": "stripe_shared::IssuingTransaction" + }, + { + "path": "item", + "import_type": "stripe_shared::CheckoutSessionItem" + }, + { + "path": "line_item", + "import_type": "stripe_shared::InvoiceLineItem" + }, + { + "path": "login_link", + "import_type": "stripe_connect::LoginLink" + }, + { + "path": "mandate", + "import_type": "stripe_shared::Mandate" + }, + { + "path": "payment_intent", + "import_type": "stripe_shared::PaymentIntent" + }, + { + "path": "payment_link", + "import_type": "stripe_shared::PaymentLink" + }, + { + "path": "payment_method", + "import_type": "stripe_shared::PaymentMethod" + }, + { + "path": "payment_method_configuration", + "import_type": "stripe_payment::PaymentMethodConfiguration" + }, + { + "path": "payment_method_domain", + "import_type": "stripe_payment::PaymentMethodDomain" + }, + { + "path": "payout", + "import_type": "stripe_shared::Payout" + }, + { + "path": "person", + "import_type": "stripe_shared::Person" + }, + { + "path": "plan", + "import_type": "stripe_shared::Plan" + }, + { + "path": "platform_tax_fee", + "import_type": "stripe_shared::PlatformTaxFee" + }, + { + "path": "price", + "import_type": "stripe_shared::Price" + }, + { + "path": "product", + "import_type": "stripe_shared::Product" + }, + { + "path": "promotion_code", + "import_type": "stripe_shared::PromotionCode" + }, + { + "path": "quote", + "import_type": "stripe_shared::Quote" + }, + { + "path": "radar.early_fraud_warning", + "import_type": "stripe_fraud::RadarEarlyFraudWarning" + }, + { + "path": "radar.value_list", + "import_type": "stripe_fraud::RadarValueList" + }, + { + "path": "radar.value_list_item", + "import_type": "stripe_fraud::RadarValueListItem" + }, + { + "path": "refund", + "import_type": "stripe_shared::Refund" + }, + { + "path": "reporting.report_run", + "import_type": "stripe_misc::ReportingReportRun" + }, + { + "path": "reporting.report_type", + "import_type": "stripe_misc::ReportingReportType" + }, + { + "path": "reserve_transaction", + "import_type": "stripe_shared::ReserveTransaction" + }, + { + "path": "review", + "import_type": "stripe_shared::Review" + }, + { + "path": "scheduled_query_run", + "import_type": "stripe_misc::ScheduledQueryRun" + }, + { + "path": "setup_attempt", + "import_type": "stripe_shared::SetupAttempt" + }, + { + "path": "setup_intent", + "import_type": "stripe_shared::SetupIntent" + }, + { + "path": "shipping_rate", + "import_type": "stripe_shared::ShippingRate" + }, + { + "path": "source", + "import_type": "stripe_shared::Source" + }, + { + "path": "source_mandate_notification", + "import_type": "stripe_payment::SourceMandateNotification" + }, + { + "path": "source_transaction", + "import_type": "stripe_shared::SourceTransaction" + }, + { + "path": "subscription", + "import_type": "stripe_shared::Subscription" + }, + { + "path": "subscription_item", + "import_type": "stripe_shared::SubscriptionItem" + }, + { + "path": "subscription_schedule", + "import_type": "stripe_shared::SubscriptionSchedule" + }, + { + "path": "tax.calculation", + "import_type": "stripe_misc::TaxCalculation" + }, + { + "path": "tax.calculation_line_item", + "import_type": "stripe_misc::TaxCalculationLineItem" + }, + { + "path": "tax.registration", + "import_type": "stripe_misc::TaxRegistration" + }, + { + "path": "tax.settings", + "import_type": "stripe_misc::TaxSettings" + }, + { + "path": "tax.transaction", + "import_type": "stripe_misc::TaxTransaction" + }, + { + "path": "tax.transaction_line_item", + "import_type": "stripe_misc::TaxTransactionLineItem" + }, + { + "path": "tax_code", + "import_type": "stripe_shared::TaxCode" + }, + { + "path": "tax_deducted_at_source", + "import_type": "stripe_shared::TaxDeductedAtSource" + }, + { + "path": "tax_id", + "import_type": "stripe_shared::TaxId" + }, + { + "path": "tax_rate", + "import_type": "stripe_shared::TaxRate" + }, + { + "path": "terminal.configuration", + "import_type": "stripe_terminal::TerminalConfiguration" + }, + { + "path": "terminal.connection_token", + "import_type": "stripe_terminal::TerminalConnectionToken" + }, + { + "path": "terminal.location", + "import_type": "stripe_terminal::TerminalLocation" + }, + { + "path": "terminal.reader", + "import_type": "stripe_terminal::TerminalReader" + }, + { + "path": "test_helpers.test_clock", + "import_type": "stripe_shared::TestHelpersTestClock" + }, + { + "path": "token", + "import_type": "stripe_core::Token" + }, + { + "path": "topup", + "import_type": "stripe_shared::Topup" + }, + { + "path": "transfer", + "import_type": "stripe_shared::Transfer" + }, + { + "path": "transfer_reversal", + "import_type": "stripe_shared::TransferReversal" + }, + { + "path": "treasury.credit_reversal", + "import_type": "stripe_treasury::TreasuryCreditReversal" + }, + { + "path": "treasury.debit_reversal", + "import_type": "stripe_treasury::TreasuryDebitReversal" + }, + { + "path": "treasury.financial_account", + "import_type": "stripe_treasury::TreasuryFinancialAccount" + }, + { + "path": "treasury.financial_account_features", + "import_type": "stripe_treasury::TreasuryFinancialAccountFeatures" + }, + { + "path": "treasury.inbound_transfer", + "import_type": "stripe_treasury::TreasuryInboundTransfer" + }, + { + "path": "treasury.outbound_payment", + "import_type": "stripe_treasury::TreasuryOutboundPayment" + }, + { + "path": "treasury.outbound_transfer", + "import_type": "stripe_treasury::TreasuryOutboundTransfer" + }, + { + "path": "treasury.received_credit", + "import_type": "stripe_treasury::TreasuryReceivedCredit" + }, + { + "path": "treasury.received_debit", + "import_type": "stripe_treasury::TreasuryReceivedDebit" + }, + { + "path": "treasury.transaction", + "import_type": "stripe_treasury::TreasuryTransaction" + }, + { + "path": "treasury.transaction_entry", + "import_type": "stripe_treasury::TreasuryTransactionEntry" + }, + { + "path": "usage_record", + "import_type": "stripe_billing::UsageRecord" + }, + { + "path": "usage_record_summary", + "import_type": "stripe_shared::UsageRecordSummary" + }, + { + "path": "webhook_endpoint", + "import_type": "stripe_misc::WebhookEndpoint" + } +] \ No newline at end of file diff --git a/openapi/src/codegen.rs b/openapi/src/codegen.rs index 0d4935ad9..766ab2b4d 100644 --- a/openapi/src/codegen.rs +++ b/openapi/src/codegen.rs @@ -3,6 +3,7 @@ use std::path::PathBuf; use anyhow::Context; use indoc::formatdoc; +use serde::Serialize; use crate::components::{get_components, Components}; use crate::crate_table::write_crate_table; @@ -63,8 +64,8 @@ impl CodeGen { let crate_mod_path = crate_path.join("mod.rs"); for (ident, typ_info) in &self.components.extra_types { let mut out = String::new(); - let metadata = ObjectMetadata::new(ident.clone(), ObjectKind::Type); - self.components.write_object(&typ_info.obj, &metadata, &mut out); + let metadata = ObjectMetadata::new(ident.clone()); + self.components.write_object(&typ_info.obj, &metadata, typ_info.usage, &mut out); write_to_file(out, crate_path.join(format!("{}.rs", typ_info.mod_path)))?; append_to_file( format!("pub mod {0}; pub use {0}::{1};", typ_info.mod_path, ident), @@ -80,7 +81,8 @@ impl CodeGen { self.write_api_version_file()?; write_generated_for_webhooks(&self.components) .context("Could not write webhook generated code")?; - write_crate_table(&self.components) + write_crate_table(&self.components)?; + self.write_object_info_for_testing() } fn write_crate_base(&self) -> anyhow::Result<()> { @@ -116,11 +118,16 @@ impl CodeGen { {doc_comment} extern crate self as {crate_name}; + + 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) } Ok(()) } @@ -183,9 +190,9 @@ impl CodeGen { for (ident, obj) in &comp.deduplicated_objects { let mut out = String::new(); - let metadata = ObjectMetadata::new(ident.clone(), obj.info.kind); - self.components.write_object(&obj.object, &metadata, &mut out); - let dst_file = match obj.info.kind { + let metadata = ObjectMetadata::new(ident.clone()); + self.components.write_object(&obj.object, &metadata, obj.info.usage, &mut out); + let dst_file = match obj.info.usage.kind { ObjectKind::RequestParam | ObjectKind::RequestReturned => { comp.get_requests_content_path() } @@ -201,8 +208,36 @@ impl CodeGen { let base_obj = comp.rust_obj(); let schema = self.spec.get_component_schema(comp.path()); let doc_comment = infer_doc_comment(schema, comp.stripe_doc_url.as_deref()); - let meta = ObjectMetadata::new(comp.ident().clone(), ObjectKind::Type).doc(doc_comment); + let meta = ObjectMetadata::new(comp.ident().clone()).doc(doc_comment); gen_obj(base_obj, &meta, comp, &self.components) } + + fn write_object_info_for_testing(&self) -> anyhow::Result<()> { + #[derive(Serialize)] + struct ObjectInfo { + path: String, + import_type: String, + } + let mut checks = String::new(); + for (path, obj) in &self.components.components { + if obj.object_name().is_none() { + continue; + } + let krate = obj.krate().unwrap().base(); + let import_path = format!("{krate}::{}", obj.ident()); + let _ = writeln!(checks, r#"check_object::<{import_path}>(resources, "{path}");"#); + } + let content = formatdoc! { + r#" + use crate::deserialization_fixture::check_object; + + pub fn check_fixtures(resources: &serde_json::Value) {{ + {checks} + }} + "# + }; + + write_to_file(content, "tests/mod.rs") + } } diff --git a/openapi/src/components.rs b/openapi/src/components.rs index b0d3a2d05..31bbe55d9 100644 --- a/openapi/src/components.rs +++ b/openapi/src/components.rs @@ -12,7 +12,7 @@ use crate::deduplication::{deduplicate_types, DeduppedObject}; use crate::overrides::Overrides; use crate::printable::{PrintableContainer, PrintableType}; use crate::requests::parse_requests; -use crate::rust_object::{ObjectKind, RustObject}; +use crate::rust_object::{ObjectKind, ObjectUsage, RustObject}; use crate::rust_type::{Container, PathToType, RustType}; use crate::spec::Spec; use crate::stripe_object::{ @@ -29,6 +29,7 @@ pub struct TypeSpec { pub doc: Option, pub ident: RustIdent, pub mod_path: String, + pub usage: ObjectUsage, } pub struct Components { @@ -107,7 +108,7 @@ impl Components { RustType::Path { path: PathToType::Deduplicated { path, ident }, is_ref } => { let referred_typ = self.get_dedupped_type(ident, path); let has_ref = referred_typ.object.has_reference(self); - let path = if referred_typ.info.kind == ObjectKind::Type { + let path = if referred_typ.info.usage.kind == ObjectKind::Type { Some(PathInfo { krate: self.get(path).krate_unwrapped().for_types(), path: None, @@ -158,7 +159,7 @@ impl Components { pub fn deps_for_webhooks(&self) -> IndexSet<&ComponentPath> { let mut dep_collector = DependencyCollector::new(); for obj in &self.webhook_objs { - dep_collector.visit_typ(&obj.typ); + dep_collector.visit_typ(&obj.typ, ObjectUsage::type_def()); } dep_collector.deps } @@ -237,6 +238,7 @@ impl Components { doc: override_meta.metadata.doc, ident: override_meta.metadata.ident, mod_path: override_meta.mod_path, + usage: ObjectUsage { kind: ObjectKind::Type, used_as_request_param: true }, }, ); } @@ -352,7 +354,7 @@ impl<'a> DependencyCollector<'a> { } impl<'a> Visit<'a> for DependencyCollector<'a> { - fn visit_typ(&mut self, typ: &'a RustType) + fn visit_typ(&mut self, typ: &'a RustType, object_usage: ObjectUsage) where Self: Sized, { @@ -360,7 +362,7 @@ impl<'a> Visit<'a> for DependencyCollector<'a> { RustType::Path { path: PathToType::Component(path), .. } => { self.deps.insert(path); } - _ => typ.visit(self), + _ => typ.visit(self, object_usage), } } } diff --git a/openapi/src/deduplication.rs b/openapi/src/deduplication.rs index 8dc1930ba..47277d393 100644 --- a/openapi/src/deduplication.rs +++ b/openapi/src/deduplication.rs @@ -2,7 +2,7 @@ use indexmap::map::Entry; use indexmap::IndexMap; use tracing::debug; -use crate::rust_object::{ObjectKind, ObjectMetadata, RustObject}; +use crate::rust_object::{ObjectKind, ObjectMetadata, ObjectUsage, RustObject}; use crate::rust_type::{PathToType, RustType}; use crate::stripe_object::StripeObject; use crate::types::{ComponentPath, RustIdent}; @@ -10,29 +10,29 @@ use crate::visitor::{Visit, VisitMut}; #[derive(Debug, Default)] struct CollectDuplicateObjects { - objs: IndexMap>, + objs: IndexMap>, } impl Visit<'_> for CollectDuplicateObjects { - fn visit_obj(&mut self, obj: &RustObject, meta: Option<&ObjectMetadata>) { + fn visit_obj(&mut self, obj: &RustObject, meta: Option<&ObjectMetadata>, usage: ObjectUsage) { if let Some(meta) = meta { match self.objs.entry(obj.clone()) { Entry::Occupied(mut occ) => { - occ.get_mut().push(meta.clone()); + occ.get_mut().push((meta.clone(), usage)); } Entry::Vacant(entry) => { - entry.insert(vec![meta.clone()]); + entry.insert(vec![(meta.clone(), usage)]); } } }; - obj.visit(self); + obj.visit(self, usage); } } #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub struct DeduppedObjectInfo { pub ident: RustIdent, - pub kind: ObjectKind, + pub usage: ObjectUsage, } #[derive(Debug, Clone, Eq, PartialEq, Hash)] @@ -54,7 +54,7 @@ impl DeduplicateObjects { } impl VisitMut for DeduplicateObjects { - fn visit_typ_mut(&mut self, typ: &mut RustType) + fn visit_typ_mut(&mut self, typ: &mut RustType, usage: ObjectUsage) where Self: Sized, { @@ -69,7 +69,7 @@ impl VisitMut for DeduplicateObjects { } } } - typ.visit_mut(self); + typ.visit_mut(self, usage); } } @@ -90,33 +90,37 @@ fn implied_name_from_doc(doc: &str) -> Option<&str> { second_word } -fn maybe_infer_by_field_name(meta: &[ObjectMetadata]) -> Option { - let type_data = meta.iter().find(|m| m.kind == ObjectKind::Type)?; +fn maybe_infer_by_field_name(meta: &[(ObjectMetadata, ObjectUsage)]) -> Option { + let (type_data, _) = meta.iter().find(|(_, usage)| usage.kind == ObjectKind::Type)?; let parent = type_data.parent.as_ref()?; let field_name = type_data.field_name.as_ref()?; - if meta.iter().any(|m| m.field_name.as_ref() != Some(field_name)) { + if meta.iter().any(|(m, _)| m.field_name.as_ref() != Some(field_name)) { return None; } Some(DeduppedObjectInfo { ident: RustIdent::joined(parent, field_name), - kind: ObjectKind::Type, + usage: ObjectUsage { + kind: ObjectKind::Type, + used_as_request_param: meta.iter().any(|(_, usage)| usage.used_as_request_param), + }, }) } /// Try to infer an identifier given metadata about identical objects -fn infer_dedupped_ident(meta: &[ObjectMetadata]) -> Option { - let first = meta.first().unwrap(); - if let Some(title) = &first.title { +fn infer_dedupped_ident(objs: &[(ObjectMetadata, ObjectUsage)]) -> Option { + let first = objs.first().unwrap(); + let first_meta = &first.0; + if let Some(title) = &first_meta.title { // `param` is used very generally and will not be a helpful name to infer - if title != "param" && meta.iter().all(|m| m.title.as_ref() == Some(title)) { + if title != "param" && objs.iter().all(|(m, _)| m.title.as_ref() == Some(title)) { return Some(RustIdent::create(title)); } } - if let Some(doc_name) = implied_name_from_meta_doc(first) { - if let Some(parent) = &first.parent { - if meta.iter().all(|m| { + if let Some(doc_name) = implied_name_from_meta_doc(first_meta) { + if let Some(parent) = &first_meta.parent { + if objs.iter().all(|(m, _)| { implied_name_from_meta_doc(m) == Some(doc_name) && m.parent.as_ref() == Some(parent) }) { return Some(RustIdent::joined(parent, doc_name)); @@ -127,7 +131,7 @@ fn infer_dedupped_ident(meta: &[ObjectMetadata]) -> Option { } fn infer_dedupped_object_for( - meta: &[ObjectMetadata], + meta: &[(ObjectMetadata, ObjectUsage)], obj: &RustObject, ) -> Option { if matches!(obj, RustObject::FieldlessEnum(_)) { @@ -136,9 +140,10 @@ fn infer_dedupped_object_for( } } let ident = infer_dedupped_ident(meta)?; - let first_kind = meta.first().unwrap().kind; - if meta.iter().all(|m| m.kind == first_kind) { - return Some(DeduppedObjectInfo { ident, kind: first_kind }); + let first = meta.first().unwrap(); + let first_usage = first.1; + if meta.iter().all(|(_, usage)| *usage == first_usage) { + return Some(DeduppedObjectInfo { ident, usage: first_usage }); } None } diff --git a/openapi/src/main.rs b/openapi/src/main.rs index 086e76de8..7055f7530 100644 --- a/openapi/src/main.rs +++ b/openapi/src/main.rs @@ -54,7 +54,7 @@ fn main() -> Result<()> { } fs::create_dir_all(out_path).context("could not create out folder")?; - info!("generating code for {} to {}", in_path, out_path.display()); + info!("generating code for {in_path} to {}", out_path.display()); let spec = if let Some(version) = args.fetch { let raw = fetch_spec(version, &in_path)?; @@ -92,6 +92,7 @@ fn main() -> Result<()> { fmt_cmd.arg(format!("out/{}/src/mod.rs", krate.generated_out_path())); } fmt_cmd.arg("out/stripe_webhook/mod.rs"); + fmt_cmd.arg("out/tests/mod.rs"); if !args.dry_run { info!("Formatting generated files"); @@ -103,6 +104,7 @@ fn main() -> Result<()> { info!("Copying generated files"); run_rsync("out/crates/", "../generated/")?; run_rsync("out/stripe_webhook/", "../stripe_webhook/src/generated/")?; + run_rsync("out/tests/", "../tests/tests/it/generated/")?; std::process::Command::new("cp") .arg("out/crate_info.md") diff --git a/openapi/src/object_writing.rs b/openapi/src/object_writing.rs index ea3efe846..64844406d 100644 --- a/openapi/src/object_writing.rs +++ b/openapi/src/object_writing.rs @@ -3,7 +3,8 @@ use std::fmt::Write; use crate::components::Components; use crate::ids::write_object_id; use crate::printable::Lifetime; -use crate::rust_object::{as_enum_of_objects, ObjectMetadata, RustObject}; +use crate::rust_object::EnumOfObjects::ObjectUnion; +use crate::rust_object::{as_enum_of_objects, ObjectMetadata, ObjectUsage, RustObject}; use crate::rust_type::RustType; use crate::stripe_object::{RequestSpec, StripeObject}; use crate::templates::object_trait::{write_object_trait, write_object_trait_for_enum}; @@ -13,14 +14,20 @@ use crate::templates::ObjectWriter; const ADD_UNKNOWN_VARIANT_THRESHOLD: usize = 12; impl Components { - fn write_rust_type_objs(&self, typ: &RustType, out: &mut String) { + fn write_rust_type_objs(&self, typ: &RustType, out: &mut String, usage: ObjectUsage) { let Some((obj, meta)) = typ.extract_object() else { return; }; - self.write_object(obj, meta, out); + self.write_object(obj, meta, usage, out); } - pub fn write_object(&self, obj: &RustObject, metadata: &ObjectMetadata, out: &mut String) { + pub fn write_object( + &self, + obj: &RustObject, + metadata: &ObjectMetadata, + usage: ObjectUsage, + out: &mut String, + ) { if let Some(doc) = &metadata.doc { let comment = write_doc_comment(doc, 0); let _ = write!(out, "{comment}"); @@ -31,7 +38,7 @@ impl Components { let lifetime = if has_ref { Some(Lifetime) } else { None }; let ident = &metadata.ident; - let mut writer = ObjectWriter::new(self, ident, metadata.kind); + let mut writer = ObjectWriter::new(self, ident, usage); writer.lifetime(lifetime).derive_copy(obj.is_copy(self)); match obj { @@ -42,7 +49,7 @@ impl Components { for field in fields { if let Some((obj, meta)) = field.rust_type.extract_object() { - self.write_object(obj, meta, out); + self.write_object(obj, meta, usage, out); } } } @@ -56,12 +63,12 @@ impl Components { if let Some(objects) = as_enum_of_objects(self, variants) { writer.write_enum_of_objects(out, &objects); } else { - writer.write_enum_variants(out, variants); + writer.write_arbitrary_enum_variants(out, variants); } for variant in variants { if let Some(typ) = &variant.rust_type { if let Some((obj, meta)) = typ.extract_object() { - self.write_object(obj, meta, out); + self.write_object(obj, meta, usage, out); } } } @@ -78,7 +85,7 @@ pub fn gen_obj( ) -> String { let mut out = String::with_capacity(128); - components.write_object(obj, meta, &mut out); + components.write_object(obj, meta, ObjectUsage::type_def(), &mut out); let ident = &meta.ident; if let Some(id_typ) = comp.id_type() { @@ -89,7 +96,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"); @@ -112,12 +122,12 @@ pub fn gen_requests(specs: &[RequestSpec], components: &Components) -> String { let mut out = String::with_capacity(128); for req in specs { - components.write_rust_type_objs(&req.params, &mut out); + components.write_rust_type_objs(&req.params, &mut out, ObjectUsage::request_param()); let req_body = req.gen(components); let _ = write!(out, "{}", req_body); - components.write_rust_type_objs(&req.returned, &mut out); + components.write_rust_type_objs(&req.returned, &mut out, ObjectUsage::return_type()); } out } diff --git a/openapi/src/overrides.rs b/openapi/src/overrides.rs index 7b37f3149..5b5ec6380 100644 --- a/openapi/src/overrides.rs +++ b/openapi/src/overrides.rs @@ -2,7 +2,7 @@ use anyhow::Context; use indexmap::IndexMap; use crate::components::{Components, RequestSource}; -use crate::rust_object::{ObjectKind, ObjectMetadata, RustObject}; +use crate::rust_object::{ObjectMetadata, ObjectUsage, RustObject}; use crate::rust_type::{PathToType, RustType}; use crate::stripe_object::OperationType; use crate::types::RustIdent; @@ -60,19 +60,18 @@ fn get_override_object( .context("Could not extract field")? .extract_object() .context("Not an object")?; - let metadata = ObjectMetadata::new(RustIdent::unchanged(data.ident), ObjectKind::Type) - .doc(data.doc.to_string()); + let metadata = ObjectMetadata::new(RustIdent::unchanged(data.ident)).doc(data.doc.to_string()); Ok((obj.clone(), OverrideMetadata { metadata, mod_path: data.mod_path.to_string() })) } impl VisitMut for Overrides { - fn visit_typ_mut(&mut self, typ: &mut RustType) { + fn visit_typ_mut(&mut self, typ: &mut RustType, usage: ObjectUsage) { if let Some((obj, _)) = typ.as_object_mut() { if let Some(meta) = self.overrides.get(obj) { *typ = RustType::path(PathToType::Shared(meta.metadata.ident.clone()), false); } } - typ.visit_mut(self); + typ.visit_mut(self, usage); } } diff --git a/openapi/src/requests.rs b/openapi/src/requests.rs index 6b1ec6394..6a14d76d9 100644 --- a/openapi/src/requests.rs +++ b/openapi/src/requests.rs @@ -5,7 +5,7 @@ use heck::ToSnakeCase; use openapiv3::{Parameter, ParameterData, ParameterSchemaOrContent, ReferenceOr, Schema}; use tracing::debug; -use crate::rust_object::{ObjectKind, ObjectMetadata, RustObject}; +use crate::rust_object::{ObjectMetadata, RustObject}; use crate::rust_type::{RustType, SimpleType}; use crate::spec::{get_ok_response_schema, get_request_form_parameters, Spec}; use crate::spec_inference::Inference; @@ -192,12 +192,10 @@ fn build_request( ) -> anyhow::Result { let params_ident = RustIdent::joined(method_name, parent_ident); let return_ident = RustIdent::joined(¶ms_ident, "returned"); - let return_type = Inference::new(&return_ident, ObjectKind::RequestReturned) - .required(true) - .infer_schema_or_ref_type(req.returned); + let return_type = + Inference::new(&return_ident).required(true).infer_schema_or_ref_type(req.returned); - let param_inference = - Inference::new(¶ms_ident, ObjectKind::RequestParam).can_borrow(true).required(true); + let param_inference = Inference::new(¶ms_ident).can_borrow(true).required(true); let param_typ = match &req.params { RequestParams::Form(schema) => schema.map(|s| param_inference.infer_schema_or_ref_type(s)), @@ -219,16 +217,13 @@ fn build_request( } Some(RustType::Object( RustObject::Struct(struct_fields), - ObjectMetadata::new(params_ident.clone(), ObjectKind::RequestParam), + ObjectMetadata::new(params_ident.clone()), )) } }, } .unwrap_or_else(|| { - RustType::Object( - RustObject::Struct(vec![]), - ObjectMetadata::new(params_ident.clone(), ObjectKind::RequestParam), - ) + RustType::Object(RustObject::Struct(vec![]), ObjectMetadata::new(params_ident.clone())) }); let req_path = req.path.trim_start_matches("/v1"); @@ -238,7 +233,7 @@ fn build_request( let ParameterSchemaOrContent::Schema(schema) = ¶m.format else { bail!("Expected path parameter to follow schema format"); }; - let base_param_typ = Inference::new(¶ms_ident, ObjectKind::RequestParam) + let base_param_typ = Inference::new(¶ms_ident) .can_borrow(true) .required(param.required) .maybe_description(param.description.as_deref()) diff --git a/openapi/src/rust_object.rs b/openapi/src/rust_object.rs index ef6f28003..58bb7ec92 100644 --- a/openapi/src/rust_object.rs +++ b/openapi/src/rust_object.rs @@ -29,13 +29,12 @@ pub struct ObjectMetadata { pub title: Option, /// The name of the field in the OpenAPI schema pub field_name: Option, - pub kind: ObjectKind, pub parent: Option, } impl ObjectMetadata { - pub fn new(ident: RustIdent, kind: ObjectKind) -> Self { - Self { ident, doc: None, title: None, field_name: None, kind, parent: None } + pub fn new(ident: RustIdent) -> Self { + Self { ident, doc: None, title: None, field_name: None, parent: None } } /// Attach a doc comment. @@ -58,17 +57,17 @@ impl RustObject { } } - pub fn visit<'a, T: Visit<'a>>(&'a self, visitor: &mut T) { + pub fn visit<'a, T: Visit<'a>>(&'a self, visitor: &mut T, usage: ObjectUsage) { match self { Self::Struct(fields) => { for field in fields { - visitor.visit_typ(&field.rust_type); + visitor.visit_typ(&field.rust_type, usage); } } Self::Enum(variants) => { for variant in variants { if let Some(typ) = &variant.rust_type { - visitor.visit_typ(typ); + visitor.visit_typ(typ, usage); } } } @@ -76,17 +75,17 @@ impl RustObject { } } - pub fn visit_mut(&mut self, visitor: &mut T) { + pub fn visit_mut(&mut self, visitor: &mut T, usage: ObjectUsage) { match self { Self::Struct(fields) => { for field in fields { - visitor.visit_typ_mut(&mut field.rust_type); + visitor.visit_typ_mut(&mut field.rust_type, usage); } } Self::Enum(variants) => { for variant in variants { if let Some(typ) = &mut variant.rust_type { - visitor.visit_typ_mut(typ); + visitor.visit_typ_mut(typ, usage); } } } @@ -219,24 +218,109 @@ 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> { - let mut object_map = IndexMap::new(); +fn as_object_union( + components: &Components, + variants: &[EnumVariant], +) -> Option> { + 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 { + 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 { + 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), +} + +#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] +pub struct ObjectUsage { + pub kind: ObjectKind, + pub used_as_request_param: bool, +} + +impl ObjectUsage { + fn new(kind: ObjectKind, used_as_request_param: bool) -> Self { + Self { kind, used_as_request_param } + } + + pub fn request_param() -> Self { + Self::new(ObjectKind::RequestParam, true) + } + + pub fn type_def() -> Self { + Self::new(ObjectKind::Type, false) + } + + pub fn return_type() -> Self { + Self::new(ObjectKind::RequestReturned, false) + } + + pub fn should_impl_serialize(self) -> bool { + self.used_as_request_param + } + + pub fn should_impl_deserialize(self) -> bool { + matches!(self.kind, ObjectKind::RequestReturned | ObjectKind::Type) + } } #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] @@ -249,16 +333,14 @@ pub enum ObjectKind { Type, } -impl ObjectKind { - pub fn is_request_param(self) -> bool { - matches!(self, Self::RequestParam) - } - - pub fn should_impl_serialize(self) -> bool { - true - } +#[derive(Debug)] +pub struct PathAndIdent { + pub path: ComponentPath, + pub ident: RustIdent, +} - pub fn should_impl_deserialize(self) -> bool { - matches!(self, Self::RequestReturned | Self::Type) - } +#[derive(Debug)] +pub struct MaybeDeleted { + pub base: PathAndIdent, + pub deleted: PathAndIdent, } diff --git a/openapi/src/rust_type.rs b/openapi/src/rust_type.rs index 63f3bd2c2..35507b219 100644 --- a/openapi/src/rust_type.rs +++ b/openapi/src/rust_type.rs @@ -1,7 +1,7 @@ use std::fmt::{Debug, Display, Formatter}; use crate::components::Components; -use crate::rust_object::{ObjectMetadata, RustObject}; +use crate::rust_object::{ObjectMetadata, ObjectUsage, RustObject}; use crate::types::{ComponentPath, RustIdent}; use crate::visitor::{Visit, VisitMut}; @@ -176,6 +176,13 @@ impl RustType { } } + pub fn with_option_stripped(&self) -> &Self { + match self { + RustType::Container(Container::Option(inner)) => inner, + _ => self, + } + } + /// Does this contain a reference? Primarily used for detecting types that may /// require lifetimes. pub fn has_reference(&self, components: &Components) -> bool { @@ -195,8 +202,8 @@ impl RustType { Self::path(PathToType::Component(path), false) } - pub fn serde_json_value(is_ref: bool) -> Self { - Self::Simple(SimpleType::Ext(ExtType::Value { is_ref })) + pub fn json_value() -> Self { + Self::Simple(SimpleType::Ext(ExtType::Value)) } pub fn object_id(id_path: ComponentPath, is_ref: bool) -> Self { @@ -210,13 +217,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 { @@ -251,25 +251,25 @@ impl RustType { self.as_object().map(|r| r.0) } - pub fn visit<'a, T: Visit<'a>>(&'a self, visitor: &mut T) { + pub fn visit<'a, T: Visit<'a>>(&'a self, visitor: &mut T, usage: ObjectUsage) { use RustType::*; match self { Object(obj, meta) => { - visitor.visit_obj(obj, Some(meta)); + visitor.visit_obj(obj, Some(meta), usage); } Simple(_) | Path { .. } => {} - Container(inner) => visitor.visit_typ(inner.value_typ()), + Container(inner) => visitor.visit_typ(inner.value_typ(), usage), } } - pub fn visit_mut(&mut self, visitor: &mut T) { + pub fn visit_mut(&mut self, visitor: &mut T, usage: ObjectUsage) { use RustType::*; match self { Object(obj, meta) => { - visitor.visit_obj_mut(obj, Some(meta)); + visitor.visit_obj_mut(obj, Some(meta), usage); } Simple(_) | Path { .. } => {} - Container(inner) => visitor.visit_typ_mut(inner.value_typ_mut()), + Container(inner) => visitor.visit_typ_mut(inner.value_typ_mut(), usage), } } } @@ -369,12 +369,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 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) } pub const fn ident(self) -> &'static str { @@ -438,10 +438,8 @@ pub enum ExtType { RangeQueryTs, Timestamp, AlwaysTrue, - /// serde_json::Value - Value { - is_ref: bool, - }, + /// Arbitrary JSON value + Value, } impl ExtType { @@ -451,7 +449,7 @@ impl ExtType { Self::RangeQueryTs => "stripe_types::RangeQueryTs", Self::Timestamp => "stripe_types::Timestamp", Self::AlwaysTrue => "stripe_types::AlwaysTrue", - Self::Value { .. } => "serde_json::Value", + Self::Value => "miniserde::json::Value", } } @@ -461,7 +459,7 @@ impl ExtType { Self::RangeQueryTs => "RangeQueryTs", Self::Timestamp => "Timestamp", Self::AlwaysTrue => "AlwaysTrue", - Self::Value { .. } => "Value", + Self::Value => "Value", } } } diff --git a/openapi/src/spec_fetch.rs b/openapi/src/spec_fetch.rs index dc67ba5d3..2702b1336 100644 --- a/openapi/src/spec_fetch.rs +++ b/openapi/src/spec_fetch.rs @@ -5,6 +5,7 @@ use regex_lite::Regex; use reqwest::blocking::Client; use reqwest::header::USER_AGENT; use serde_json::Value; +use tracing::info; const VERSION_FILE_PATH: &str = "version.json"; @@ -67,7 +68,9 @@ pub fn fetch_spec(version: SpecVersion, in_path: &str) -> anyhow::Result SpecVersion::Version(v) => v, }; - tracing::info!("fetching OpenAPI spec version {}", desired_version); + ensure_correct_fixtures_file(&desired_version)?; + + info!("fetching OpenAPI spec version {}", desired_version); if let Some(value) = fs::File::open(in_path) .ok() @@ -87,8 +90,7 @@ pub fn fetch_spec(version: SpecVersion, in_path: &str) -> anyhow::Result } let url = format!( - "https://raw.githubusercontent.com/stripe/openapi/{}/openapi/spec3.sdk.json", - &desired_version + "https://raw.githubusercontent.com/stripe/openapi/{desired_version}/openapi/spec3.sdk.json" ); let mut spec: Value = client.get(url).send()?.error_for_status()?.json()?; @@ -96,7 +98,7 @@ pub fn fetch_spec(version: SpecVersion, in_path: &str) -> anyhow::Result let writer = fs::File::create(in_path)?; serde_json::to_writer_pretty(writer, &spec)?; - tracing::info!("Wrote OpenAPI spec to {}", in_path); + info!("Wrote OpenAPI spec to {}", in_path); let version_file_writer = fs::File::create(VERSION_FILE_PATH)?; serde_json::to_writer_pretty(version_file_writer, &VersionFile { version: desired_version })?; @@ -104,6 +106,40 @@ pub fn fetch_spec(version: SpecVersion, in_path: &str) -> anyhow::Result Ok(spec) } +fn ensure_correct_fixtures_file(desired_version: &str) -> anyhow::Result<()> { + if let Ok(file) = fs::File::open("fixtures.json") { + let fixtures: Value = serde_json::from_reader(file)?; + let curr_fixtures_version = read_fixtures_version(&fixtures); + if curr_fixtures_version == Some(desired_version) { + return Ok(()); + } + } + + fetch_new_fixtures(desired_version) +} + +fn fetch_new_fixtures(desired_version: &str) -> anyhow::Result<()> { + info!("Fetching new fixtures file"); + + let client = Client::new(); + let url = format!( + "https://raw.githubusercontent.com/stripe/openapi/{desired_version}/openapi/fixtures3.json" + ); + let mut spec: Value = client.get(url).send()?.error_for_status()?.json()?; + spec.as_object_mut() + .context("expected object")? + .insert("version".into(), Value::String(desired_version.into())); + + let writer = fs::File::create("fixtures.json")?; + serde_json::to_writer_pretty(writer, &spec)?; + info!("Finished writing fixtures file"); + Ok(()) +} + +fn read_fixtures_version(fixtures: &Value) -> Option<&str> { + fixtures.get("version")?.as_str() +} + fn write_x_stripe_tag(spec: &mut Value, version: &str) -> anyhow::Result<()> { spec.as_object_mut() .context("must be an object")? diff --git a/openapi/src/spec_inference.rs b/openapi/src/spec_inference.rs index af5fdd929..16ec3a0f0 100644 --- a/openapi/src/spec_inference.rs +++ b/openapi/src/spec_inference.rs @@ -8,9 +8,7 @@ use openapiv3::{ Type, VariantOrUnknownOrEmpty, }; -use crate::rust_object::{ - EnumVariant, FieldlessVariant, ObjectKind, ObjectMetadata, RustObject, StructField, -}; +use crate::rust_object::{EnumVariant, FieldlessVariant, ObjectMetadata, RustObject, StructField}; use crate::rust_type::{ExtType, IntType, RustType, SimpleType}; use crate::spec::{ as_data_array_item, as_object_enum_name, is_enum_with_just_empty_string, ExpansionResources, @@ -26,11 +24,10 @@ pub struct Inference<'a> { description: Option<&'a str>, title: Option<&'a str>, required: bool, - kind: ObjectKind, } impl<'a> Inference<'a> { - pub fn new(ident: &'a RustIdent, kind: ObjectKind) -> Self { + pub fn new(ident: &'a RustIdent) -> Self { Self { can_borrow: false, field_name: None, @@ -39,7 +36,6 @@ impl<'a> Inference<'a> { curr_ident: ident, id_path: None, title: None, - kind, } } @@ -95,7 +91,6 @@ impl<'a> Inference<'a> { doc: self.description.map(|d| d.to_string()), title: self.title.map(|t| t.to_string()), field_name: self.field_name.map(|t| t.to_string()), - kind: self.kind, parent: Some(self.curr_ident.clone()), }, ) @@ -224,9 +219,9 @@ 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 RustType::json_value(); } // Generate the struct type diff --git a/openapi/src/stripe_object.rs b/openapi/src/stripe_object.rs index ee228025b..d11d43c6a 100644 --- a/openapi/src/stripe_object.rs +++ b/openapi/src/stripe_object.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize}; use crate::crates::Crate; use crate::deduplication::DeduppedObject; -use crate::rust_object::{ObjectKind, RustObject}; +use crate::rust_object::{ObjectUsage, RustObject}; use crate::rust_type::RustType; use crate::spec_inference::Inference; use crate::types::{ComponentPath, RustIdent}; @@ -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 } @@ -141,6 +145,10 @@ impl StripeObject { RustIdent::create(format!("{}Id", self.ident())) } + pub fn object_name_ident(&self) -> RustIdent { + RustIdent::create(format!("{}ObjectName", self.ident())) + } + pub fn id_type(&self) -> Option<&RustType> { self.data.id_type.as_ref() } @@ -160,14 +168,14 @@ impl StripeObject { } pub fn visit<'a, V: Visit<'a>>(&'a self, visitor: &mut V) { - visitor.visit_obj(&self.data.obj, None); + visitor.visit_obj(&self.data.obj, None, ObjectUsage::type_def()); for req in &self.requests { visitor.visit_req(req); } } pub fn visit_mut(&mut self, visitor: &mut V) { - visitor.visit_obj_mut(&mut self.data.obj, None); + visitor.visit_obj_mut(&mut self.data.obj, None, ObjectUsage::type_def()); for req in &mut self.requests { visitor.visit_req_mut(req); } @@ -187,17 +195,16 @@ pub fn parse_stripe_schema_as_rust_object( ident: &RustIdent, ) -> StripeObjectData { let not_deleted_path = path.as_not_deleted(); - let infer_ctx = - Inference::new(ident, ObjectKind::Type).id_path(¬_deleted_path).required(true); + let infer_ctx = Inference::new(ident).id_path(¬_deleted_path).required(true); let typ = infer_ctx.infer_schema_type(schema); - let Some((mut rust_obj, _)) = typ.into_object() else { + let Some((rust_obj, _)) = typ.into_object() else { panic!("Unexpected top level schema type for {}", path); }; - match &mut rust_obj { + match &rust_obj { RustObject::Struct(fields) => { let mut id_type = None; let mut object_name = None; - fields.retain(|field| { + for field in fields { if field.field_name == "id" && field.rust_type.as_id_or_opt_id_path().is_some() { id_type = Some(field.rust_type.clone()); } @@ -208,14 +215,10 @@ pub fn parse_stripe_schema_as_rust_object( if variants.len() == 1 { let first = variants.first().unwrap(); object_name = Some(first.wire_name.clone()); - // The object name is used purely as a discriminant, so is - // unnecessary to generate 1-enum type for. - return false; } } } - true - }); + } StripeObjectData { obj: rust_obj, object_name, id_type } } RustObject::Enum(_) => { @@ -334,13 +337,13 @@ pub struct RequestSpec { impl RequestSpec { pub fn visit<'a, V: Visit<'a>>(&'a self, visitor: &mut V) { - visitor.visit_typ(&self.returned); - visitor.visit_typ(&self.params); + visitor.visit_typ(&self.returned, ObjectUsage::return_type()); + visitor.visit_typ(&self.params, ObjectUsage::request_param()); } pub fn visit_mut(&mut self, visitor: &mut V) { - visitor.visit_typ_mut(&mut self.returned); - visitor.visit_typ_mut(&mut self.params); + visitor.visit_typ_mut(&mut self.returned, ObjectUsage::return_type()); + visitor.visit_typ_mut(&mut self.params, ObjectUsage::request_param()); } } diff --git a/openapi/src/templates/cargo_toml.rs b/openapi/src/templates/cargo_toml.rs index 586fdebbb..d78266d70 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_features: Vec) -> String { let mut crate_dep_section = String::new(); + + let mut serde_features = vec!["stripe_types/serde".into()]; for dep in crate_deps { let dep_path = format!("../../generated/{}", dep.name()); let _ = writeln!(crate_dep_section, r#"{} = {{path = "{}"}}"#, dep.name(), dep_path); + serde_features.push(format!("{}/serde", dep.name())); } + let serde_features_str = + serde_features.into_iter().map(|f| format!(r#""{f}""#)).collect::>().join(","); + // Dependencies only needed for libraries which implement Stripe requests let request_deps = if krate == Crate::SHARED { "".into() @@ -55,14 +61,17 @@ pub fn gen_crate_toml(krate: Crate, crate_deps: Vec, crate_features: Vec< [dependencies] serde.workspace = true - smol_str.workspace = true serde_json.workspace = true + smol_str.workspace = true + miniserde.workspace = true stripe_types = {{path = "../../stripe_types"}} {request_deps} {crate_dep_section} - + + [features] + serde = [{serde_features_str}] {features} "# } @@ -99,7 +108,6 @@ fn gen_feature_section(mut crate_features: Vec) -> 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..653747be4 100644 --- a/openapi/src/templates/enums.rs +++ b/openapi/src/templates/enums.rs @@ -1,16 +1,22 @@ 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}; +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::{ + maybe_serde_gate, write_gated_serde_derive, write_gated_serde_rename, write_gated_serde_tag, + write_serde_derive, SerOrDeser, +}; impl<'a> ObjectWriter<'a> { - pub fn write_enum_variants(&self, out: &mut String, variants: &[EnumVariant]) { + /// Fallback case if no more specific structure inferred + pub fn write_arbitrary_enum_variants(&self, out: &mut String, variants: &[EnumVariant]) { + if !self.usage.used_as_request_param { + unimplemented!(); + } let enum_name = self.ident; // Build the body of the enum definition @@ -24,7 +30,8 @@ impl<'a> ObjectWriter<'a> { let _ = writeln!(enum_body, "{variant},"); } } - self.write_automatic_derives(out); + write_derives_line(out, self.derives); + write_serde_derive(out, SerOrDeser::Ser); let lifetime_str = self.lifetime_param(); let _ = writedoc!( out, @@ -37,36 +44,55 @@ impl<'a> ObjectWriter<'a> { ); } - 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.usage.used_as_request_param { 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); + write_derives_line(out, self.derives); + write_gated_serde_derive(out, SerOrDeser::Ser); + write_gated_serde_derive(out, SerOrDeser::Deser); 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} "# ); } @@ -110,7 +136,6 @@ impl<'a> ObjectWriter<'a> { // the (potentially many) strings in `as_str` and `from_str` used with the default derive. // These derived implementations often show up running `llvm-lines`, so easy // binary size + compile time win by doing this. - write_derives_line(out, self.derives.eq(true).debug(false)); self.write_nonexhaustive_attr(out); let _ = writedoc!( @@ -151,39 +176,67 @@ impl<'a> ObjectWriter<'a> { "# ); - if self.obj_kind.should_impl_serialize() { - let _ = writedoc!( - out, - r#" - impl serde::Serialize for {enum_name} {{ + let gate = maybe_serde_gate(!self.usage.should_impl_serialize()); + let _ = writedoc!( + out, + r#" + {gate}impl serde::Serialize for {enum_name} {{ fn serialize(&self, serializer: S) -> Result 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))") - } 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)?)") + }; + + if self.usage.should_impl_deserialize() { let _ = writedoc!( out, r#" + impl miniserde::Deserialize for {enum_name} {{ + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor {{ + crate::Place::new(out) + }} + }} + + 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(()) + }} + }} + + stripe_types::impl_from_val_with_from_str!({enum_name}); + "# + ); + } + + 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 _ = writedoc!( + out, + r#" + #[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for {enum_name} {{ fn deserialize>(deserializer: D) -> Result {{ use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - {ret_line} + {serde_ret_line} }} }} "# - ); - } + ); } } diff --git a/openapi/src/templates/miniserde.rs b/openapi/src/templates/miniserde.rs new file mode 100644 index 000000000..8cff7e997 --- /dev/null +++ b/openapi/src/templates/miniserde.rs @@ -0,0 +1,300 @@ +use std::fmt::Write; + +use indoc::{formatdoc, writedoc}; + +use crate::components::Components; +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#" + #[derive(Default)] + pub struct {builder_name} {{ + inner: stripe_types::miniserde_helpers::{inner_builder_type}, + }} + + 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) -> &mut dyn Visitor {{ + Place::new(out) + }} + }} + + impl Visitor for Place<{ident}> {{ + fn map(&mut self) -> Result> {{ + 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 {{ + {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 {{ + Some(match key {{ + {cons_inner} + _ => return None, + }}) + }} + }} + + impl FromValueOpt for {ident} {{ + fn from_value(v: Value) -> Option {{ + 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, self.components); + let _ = writedoc! { + out, + r#" + #[doc(hidden)] + pub struct {builder_name} {{ + {builder_inner} + }} + + #[allow(unused_variables, clippy::match_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], + components: &Components, +) -> 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 is_copy = field.rust_type.is_copy(components); + + // For types which implement `Copy`, we don't need to call `.take()`. Does not affect + // behavior, but helps a bit according to `llvm-lines` and binary size, so may as well since + // unnecessary `take()` is not optimized out + let take = if is_copy { "" } else { ".take()" }; + let _ = writeln!(finish_inner, "{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>` to `Ok(Some)` so that missing + // values are allowed for option types + let _ = writeln!(builder_new_inner, "{f_name}: Deserialize::default(),"); + } + + formatdoc! {r#" + impl Deserialize for {ident} {{ + fn begin(out: &mut Option) -> &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> {{ + 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} + _ => ::ignore(), + }}) + }} + + fn deser_default() -> Self {{ + Self {{ + {builder_new_inner} + }} + }} + + fn take_out(&mut self) -> Option {{ + Some(Self::Out {{ {finish_inner} }}) + }} + }} + + impl<'a> Map for Builder<'a> {{ + fn key(&mut self, k: &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 {{ + 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..a5d3417b4 100644 --- a/openapi/src/templates/mod.rs +++ b/openapi/src/templates/mod.rs @@ -1,10 +1,13 @@ //! This module holds methods relating to the generation of rust code. pub mod cargo_toml; -pub mod derives; pub mod enums; + +#[doc(hidden)] +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, ) { 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..16668723b 100644 --- a/openapi/src/templates/object_writer.rs +++ b/openapi/src/templates/object_writer.rs @@ -2,30 +2,29 @@ use std::fmt::Write; use crate::components::Components; use crate::printable::{Lifetime, PrintableType}; -use crate::rust_object::ObjectKind; +use crate::rust_object::ObjectUsage; use crate::rust_type::RustType; -use crate::templates::derives::Derives; use crate::types::RustIdent; #[derive(Copy, Clone)] pub struct ObjectWriter<'a> { pub components: &'a Components, - pub derives: Derives, pub lifetime: Option, + pub derives: Derives, pub ident: &'a RustIdent, pub provide_unknown_variant: bool, - pub obj_kind: ObjectKind, + pub usage: ObjectUsage, } impl<'a> ObjectWriter<'a> { - pub fn new(components: &'a Components, ident: &'a RustIdent, obj_kind: ObjectKind) -> Self { + pub fn new(components: &'a Components, ident: &'a RustIdent, usage: ObjectUsage) -> Self { Self { components, - derives: Derives::new(), lifetime: None, + derives: Derives::new(), ident, provide_unknown_variant: false, - obj_kind, + usage, } } @@ -45,7 +44,7 @@ impl<'a> ObjectWriter<'a> { } pub fn derive_default(&mut self, derive_default: bool) -> &mut Self { - self.derives = self.derives.default(derive_default); + self.derives = self.derives.derive_default(derive_default); self } @@ -62,13 +61,6 @@ impl<'a> ObjectWriter<'a> { let _ = out.write_str("#[non_exhaustive]"); } } - - pub fn write_automatic_derives(&self, out: &mut String) { - let mut derives = self.derives; - derives.serialize = self.obj_kind.should_impl_serialize(); - derives.deserialize = self.obj_kind.should_impl_deserialize(); - write_derives_line(out, derives) - } } pub fn write_derives_line(out: &mut String, derives: Derives) { @@ -86,11 +78,45 @@ 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(")]"); +} + +#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +pub struct Derives { + pub copy: bool, + pub debug: bool, + pub default: bool, + pub eq: bool, +} + +impl Derives { + pub fn new() -> Self { + Self::default() + } + + pub fn debug(mut self, debug: bool) -> Self { + self.debug = debug; + self + } + + pub fn copy(mut self, copy: bool) -> Self { + self.copy = copy; + self } - if derives.deserialize { - let _ = write!(out, "serde::Deserialize,"); + + pub fn derive_default(mut self, default: bool) -> Self { + self.default = default; + self + } + + pub fn eq(mut self, eq: bool) -> Self { + self.eq = eq; + self + } +} + +impl Default for Derives { + fn default() -> Self { + Self { debug: true, copy: false, default: false, eq: false } } - let _ = out.write_str(")]"); } diff --git a/openapi/src/templates/structs.rs b/openapi/src/templates/structs.rs index fc6553b74..3ee3f30cf 100644 --- a/openapi/src/templates/structs.rs +++ b/openapi/src/templates/structs.rs @@ -3,8 +3,13 @@ use std::fmt::Write; 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::rust_object::{ObjectKind, StructField, Visibility}; +use crate::rust_type::{ExtType, RustType, SimpleType}; +use crate::templates::object_writer::write_derives_line; +use crate::templates::utils::{ + write_doc_comment, write_gated_serde_derive, write_maybe_gated_serde_rename, + write_maybe_gated_serde_tag, write_serde_derive, SerOrDeser, +}; use crate::templates::ObjectWriter; impl<'a> ObjectWriter<'a> { @@ -17,7 +22,17 @@ impl<'a> ObjectWriter<'a> { } let lifetime_str = self.lifetime_param(); - self.write_automatic_derives(out); + write_derives_line(out, self.derives); + + // In theory this could be supported, but it would require not borrowing in request structs + if !matches!(self.usage.kind, ObjectKind::RequestParam) { + write_gated_serde_derive(out, SerOrDeser::Deser); + } + if self.usage.should_impl_serialize() { + write_serde_derive(out, SerOrDeser::Ser); + } else { + write_gated_serde_derive(out, SerOrDeser::Ser); + } let _ = writedoc!( out, r" @@ -27,7 +42,7 @@ impl<'a> ObjectWriter<'a> { " ); - if self.obj_kind.is_request_param() { + if self.usage.used_as_request_param { let cons_body = if self.derives.default { r" pub fn new() -> Self { @@ -72,19 +87,45 @@ impl<'a> ObjectWriter<'a> { " ); } + if self.usage.should_impl_deserialize() { + self.gen_miniserde_struct_deserialize(out, fields) + } } fn write_struct_field(&self, out: &mut String, field: &StructField) { + let needs_gate = !self.usage.should_impl_serialize(); if let Some(doc_comment) = &field.doc_comment { let _ = writeln!(out, "{}", write_doc_comment(doc_comment, 1).trim_end()); } if let Some(renamer) = &field.rename_as { - write_serde_rename(out, renamer); + write_maybe_gated_serde_rename(out, renamer, needs_gate); } - 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 && field.rust_type.is_option() && self.usage.used_as_request_param { + write_maybe_gated_serde_tag( + out, + r#"skip_serializing_if = "Option::is_none""#, + needs_gate, + ); + } + + if matches!( + field.rust_type.with_option_stripped(), + RustType::Simple(SimpleType::Ext(ExtType::Value { .. })) + ) { + let with = + if field.rust_type.is_option() { "with_serde_json_opt" } else { "with_serde_json" }; + write_maybe_gated_serde_tag( + out, + format!(r#"with = "stripe_types::{with}""#), + needs_gate, + ); + } + + // For the private `AlwaysTrue` or `ObjectName` 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..10421bdce 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,54 @@ 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 maybe_serde_gate(should_gate: bool) -> &'static str { + if should_gate { + r#"#[cfg(feature = "serde")]"# + } else { + "" + } +} + +pub enum SerOrDeser { + Ser, + Deser, +} + +impl SerOrDeser { + pub fn as_str(&self) -> &'static str { + match self { + SerOrDeser::Ser => "Serialize", + SerOrDeser::Deser => "Deserialize", + } + } +} + +pub fn write_gated_serde_derive(out: &mut String, kind: SerOrDeser) { + let _ = write!(out, r#"#[cfg_attr(feature = "serde", derive(serde::{}))]"#, kind.as_str()); +} + +pub fn write_serde_derive(out: &mut String, kind: SerOrDeser) { + let _ = write!(out, r#"#[derive(serde::{})]"#, kind.as_str()); +} + +pub fn write_gated_serde_rename(out: &mut String, rename: &str) { + write_gated_serde_tag(out, format!(r#"rename = "{rename}""#)); +} + +pub fn write_maybe_gated_serde_rename(out: &mut String, rename: &str, should_gate: bool) { + write_maybe_gated_serde_tag(out, format!(r#"rename = "{rename}""#), should_gate); +} + +pub fn write_gated_serde_tag(out: &mut String, tag: impl Display) { + let _ = writeln!(out, r#"#[cfg_attr(feature = "serde", serde({tag}))]"#); +} + +pub fn write_maybe_gated_serde_tag(out: &mut String, tag: impl Display, should_gate: bool) { + if should_gate { + write_gated_serde_tag(out, tag) + } else { + let _ = writeln!(out, r#"#[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/visitor.rs b/openapi/src/visitor.rs index 9d8ca25fb..aea83c9f2 100644 --- a/openapi/src/visitor.rs +++ b/openapi/src/visitor.rs @@ -1,20 +1,24 @@ -use crate::rust_object::{ObjectMetadata, RustObject}; +use crate::rust_object::{ObjectMetadata, ObjectUsage, RustObject}; use crate::rust_type::RustType; use crate::stripe_object::{RequestSpec, StripeObject}; pub trait Visit<'a> { - fn visit_obj(&mut self, obj: &'a RustObject, _meta: Option<&'a ObjectMetadata>) - where + fn visit_obj( + &mut self, + obj: &'a RustObject, + _meta: Option<&'a ObjectMetadata>, + usage: ObjectUsage, + ) where Self: Sized, { - obj.visit(self); + obj.visit(self, usage); } - fn visit_typ(&mut self, typ: &'a RustType) + fn visit_typ(&mut self, typ: &'a RustType, usage: ObjectUsage) where Self: Sized, { - typ.visit(self); + typ.visit(self, usage); } fn visit_req(&mut self, req: &'a RequestSpec) @@ -33,18 +37,22 @@ pub trait Visit<'a> { } pub trait VisitMut { - fn visit_obj_mut(&mut self, obj: &mut RustObject, _meta: Option<&ObjectMetadata>) - where + fn visit_obj_mut( + &mut self, + obj: &mut RustObject, + _meta: Option<&ObjectMetadata>, + usage: ObjectUsage, + ) where Self: Sized, { - obj.visit_mut(self); + obj.visit_mut(self, usage); } - fn visit_typ_mut(&mut self, typ: &mut RustType) + fn visit_typ_mut(&mut self, typ: &mut RustType, usage: ObjectUsage) where Self: Sized, { - typ.visit_mut(self); + typ.visit_mut(self, usage); } fn visit_req_mut(&mut self, req: &mut RequestSpec) diff --git a/openapi/src/webhook.rs b/openapi/src/webhook.rs index de6db1fcb..f6d3e5bae 100644 --- a/openapi/src/webhook.rs +++ b/openapi/src/webhook.rs @@ -8,10 +8,9 @@ use openapiv3::Schema; use crate::components::Components; use crate::crates::Crate; use crate::printable::PrintableType; -use crate::rust_object::{as_enum_of_objects, ObjectKind, RustObject}; +use crate::rust_object::{as_enum_of_objects, ObjectUsage, 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::utils::write_doc_comment; use crate::templates::ObjectWriter; @@ -29,14 +28,14 @@ fn write_event_object(components: &Components, out_path: &Path) -> anyhow::Resul let mut enum_body = String::new(); let mut match_inner = 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 { RustObject::Enum(variants) => as_enum_of_objects(components, variants), _ => None, }) { - ObjectWriter::new(components, &ident, ObjectKind::Type) + ObjectWriter::new(components, &ident, ObjectUsage::type_def()) .write_enum_of_objects(&mut out, &enum_objs); ( PrintableType::QualifiedPath { @@ -69,15 +68,15 @@ 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 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}(FromValueOpt::from_value(data)?),"# ); } - let _ = writeln!(enum_body, "Unknown(serde_json::Value),"); + let _ = writeln!(enum_body, "Unknown(miniserde::json::Value),"); - write_derives_line(&mut out, Derives::new()); + write_derives_line(&mut out, Default::default()); let _ = writedoc! {out, r#" #[non_exhaustive] /// The event data for a webhook event. @@ -88,10 +87,11 @@ 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 {{ - Ok(match typ {{ + pub(crate) fn from_raw_data(typ: &str, data: miniserde::json::Value) -> Option {{ + use stripe_types::miniserde_helpers::FromValueOpt; + Some(match typ {{ {match_inner} - _ => EventObject::Unknown(data), + _ => Self::Unknown(data), }}) }} }} @@ -103,7 +103,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, } @@ -118,11 +118,11 @@ impl WebhookObject { let desc = schema.schema_data.description.as_ref().context("expected description")?; let ident = RustIdent::create(event_type); - let infer_ctx = Inference::new(&ident, ObjectKind::Type); + let infer_ctx = Inference::new(&ident); 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..4d74aa284 100644 --- a/stripe_types/Cargo.toml +++ b/stripe_types/Cargo.toml @@ -12,9 +12,13 @@ keywords.workspace = true categories.workspace = true [dependencies] -serde = {workspace = true } +serde.workspace = true smol_str.workspace = true serde_json.workspace = true +miniserde.workspace = true [dev-dependencies] -serde_qs = "0.12.0" \ No newline at end of file +serde_qs = "0.12.0" + +[features] +serde = [] \ No newline at end of file diff --git a/stripe_types/src/currency.rs b/stripe_types/src/currency.rs index 6bf2ade64..49273eca7 100644 --- a/stripe_types/src/currency.rs +++ b/stripe_types/src/currency.rs @@ -1,9 +1,10 @@ -use serde::{Deserialize, Serialize}; +use serde::Serialize; /// Currency is the list of supported currencies. /// /// For more details see . -#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq, Hash, Default)] +#[derive(Copy, Clone, Debug, Eq, Serialize, PartialEq, Hash, Default, miniserde::Deserialize)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] pub enum Currency { #[serde(rename = "byn")] BYN, // Belarusian Ruble @@ -488,8 +489,8 @@ mod tests { #[test] fn deserialize_currency() { - assert_eq!(serde_json::from_str::("\"aed\"").unwrap(), Currency::AED); - assert_eq!(serde_json::from_str::("\"usd\"").unwrap(), Currency::USD); - assert_eq!(serde_json::from_str::("\"zmw\"").unwrap(), Currency::ZMW); + assert_eq!(miniserde::json::from_str::("\"aed\"").unwrap(), Currency::AED); + assert_eq!(miniserde::json::from_str::("\"usd\"").unwrap(), Currency::USD); + assert_eq!(miniserde::json::from_str::("\"zmw\"").unwrap(), Currency::ZMW); } } diff --git a/stripe_types/src/expandable.rs b/stripe_types/src/expandable.rs index 2d942c107..d4269b205 100644 --- a/stripe_types/src/expandable.rs +++ b/stripe_types/src/expandable.rs @@ -1,4 +1,4 @@ -use serde::{Deserialize, Serialize}; +use serde::Serialize; use crate::Object; @@ -9,7 +9,8 @@ use crate::Object; /// loaded as an object instead. /// /// For more details see . -#[derive(Clone, Debug, Serialize, Deserialize)] // TODO: Implement deserialize by hand for better error messages +#[derive(Clone, Debug, Serialize)] // TODO: Implement deserialize by hand for better error messages with `serde` enabled +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] #[serde(untagged)] pub enum Expandable { Id(T::Id), @@ -54,3 +55,99 @@ impl Expandable { } } } + +#[doc(hidden)] +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); + + /// Internal implementation details + 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>` 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 + where + Self::Out: Sized; + } + + /// Internal implementation details + pub trait ObjectDeser + where + Self: Sized, + { + type Builder: MapBuilder; + } + + impl Deserialize for Expandable + where + T: Object + Deserialize + ObjectDeser, + { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct ExpandableBuilder<'a, T: ObjectDeser + Object> { + out: &'a mut Option>, + 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 Visitor for Place> + 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> { + Ok(Box::new(ExpandableBuilder { + out: &mut self.out, + builder: T::Builder::deser_default(), + })) + } + } + + impl FromValueOpt for Expandable { + fn from_value(v: Value) -> Option { + 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, + } + } + } +} + +pub use miniserde::{MapBuilder, ObjectDeser}; diff --git a/stripe_types/src/ids.rs b/stripe_types/src/ids.rs index 36e123179..c18733a64 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 { @@ -11,6 +12,7 @@ macro_rules! def_id_serde_impls { } } + #[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for $struct_name { fn deserialize(deserializer: D) -> Result where @@ -20,6 +22,27 @@ macro_rules! def_id_serde_impls { s.parse::().map_err(::serde::de::Error::custom) } } + + impl stripe_types::FromCursor for $struct_name { + fn from_cursor(val: &str) -> Option { + use std::str::FromStr; + Self::from_str(val).ok() + } + } + + impl miniserde::Deserialize for $struct_name { + fn begin(out: &mut Option) -> &mut dyn miniserde::de::Visitor { + crate::Place::new(out) + } + } + + 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(()) + } + } + $crate::impl_from_val_with_from_str!($struct_name); }; } @@ -244,7 +267,6 @@ impl std::error::Error for ParseIdError { mod tests { use std::str::FromStr; - use serde::de::DeserializeOwned; use serde::Serialize; def_id!(ChargeId, "ch_" | "py_"); @@ -258,18 +280,18 @@ mod tests { fn assert_ser_de_roundtrip(id: &str) where - T: DeserializeOwned + Serialize + FromStr + std::fmt::Display + std::fmt::Debug, + T: miniserde::Deserialize + Serialize + FromStr + std::fmt::Display + std::fmt::Debug, ::Err: std::fmt::Debug, { let parsed_id = T::from_str(id).expect("Could not parse id"); - let ser = serde_json::to_string(&parsed_id).expect("Could not serialize id"); - let deser: T = serde_json::from_str(&ser).expect("Could not deserialize id"); + let ser = serde_json::to_string(&parsed_id).expect("Could not serialize"); + let deser: T = miniserde::json::from_str(&ser).expect("Could not deserialize id"); assert_eq!(deser.to_string(), id.to_string()); } - fn assert_deser_err(id: &str) { + fn assert_deser_err(id: &str) { let json_str = format!(r#""{}""#, id); - let deser: Result = serde_json::from_str(&json_str); + let deser: Result = miniserde::json::from_str(&json_str); assert!(deser.is_err(), "Expected error, got {:?}", deser); } diff --git a/stripe_types/src/lib.rs b/stripe_types/src/lib.rs index 08e1a4ec8..9483690cc 100644 --- a/stripe_types/src/lib.rs +++ b/stripe_types/src/lib.rs @@ -11,6 +11,15 @@ pub use expandable::*; pub use ids::*; pub use pagination::*; pub use params::*; +pub use serde_helpers::{with_serde_json, with_serde_json_opt}; + +miniserde::make_place!(Place); + +#[doc(hidden)] +pub mod miniserde_helpers; + +#[doc(hidden)] +pub mod serde_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..a8c8288de --- /dev/null +++ b/stripe_types/src/miniserde_helpers.rs @@ -0,0 +1,247 @@ +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 { + object: Object, + key: Option, + value: Option, +} + +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(); + self.key = Some(k.to_owned()); + Ok(Deserialize::begin(&mut self.value)) + } + + pub fn finish_inner(&mut self) -> Option<(String, Object)> { + self.shift(); + let object_key = self.object.get("object").and_then(|o| match o { + Value::String(object_key) => Some(object_key.clone()), + _ => None, + })?; + let final_object = mem::replace(&mut self.object, Object::new()); + Some((object_key, final_object)) + } +} + +#[derive(Default)] +pub struct MaybeDeletedBuilderInner { + object: Object, + key: Option, + value: Option, +} + +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 + where + Self: Sized; +} + +impl FromValueOpt for bool { + fn from_value(v: Value) -> Option { + match v { + Value::Bool(b) => Some(b), + _ => None, + } + } +} + +impl FromValueOpt for i64 { + fn from_value(v: Value) -> Option { + 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 { + 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 { + 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 { + 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 { + 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 { + match v { + Value::String(str) => Some(str), + _ => None, + } + } +} + +impl FromValueOpt for Option { + fn from_value(v: Value) -> Option { + match v { + Value::Null => Some(None), + val => Some(T::from_value(val)), + } + } +} + +impl FromValueOpt for Vec { + fn from_value(v: Value) -> Option { + match v { + Value::Array(items) => items.into_iter().map(|i| T::from_value(i)).collect(), + _ => None, + } + } +} + +impl FromValueOpt for HashMap { + fn from_value(v: Value) -> Option { + let Value::Object(obj) = v else { + return None; + }; + obj.into_iter() + .map(|(k, v)| { + let v = V::from_value(v)?; + Some((k, v)) + }) + .collect::>>() + } +} + +impl FromValueOpt for HashMap { + fn from_value(v: Value) -> Option { + 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::>>() + } +} + +pub fn extract_object_discr(value: Value) -> Option<(String, Object)> { + let Value::Object(obj) = value else { return None }; + let obj_name = obj.get("object")?; + let obj_str = match obj_name { + Value::String(str) => str.to_string(), + _ => return None, + }; + Some((obj_str, obj)) +} + +impl FromValueOpt for Value { + fn from_value(v: Value) -> Option { + Some(v) + } +} + +impl FromValueOpt for Box { + fn from_value(v: Value) -> Option { + 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 { + 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..6a5352fc3 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 miniserde::Deserialize; +use serde::ser::SerializeStruct; +use serde::{Serialize, Serializer}; 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; +pub trait FromCursor { + fn from_cursor(val: &str) -> Option + where + Self: Sized; +} + +impl FromCursor for smol_str::SmolStr { + fn from_cursor(val: &str) -> Option { + Self::from_str(val).ok() + } +} + +impl FromCursor for Option { + fn from_cursor(val: &str) -> Option { + Some(T::from_cursor(val)) + } } pub trait AsCursorOpt { @@ -38,6 +50,14 @@ impl AsCursorOpt for Option { } } +/// 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` and `SearchList` to be treated the same. Not part of the /// public API. /// @@ -47,7 +67,7 @@ impl AsCursorOpt for Option { /// 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: Deserialize { /// Underlying single element type, e.g. `Account` type Data; @@ -77,7 +97,11 @@ pub struct ListParts { pub has_more: bool, } -impl PaginableList for List { +impl PaginableList for List +where + T: Object, + List: Deserialize, +{ type Data = T; fn into_parts(self) -> ListParts { @@ -110,7 +134,8 @@ impl PaginableList for List { /// A single page of a cursor-paginated list of an object. /// /// For more details, see -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] pub struct List { pub data: Vec, pub has_more: bool, @@ -118,6 +143,25 @@ pub struct List { pub url: String, } +// Manually implementing this because we need to add the "object": "list" key. The workarounds +// mentioned in https://github.com/serde-rs/serde/issues/760 require adding a 1-enum variant, which has the downside +// that either this field is public (so consumers now have to add this meaningless field) or it is private (and +// we have a breaking change where `List` cannot be constructed with struct literal syntax) +impl Serialize for List { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut ser = serializer.serialize_struct("List", 5)?; + ser.serialize_field("data", &self.data)?; + ser.serialize_field("has_more", &self.has_more)?; + ser.serialize_field("total_count", &self.total_count)?; + ser.serialize_field("url", &self.url)?; + ser.serialize_field("object", "list")?; + ser.end() + } +} + impl Clone for List { fn clone(&self) -> Self { List { @@ -132,7 +176,8 @@ impl Clone for List { /// A single page of a cursor-paginated list of a search object. /// /// For more details, see -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Serialize)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] pub struct SearchList { pub url: String, pub has_more: bool, @@ -153,7 +198,10 @@ impl Clone for SearchList { } } -impl PaginableList for SearchList { +impl PaginableList for SearchList +where + SearchList: Deserialize, +{ type Data = T; /// NB: here we lose `next_page`, so we should be sure to `update_params` @@ -185,3 +233,134 @@ impl PaginableList for SearchList { } } } + +#[doc(hidden)] +mod impl_deserialize { + 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 Deserialize for List { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place> { + fn map(&mut self) -> miniserde::Result> { + 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>, + data: Option>, + has_more: Option, + total_count: Option>, + url: Option, + } + + 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(::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.ok_or(Error)?; + let total_count = self.total_count.ok_or(Error)?; + *self.out = Some(List { data, has_more, total_count, url }); + Ok(()) + } + } + + impl FromValueOpt for List { + fn from_value(v: Value) -> Option { + let mut data: Option> = None; + let mut has_more: Option = None; + let mut total_count: Option> = Some(None); + let mut url: Option = 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 Deserialize for SearchList { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + struct SearchListBuilder<'a, T> { + out: &'a mut Option>, + data: Option>, + has_more: Option, + total_count: Option>, + url: Option, + next_page: Option>, + } + + impl Visitor for Place> { + fn map(&mut self) -> miniserde::Result> { + 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(::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..fec447fb4 100644 --- a/stripe_types/src/params.rs +++ b/stripe_types/src/params.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use serde::{Deserializer, Serialize, Serializer}; +use serde::{Serialize, Serializer}; #[derive(Copy, Clone, Eq, PartialEq, Debug)] pub struct AlwaysTrue; @@ -14,10 +14,11 @@ impl serde::Serialize for AlwaysTrue { } } +#[cfg(feature = "serde")] impl<'de> serde::Deserialize<'de> for AlwaysTrue { fn deserialize(deserializer: D) -> Result where - D: Deserializer<'de>, + D: serde::Deserializer<'de>, { let bool_: bool = serde::Deserialize::deserialize(deserializer)?; if !bool_ { @@ -28,6 +29,44 @@ impl<'de> serde::Deserialize<'de> for AlwaysTrue { } } +#[doc(hidden)] +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) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + 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 { + let b = bool::from_value(v)?; + if b { + Some(AlwaysTrue) + } else { + None + } + } + } +} + pub type Metadata = HashMap; pub type Timestamp = i64; diff --git a/stripe_types/src/serde_helpers.rs b/stripe_types/src/serde_helpers.rs new file mode 100644 index 000000000..38d1109cc --- /dev/null +++ b/stripe_types/src/serde_helpers.rs @@ -0,0 +1,119 @@ +use miniserde::json::{Array, Number}; +use miniserde::json::{Object, Value as MiniValue}; +use serde::ser::{SerializeMap, SerializeSeq}; +use serde::{Serialize, Serializer}; +use serde_json::Value; + +struct Wrapper<'a>(&'a miniserde::json::Value); + +impl Serialize for Wrapper<'_> { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match &self.0 { + MiniValue::Null => serializer.serialize_none(), + MiniValue::Bool(bool) => serializer.serialize_bool(*bool), + MiniValue::Number(num) => match num { + Number::U64(uint) => serializer.serialize_u64(*uint), + Number::I64(int) => serializer.serialize_i64(*int), + Number::F64(float) => serializer.serialize_f64(*float), + }, + MiniValue::String(str) => serializer.serialize_str(str), + MiniValue::Array(items) => { + let mut seq = serializer.serialize_seq(Some(items.len()))?; + for item in items { + seq.serialize_element(&Wrapper(item))?; + } + seq.end() + } + MiniValue::Object(items) => { + let mut seq = serializer.serialize_map(Some(items.len()))?; + for (key, v) in items { + seq.serialize_entry(key, &Wrapper(v))?; + } + seq.end() + } + } + } +} + +pub mod with_serde_json { + use miniserde::json::Value as MiniValue; + use serde::{Deserialize, Deserializer, Serialize, Serializer}; + use serde_json::Value; + + use crate::serde_helpers::{serde_json_to_mini, Wrapper}; + + pub fn deserialize<'de, D>(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value = Value::deserialize(deserializer)?; + serde_json_to_mini(value).ok_or_else(|| { + serde::de::Error::custom("could not convert serde_json::Value to miniserde::Value") + }) + } + + pub fn serialize(val: &MiniValue, s: S) -> Result { + Wrapper(val).serialize(s) + } +} + +pub mod with_serde_json_opt { + use miniserde::json::Value as MiniValue; + use serde::{Deserialize, Deserializer, Serializer}; + use serde_json::Value; + + use crate::serde_helpers::{serde_json_to_mini, Wrapper}; + + pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> + where + D: Deserializer<'de>, + { + let value: Option = Deserialize::deserialize(deserializer)?; + match value { + None => Ok(None), + Some(s) => Ok(Some(serde_json_to_mini(s).ok_or_else(|| { + serde::de::Error::custom("could not convert serde_json::Value to miniserde::Value") + })?)), + } + } + + pub fn serialize(val: &Option, s: S) -> Result { + match val { + None => s.serialize_none(), + Some(v) => s.serialize_some(&Wrapper(v)), + } + } +} + +fn serde_json_to_mini(val: Value) -> Option { + Some(match val { + Value::Null => MiniValue::Null, + Value::Bool(bool) => MiniValue::Bool(bool), + Value::Number(num) => { + if let Some(float) = num.as_f64() { + MiniValue::Number(Number::F64(float)) + } else if let Some(uint) = num.as_u64() { + MiniValue::Number(Number::U64(uint)) + } else if let Some(int) = num.as_i64() { + MiniValue::Number(Number::I64(int)) + } else { + return None; + } + } + Value::String(str) => MiniValue::String(str), + Value::Array(arr) => { + let arr_conv = arr.into_iter().map(serde_json_to_mini).collect::>>()?; + MiniValue::Array(Array::from_iter(arr_conv)) + } + Value::Object(obj) => { + let items = obj + .into_iter() + .map(|(key, val)| serde_json_to_mini(val).map(|v| (key, v))) + .collect::>>()?; + MiniValue::Object(Object::from_iter(items)) + } + }) +} diff --git a/stripe_webhook/Cargo.toml b/stripe_webhook/Cargo.toml index f37595c9b..04de96da5 100644 --- a/stripe_webhook/Cargo.toml +++ b/stripe_webhook/Cargo.toml @@ -12,19 +12,22 @@ 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" -serde_json.workspace = true +miniserde.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 } + +[dev-dependencies] +serde_json.workspace = true [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..492a74c00 100644 --- a/stripe_webhook/src/generated/mod.rs +++ b/stripe_webhook/src/generated/mod.rs @@ -1,71 +1,672 @@ -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(tag = "object"))] pub enum AccountExternalAccountCreated { - #[serde(rename = "bank_account")] + #[cfg_attr(feature = "serde", serde(rename = "bank_account"))] BankAccount(stripe_shared::BankAccount), - #[serde(rename = "card")] + #[cfg_attr(feature = "serde", serde(rename = "card"))] Card(stripe_shared::Card), - #[serde(rename = "source")] + #[cfg_attr(feature = "serde", serde(rename = "source"))] Source(stripe_shared::Source), } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] + +#[derive(Default)] +pub struct AccountExternalAccountCreatedBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +const _: () = { + use 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, + builder: AccountExternalAccountCreatedBuilder, + } + + impl Deserialize for AccountExternalAccountCreated { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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 { + 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 { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(tag = "object"))] pub enum AccountExternalAccountDeleted { - #[serde(rename = "bank_account")] + #[cfg_attr(feature = "serde", serde(rename = "bank_account"))] BankAccount(stripe_shared::BankAccount), - #[serde(rename = "card")] + #[cfg_attr(feature = "serde", serde(rename = "card"))] Card(stripe_shared::Card), - #[serde(rename = "source")] + #[cfg_attr(feature = "serde", serde(rename = "source"))] Source(stripe_shared::Source), } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] + +#[derive(Default)] +pub struct AccountExternalAccountDeletedBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +const _: () = { + use 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, + builder: AccountExternalAccountDeletedBuilder, + } + + impl Deserialize for AccountExternalAccountDeleted { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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 { + 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 { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(tag = "object"))] pub enum AccountExternalAccountUpdated { - #[serde(rename = "bank_account")] + #[cfg_attr(feature = "serde", serde(rename = "bank_account"))] BankAccount(stripe_shared::BankAccount), - #[serde(rename = "card")] + #[cfg_attr(feature = "serde", serde(rename = "card"))] Card(stripe_shared::Card), - #[serde(rename = "source")] + #[cfg_attr(feature = "serde", serde(rename = "source"))] Source(stripe_shared::Source), } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] + +#[derive(Default)] +pub struct AccountExternalAccountUpdatedBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +const _: () = { + use 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, + builder: AccountExternalAccountUpdatedBuilder, + } + + impl Deserialize for AccountExternalAccountUpdated { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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 { + 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 { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(tag = "object"))] pub enum CustomerSourceCreated { - #[serde(rename = "bank_account")] + #[cfg_attr(feature = "serde", serde(rename = "bank_account"))] BankAccount(stripe_shared::BankAccount), - #[serde(rename = "card")] + #[cfg_attr(feature = "serde", serde(rename = "card"))] Card(stripe_shared::Card), - #[serde(rename = "source")] + #[cfg_attr(feature = "serde", serde(rename = "source"))] Source(stripe_shared::Source), } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] + +#[derive(Default)] +pub struct CustomerSourceCreatedBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +const _: () = { + use 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, + builder: CustomerSourceCreatedBuilder, + } + + impl Deserialize for CustomerSourceCreated { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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 { + 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 { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(tag = "object"))] pub enum CustomerSourceDeleted { - #[serde(rename = "bank_account")] + #[cfg_attr(feature = "serde", serde(rename = "bank_account"))] BankAccount(stripe_shared::BankAccount), - #[serde(rename = "card")] + #[cfg_attr(feature = "serde", serde(rename = "card"))] Card(stripe_shared::Card), - #[serde(rename = "source")] + #[cfg_attr(feature = "serde", serde(rename = "source"))] Source(stripe_shared::Source), } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] + +#[derive(Default)] +pub struct CustomerSourceDeletedBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +const _: () = { + use 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, + builder: CustomerSourceDeletedBuilder, + } + + impl Deserialize for CustomerSourceDeleted { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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 { + 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 { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(tag = "object"))] pub enum CustomerSourceExpiring { - #[serde(rename = "card")] + #[cfg_attr(feature = "serde", serde(rename = "card"))] Card(stripe_shared::Card), - #[serde(rename = "source")] + #[cfg_attr(feature = "serde", serde(rename = "source"))] Source(stripe_shared::Source), } -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -#[serde(tag = "object")] + +#[derive(Default)] +pub struct CustomerSourceExpiringBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +const _: () = { + use 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, + builder: CustomerSourceExpiringBuilder, + } + + impl Deserialize for CustomerSourceExpiring { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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 { + 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 { + let (typ, obj) = stripe_types::miniserde_helpers::extract_object_discr(v)?; + Self::construct(&typ, obj) + } + } +}; + +#[derive(Clone, Debug)] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(tag = "object"))] pub enum CustomerSourceUpdated { - #[serde(rename = "bank_account")] + #[cfg_attr(feature = "serde", serde(rename = "bank_account"))] BankAccount(stripe_shared::BankAccount), - #[serde(rename = "card")] + #[cfg_attr(feature = "serde", serde(rename = "card"))] Card(stripe_shared::Card), - #[serde(rename = "source")] + #[cfg_attr(feature = "serde", serde(rename = "source"))] Source(stripe_shared::Source), } + +#[derive(Default)] +pub struct CustomerSourceUpdatedBuilder { + inner: stripe_types::miniserde_helpers::ObjectBuilderInner, +} + +const _: () = { + use 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, + builder: CustomerSourceUpdatedBuilder, + } + + impl Deserialize for CustomerSourceUpdated { + fn begin(out: &mut Option) -> &mut dyn Visitor { + Place::new(out) + } + } + + impl Visitor for Place { + fn map(&mut self) -> Result> { + 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 { + 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 { + 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 { + 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. @@ -601,627 +1202,576 @@ 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(miniserde::json::Value), } impl EventObject { - pub(crate) fn from_raw_data(typ: &str, data: serde_json::Value) -> serde_json::Result { - Ok(match typ { + pub(crate) fn from_raw_data(typ: &str, data: miniserde::json::Value) -> Option { + use stripe_types::miniserde_helpers::FromValueOpt; + Some(match typ { "account.application.authorized" => { - EventObject::AccountApplicationAuthorized(serde_json::from_value(data)?) + Self::AccountApplicationAuthorized(FromValueOpt::from_value(data)?) } "account.application.deauthorized" => { - EventObject::AccountApplicationDeauthorized(serde_json::from_value(data)?) + Self::AccountApplicationDeauthorized(FromValueOpt::from_value(data)?) } "account.external_account.created" => { - EventObject::AccountExternalAccountCreated(serde_json::from_value(data)?) + Self::AccountExternalAccountCreated(FromValueOpt::from_value(data)?) } "account.external_account.deleted" => { - EventObject::AccountExternalAccountDeleted(serde_json::from_value(data)?) + Self::AccountExternalAccountDeleted(FromValueOpt::from_value(data)?) } "account.external_account.updated" => { - EventObject::AccountExternalAccountUpdated(serde_json::from_value(data)?) + Self::AccountExternalAccountUpdated(FromValueOpt::from_value(data)?) } - "account.updated" => EventObject::AccountUpdated(serde_json::from_value(data)?), + "account.updated" => Self::AccountUpdated(FromValueOpt::from_value(data)?), "application_fee.created" => { - EventObject::ApplicationFeeCreated(serde_json::from_value(data)?) + Self::ApplicationFeeCreated(FromValueOpt::from_value(data)?) } "application_fee.refund.updated" => { - EventObject::ApplicationFeeRefundUpdated(serde_json::from_value(data)?) + Self::ApplicationFeeRefundUpdated(FromValueOpt::from_value(data)?) } "application_fee.refunded" => { - EventObject::ApplicationFeeRefunded(serde_json::from_value(data)?) + Self::ApplicationFeeRefunded(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_core")] - "balance.available" => EventObject::BalanceAvailable(serde_json::from_value(data)?), + "balance.available" => Self::BalanceAvailable(FromValueOpt::from_value(data)?), #[cfg(feature = "stripe_billing")] "billing_portal.configuration.created" => { - EventObject::BillingPortalConfigurationCreated(serde_json::from_value(data)?) + Self::BillingPortalConfigurationCreated(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_billing")] "billing_portal.configuration.updated" => { - EventObject::BillingPortalConfigurationUpdated(serde_json::from_value(data)?) + Self::BillingPortalConfigurationUpdated(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_billing")] "billing_portal.session.created" => { - EventObject::BillingPortalSessionCreated(serde_json::from_value(data)?) + Self::BillingPortalSessionCreated(FromValueOpt::from_value(data)?) } - "capability.updated" => EventObject::CapabilityUpdated(serde_json::from_value(data)?), + "capability.updated" => Self::CapabilityUpdated(FromValueOpt::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(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" => { - EventObject::ChargeDisputeFundsReinstated(serde_json::from_value(data)?) + Self::ChargeDisputeFundsReinstated(FromValueOpt::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(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" => { - EventObject::CheckoutSessionAsyncPaymentFailed(serde_json::from_value(data)?) + Self::CheckoutSessionAsyncPaymentFailed(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_checkout")] "checkout.session.async_payment_succeeded" => { - EventObject::CheckoutSessionAsyncPaymentSucceeded(serde_json::from_value(data)?) + Self::CheckoutSessionAsyncPaymentSucceeded(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_checkout")] "checkout.session.completed" => { - EventObject::CheckoutSessionCompleted(serde_json::from_value(data)?) + Self::CheckoutSessionCompleted(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_checkout")] "checkout.session.expired" => { - EventObject::CheckoutSessionExpired(serde_json::from_value(data)?) + Self::CheckoutSessionExpired(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_misc")] - "climate.order.canceled" => { - EventObject::ClimateOrderCanceled(serde_json::from_value(data)?) - } + "climate.order.canceled" => Self::ClimateOrderCanceled(FromValueOpt::from_value(data)?), #[cfg(feature = "stripe_misc")] - "climate.order.created" => { - EventObject::ClimateOrderCreated(serde_json::from_value(data)?) - } + "climate.order.created" => Self::ClimateOrderCreated(FromValueOpt::from_value(data)?), #[cfg(feature = "stripe_misc")] - "climate.order.delayed" => { - EventObject::ClimateOrderDelayed(serde_json::from_value(data)?) - } + "climate.order.delayed" => Self::ClimateOrderDelayed(FromValueOpt::from_value(data)?), #[cfg(feature = "stripe_misc")] "climate.order.delivered" => { - EventObject::ClimateOrderDelivered(serde_json::from_value(data)?) + Self::ClimateOrderDelivered(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_misc")] "climate.order.product_substituted" => { - EventObject::ClimateOrderProductSubstituted(serde_json::from_value(data)?) + Self::ClimateOrderProductSubstituted(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_misc")] "climate.product.created" => { - EventObject::ClimateProductCreated(serde_json::from_value(data)?) + Self::ClimateProductCreated(FromValueOpt::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)?), + Self::ClimateProductPricingUpdated(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, - )?) + Self::FinancialConnectionsAccountRefreshedBalance(FromValueOpt::from_value(data)?) } #[cfg(feature = "stripe_misc")] "financial_connections.account.refreshed_transactions" => { - EventObject::FinancialConnectionsAccountRefreshedTransactions( - serde_json::from_value(data)?, - ) + Self::FinancialConnectionsAccountRefreshedTransactions(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 9b11134a9..0b6c267ca 100644 --- a/stripe_webhook/src/webhook.rs +++ b/stripe_webhook/src/webhook.rs @@ -43,7 +43,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, + pub previous_attributes: Option, } pub struct Webhook { @@ -108,7 +108,12 @@ 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 = miniserde::json::from_str(payload) + .map_err(|_| WebhookError::BadParse("could not deserialize webhook event".into()))?; + + 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, @@ -117,7 +122,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, @@ -214,7 +219,7 @@ mod tests { "data": { "object": data, }, - "type": Value::String(event_type.to_string()) + "type": event_type.to_string() }) } diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 9ad327741..14cb565fc 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -6,21 +6,27 @@ publish = false [dev-dependencies] serde.workspace = true -serde_json = "1" +miniserde.workspace = true serde_qs = "0.12.0" +serde_json.workspace = true chrono = "0.4.26" 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"} +stripe_types = { path = "../stripe_types", features = ["serde"] } +async-stripe = { path = "../async-stripe" } +stripe_connect = { path = "../generated/stripe_connect", features = ["account", "transfer_reversal", "serde"] } +stripe_billing = { path = "../generated/stripe_billing", features = ["invoice", "plan", "subscription", "subscription_item", "usage_record", "serde"] } +stripe_core = { path = "../generated/stripe_core", features = ["customer", "charge", "token", "serde"] } +stripe_checkout = { path = "../generated/stripe_checkout", features = ["checkout_session", "serde"] } +stripe_product = { path = "../generated/stripe_product", features = ["product", "price", "promotion_code", "serde"] } +stripe_payment = { path = "../generated/stripe_payment", features = ["serde"] } +stripe_treasury = { path = "../generated/stripe_treasury", features = ["serde"] } +stripe_terminal = { path = "../generated/stripe_terminal", features = ["serde"] } +stripe_fraud = { path = "../generated/stripe_fraud", features = ["serde"] } +stripe_issuing = { path = "../generated/stripe_issuing", features = ["serde"] } +stripe_misc = { path = "../generated/stripe_misc", features = ["serde"] } [features] async = [] diff --git a/tests/tests/it/deser.rs b/tests/tests/it/deser.rs index a04e4e1c2..5f12e5773 100644 --- a/tests/tests/it/deser.rs +++ b/tests/tests/it/deser.rs @@ -1,13 +1,17 @@ -use serde_json::json; -use stripe_core::{Charge, ChargeStatus, Customer}; -use stripe_types::Currency; +use miniserde::json::from_str; +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, 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, + "balance": 0, "created": 1542631579, "currency": null, "default_source": "card_ABCD", @@ -61,9 +65,15 @@ fn deserialize_customer_with_card() { }, "tax_info": null, "tax_info_verification": null - }); - let result = serde_json::from_value::(example); - assert!(result.is_ok(), "expected ok; was {:?}", result); + }) +} + +#[test] +fn deserialize_customer_with_card() { + let example = mock_customer_with_card().to_string(); + let result: Customer = from_str(&example).expect("deserialization failed"); + assert_eq!(result.balance, Some(0)); + assert!(!result.livemode); } #[test] @@ -142,9 +152,11 @@ fn deserialize_customer_with_source() { }, "tax_info": null, "tax_info_verification": null - }); - let result = serde_json::from_value::(example); - assert!(result.is_ok(), "expected ok; was {:?}", result); + }) + .to_string(); + + let result: Customer = from_str(&example).unwrap(); + assert_eq!(result.description, None); } #[test] @@ -195,9 +207,10 @@ fn deserialize_checkout_event() { "success_url": "https://example.com/success" } } - }); - let result = serde_json::from_value::(example); - assert!(result.is_ok(), "expected ok; was {:?}", result); + }) + .to_string(); + let result: Event = from_str(&example).unwrap(); + assert_eq!(result.pending_webhooks, 1); } #[test] @@ -213,16 +226,187 @@ fn deserialize_charge_with_no_refunds() { "currency": "cad", "created": 1703349829, "disputed": false, + "object": "charge", "id": "ch_123", "livemode": false, "metadata": {}, "paid": false, "status": "pending", "refunded": false, - }); - let charge: Charge = serde_json::from_value(example).unwrap(); + }) + .to_string(); + let charge: Charge = from_str(&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, + "object": "file", + "purpose": "account_requirement" + }) +} + +#[test] +fn deserialize_file() { + let file = mock_file(); + let file: File = from_str(&file.to_string()).unwrap(); + assert_eq!(file.purpose, FilePurpose::AccountRequirement); + assert_eq!(file.created, FILE_CREATED); +} + +#[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 = from_str(&data.to_string()).unwrap(); + assert_eq!(id.id, FileId::from_str("file_123").unwrap()); +} + +#[test] +fn deserialize_account_with_external_accounts() { + let acct_url = "/v1/accounts/acct_123/external_accounts"; + let account = json!({ + "id": "acct_123", + "object": "account", + "external_accounts": { + "data": [], + "has_more": false, + "object": "list", + "url": acct_url + }, + }); + let result: Account = from_str(&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 = + from_str(&payment_source.to_string()).expect("could not deserialize payment source"); + assert_payment_source_matches(&result); +} + +#[test] +fn deserialize_expandable() { + let file_link_base = json!({ + "created": 1704511150, + "expired": false, + "livemode": false, + "object": "file_link", + "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 = from_str(&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 = from_str(&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, + "object": "customer", + "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 = from_str(&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 = from_str(&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", + "object": "customer" + }); + let result: RetrieveCustomerReturned = from_str(&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 = from_str(&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/deserialization_fixture.rs b/tests/tests/it/deserialization_fixture.rs new file mode 100644 index 000000000..8e55fa65a --- /dev/null +++ b/tests/tests/it/deserialization_fixture.rs @@ -0,0 +1,148 @@ +use std::fmt::{Display, Formatter, Write}; +use std::fs::File; + +use serde_json::Value; + +#[test] +fn fixtures() { + let data: Value = + serde_json::from_reader(File::open("../openapi/fixtures.json").unwrap()).unwrap(); + let resources = &data["resources"]; + super::generated::check_fixtures(resources); +} + +const SKIP_PATHS: &[&str] = &[ + // Fixture data includes "id": "" and we don't deserialize the empty string to a valid id + "deleted_discount", + // https://github.com/stripe/openapi/issues/68 + "product", + // We expect the "plan" field to be required when deserializing the `SubscriptionItem` at the path + // `subscription.items.data`, but the field is not included in the provided fixture. See + // https://github.com/stripe/openapi/issues/138 and linked issue for some context. + "subscription", + "subscription_item", + "subscription_schedule", + // We expect a "billing_details" field at the path `treasury.outbound_payment.destination_payment_method_details`, + // but it is not present + "treasury.outbound_payment", +]; + +pub fn check_object(resources: &Value, key: &str) { + if SKIP_PATHS.contains(&key) { + return; + } + + let Some(fixture) = resources.as_object().unwrap().get(key) else { + println!("skipping component {key} since it was not found in the fixture data"); + return; + }; + let as_str = serde_json::to_string(fixture).unwrap(); + let result: T = miniserde::json::from_str(&as_str).unwrap_or_else(|_| { + panic!("could not deserialize fixture for {key}, data was {as_str}"); + }); + + let result_str = serde_json::to_string(&result).unwrap(); + let as_val: Value = serde_json::from_str(&result_str).unwrap(); + assert_json_matches(&as_val, fixture, &mut JsonKeyPath::new(key)); +} + +struct JsonKeyPath { + keys: Vec, +} + +impl JsonKeyPath { + pub fn new(base: impl ToString) -> Self { + Self { keys: vec![base.to_string()] } + } + + pub fn add_key(&mut self, new_key: impl ToString) { + self.keys.push(new_key.to_string()); + } + + pub fn pop_key(&mut self) { + self.keys.pop(); + } +} + +impl Display for JsonKeyPath { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + for (i, key) in self.keys.iter().enumerate() { + if i != 0 { + f.write_char('.')?; + } + write!(f, "{key}")?; + } + Ok(()) + } +} + +fn assert_json_matches(result: &Value, expected: &Value, key_path: &mut JsonKeyPath) { + let result = match result { + Value::Array(arr) => { + let Some(expected_arr) = expected.as_array() else { + panic!("Key {key_path}, result was array, but expected was {expected:?}") + }; + if arr.len() != expected_arr.len() { + panic!("Key {key_path}, mismatched array lengths, result was {result:?}, but expected was {expected:?}") + } + for (i, item) in arr.iter().enumerate() { + key_path.add_key(i); + assert_json_matches(item, &expected_arr[i], key_path); + + key_path.pop_key(); + } + return; + } + Value::Object(obj) => obj, + Value::Number(number) => { + let Some(expected_num) = expected.as_number() else { + panic!("Key {key_path}, result was number, but expected was {expected:?}") + }; + // NB: we compare floats here because the raw types will not be equivalent -> for example + // `19` in raw JSON can be deserialized into an `f64` field, which will then print as `19.0`. + assert_eq!(number.as_f64().unwrap(), expected_num.as_f64().unwrap()); + return; + } + _ => { + return assert_eq!( + result, expected, + "Key {key_path}, result was {result:?}, expected was {expected:?}" + ); + } + }; + + let Some(expected) = expected.as_object() else { + panic!("Key {key_path}, result was object, but expected was {expected:?}") + }; + + for (key, val) in result { + key_path.add_key(key); + match expected.get(key) { + None => { + // `expected` should only be missing a key result has if it was just not provided in the input json + assert!( + val.is_null(), + "Key {key_path}, result was {val:?}, expected did not include this key" + ) + } + Some(expected_val) => { + assert_json_matches(val, expected_val, key_path); + } + } + key_path.pop_key(); + } + for (key, val) in expected { + key_path.add_key(key); + match result.get(key) { + None => { + // This is a possible case if the fixture contains keys that have since been removed + // from the OpenAPI schema + println!("Key {key_path}, expected had value {val:?}, result did not have key.",); + } + Some(result_val) => { + assert_json_matches(result_val, val, key_path); + } + } + key_path.pop_key(); + } +} diff --git a/tests/tests/it/generated/mod.rs b/tests/tests/it/generated/mod.rs new file mode 100644 index 000000000..2e4054971 --- /dev/null +++ b/tests/tests/it/generated/mod.rs @@ -0,0 +1,218 @@ +use crate::deserialization_fixture::check_object; + +pub fn check_fixtures(resources: &serde_json::Value) { + check_object::(resources, "account"); + check_object::(resources, "account_link"); + check_object::(resources, "account_session"); + check_object::(resources, "apple_pay_domain"); + check_object::(resources, "application"); + check_object::(resources, "application_fee"); + check_object::(resources, "apps.secret"); + check_object::(resources, "balance"); + check_object::(resources, "balance_transaction"); + check_object::(resources, "bank_account"); + check_object::( + resources, + "billing_portal.configuration", + ); + check_object::(resources, "billing_portal.session"); + check_object::(resources, "capability"); + check_object::(resources, "card"); + check_object::(resources, "cash_balance"); + check_object::(resources, "charge"); + check_object::(resources, "checkout.session"); + check_object::(resources, "climate.order"); + check_object::(resources, "climate.product"); + check_object::(resources, "climate.supplier"); + check_object::( + resources, + "connect_collection_transfer", + ); + check_object::(resources, "country_spec"); + check_object::(resources, "coupon"); + check_object::(resources, "credit_note"); + check_object::(resources, "credit_note_line_item"); + check_object::(resources, "customer"); + check_object::( + resources, + "customer_balance_transaction", + ); + check_object::( + resources, + "customer_cash_balance_transaction", + ); + check_object::(resources, "customer_session"); + check_object::(resources, "deleted_account"); + check_object::(resources, "deleted_apple_pay_domain"); + check_object::(resources, "deleted_bank_account"); + check_object::(resources, "deleted_card"); + check_object::(resources, "deleted_coupon"); + check_object::(resources, "deleted_customer"); + check_object::(resources, "deleted_discount"); + check_object::(resources, "deleted_invoice"); + check_object::(resources, "deleted_invoiceitem"); + check_object::(resources, "deleted_person"); + check_object::(resources, "deleted_plan"); + check_object::(resources, "deleted_product"); + check_object::(resources, "deleted_radar.value_list"); + check_object::( + resources, + "deleted_radar.value_list_item", + ); + check_object::(resources, "deleted_subscription_item"); + check_object::(resources, "deleted_tax_id"); + check_object::( + resources, + "deleted_terminal.configuration", + ); + check_object::( + resources, + "deleted_terminal.location", + ); + check_object::(resources, "deleted_terminal.reader"); + check_object::( + resources, + "deleted_test_helpers.test_clock", + ); + check_object::(resources, "deleted_webhook_endpoint"); + check_object::(resources, "discount"); + check_object::(resources, "dispute"); + check_object::(resources, "ephemeral_key"); + check_object::(resources, "event"); + check_object::(resources, "exchange_rate"); + check_object::(resources, "fee_refund"); + check_object::(resources, "file"); + check_object::(resources, "file_link"); + check_object::( + resources, + "financial_connections.account", + ); + check_object::( + resources, + "financial_connections.account_owner", + ); + check_object::( + resources, + "financial_connections.account_ownership", + ); + check_object::( + resources, + "financial_connections.session", + ); + check_object::( + resources, + "financial_connections.transaction", + ); + check_object::(resources, "funding_instructions"); + check_object::( + resources, + "identity.verification_report", + ); + check_object::( + resources, + "identity.verification_session", + ); + check_object::(resources, "invoice"); + check_object::(resources, "invoiceitem"); + check_object::(resources, "issuing.authorization"); + check_object::(resources, "issuing.card"); + check_object::(resources, "issuing.cardholder"); + check_object::(resources, "issuing.dispute"); + check_object::(resources, "issuing.token"); + check_object::(resources, "issuing.transaction"); + check_object::(resources, "item"); + check_object::(resources, "line_item"); + check_object::(resources, "login_link"); + check_object::(resources, "mandate"); + check_object::(resources, "payment_intent"); + check_object::(resources, "payment_link"); + check_object::(resources, "payment_method"); + check_object::( + resources, + "payment_method_configuration", + ); + check_object::(resources, "payment_method_domain"); + check_object::(resources, "payout"); + check_object::(resources, "person"); + check_object::(resources, "plan"); + check_object::(resources, "platform_tax_fee"); + check_object::(resources, "price"); + check_object::(resources, "product"); + check_object::(resources, "promotion_code"); + check_object::(resources, "quote"); + check_object::(resources, "radar.early_fraud_warning"); + check_object::(resources, "radar.value_list"); + check_object::(resources, "radar.value_list_item"); + check_object::(resources, "refund"); + check_object::(resources, "reporting.report_run"); + check_object::(resources, "reporting.report_type"); + check_object::(resources, "reserve_transaction"); + check_object::(resources, "review"); + check_object::(resources, "scheduled_query_run"); + check_object::(resources, "setup_attempt"); + check_object::(resources, "setup_intent"); + check_object::(resources, "shipping_rate"); + check_object::(resources, "source"); + check_object::( + resources, + "source_mandate_notification", + ); + check_object::(resources, "source_transaction"); + check_object::(resources, "subscription"); + check_object::(resources, "subscription_item"); + check_object::(resources, "subscription_schedule"); + check_object::(resources, "tax.calculation"); + check_object::(resources, "tax.calculation_line_item"); + check_object::(resources, "tax.registration"); + check_object::(resources, "tax.settings"); + check_object::(resources, "tax.transaction"); + check_object::(resources, "tax.transaction_line_item"); + check_object::(resources, "tax_code"); + check_object::(resources, "tax_deducted_at_source"); + check_object::(resources, "tax_id"); + check_object::(resources, "tax_rate"); + check_object::(resources, "terminal.configuration"); + check_object::( + resources, + "terminal.connection_token", + ); + check_object::(resources, "terminal.location"); + check_object::(resources, "terminal.reader"); + check_object::(resources, "test_helpers.test_clock"); + check_object::(resources, "token"); + check_object::(resources, "topup"); + check_object::(resources, "transfer"); + check_object::(resources, "transfer_reversal"); + check_object::(resources, "treasury.credit_reversal"); + check_object::(resources, "treasury.debit_reversal"); + check_object::( + resources, + "treasury.financial_account", + ); + check_object::( + resources, + "treasury.financial_account_features", + ); + check_object::( + resources, + "treasury.inbound_transfer", + ); + check_object::( + resources, + "treasury.outbound_payment", + ); + check_object::( + resources, + "treasury.outbound_transfer", + ); + check_object::(resources, "treasury.received_credit"); + check_object::(resources, "treasury.received_debit"); + check_object::(resources, "treasury.transaction"); + check_object::( + resources, + "treasury.transaction_entry", + ); + check_object::(resources, "usage_record"); + check_object::(resources, "usage_record_summary"); + check_object::(resources, "webhook_endpoint"); +} diff --git a/tests/tests/it/main.rs b/tests/tests/it/main.rs index a0366d4b0..543f7ab76 100644 --- a/tests/tests/it/main.rs +++ b/tests/tests/it/main.rs @@ -1,6 +1,7 @@ // Needed for `json!` usage in tests #![recursion_limit = "256"] mod deser; +pub mod generated; mod mock; mod price; @@ -10,5 +11,6 @@ mod async_tests; mod blocking; // NB: pagination utils ideally could be used for blocking tests as well, but tricky because the `MockServer` is async // and the blocking client unconditionally creates its own runtime already +mod deserialization_fixture; #[cfg(feature = "async")] mod pagination_utils; diff --git a/tests/tests/it/price.rs b/tests/tests/it/price.rs index 4f85341f5..db965791b 100644 --- a/tests/tests/it/price.rs +++ b/tests/tests/it/price.rs @@ -1,3 +1,4 @@ +use miniserde::json::from_str; use stripe_product::{CurrencyOptionTaxBehavior, Price}; use stripe_types::Currency; @@ -49,10 +50,7 @@ fn deserialize_currency_options() { } "#; - let result: Result = serde_json::from_str(fixture); - assert!(result.is_ok()); - - let price = result.unwrap(); + let price: Price = from_str(fixture).unwrap(); assert!(&price.currency_options.is_some()); let currency_options = price.currency_options.unwrap();