Skip to content

Commit

Permalink
Add fixture testing and serialize object keys
Browse files Browse the repository at this point in the history
Fix object keys in tests
  • Loading branch information
mzeitlin11 committed Apr 8, 2024
1 parent 7f9d426 commit 42cf51c
Show file tree
Hide file tree
Showing 401 changed files with 16,215 additions and 1,319 deletions.
77 changes: 77 additions & 0 deletions generated/stripe_billing/src/billing_portal_configuration/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ 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<std::collections::HashMap<String, String>>,
/// 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,
}
Expand All @@ -41,6 +43,7 @@ pub struct BillingPortalConfigurationBuilder {
livemode: Option<bool>,
login_page: Option<stripe_billing::PortalLoginPage>,
metadata: Option<Option<std::collections::HashMap<String, String>>>,
object: Option<BillingPortalConfigurationObject>,
updated: Option<stripe_types::Timestamp>,
}

Expand Down Expand Up @@ -89,6 +92,7 @@ const _: () = {
"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),

_ => <dyn Visitor>::ignore(),
Expand All @@ -108,6 +112,7 @@ const _: () = {
livemode: Deserialize::default(),
login_page: Deserialize::default(),
metadata: Deserialize::default(),
object: Deserialize::default(),
updated: Deserialize::default(),
}
}
Expand All @@ -125,6 +130,7 @@ const _: () = {
livemode: self.livemode?,
login_page: self.login_page.take()?,
metadata: self.metadata.take()?,
object: self.object?,
updated: self.updated?,
})
}
Expand Down Expand Up @@ -166,6 +172,7 @@ const _: () = {
"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)?),

_ => {}
Expand All @@ -175,6 +182,76 @@ const _: () = {
}
}
};
/// 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<Self, Self::Err> {
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<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl miniserde::Deserialize for BillingPortalConfigurationObject {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}

impl miniserde::de::Visitor for crate::Place<BillingPortalConfigurationObject> {
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<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use std::str::FromStr;
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 {
Expand Down
75 changes: 75 additions & 0 deletions generated/stripe_billing/src/billing_portal_session/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,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<stripe_billing::BillingPortalSessionLocale>,
/// 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).
Expand All @@ -51,6 +53,7 @@ pub struct BillingPortalSessionBuilder {
id: Option<stripe_billing::BillingPortalSessionId>,
livemode: Option<bool>,
locale: Option<Option<stripe_billing::BillingPortalSessionLocale>>,
object: Option<BillingPortalSessionObject>,
on_behalf_of: Option<Option<String>>,
return_url: Option<Option<String>>,
url: Option<String>,
Expand Down Expand Up @@ -97,6 +100,7 @@ const _: () = {
"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),
Expand All @@ -114,6 +118,7 @@ const _: () = {
id: Deserialize::default(),
livemode: Deserialize::default(),
locale: Deserialize::default(),
object: Deserialize::default(),
on_behalf_of: Deserialize::default(),
return_url: Deserialize::default(),
url: Deserialize::default(),
Expand All @@ -129,6 +134,7 @@ const _: () = {
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()?,
Expand Down Expand Up @@ -166,6 +172,7 @@ const _: () = {
"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)?),
Expand All @@ -177,6 +184,74 @@ const _: () = {
}
}
};
/// 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<Self, Self::Err> {
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<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl miniserde::Deserialize for BillingPortalSessionObject {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}

impl miniserde::de::Visitor for crate::Place<BillingPortalSessionObject> {
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<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use std::str::FromStr;
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pub struct PortalFlowsSubscriptionUpdateConfirmItem {
/// The price must also be included in the configuration's [`features.subscription_update.products`](https://stripe.com/docs/api/customer_portal/configuration#portal_configuration_object-features-subscription_update-products).
pub price: Option<String>,
/// [Quantity](https://stripe.com/docs/subscriptions/quantities) for this item that the customer should subscribe to through this flow.
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub quantity: Option<u64>,
}
#[doc(hidden)]
Expand Down
75 changes: 75 additions & 0 deletions generated/stripe_billing/src/usage_record/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pub struct UsageRecord {
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.
Expand All @@ -23,6 +25,7 @@ pub struct UsageRecord {
pub struct UsageRecordBuilder {
id: Option<stripe_billing::UsageRecordId>,
livemode: Option<bool>,
object: Option<UsageRecordObject>,
quantity: Option<u64>,
subscription_item: Option<String>,
timestamp: Option<stripe_types::Timestamp>,
Expand Down Expand Up @@ -64,6 +67,7 @@ const _: () = {
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),
Expand All @@ -76,6 +80,7 @@ const _: () = {
Self {
id: Deserialize::default(),
livemode: Deserialize::default(),
object: Deserialize::default(),
quantity: Deserialize::default(),
subscription_item: Deserialize::default(),
timestamp: Deserialize::default(),
Expand All @@ -86,6 +91,7 @@ const _: () = {
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?,
Expand Down Expand Up @@ -118,6 +124,7 @@ const _: () = {
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)?),
Expand All @@ -129,6 +136,74 @@ const _: () = {
}
}
};
/// 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<Self, Self::Err> {
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<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl miniserde::Deserialize for UsageRecordObject {
fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
crate::Place::new(out)
}
}

impl miniserde::de::Visitor for crate::Place<UsageRecordObject> {
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<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use std::str::FromStr;
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
pub struct CheckoutAcssDebitMandateOptions {
/// A URL for custom mandate text
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub custom_mandate_url: Option<String>,
/// List of Stripe products where this mandate can be selected automatically.
/// Returned when the Session is in `setup` mode.
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub default_for: Option<Vec<CheckoutAcssDebitMandateOptionsDefaultFor>>,
/// Description of the interval.
/// Only required if the 'payment_schedule' parameter is 'interval' or 'combined'.
Expand Down
Loading

0 comments on commit 42cf51c

Please sign in to comment.