Skip to content

Commit

Permalink
Deduplication WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mzeitlin11 committed Dec 27, 2023
1 parent acc796e commit 4b4f493
Show file tree
Hide file tree
Showing 127 changed files with 4,754 additions and 18,517 deletions.
7 changes: 3 additions & 4 deletions examples/endpoints/src/checkout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
//! If you'd rather avoid this, you can use a [stripe_types::PaymentLink].
use stripe::StripeError;
use stripe_checkout::checkout_session::{
CreateCheckoutSession, CreateCheckoutSessionLineItems, CreateCheckoutSessionMode,
};
use stripe_checkout::checkout_session::{CreateCheckoutSession, CreateCheckoutSessionLineItems};
use stripe_checkout::CheckoutSessionMode;
use stripe_core::customer::CreateCustomer;
use stripe_product::price::CreatePrice;
use stripe_product::product::CreateProduct;
Expand Down Expand Up @@ -69,7 +68,7 @@ pub async fn run_checkout_session_example(client: &stripe::Client) -> Result<(),
let mut params = CreateCheckoutSession::new();
params.cancel_url = Some("http://test.com/cancel");
params.customer = Some(customer.id.as_str());
params.mode = Some(CreateCheckoutSessionMode::Payment);
params.mode = Some(CheckoutSessionMode::Payment);
params.line_items = Some(&line_items);
params.expand = Some(&["line_items", "line_items.data.price.product"]);
params.send(client).await?
Expand Down
14 changes: 6 additions & 8 deletions examples/endpoints/src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,16 @@
//! brand color. See more: <https://dashboard.stripe.com/connect/accounts/overview>
use stripe::StripeError;
use stripe_connect::account::{
CreateAccount, CreateAccountCapabilities, CreateAccountCapabilitiesCardPayments,
CreateAccountCapabilitiesTransfers, CreateAccountType,
};
use stripe_connect::account::{CapabilitiesParam, CapabilityParam, CreateAccount};
use stripe_connect::account_link::{CreateAccountLink, CreateAccountLinkType};
use stripe_connect::AccountType;

pub async fn run_connect_example(client: &stripe::Client) -> Result<(), StripeError> {
let account = CreateAccount {
type_: Some(CreateAccountType::Express),
capabilities: Some(CreateAccountCapabilities {
card_payments: Some(CreateAccountCapabilitiesCardPayments { requested: Some(true) }),
transfers: Some(CreateAccountCapabilitiesTransfers { requested: Some(true) }),
type_: Some(AccountType::Express),
capabilities: Some(CapabilitiesParam {
card_payments: Some(CapabilityParam { requested: Some(true) }),
transfers: Some(CapabilityParam { requested: Some(true) }),
..Default::default()
}),
..Default::default()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub struct CreateBillingPortalConfigurationFeatures<'a> {
pub subscription_cancel: Option<CreateBillingPortalConfigurationFeaturesSubscriptionCancel<'a>>,
/// Information about pausing subscriptions in the portal.
#[serde(skip_serializing_if = "Option::is_none")]
pub subscription_pause: Option<CreateBillingPortalConfigurationFeaturesSubscriptionPause>,
pub subscription_pause: Option<SubscriptionPauseParam>,
/// Information about updating subscriptions in the portal.
#[serde(skip_serializing_if = "Option::is_none")]
pub subscription_update: Option<CreateBillingPortalConfigurationFeaturesSubscriptionUpdate<'a>>,
Expand Down Expand Up @@ -462,18 +462,6 @@ impl serde::Serialize
serializer.serialize_str(self.as_str())
}
}
/// Information about pausing subscriptions in the portal.
#[derive(Copy, Clone, Debug, Default, serde::Serialize)]
pub struct CreateBillingPortalConfigurationFeaturesSubscriptionPause {
/// Whether the feature is enabled.
#[serde(skip_serializing_if = "Option::is_none")]
pub enabled: Option<bool>,
}
impl CreateBillingPortalConfigurationFeaturesSubscriptionPause {
pub fn new() -> Self {
Self::default()
}
}
/// Information about updating subscriptions in the portal.
#[derive(Copy, Clone, Debug, serde::Serialize)]
pub struct CreateBillingPortalConfigurationFeaturesSubscriptionUpdate<'a> {
Expand All @@ -483,7 +471,7 @@ pub struct CreateBillingPortalConfigurationFeaturesSubscriptionUpdate<'a> {
/// Whether the feature is enabled.
pub enabled: bool,
/// The list of up to 10 products that support subscription updates.
pub products: &'a [CreateBillingPortalConfigurationFeaturesSubscriptionUpdateProducts<'a>],
pub products: &'a [SubscriptionUpdateProductParam<'a>],
/// Determines how to handle prorations resulting from subscription updates.
/// Valid values are `none`, `create_prorations`, and `always_invoice`.
#[serde(skip_serializing_if = "Option::is_none")]
Expand All @@ -494,7 +482,7 @@ impl<'a> CreateBillingPortalConfigurationFeaturesSubscriptionUpdate<'a> {
pub fn new(
default_allowed_updates: &'a [CreateBillingPortalConfigurationFeaturesSubscriptionUpdateDefaultAllowedUpdates],
enabled: bool,
products: &'a [CreateBillingPortalConfigurationFeaturesSubscriptionUpdateProducts<'a>],
products: &'a [SubscriptionUpdateProductParam<'a>],
) -> Self {
Self { default_allowed_updates, enabled, products, proration_behavior: None }
}
Expand Down Expand Up @@ -563,19 +551,6 @@ impl serde::Serialize
serializer.serialize_str(self.as_str())
}
}
/// The list of up to 10 products that support subscription updates.
#[derive(Copy, Clone, Debug, serde::Serialize)]
pub struct CreateBillingPortalConfigurationFeaturesSubscriptionUpdateProducts<'a> {
/// The list of price IDs for the product that a subscription can be updated to.
pub prices: &'a [&'a str],
/// The product id.
pub product: &'a str,
}
impl<'a> CreateBillingPortalConfigurationFeaturesSubscriptionUpdateProducts<'a> {
pub fn new(prices: &'a [&'a str], product: &'a str) -> Self {
Self { prices, product }
}
}
/// Determines how to handle prorations resulting from subscription updates.
/// Valid values are `none`, `create_prorations`, and `always_invoice`.
#[derive(Copy, Clone, Eq, PartialEq)]
Expand Down Expand Up @@ -729,7 +704,7 @@ pub struct UpdateBillingPortalConfigurationFeatures<'a> {
pub subscription_cancel: Option<UpdateBillingPortalConfigurationFeaturesSubscriptionCancel<'a>>,
/// Information about pausing subscriptions in the portal.
#[serde(skip_serializing_if = "Option::is_none")]
pub subscription_pause: Option<UpdateBillingPortalConfigurationFeaturesSubscriptionPause>,
pub subscription_pause: Option<SubscriptionPauseParam>,
/// Information about updating subscriptions in the portal.
#[serde(skip_serializing_if = "Option::is_none")]
pub subscription_update: Option<UpdateBillingPortalConfigurationFeaturesSubscriptionUpdate<'a>>,
Expand Down Expand Up @@ -1075,18 +1050,6 @@ impl serde::Serialize
serializer.serialize_str(self.as_str())
}
}
/// Information about pausing subscriptions in the portal.
#[derive(Copy, Clone, Debug, Default, serde::Serialize)]
pub struct UpdateBillingPortalConfigurationFeaturesSubscriptionPause {
/// Whether the feature is enabled.
#[serde(skip_serializing_if = "Option::is_none")]
pub enabled: Option<bool>,
}
impl UpdateBillingPortalConfigurationFeaturesSubscriptionPause {
pub fn new() -> Self {
Self::default()
}
}
/// Information about updating subscriptions in the portal.
#[derive(Copy, Clone, Debug, Default, serde::Serialize)]
pub struct UpdateBillingPortalConfigurationFeaturesSubscriptionUpdate<'a> {
Expand All @@ -1100,8 +1063,7 @@ pub struct UpdateBillingPortalConfigurationFeaturesSubscriptionUpdate<'a> {
pub enabled: Option<bool>,
/// The list of up to 10 products that support subscription updates.
#[serde(skip_serializing_if = "Option::is_none")]
pub products:
Option<&'a [UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateProducts<'a>]>,
pub products: Option<&'a [SubscriptionUpdateProductParam<'a>]>,
/// Determines how to handle prorations resulting from subscription updates.
/// Valid values are `none`, `create_prorations`, and `always_invoice`.
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -1177,19 +1139,6 @@ impl serde::Serialize
serializer.serialize_str(self.as_str())
}
}
/// The list of up to 10 products that support subscription updates.
#[derive(Copy, Clone, Debug, serde::Serialize)]
pub struct UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateProducts<'a> {
/// The list of price IDs for the product that a subscription can be updated to.
pub prices: &'a [&'a str],
/// The product id.
pub product: &'a str,
}
impl<'a> UpdateBillingPortalConfigurationFeaturesSubscriptionUpdateProducts<'a> {
pub fn new(prices: &'a [&'a str], product: &'a str) -> Self {
Self { prices, product }
}
}
/// Determines how to handle prorations resulting from subscription updates.
/// Valid values are `none`, `create_prorations`, and `always_invoice`.
#[derive(Copy, Clone, Eq, PartialEq)]
Expand Down Expand Up @@ -1302,3 +1251,26 @@ impl<'a> RetrieveBillingPortalConfiguration<'a> {
client.get_query(&format!("/billing_portal/configurations/{configuration}"), self)
}
}
#[derive(Copy, Clone, Debug, Default, serde::Serialize)]
pub struct SubscriptionPauseParam {
/// Whether the feature is enabled.
#[serde(skip_serializing_if = "Option::is_none")]
pub enabled: Option<bool>,
}
impl SubscriptionPauseParam {
pub fn new() -> Self {
Self::default()
}
}
#[derive(Copy, Clone, Debug, serde::Serialize)]
pub struct SubscriptionUpdateProductParam<'a> {
/// The list of price IDs for the product that a subscription can be updated to.
pub prices: &'a [&'a str],
/// The product id.
pub product: &'a str,
}
impl<'a> SubscriptionUpdateProductParam<'a> {
pub fn new(prices: &'a [&'a str], product: &'a str) -> Self {
Self { prices, product }
}
}
Loading

0 comments on commit 4b4f493

Please sign in to comment.