Skip to content

Commit

Permalink
Try using just path to infer object struct name
Browse files Browse the repository at this point in the history
  • Loading branch information
mzeitlin11 committed Nov 30, 2023
1 parent b7630f9 commit 30eb3c1
Show file tree
Hide file tree
Showing 201 changed files with 11,954 additions and 12,775 deletions.
210 changes: 105 additions & 105 deletions crate_info.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/endpoints/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ stripe_billing = {path = "../../generated/stripe_billing", features = ["subscrip
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 = ["session"]}
stripe_checkout = {path = "../../generated/stripe_checkout", features = ["checkout_session"]}
stripe_connect = {path = "../../generated/stripe_connect", features = ["account", "account_link"]}

[features]
Expand Down
10 changes: 6 additions & 4 deletions examples/endpoints/src/checkout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
//! If you'd rather avoid this, you can use a [stripe_types::PaymentLink].

use stripe::StripeError;
use stripe_checkout::session::{CreateSession, CreateSessionLineItems, CreateSessionMode};
use stripe_checkout::checkout_session::{
CreateCheckoutSession, CreateCheckoutSessionLineItems, CreateCheckoutSessionMode,
};
use stripe_core::customer::CreateCustomer;
use stripe_product::price::CreatePrice;
use stripe_product::product::CreateProduct;
Expand Down Expand Up @@ -58,16 +60,16 @@ pub async fn run_checkout_session_example(client: &stripe::Client) -> Result<(),
);

// finally, create a checkout session for this product / price
let line_items = vec![CreateSessionLineItems {
let line_items = vec![CreateCheckoutSessionLineItems {
quantity: Some(3),
price: Some(&price.id),
..Default::default()
}];
let checkout_session = {
let mut params = CreateSession::new();
let mut params = CreateCheckoutSession::new();
params.cancel_url = Some("http://test.com/cancel");
params.customer = Some(customer.id.as_str());
params.mode = Some(CreateSessionMode::Payment);
params.mode = Some(CreateCheckoutSessionMode::Payment);
params.line_items = Some(&line_items);
params.expand = Some(&["line_items", "line_items.data.price.product"]);
params.send(client).await?
Expand Down
4 changes: 2 additions & 2 deletions examples/webhook-actix/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn handle_webhook(req: HttpRequest, payload: web::Bytes) -> Result<(), Webho
}
}
EventType::CheckoutSessionCompleted => {
if let EventObject::Session(session) = event.data.object {
if let EventObject::CheckoutSession(session) = event.data.object {
handle_checkout_session(session)?;
}
}
Expand All @@ -67,7 +67,7 @@ fn handle_account_updated(account: stripe_types::Account) -> Result<(), WebhookE
Ok(())
}

fn handle_checkout_session(session: stripe_checkout::Session) -> Result<(), WebhookError> {
fn handle_checkout_session(session: stripe_checkout::CheckoutSession) -> Result<(), WebhookError> {
println!("Received checkout session completed webhook with id: {:?}", session.id);
Ok(())
}
2 changes: 1 addition & 1 deletion examples/webhook-axum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ where
async fn handle_webhook(StripeEvent(event): StripeEvent) {
match event.type_ {
EventType::CheckoutSessionCompleted => {
if let EventObject::Session(session) = event.data.object {
if let EventObject::CheckoutSession(session) = event.data.object {
println!("Received checkout session completed webhook with id: {:?}", session.id);
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/webhook-rocket/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use rocket::data::{self, Data, FromData, ToByteUnit};
use rocket::http::Status;
use rocket::outcome::Outcome;
use rocket::request::{FromRequest, Request};
use stripe_checkout::Session;
use stripe_checkout::CheckoutSession;
use stripe_webhook::{EventObject, EventType, Webhook};

#[launch]
Expand All @@ -36,7 +36,7 @@ pub async fn stripe_webhooks(stripe_signature: StripeSignature<'_>, payload: Pay
) {
match event.type_ {
EventType::CheckoutSessionCompleted => {
if let EventObject::Session(session) = event.data.object {
if let EventObject::CheckoutSession(session) = event.data.object {
match checkout_session_completed(session) {
Ok(_) => Status::Accepted,
Err(_) => Status::BadRequest,
Expand All @@ -52,7 +52,7 @@ pub async fn stripe_webhooks(stripe_signature: StripeSignature<'_>, payload: Pay
}
}

fn checkout_session_completed<'a>(session: Session) -> Result<(), &'a str> {
fn checkout_session_completed<'a>(session: CheckoutSession) -> Result<(), &'a str> {
println!("Checkout Session Completed");
println!("{:?}", session.id);
Ok(())
Expand Down
22 changes: 11 additions & 11 deletions generated/stripe_billing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,37 +35,37 @@ runtime-blocking-rustls = ["async-stripe/runtime-blocking-rustls"]
runtime-blocking-rustls-webpki = ["async-stripe/runtime-blocking-rustls-webpki"]
runtime-async-std-surf = ["async-stripe/runtime-async-std-surf"]

billing_portal_configuration = []
billing_portal_session = []
credit_note = []
credit_note_line_item = []
invoice = []
invoice_item = []
invoice_line_item = []
invoiceitem = []
line_item = []
plan = []
portal_configuration = []
portal_session = []
quote = []
subscription = []
subscription_item = []
subscription_schedule = []
tax_id = []
test_clock = []
test_helpers_test_clock = []
usage_record = []
usage_record_summary = []

full = ["credit_note",
full = ["billing_portal_configuration",
"billing_portal_session",
"credit_note",
"credit_note_line_item",
"invoice",
"invoice_item",
"invoice_line_item",
"invoiceitem",
"line_item",
"plan",
"portal_configuration",
"portal_session",
"quote",
"subscription",
"subscription_item",
"subscription_schedule",
"tax_id",
"test_clock",
"test_helpers_test_clock",
"usage_record",
"usage_record_summary"]

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// A portal configuration describes the functionality and behavior of a portal session.
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]

Check warning on line 2 in generated/stripe_billing/src/billing_portal_configuration/mod.rs

View check run for this annotation

Codecov / codecov/patch

generated/stripe_billing/src/billing_portal_configuration/mod.rs#L2

Added line #L2 was not covered by tests
pub struct PortalConfiguration {
pub struct BillingPortalConfiguration {
/// Whether the configuration is active and can be used to create portal sessions.
pub active: bool,
/// ID of the Connect Application that created the configuration.
Expand All @@ -16,7 +16,7 @@ pub struct PortalConfiguration {
pub default_return_url: Option<String>,
pub features: stripe_billing::PortalFeatures,
/// Unique identifier for the object.
pub id: stripe_billing::portal_configuration::BillingPortalConfigurationId,
pub id: stripe_billing::billing_portal_configuration::BillingPortalConfigurationId,
/// Whether the configuration is the default.
///
/// If `true`, this configuration can be managed in the Dashboard and portal sessions will use this configuration unless it is overriden when creating the session.
Expand All @@ -33,14 +33,14 @@ pub struct PortalConfiguration {
/// Measured in seconds since the Unix epoch.
pub updated: stripe_types::Timestamp,
}
impl stripe_types::Object for PortalConfiguration {
type Id = stripe_billing::portal_configuration::BillingPortalConfigurationId;
impl stripe_types::Object for BillingPortalConfiguration {
type Id = stripe_billing::billing_portal_configuration::BillingPortalConfigurationId;
fn id(&self) -> Option<&str> {
Some(self.id.as_str())
}

Check warning on line 40 in generated/stripe_billing/src/billing_portal_configuration/mod.rs

View check run for this annotation

Codecov / codecov/patch

generated/stripe_billing/src/billing_portal_configuration/mod.rs#L38-L40

Added lines #L38 - L40 were not covered by tests
}
stripe_types::def_id!(BillingPortalConfigurationId, "bpc_");
#[cfg(feature = "portal_configuration")]
#[cfg(feature = "billing_portal_configuration")]
mod requests;
#[cfg(feature = "portal_configuration")]
#[cfg(feature = "billing_portal_configuration")]
pub use requests::*;
Loading

0 comments on commit 30eb3c1

Please sign in to comment.