From 975440d8faedcc79bdefbd83c1c0fbe92c242c8b Mon Sep 17 00:00:00 2001 From: Matthew Zeitlin <37011898+mzeitlin11@users.noreply.github.com> Date: Thu, 30 Nov 2023 15:16:06 -0500 Subject: [PATCH] Add some manual renaming to lessen breaking changes / use clearer names --- crate_info.md | 6 +- generated/stripe_billing/Cargo.toml | 8 +- .../src/checkout_session_item/mod.rs | 1 + .../stripe_billing/src/invoice/requests.rs | 4 +- .../stripe_billing/src/invoice_item/mod.rs | 5 + .../{invoiceitem => invoice_item}/requests.rs | 164 +++++++++--------- .../src/invoice_line_item/mod.rs | 5 + .../requests.rs | 98 +++++------ .../stripe_billing/src/invoiceitem/mod.rs | 5 - generated/stripe_billing/src/item/mod.rs | 1 - generated/stripe_billing/src/line_item/mod.rs | 5 - generated/stripe_billing/src/mod.rs | 12 +- .../stripe_billing/src/quote/requests.rs | 8 +- .../src/checkout_session/mod.rs | 2 +- .../src/checkout_session/requests.rs | 4 +- generated/stripe_connect/Cargo.toml | 4 +- .../src/application_fee_refund/mod.rs | 5 + .../requests.rs | 36 ++-- .../stripe_connect/src/fee_refund/mod.rs | 5 - generated/stripe_connect/src/mod.rs | 4 +- .../src/payment_link/requests.rs | 4 +- openapi/src/components.rs | 5 +- openapi/src/ids.rs | 10 +- openapi/src/object_writing.rs | 2 +- openapi/src/spec_inference.rs | 4 - openapi/src/stripe_object.rs | 65 ++++--- .../src/generated/application_fee/mod.rs | 2 +- .../mod.rs | 10 +- .../balance_transaction_source/mod.rs | 4 +- .../{item => checkout_session_item}/mod.rs | 10 +- .../src/generated/deleted_invoiceitem/mod.rs | 4 +- stripe_types/src/generated/invoice/mod.rs | 2 +- .../{invoiceitem => invoice_item}/mod.rs | 10 +- .../{line_item => invoice_line_item}/mod.rs | 37 ++-- stripe_types/src/generated/mod.rs | 16 +- .../src/generated/payment_link/mod.rs | 2 +- stripe_types/src/generated/quote/mod.rs | 2 +- .../generated/quotes_resource_upfront/mod.rs | 2 +- stripe_webhook/src/generated/mod.rs | 4 +- 39 files changed, 296 insertions(+), 281 deletions(-) create mode 100644 generated/stripe_billing/src/checkout_session_item/mod.rs create mode 100644 generated/stripe_billing/src/invoice_item/mod.rs rename generated/stripe_billing/src/{invoiceitem => invoice_item}/requests.rs (87%) create mode 100644 generated/stripe_billing/src/invoice_line_item/mod.rs rename generated/stripe_billing/src/{line_item => invoice_line_item}/requests.rs (86%) delete mode 100644 generated/stripe_billing/src/invoiceitem/mod.rs delete mode 100644 generated/stripe_billing/src/item/mod.rs delete mode 100644 generated/stripe_billing/src/line_item/mod.rs create mode 100644 generated/stripe_connect/src/application_fee_refund/mod.rs rename generated/stripe_connect/src/{fee_refund => application_fee_refund}/requests.rs (86%) delete mode 100644 generated/stripe_connect/src/fee_refund/mod.rs rename stripe_types/src/generated/{fee_refund => application_fee_refund}/mod.rs (84%) rename stripe_types/src/generated/{item => checkout_session_item}/mod.rs (84%) rename stripe_types/src/generated/{invoiceitem => invoice_item}/mod.rs (95%) rename stripe_types/src/generated/{line_item => invoice_line_item}/mod.rs (85%) diff --git a/crate_info.md b/crate_info.md index 10dfc23ee..5ea225755 100644 --- a/crate_info.md +++ b/crate_info.md @@ -5,8 +5,8 @@ | CreditNote | CreditNote | stripe_billing | credit_note | | CreditNoteLineItem | CreditNoteLineItem | stripe_billing | credit_note_line_item | | Invoice | Invoice | stripe_billing | invoice | -| Invoiceitem | Invoiceitem | stripe_billing | invoiceitem | -| LineItem | LineItem | stripe_billing | line_item | +| InvoiceItem | Invoiceitem | stripe_billing | invoice_item | +| InvoiceLineItem | LineItem | stripe_billing | invoice_line_item | | UsageRecordSummary | UsageRecordSummary | stripe_billing | usage_record_summary | | Plan | Plan | stripe_billing | plan | | Quote | Quote | stripe_billing | quote | @@ -25,7 +25,7 @@ | Capability | Capability | stripe_connect | capability | | CountrySpec | CountrySpec | stripe_connect | country_spec | | ExternalAccount | ExternalAccount | stripe_connect | external_account | -| FeeRefund | FeeRefund | stripe_connect | fee_refund | +| ApplicationFeeRefund | FeeRefund | stripe_connect | application_fee_refund | | LoginLink | LoginLink | stripe_connect | login_link | | Person | Person | stripe_connect | person | | Topup | Topup | stripe_connect | topup | diff --git a/generated/stripe_billing/Cargo.toml b/generated/stripe_billing/Cargo.toml index 0187160ca..e8e28635d 100644 --- a/generated/stripe_billing/Cargo.toml +++ b/generated/stripe_billing/Cargo.toml @@ -40,8 +40,8 @@ billing_portal_session = [] credit_note = [] credit_note_line_item = [] invoice = [] -invoiceitem = [] -line_item = [] +invoice_item = [] +invoice_line_item = [] plan = [] quote = [] subscription = [] @@ -57,8 +57,8 @@ full = ["billing_portal_configuration", "credit_note", "credit_note_line_item", "invoice", -"invoiceitem", -"line_item", +"invoice_item", +"invoice_line_item", "plan", "quote", "subscription", diff --git a/generated/stripe_billing/src/checkout_session_item/mod.rs b/generated/stripe_billing/src/checkout_session_item/mod.rs new file mode 100644 index 000000000..71063be53 --- /dev/null +++ b/generated/stripe_billing/src/checkout_session_item/mod.rs @@ -0,0 +1 @@ +pub use stripe_types::checkout_session_item::*; diff --git a/generated/stripe_billing/src/invoice/requests.rs b/generated/stripe_billing/src/invoice/requests.rs index 0814f2f09..3fe71aacd 100644 --- a/generated/stripe_billing/src/invoice/requests.rs +++ b/generated/stripe_billing/src/invoice/requests.rs @@ -4551,10 +4551,10 @@ impl<'a> UpcomingLinesInvoice<'a> { pub fn send( &self, client: &stripe::Client, - ) -> stripe::Response> { + ) -> stripe::Response> { client.get_query("/invoices/upcoming/lines", self) } - pub fn paginate(self) -> stripe::ListPaginator { + pub fn paginate(self) -> stripe::ListPaginator { stripe::ListPaginator::from_params("/invoices/upcoming/lines", self) } } diff --git a/generated/stripe_billing/src/invoice_item/mod.rs b/generated/stripe_billing/src/invoice_item/mod.rs new file mode 100644 index 000000000..934d85d83 --- /dev/null +++ b/generated/stripe_billing/src/invoice_item/mod.rs @@ -0,0 +1,5 @@ +pub use stripe_types::invoice_item::*; +#[cfg(feature = "invoice_item")] +mod requests; +#[cfg(feature = "invoice_item")] +pub use requests::*; diff --git a/generated/stripe_billing/src/invoiceitem/requests.rs b/generated/stripe_billing/src/invoice_item/requests.rs similarity index 87% rename from generated/stripe_billing/src/invoiceitem/requests.rs rename to generated/stripe_billing/src/invoice_item/requests.rs index 49cfbb6bb..aec5e150b 100644 --- a/generated/stripe_billing/src/invoiceitem/requests.rs +++ b/generated/stripe_billing/src/invoice_item/requests.rs @@ -1,5 +1,5 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListInvoiceitem<'a> { +pub struct ListInvoiceItem<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub created: Option, /// The identifier of the customer whose invoice items to return. @@ -40,28 +40,28 @@ pub struct ListInvoiceitem<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub starting_after: Option<&'a str>, } -impl<'a> ListInvoiceitem<'a> { +impl<'a> ListInvoiceItem<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> ListInvoiceitem<'a> { +impl<'a> ListInvoiceItem<'a> { /// Returns a list of your invoice items. /// /// Invoice items are returned sorted by creation date, with the most recently created invoice items appearing first. pub fn send( &self, client: &stripe::Client, - ) -> stripe::Response> { + ) -> stripe::Response> { client.get_query("/invoiceitems", self) } - pub fn paginate(self) -> stripe::ListPaginator { + pub fn paginate(self) -> stripe::ListPaginator { stripe::ListPaginator::from_params("/invoiceitems", self) } } -impl<'a> stripe::PaginationParams for ListInvoiceitem<'a> {} +impl<'a> stripe::PaginationParams for ListInvoiceItem<'a> {} #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateInvoiceitem<'a> { +pub struct CreateInvoiceItem<'a> { /// The integer amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice. /// /// Passing in a negative `amount` will reduce the `amount_due` on the invoice. @@ -86,7 +86,7 @@ pub struct CreateInvoiceitem<'a> { pub discountable: Option, /// The coupons to redeem into discounts for the invoice item or invoice line item. #[serde(skip_serializing_if = "Option::is_none")] - pub discounts: Option<&'a [CreateInvoiceitemDiscounts<'a>]>, + pub discounts: Option<&'a [CreateInvoiceItemDiscounts<'a>]>, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, @@ -110,13 +110,13 @@ pub struct CreateInvoiceitem<'a> { /// If you have [Stripe Revenue Recognition](https://stripe.com/docs/revenue-recognition) enabled, the period will be used to recognize and defer revenue. /// See the [Revenue Recognition documentation](https://stripe.com/docs/revenue-recognition/methodology/subscriptions-and-invoicing) for details. #[serde(skip_serializing_if = "Option::is_none")] - pub period: Option, + pub period: Option, /// The ID of the price object. #[serde(skip_serializing_if = "Option::is_none")] pub price: Option<&'a str>, /// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. #[serde(skip_serializing_if = "Option::is_none")] - pub price_data: Option>, + pub price_data: Option>, /// Non-negative integer. /// /// The quantity of units for the invoice item. @@ -135,7 +135,7 @@ pub struct CreateInvoiceitem<'a> { /// One of `inclusive`, `exclusive`, or `unspecified`. /// Once specified as either `inclusive` or `exclusive`, it cannot be changed. #[serde(skip_serializing_if = "Option::is_none")] - pub tax_behavior: Option, + pub tax_behavior: Option, /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID. #[serde(skip_serializing_if = "Option::is_none")] pub tax_code: Option<&'a str>, @@ -156,7 +156,7 @@ pub struct CreateInvoiceitem<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub unit_amount_decimal: Option<&'a str>, } -impl<'a> CreateInvoiceitem<'a> { +impl<'a> CreateInvoiceItem<'a> { pub fn new(customer: &'a str) -> Self { Self { amount: None, @@ -183,7 +183,7 @@ impl<'a> CreateInvoiceitem<'a> { } /// The coupons to redeem into discounts for the invoice item or invoice line item. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateInvoiceitemDiscounts<'a> { +pub struct CreateInvoiceItemDiscounts<'a> { /// ID of the coupon to create a new discount for. #[serde(skip_serializing_if = "Option::is_none")] pub coupon: Option<&'a str>, @@ -191,7 +191,7 @@ pub struct CreateInvoiceitemDiscounts<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub discount: Option<&'a str>, } -impl<'a> CreateInvoiceitemDiscounts<'a> { +impl<'a> CreateInvoiceItemDiscounts<'a> { pub fn new() -> Self { Self::default() } @@ -202,7 +202,7 @@ impl<'a> CreateInvoiceitemDiscounts<'a> { /// If you have [Stripe Revenue Recognition](https://stripe.com/docs/revenue-recognition) enabled, the period will be used to recognize and defer revenue. /// See the [Revenue Recognition documentation](https://stripe.com/docs/revenue-recognition/methodology/subscriptions-and-invoicing) for details. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateInvoiceitemPeriod { +pub struct CreateInvoiceItemPeriod { /// The end of the period, which must be greater than or equal to the start. /// /// This value is inclusive. @@ -212,14 +212,14 @@ pub struct CreateInvoiceitemPeriod { /// This value is inclusive. pub start: stripe_types::Timestamp, } -impl CreateInvoiceitemPeriod { +impl CreateInvoiceItemPeriod { pub fn new(end: stripe_types::Timestamp, start: stripe_types::Timestamp) -> Self { Self { end, start } } } /// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct CreateInvoiceitemPriceData<'a> { +pub struct CreateInvoiceItemPriceData<'a> { /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. /// /// Must be a [supported currency](https://stripe.com/docs/currencies). @@ -232,7 +232,7 @@ pub struct CreateInvoiceitemPriceData<'a> { /// One of `inclusive`, `exclusive`, or `unspecified`. /// Once specified as either `inclusive` or `exclusive`, it cannot be changed. #[serde(skip_serializing_if = "Option::is_none")] - pub tax_behavior: Option, + pub tax_behavior: Option, /// A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge. #[serde(skip_serializing_if = "Option::is_none")] pub unit_amount: Option, @@ -242,7 +242,7 @@ pub struct CreateInvoiceitemPriceData<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub unit_amount_decimal: Option<&'a str>, } -impl<'a> CreateInvoiceitemPriceData<'a> { +impl<'a> CreateInvoiceItemPriceData<'a> { pub fn new(currency: stripe_types::Currency, product: &'a str) -> Self { Self { currency, product, tax_behavior: None, unit_amount: None, unit_amount_decimal: None } } @@ -253,14 +253,14 @@ impl<'a> CreateInvoiceitemPriceData<'a> { /// One of `inclusive`, `exclusive`, or `unspecified`. /// Once specified as either `inclusive` or `exclusive`, it cannot be changed. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoiceitemPriceDataTaxBehavior { +pub enum CreateInvoiceItemPriceDataTaxBehavior { Exclusive, Inclusive, Unspecified, } -impl CreateInvoiceitemPriceDataTaxBehavior { +impl CreateInvoiceItemPriceDataTaxBehavior { pub fn as_str(self) -> &'static str { - use CreateInvoiceitemPriceDataTaxBehavior::*; + use CreateInvoiceItemPriceDataTaxBehavior::*; match self { Exclusive => "exclusive", Inclusive => "inclusive", @@ -269,10 +269,10 @@ impl CreateInvoiceitemPriceDataTaxBehavior { } } -impl std::str::FromStr for CreateInvoiceitemPriceDataTaxBehavior { +impl std::str::FromStr for CreateInvoiceItemPriceDataTaxBehavior { type Err = (); fn from_str(s: &str) -> Result { - use CreateInvoiceitemPriceDataTaxBehavior::*; + use CreateInvoiceItemPriceDataTaxBehavior::*; match s { "exclusive" => Ok(Exclusive), "inclusive" => Ok(Inclusive), @@ -281,23 +281,23 @@ impl std::str::FromStr for CreateInvoiceitemPriceDataTaxBehavior { } } } -impl AsRef for CreateInvoiceitemPriceDataTaxBehavior { +impl AsRef for CreateInvoiceItemPriceDataTaxBehavior { fn as_ref(&self) -> &str { self.as_str() } } -impl std::fmt::Display for CreateInvoiceitemPriceDataTaxBehavior { +impl std::fmt::Display for CreateInvoiceItemPriceDataTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateInvoiceitemPriceDataTaxBehavior { +impl std::fmt::Debug for CreateInvoiceItemPriceDataTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateInvoiceitemPriceDataTaxBehavior { +impl serde::Serialize for CreateInvoiceItemPriceDataTaxBehavior { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, @@ -311,14 +311,14 @@ impl serde::Serialize for CreateInvoiceitemPriceDataTaxBehavior { /// One of `inclusive`, `exclusive`, or `unspecified`. /// Once specified as either `inclusive` or `exclusive`, it cannot be changed. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum CreateInvoiceitemTaxBehavior { +pub enum CreateInvoiceItemTaxBehavior { Exclusive, Inclusive, Unspecified, } -impl CreateInvoiceitemTaxBehavior { +impl CreateInvoiceItemTaxBehavior { pub fn as_str(self) -> &'static str { - use CreateInvoiceitemTaxBehavior::*; + use CreateInvoiceItemTaxBehavior::*; match self { Exclusive => "exclusive", Inclusive => "inclusive", @@ -327,10 +327,10 @@ impl CreateInvoiceitemTaxBehavior { } } -impl std::str::FromStr for CreateInvoiceitemTaxBehavior { +impl std::str::FromStr for CreateInvoiceItemTaxBehavior { type Err = (); fn from_str(s: &str) -> Result { - use CreateInvoiceitemTaxBehavior::*; + use CreateInvoiceItemTaxBehavior::*; match s { "exclusive" => Ok(Exclusive), "inclusive" => Ok(Inclusive), @@ -339,23 +339,23 @@ impl std::str::FromStr for CreateInvoiceitemTaxBehavior { } } } -impl AsRef for CreateInvoiceitemTaxBehavior { +impl AsRef for CreateInvoiceItemTaxBehavior { fn as_ref(&self) -> &str { self.as_str() } } -impl std::fmt::Display for CreateInvoiceitemTaxBehavior { +impl std::fmt::Display for CreateInvoiceItemTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for CreateInvoiceitemTaxBehavior { +impl std::fmt::Debug for CreateInvoiceItemTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for CreateInvoiceitemTaxBehavior { +impl serde::Serialize for CreateInvoiceItemTaxBehavior { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, @@ -363,37 +363,37 @@ impl serde::Serialize for CreateInvoiceitemTaxBehavior { serializer.serialize_str(self.as_str()) } } -impl<'a> CreateInvoiceitem<'a> { +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. - pub fn send(&self, client: &stripe::Client) -> stripe::Response { + pub fn send(&self, client: &stripe::Client) -> stripe::Response { client.send_form("/invoiceitems", self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveInvoiceitem<'a> { +pub struct RetrieveInvoiceItem<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, } -impl<'a> RetrieveInvoiceitem<'a> { +impl<'a> RetrieveInvoiceItem<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> RetrieveInvoiceitem<'a> { +impl<'a> RetrieveInvoiceItem<'a> { /// Retrieves the invoice item with the given ID. pub fn send( &self, client: &stripe::Client, - invoiceitem: &stripe_types::invoiceitem::InvoiceitemId, - ) -> stripe::Response { + invoiceitem: &stripe_types::invoice_item::InvoiceItemId, + ) -> stripe::Response { client.get_query(&format!("/invoiceitems/{invoiceitem}"), self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateInvoiceitem<'a> { +pub struct UpdateInvoiceItem<'a> { /// The integer amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice. /// /// If you want to apply a credit to the customer's account, pass a negative amount. @@ -415,7 +415,7 @@ pub struct UpdateInvoiceitem<'a> { /// Item discounts are applied before invoice discounts. /// Pass an empty string to remove previously-defined discounts. #[serde(skip_serializing_if = "Option::is_none")] - pub discounts: Option<&'a [UpdateInvoiceitemDiscounts<'a>]>, + pub discounts: Option<&'a [UpdateInvoiceItemDiscounts<'a>]>, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, @@ -432,13 +432,13 @@ pub struct UpdateInvoiceitem<'a> { /// If you have [Stripe Revenue Recognition](https://stripe.com/docs/revenue-recognition) enabled, the period will be used to recognize and defer revenue. /// See the [Revenue Recognition documentation](https://stripe.com/docs/revenue-recognition/methodology/subscriptions-and-invoicing) for details. #[serde(skip_serializing_if = "Option::is_none")] - pub period: Option, + pub period: Option, /// The ID of the price object. #[serde(skip_serializing_if = "Option::is_none")] pub price: Option<&'a str>, /// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. #[serde(skip_serializing_if = "Option::is_none")] - pub price_data: Option>, + pub price_data: Option>, /// Non-negative integer. /// /// The quantity of units for the invoice item. @@ -450,7 +450,7 @@ pub struct UpdateInvoiceitem<'a> { /// One of `inclusive`, `exclusive`, or `unspecified`. /// Once specified as either `inclusive` or `exclusive`, it cannot be changed. #[serde(skip_serializing_if = "Option::is_none")] - pub tax_behavior: Option, + pub tax_behavior: Option, /// A [tax code](https://stripe.com/docs/tax/tax-categories) ID. #[serde(skip_serializing_if = "Option::is_none")] pub tax_code: Option<&'a str>, @@ -472,7 +472,7 @@ pub struct UpdateInvoiceitem<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub unit_amount_decimal: Option<&'a str>, } -impl<'a> UpdateInvoiceitem<'a> { +impl<'a> UpdateInvoiceItem<'a> { pub fn new() -> Self { Self::default() } @@ -482,7 +482,7 @@ impl<'a> UpdateInvoiceitem<'a> { /// Item discounts are applied before invoice discounts. /// Pass an empty string to remove previously-defined discounts. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateInvoiceitemDiscounts<'a> { +pub struct UpdateInvoiceItemDiscounts<'a> { /// ID of the coupon to create a new discount for. #[serde(skip_serializing_if = "Option::is_none")] pub coupon: Option<&'a str>, @@ -490,7 +490,7 @@ pub struct UpdateInvoiceitemDiscounts<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub discount: Option<&'a str>, } -impl<'a> UpdateInvoiceitemDiscounts<'a> { +impl<'a> UpdateInvoiceItemDiscounts<'a> { pub fn new() -> Self { Self::default() } @@ -501,7 +501,7 @@ impl<'a> UpdateInvoiceitemDiscounts<'a> { /// If you have [Stripe Revenue Recognition](https://stripe.com/docs/revenue-recognition) enabled, the period will be used to recognize and defer revenue. /// See the [Revenue Recognition documentation](https://stripe.com/docs/revenue-recognition/methodology/subscriptions-and-invoicing) for details. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateInvoiceitemPeriod { +pub struct UpdateInvoiceItemPeriod { /// The end of the period, which must be greater than or equal to the start. /// /// This value is inclusive. @@ -511,14 +511,14 @@ pub struct UpdateInvoiceitemPeriod { /// This value is inclusive. pub start: stripe_types::Timestamp, } -impl UpdateInvoiceitemPeriod { +impl UpdateInvoiceItemPeriod { pub fn new(end: stripe_types::Timestamp, start: stripe_types::Timestamp) -> Self { Self { end, start } } } /// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateInvoiceitemPriceData<'a> { +pub struct UpdateInvoiceItemPriceData<'a> { /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. /// /// Must be a [supported currency](https://stripe.com/docs/currencies). @@ -531,7 +531,7 @@ pub struct UpdateInvoiceitemPriceData<'a> { /// One of `inclusive`, `exclusive`, or `unspecified`. /// Once specified as either `inclusive` or `exclusive`, it cannot be changed. #[serde(skip_serializing_if = "Option::is_none")] - pub tax_behavior: Option, + pub tax_behavior: Option, /// A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge. #[serde(skip_serializing_if = "Option::is_none")] pub unit_amount: Option, @@ -541,7 +541,7 @@ pub struct UpdateInvoiceitemPriceData<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub unit_amount_decimal: Option<&'a str>, } -impl<'a> UpdateInvoiceitemPriceData<'a> { +impl<'a> UpdateInvoiceItemPriceData<'a> { pub fn new(currency: stripe_types::Currency, product: &'a str) -> Self { Self { currency, product, tax_behavior: None, unit_amount: None, unit_amount_decimal: None } } @@ -552,14 +552,14 @@ impl<'a> UpdateInvoiceitemPriceData<'a> { /// One of `inclusive`, `exclusive`, or `unspecified`. /// Once specified as either `inclusive` or `exclusive`, it cannot be changed. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoiceitemPriceDataTaxBehavior { +pub enum UpdateInvoiceItemPriceDataTaxBehavior { Exclusive, Inclusive, Unspecified, } -impl UpdateInvoiceitemPriceDataTaxBehavior { +impl UpdateInvoiceItemPriceDataTaxBehavior { pub fn as_str(self) -> &'static str { - use UpdateInvoiceitemPriceDataTaxBehavior::*; + use UpdateInvoiceItemPriceDataTaxBehavior::*; match self { Exclusive => "exclusive", Inclusive => "inclusive", @@ -568,10 +568,10 @@ impl UpdateInvoiceitemPriceDataTaxBehavior { } } -impl std::str::FromStr for UpdateInvoiceitemPriceDataTaxBehavior { +impl std::str::FromStr for UpdateInvoiceItemPriceDataTaxBehavior { type Err = (); fn from_str(s: &str) -> Result { - use UpdateInvoiceitemPriceDataTaxBehavior::*; + use UpdateInvoiceItemPriceDataTaxBehavior::*; match s { "exclusive" => Ok(Exclusive), "inclusive" => Ok(Inclusive), @@ -580,23 +580,23 @@ impl std::str::FromStr for UpdateInvoiceitemPriceDataTaxBehavior { } } } -impl AsRef for UpdateInvoiceitemPriceDataTaxBehavior { +impl AsRef for UpdateInvoiceItemPriceDataTaxBehavior { fn as_ref(&self) -> &str { self.as_str() } } -impl std::fmt::Display for UpdateInvoiceitemPriceDataTaxBehavior { +impl std::fmt::Display for UpdateInvoiceItemPriceDataTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateInvoiceitemPriceDataTaxBehavior { +impl std::fmt::Debug for UpdateInvoiceItemPriceDataTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateInvoiceitemPriceDataTaxBehavior { +impl serde::Serialize for UpdateInvoiceItemPriceDataTaxBehavior { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, @@ -610,14 +610,14 @@ impl serde::Serialize for UpdateInvoiceitemPriceDataTaxBehavior { /// One of `inclusive`, `exclusive`, or `unspecified`. /// Once specified as either `inclusive` or `exclusive`, it cannot be changed. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateInvoiceitemTaxBehavior { +pub enum UpdateInvoiceItemTaxBehavior { Exclusive, Inclusive, Unspecified, } -impl UpdateInvoiceitemTaxBehavior { +impl UpdateInvoiceItemTaxBehavior { pub fn as_str(self) -> &'static str { - use UpdateInvoiceitemTaxBehavior::*; + use UpdateInvoiceItemTaxBehavior::*; match self { Exclusive => "exclusive", Inclusive => "inclusive", @@ -626,10 +626,10 @@ impl UpdateInvoiceitemTaxBehavior { } } -impl std::str::FromStr for UpdateInvoiceitemTaxBehavior { +impl std::str::FromStr for UpdateInvoiceItemTaxBehavior { type Err = (); fn from_str(s: &str) -> Result { - use UpdateInvoiceitemTaxBehavior::*; + use UpdateInvoiceItemTaxBehavior::*; match s { "exclusive" => Ok(Exclusive), "inclusive" => Ok(Inclusive), @@ -638,23 +638,23 @@ impl std::str::FromStr for UpdateInvoiceitemTaxBehavior { } } } -impl AsRef for UpdateInvoiceitemTaxBehavior { +impl AsRef for UpdateInvoiceItemTaxBehavior { fn as_ref(&self) -> &str { self.as_str() } } -impl std::fmt::Display for UpdateInvoiceitemTaxBehavior { +impl std::fmt::Display for UpdateInvoiceItemTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateInvoiceitemTaxBehavior { +impl std::fmt::Debug for UpdateInvoiceItemTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateInvoiceitemTaxBehavior { +impl serde::Serialize for UpdateInvoiceItemTaxBehavior { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, @@ -662,33 +662,33 @@ impl serde::Serialize for UpdateInvoiceitemTaxBehavior { serializer.serialize_str(self.as_str()) } } -impl<'a> UpdateInvoiceitem<'a> { +impl<'a> UpdateInvoiceItem<'a> { /// Updates the amount or description of an invoice item on an upcoming invoice. /// /// Updating an invoice item is only possible before the invoice it’s attached to is closed. pub fn send( &self, client: &stripe::Client, - invoiceitem: &stripe_types::invoiceitem::InvoiceitemId, - ) -> stripe::Response { + invoiceitem: &stripe_types::invoice_item::InvoiceItemId, + ) -> stripe::Response { client.send_form(&format!("/invoiceitems/{invoiceitem}"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct DeleteInvoiceitem {} -impl DeleteInvoiceitem { +pub struct DeleteInvoiceItem {} +impl DeleteInvoiceItem { pub fn new() -> Self { Self::default() } } -impl DeleteInvoiceitem { +impl DeleteInvoiceItem { /// Deletes an invoice item, removing it from an invoice. /// /// Deleting invoice items is only possible when they’re not attached to invoices, or if it’s attached to a draft invoice. pub fn send( &self, client: &stripe::Client, - invoiceitem: &stripe_types::invoiceitem::InvoiceitemId, + invoiceitem: &stripe_types::invoice_item::InvoiceItemId, ) -> stripe::Response { client.send_form(&format!("/invoiceitems/{invoiceitem}"), self, http_types::Method::Delete) } diff --git a/generated/stripe_billing/src/invoice_line_item/mod.rs b/generated/stripe_billing/src/invoice_line_item/mod.rs new file mode 100644 index 000000000..328c5519a --- /dev/null +++ b/generated/stripe_billing/src/invoice_line_item/mod.rs @@ -0,0 +1,5 @@ +pub use stripe_types::invoice_line_item::*; +#[cfg(feature = "invoice_line_item")] +mod requests; +#[cfg(feature = "invoice_line_item")] +pub use requests::*; diff --git a/generated/stripe_billing/src/line_item/requests.rs b/generated/stripe_billing/src/invoice_line_item/requests.rs similarity index 86% rename from generated/stripe_billing/src/line_item/requests.rs rename to generated/stripe_billing/src/invoice_line_item/requests.rs index 3cd784f4a..cf1638bd8 100644 --- a/generated/stripe_billing/src/line_item/requests.rs +++ b/generated/stripe_billing/src/invoice_line_item/requests.rs @@ -1,5 +1,5 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListLineItem<'a> { +pub struct ListInvoiceLineItem<'a> { /// A cursor for use in pagination. /// /// `ending_before` is an object ID that defines your place in the list. @@ -21,12 +21,12 @@ pub struct ListLineItem<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub starting_after: Option<&'a str>, } -impl<'a> ListLineItem<'a> { +impl<'a> ListInvoiceLineItem<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> ListLineItem<'a> { +impl<'a> ListInvoiceLineItem<'a> { /// When retrieving an invoice, you’ll get a **lines** property containing the total count of line items and the first handful of those items. /// /// There is also a URL where you can retrieve the full (paginated) list of line items. @@ -34,19 +34,19 @@ impl<'a> ListLineItem<'a> { &self, client: &stripe::Client, invoice: &stripe_types::invoice::InvoiceId, - ) -> stripe::Response> { + ) -> stripe::Response> { client.get_query(&format!("/invoices/{invoice}/lines"), self) } pub fn paginate( self, invoice: &stripe_types::invoice::InvoiceId, - ) -> stripe::ListPaginator { + ) -> stripe::ListPaginator { stripe::ListPaginator::from_params(&format!("/invoices/{invoice}/lines"), self) } } -impl<'a> stripe::PaginationParams for ListLineItem<'a> {} +impl<'a> stripe::PaginationParams for ListInvoiceLineItem<'a> {} #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateLineItem<'a> { +pub struct UpdateInvoiceLineItem<'a> { /// The integer amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice. /// /// If you want to apply a credit to the customer's account, pass a negative amount. @@ -68,7 +68,7 @@ pub struct UpdateLineItem<'a> { /// Item discounts are applied before invoice discounts. /// Pass an empty string to remove previously-defined discounts. #[serde(skip_serializing_if = "Option::is_none")] - pub discounts: Option<&'a [UpdateLineItemDiscounts<'a>]>, + pub discounts: Option<&'a [UpdateInvoiceLineItemDiscounts<'a>]>, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, @@ -85,13 +85,13 @@ pub struct UpdateLineItem<'a> { /// If you have [Stripe Revenue Recognition](https://stripe.com/docs/revenue-recognition) enabled, the period will be used to recognize and defer revenue. /// See the [Revenue Recognition documentation](https://stripe.com/docs/revenue-recognition/methodology/subscriptions-and-invoicing) for details. #[serde(skip_serializing_if = "Option::is_none")] - pub period: Option, + pub period: Option, /// The ID of the price object. #[serde(skip_serializing_if = "Option::is_none")] pub price: Option<&'a str>, /// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. #[serde(skip_serializing_if = "Option::is_none")] - pub price_data: Option>, + pub price_data: Option>, /// Non-negative integer. /// /// The quantity of units for the line item. @@ -103,7 +103,7 @@ pub struct UpdateLineItem<'a> { /// 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). /// Pass an empty string to remove previously defined tax amounts. #[serde(skip_serializing_if = "Option::is_none")] - pub tax_amounts: Option<&'a [UpdateLineItemTaxAmounts<'a>]>, + pub tax_amounts: Option<&'a [UpdateInvoiceLineItemTaxAmounts<'a>]>, /// The tax rates which apply to the line item. /// /// When set, the `default_tax_rates` on the invoice do not apply to this line item. @@ -111,7 +111,7 @@ pub struct UpdateLineItem<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub tax_rates: Option<&'a [&'a str]>, } -impl<'a> UpdateLineItem<'a> { +impl<'a> UpdateInvoiceLineItem<'a> { pub fn new() -> Self { Self::default() } @@ -121,7 +121,7 @@ impl<'a> UpdateLineItem<'a> { /// Item discounts are applied before invoice discounts. /// Pass an empty string to remove previously-defined discounts. #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateLineItemDiscounts<'a> { +pub struct UpdateInvoiceLineItemDiscounts<'a> { /// ID of the coupon to create a new discount for. #[serde(skip_serializing_if = "Option::is_none")] pub coupon: Option<&'a str>, @@ -129,7 +129,7 @@ pub struct UpdateLineItemDiscounts<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub discount: Option<&'a str>, } -impl<'a> UpdateLineItemDiscounts<'a> { +impl<'a> UpdateInvoiceLineItemDiscounts<'a> { pub fn new() -> Self { Self::default() } @@ -140,7 +140,7 @@ impl<'a> UpdateLineItemDiscounts<'a> { /// If you have [Stripe Revenue Recognition](https://stripe.com/docs/revenue-recognition) enabled, the period will be used to recognize and defer revenue. /// See the [Revenue Recognition documentation](https://stripe.com/docs/revenue-recognition/methodology/subscriptions-and-invoicing) for details. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateLineItemPeriod { +pub struct UpdateInvoiceLineItemPeriod { /// The end of the period, which must be greater than or equal to the start. /// /// This value is inclusive. @@ -150,14 +150,14 @@ pub struct UpdateLineItemPeriod { /// This value is inclusive. pub start: stripe_types::Timestamp, } -impl UpdateLineItemPeriod { +impl UpdateInvoiceLineItemPeriod { pub fn new(end: stripe_types::Timestamp, start: stripe_types::Timestamp) -> Self { Self { end, start } } } /// Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateLineItemPriceData<'a> { +pub struct UpdateInvoiceLineItemPriceData<'a> { /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. /// /// Must be a [supported currency](https://stripe.com/docs/currencies). @@ -171,14 +171,14 @@ pub struct UpdateLineItemPriceData<'a> { /// /// One of `product` or `product_data` is required. #[serde(skip_serializing_if = "Option::is_none")] - pub product_data: Option>, + pub product_data: Option>, /// Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. /// /// Specifies whether the price is considered inclusive of taxes or exclusive of taxes. /// One of `inclusive`, `exclusive`, or `unspecified`. /// Once specified as either `inclusive` or `exclusive`, it cannot be changed. #[serde(skip_serializing_if = "Option::is_none")] - pub tax_behavior: Option, + pub tax_behavior: Option, /// A non-negative integer in cents (or local equivalent) representing how much to charge. /// /// One of `unit_amount` or `unit_amount_decimal` is required. @@ -190,7 +190,7 @@ pub struct UpdateLineItemPriceData<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub unit_amount_decimal: Option<&'a str>, } -impl<'a> UpdateLineItemPriceData<'a> { +impl<'a> UpdateInvoiceLineItemPriceData<'a> { pub fn new(currency: stripe_types::Currency) -> Self { Self { currency, @@ -206,7 +206,7 @@ impl<'a> UpdateLineItemPriceData<'a> { /// /// One of `product` or `product_data` is required. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateLineItemPriceDataProductData<'a> { +pub struct UpdateInvoiceLineItemPriceDataProductData<'a> { /// 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. @@ -228,7 +228,7 @@ pub struct UpdateLineItemPriceDataProductData<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub tax_code: Option<&'a str>, } -impl<'a> UpdateLineItemPriceDataProductData<'a> { +impl<'a> UpdateInvoiceLineItemPriceDataProductData<'a> { pub fn new(name: &'a str) -> Self { Self { description: None, images: None, metadata: None, name, tax_code: None } } @@ -239,14 +239,14 @@ impl<'a> UpdateLineItemPriceDataProductData<'a> { /// One of `inclusive`, `exclusive`, or `unspecified`. /// Once specified as either `inclusive` or `exclusive`, it cannot be changed. #[derive(Copy, Clone, Eq, PartialEq)] -pub enum UpdateLineItemPriceDataTaxBehavior { +pub enum UpdateInvoiceLineItemPriceDataTaxBehavior { Exclusive, Inclusive, Unspecified, } -impl UpdateLineItemPriceDataTaxBehavior { +impl UpdateInvoiceLineItemPriceDataTaxBehavior { pub fn as_str(self) -> &'static str { - use UpdateLineItemPriceDataTaxBehavior::*; + use UpdateInvoiceLineItemPriceDataTaxBehavior::*; match self { Exclusive => "exclusive", Inclusive => "inclusive", @@ -255,10 +255,10 @@ impl UpdateLineItemPriceDataTaxBehavior { } } -impl std::str::FromStr for UpdateLineItemPriceDataTaxBehavior { +impl std::str::FromStr for UpdateInvoiceLineItemPriceDataTaxBehavior { type Err = (); fn from_str(s: &str) -> Result { - use UpdateLineItemPriceDataTaxBehavior::*; + use UpdateInvoiceLineItemPriceDataTaxBehavior::*; match s { "exclusive" => Ok(Exclusive), "inclusive" => Ok(Inclusive), @@ -267,23 +267,23 @@ impl std::str::FromStr for UpdateLineItemPriceDataTaxBehavior { } } } -impl AsRef for UpdateLineItemPriceDataTaxBehavior { +impl AsRef for UpdateInvoiceLineItemPriceDataTaxBehavior { fn as_ref(&self) -> &str { self.as_str() } } -impl std::fmt::Display for UpdateLineItemPriceDataTaxBehavior { +impl std::fmt::Display for UpdateInvoiceLineItemPriceDataTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateLineItemPriceDataTaxBehavior { +impl std::fmt::Debug for UpdateInvoiceLineItemPriceDataTaxBehavior { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateLineItemPriceDataTaxBehavior { +impl serde::Serialize for UpdateInvoiceLineItemPriceDataTaxBehavior { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, @@ -297,7 +297,7 @@ impl serde::Serialize for UpdateLineItemPriceDataTaxBehavior { /// 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). /// Pass an empty string to remove previously defined tax amounts. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateLineItemTaxAmounts<'a> { +pub struct UpdateInvoiceLineItemTaxAmounts<'a> { /// The amount, in cents (or local equivalent), of the tax. pub amount: i64, /// Data to find or create a TaxRate object. @@ -306,14 +306,14 @@ pub struct UpdateLineItemTaxAmounts<'a> { /// /// If the `tax_rate_data` exactly matches a previous value, Stripe will reuse the TaxRate object. /// TaxRate objects created automatically by Stripe are immediately archived, do not appear in the line item’s `tax_rates`, and cannot be directly added to invoices, payments, or line items. - pub tax_rate_data: UpdateLineItemTaxAmountsTaxRateData<'a>, + pub tax_rate_data: UpdateInvoiceLineItemTaxAmountsTaxRateData<'a>, /// The amount on which tax is calculated, in cents (or local equivalent). pub taxable_amount: i64, } -impl<'a> UpdateLineItemTaxAmounts<'a> { +impl<'a> UpdateInvoiceLineItemTaxAmounts<'a> { pub fn new( amount: i64, - tax_rate_data: UpdateLineItemTaxAmountsTaxRateData<'a>, + tax_rate_data: UpdateInvoiceLineItemTaxAmountsTaxRateData<'a>, taxable_amount: i64, ) -> Self { Self { amount, tax_rate_data, taxable_amount } @@ -326,7 +326,7 @@ impl<'a> UpdateLineItemTaxAmounts<'a> { /// If the `tax_rate_data` exactly matches a previous value, Stripe will reuse the TaxRate object. /// TaxRate objects created automatically by Stripe are immediately archived, do not appear in the line item’s `tax_rates`, and cannot be directly added to invoices, payments, or line items. #[derive(Copy, Clone, Debug, serde::Serialize)] -pub struct UpdateLineItemTaxAmountsTaxRateData<'a> { +pub struct UpdateInvoiceLineItemTaxAmountsTaxRateData<'a> { /// Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). #[serde(skip_serializing_if = "Option::is_none")] pub country: Option<&'a str>, @@ -358,9 +358,9 @@ pub struct UpdateLineItemTaxAmountsTaxRateData<'a> { pub state: Option<&'a str>, /// The high-level tax type, such as `vat` or `sales_tax`. #[serde(skip_serializing_if = "Option::is_none")] - pub tax_type: Option, + pub tax_type: Option, } -impl<'a> UpdateLineItemTaxAmountsTaxRateData<'a> { +impl<'a> UpdateInvoiceLineItemTaxAmountsTaxRateData<'a> { pub fn new(display_name: &'a str, inclusive: bool, percentage: f64) -> Self { Self { country: None, @@ -377,7 +377,7 @@ impl<'a> UpdateLineItemTaxAmountsTaxRateData<'a> { /// The high-level tax type, such as `vat` or `sales_tax`. #[derive(Copy, Clone, Eq, PartialEq)] #[non_exhaustive] -pub enum UpdateLineItemTaxAmountsTaxRateDataTaxType { +pub enum UpdateInvoiceLineItemTaxAmountsTaxRateDataTaxType { AmusementTax, CommunicationsTax, Gst, @@ -394,9 +394,9 @@ pub enum UpdateLineItemTaxAmountsTaxRateDataTaxType { /// An unrecognized value from Stripe. Should not be used as a request parameter. Unknown, } -impl UpdateLineItemTaxAmountsTaxRateDataTaxType { +impl UpdateInvoiceLineItemTaxAmountsTaxRateDataTaxType { pub fn as_str(self) -> &'static str { - use UpdateLineItemTaxAmountsTaxRateDataTaxType::*; + use UpdateInvoiceLineItemTaxAmountsTaxRateDataTaxType::*; match self { AmusementTax => "amusement_tax", CommunicationsTax => "communications_tax", @@ -416,10 +416,10 @@ impl UpdateLineItemTaxAmountsTaxRateDataTaxType { } } -impl std::str::FromStr for UpdateLineItemTaxAmountsTaxRateDataTaxType { +impl std::str::FromStr for UpdateInvoiceLineItemTaxAmountsTaxRateDataTaxType { type Err = (); fn from_str(s: &str) -> Result { - use UpdateLineItemTaxAmountsTaxRateDataTaxType::*; + use UpdateInvoiceLineItemTaxAmountsTaxRateDataTaxType::*; match s { "amusement_tax" => Ok(AmusementTax), "communications_tax" => Ok(CommunicationsTax), @@ -438,23 +438,23 @@ impl std::str::FromStr for UpdateLineItemTaxAmountsTaxRateDataTaxType { } } } -impl AsRef for UpdateLineItemTaxAmountsTaxRateDataTaxType { +impl AsRef for UpdateInvoiceLineItemTaxAmountsTaxRateDataTaxType { fn as_ref(&self) -> &str { self.as_str() } } -impl std::fmt::Display for UpdateLineItemTaxAmountsTaxRateDataTaxType { +impl std::fmt::Display for UpdateInvoiceLineItemTaxAmountsTaxRateDataTaxType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for UpdateLineItemTaxAmountsTaxRateDataTaxType { +impl std::fmt::Debug for UpdateInvoiceLineItemTaxAmountsTaxRateDataTaxType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for UpdateLineItemTaxAmountsTaxRateDataTaxType { +impl serde::Serialize for UpdateInvoiceLineItemTaxAmountsTaxRateDataTaxType { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, @@ -462,7 +462,7 @@ impl serde::Serialize for UpdateLineItemTaxAmountsTaxRateDataTaxType { serializer.serialize_str(self.as_str()) } } -impl<'a> UpdateLineItem<'a> { +impl<'a> UpdateInvoiceLineItem<'a> { /// Updates an invoice’s line item. /// /// Some fields, such as `tax_amounts`, only live on the invoice line item, so they can only be updated through this endpoint. @@ -472,7 +472,7 @@ impl<'a> UpdateLineItem<'a> { client: &stripe::Client, invoice: &stripe_types::invoice::InvoiceId, line_item_id: &str, - ) -> stripe::Response { + ) -> stripe::Response { client.send_form( &format!("/invoices/{invoice}/lines/{line_item_id}"), self, diff --git a/generated/stripe_billing/src/invoiceitem/mod.rs b/generated/stripe_billing/src/invoiceitem/mod.rs deleted file mode 100644 index a8ca275af..000000000 --- a/generated/stripe_billing/src/invoiceitem/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub use stripe_types::invoiceitem::*; -#[cfg(feature = "invoiceitem")] -mod requests; -#[cfg(feature = "invoiceitem")] -pub use requests::*; diff --git a/generated/stripe_billing/src/item/mod.rs b/generated/stripe_billing/src/item/mod.rs deleted file mode 100644 index c46f4874d..000000000 --- a/generated/stripe_billing/src/item/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub use stripe_types::item::*; diff --git a/generated/stripe_billing/src/line_item/mod.rs b/generated/stripe_billing/src/line_item/mod.rs deleted file mode 100644 index f92190361..000000000 --- a/generated/stripe_billing/src/line_item/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub use stripe_types::line_item::*; -#[cfg(feature = "line_item")] -mod requests; -#[cfg(feature = "line_item")] -pub use requests::*; diff --git a/generated/stripe_billing/src/mod.rs b/generated/stripe_billing/src/mod.rs index 730061673..92956a75b 100644 --- a/generated/stripe_billing/src/mod.rs +++ b/generated/stripe_billing/src/mod.rs @@ -80,8 +80,8 @@ pub use stripe_types::InvoiceThresholdReason; pub mod invoice_threshold_reason; pub use stripe_types::InvoiceTransferData; pub mod invoice_transfer_data; -pub use stripe_types::Invoiceitem; -pub mod invoiceitem; +pub use stripe_types::InvoiceItem; +pub mod invoice_item; pub use stripe_types::InvoicesFromInvoice; pub mod invoices_from_invoice; pub use stripe_types::InvoicesInvoiceRendering; @@ -100,10 +100,10 @@ pub use stripe_types::InvoicesShippingCost; pub mod invoices_shipping_cost; pub use stripe_types::InvoicesStatusTransitions; pub mod invoices_status_transitions; -pub use stripe_types::Item; -pub mod item; -pub use stripe_types::LineItem; -pub mod line_item; +pub use stripe_types::CheckoutSessionItem; +pub mod checkout_session_item; +pub use stripe_types::InvoiceLineItem; +pub mod invoice_line_item; pub use stripe_types::UsageRecordSummary; pub mod usage_record_summary; pub use stripe_types::Period; diff --git a/generated/stripe_billing/src/quote/requests.rs b/generated/stripe_billing/src/quote/requests.rs index 6ee5d12c0..c4421fcad 100644 --- a/generated/stripe_billing/src/quote/requests.rs +++ b/generated/stripe_billing/src/quote/requests.rs @@ -1208,13 +1208,13 @@ impl<'a> ListLineItemsQuote<'a> { &self, client: &stripe::Client, quote: &stripe_types::quote::QuoteId, - ) -> stripe::Response> { + ) -> stripe::Response> { client.get_query(&format!("/quotes/{quote}/line_items"), self) } pub fn paginate( self, quote: &stripe_types::quote::QuoteId, - ) -> stripe::ListPaginator { + ) -> stripe::ListPaginator { stripe::ListPaginator::from_params(&format!("/quotes/{quote}/line_items"), self) } } @@ -1255,13 +1255,13 @@ impl<'a> ListComputedUpfrontLineItemsQuote<'a> { &self, client: &stripe::Client, quote: &stripe_types::quote::QuoteId, - ) -> stripe::Response> { + ) -> stripe::Response> { client.get_query(&format!("/quotes/{quote}/computed_upfront_line_items"), self) } pub fn paginate( self, quote: &stripe_types::quote::QuoteId, - ) -> stripe::ListPaginator { + ) -> stripe::ListPaginator { stripe::ListPaginator::from_params( &format!("/quotes/{quote}/computed_upfront_line_items"), self, diff --git a/generated/stripe_checkout/src/checkout_session/mod.rs b/generated/stripe_checkout/src/checkout_session/mod.rs index 11f7ad4d2..9425db04d 100644 --- a/generated/stripe_checkout/src/checkout_session/mod.rs +++ b/generated/stripe_checkout/src/checkout_session/mod.rs @@ -72,7 +72,7 @@ pub struct CheckoutSession { pub invoice_creation: Option, /// The line items purchased by the customer. #[serde(default)] - pub line_items: stripe_types::List, + pub line_items: stripe_types::List, /// 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 IETF language tag of the locale Checkout is displayed in. diff --git a/generated/stripe_checkout/src/checkout_session/requests.rs b/generated/stripe_checkout/src/checkout_session/requests.rs index da982fd0b..c2c8ad670 100644 --- a/generated/stripe_checkout/src/checkout_session/requests.rs +++ b/generated/stripe_checkout/src/checkout_session/requests.rs @@ -7153,13 +7153,13 @@ impl<'a> ListLineItemsCheckoutSession<'a> { &self, client: &stripe::Client, session: &stripe_checkout::checkout_session::CheckoutSessionId, - ) -> stripe::Response> { + ) -> stripe::Response> { client.get_query(&format!("/checkout/sessions/{session}/line_items"), self) } pub fn paginate( self, session: &stripe_checkout::checkout_session::CheckoutSessionId, - ) -> stripe::ListPaginator { + ) -> stripe::ListPaginator { stripe::ListPaginator::from_params( &format!("/checkout/sessions/{session}/line_items"), self, diff --git a/generated/stripe_connect/Cargo.toml b/generated/stripe_connect/Cargo.toml index a63055010..42086c12d 100644 --- a/generated/stripe_connect/Cargo.toml +++ b/generated/stripe_connect/Cargo.toml @@ -39,11 +39,11 @@ account = [] account_link = [] account_session = [] application_fee = [] +application_fee_refund = [] apps_secret = [] capability = [] country_spec = [] external_account = [] -fee_refund = [] login_link = [] person = [] topup = [] @@ -54,11 +54,11 @@ full = ["account", "account_link", "account_session", "application_fee", +"application_fee_refund", "apps_secret", "capability", "country_spec", "external_account", -"fee_refund", "login_link", "person", "topup", diff --git a/generated/stripe_connect/src/application_fee_refund/mod.rs b/generated/stripe_connect/src/application_fee_refund/mod.rs new file mode 100644 index 000000000..92b6d1ac2 --- /dev/null +++ b/generated/stripe_connect/src/application_fee_refund/mod.rs @@ -0,0 +1,5 @@ +pub use stripe_types::application_fee_refund::*; +#[cfg(feature = "application_fee_refund")] +mod requests; +#[cfg(feature = "application_fee_refund")] +pub use requests::*; diff --git a/generated/stripe_connect/src/fee_refund/requests.rs b/generated/stripe_connect/src/application_fee_refund/requests.rs similarity index 86% rename from generated/stripe_connect/src/fee_refund/requests.rs rename to generated/stripe_connect/src/application_fee_refund/requests.rs index 8acd43638..33af73e86 100644 --- a/generated/stripe_connect/src/fee_refund/requests.rs +++ b/generated/stripe_connect/src/application_fee_refund/requests.rs @@ -1,5 +1,5 @@ #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct CreateFeeRefund<'a> { +pub struct CreateApplicationFeeRefund<'a> { /// A positive integer, in _cents (or local equivalent)_, representing how much of this fee to refund. /// /// Can refund only up to the remaining unrefunded amount of the fee. @@ -16,12 +16,12 @@ pub struct CreateFeeRefund<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option<&'a std::collections::HashMap>, } -impl<'a> CreateFeeRefund<'a> { +impl<'a> CreateApplicationFeeRefund<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> CreateFeeRefund<'a> { +impl<'a> CreateApplicationFeeRefund<'a> { /// Refunds an application fee that has previously been collected but not yet refunded. /// Funds will be refunded to the Stripe account from which the fee was originally collected. /// @@ -35,12 +35,12 @@ impl<'a> CreateFeeRefund<'a> { &self, client: &stripe::Client, id: &stripe_types::application_fee::ApplicationFeeId, - ) -> stripe::Response { + ) -> stripe::Response { client.send_form(&format!("/application_fees/{id}/refunds"), self, http_types::Method::Post) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct ListFeeRefund<'a> { +pub struct ListApplicationFeeRefund<'a> { /// A cursor for use in pagination. /// /// `ending_before` is an object ID that defines your place in the list. @@ -62,12 +62,12 @@ pub struct ListFeeRefund<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub starting_after: Option<&'a str>, } -impl<'a> ListFeeRefund<'a> { +impl<'a> ListApplicationFeeRefund<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> ListFeeRefund<'a> { +impl<'a> ListApplicationFeeRefund<'a> { /// You can see a list of the refunds belonging to a specific application fee. /// /// Note that the 10 most recent refunds are always available by default on the application fee object. @@ -76,41 +76,41 @@ impl<'a> ListFeeRefund<'a> { &self, client: &stripe::Client, id: &stripe_types::application_fee::ApplicationFeeId, - ) -> stripe::Response> { + ) -> stripe::Response> { client.get_query(&format!("/application_fees/{id}/refunds"), self) } pub fn paginate( self, id: &stripe_types::application_fee::ApplicationFeeId, - ) -> stripe::ListPaginator { + ) -> stripe::ListPaginator { stripe::ListPaginator::from_params(&format!("/application_fees/{id}/refunds"), self) } } -impl<'a> stripe::PaginationParams for ListFeeRefund<'a> {} +impl<'a> stripe::PaginationParams for ListApplicationFeeRefund<'a> {} #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct RetrieveFeeRefund<'a> { +pub struct RetrieveApplicationFeeRefund<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, } -impl<'a> RetrieveFeeRefund<'a> { +impl<'a> RetrieveApplicationFeeRefund<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> RetrieveFeeRefund<'a> { +impl<'a> RetrieveApplicationFeeRefund<'a> { /// By default, you can see the 10 most recent refunds stored directly on the application fee object, but you can also retrieve details about a specific refund stored on the application fee. pub fn send( &self, client: &stripe::Client, fee: &stripe_types::application_fee::ApplicationFeeId, id: &str, - ) -> stripe::Response { + ) -> stripe::Response { client.get_query(&format!("/application_fees/{fee}/refunds/{id}"), self) } } #[derive(Copy, Clone, Debug, Default, serde::Serialize)] -pub struct UpdateFeeRefund<'a> { +pub struct UpdateApplicationFeeRefund<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Option::is_none")] pub expand: Option<&'a [&'a str]>, @@ -122,12 +122,12 @@ pub struct UpdateFeeRefund<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option<&'a std::collections::HashMap>, } -impl<'a> UpdateFeeRefund<'a> { +impl<'a> UpdateApplicationFeeRefund<'a> { pub fn new() -> Self { Self::default() } } -impl<'a> UpdateFeeRefund<'a> { +impl<'a> UpdateApplicationFeeRefund<'a> { /// Updates the specified application fee refund by setting the values of the parameters passed. /// /// Any parameters not provided will be left unchanged. This request only accepts metadata as an argument. @@ -136,7 +136,7 @@ impl<'a> UpdateFeeRefund<'a> { client: &stripe::Client, fee: &stripe_types::application_fee::ApplicationFeeId, id: &str, - ) -> stripe::Response { + ) -> stripe::Response { client.send_form( &format!("/application_fees/{fee}/refunds/{id}"), self, diff --git a/generated/stripe_connect/src/fee_refund/mod.rs b/generated/stripe_connect/src/fee_refund/mod.rs deleted file mode 100644 index 7c87d63af..000000000 --- a/generated/stripe_connect/src/fee_refund/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub use stripe_types::fee_refund::*; -#[cfg(feature = "fee_refund")] -mod requests; -#[cfg(feature = "fee_refund")] -pub use requests::*; diff --git a/generated/stripe_connect/src/mod.rs b/generated/stripe_connect/src/mod.rs index cde387d8f..c4170cd66 100644 --- a/generated/stripe_connect/src/mod.rs +++ b/generated/stripe_connect/src/mod.rs @@ -78,8 +78,8 @@ pub use stripe_types::DeletedPerson; pub mod deleted_person; pub use stripe_types::ExternalAccount; pub mod external_account; -pub use stripe_types::FeeRefund; -pub mod fee_refund; +pub use stripe_types::ApplicationFeeRefund; +pub mod application_fee_refund; pub use stripe_types::LegalEntityCompany; pub mod legal_entity_company; pub use stripe_types::LegalEntityCompanyVerification; diff --git a/generated/stripe_payment/src/payment_link/requests.rs b/generated/stripe_payment/src/payment_link/requests.rs index acca847f6..507ca2ed4 100644 --- a/generated/stripe_payment/src/payment_link/requests.rs +++ b/generated/stripe_payment/src/payment_link/requests.rs @@ -99,13 +99,13 @@ impl<'a> ListLineItemsPaymentLink<'a> { &self, client: &stripe::Client, payment_link: &stripe_types::payment_link::PaymentLinkId, - ) -> stripe::Response> { + ) -> stripe::Response> { client.get_query(&format!("/payment_links/{payment_link}/line_items"), self) } pub fn paginate( self, payment_link: &stripe_types::payment_link::PaymentLinkId, - ) -> stripe::ListPaginator { + ) -> stripe::ListPaginator { stripe::ListPaginator::from_params( &format!("/payment_links/{payment_link}/line_items"), self, diff --git a/openapi/src/components.rs b/openapi/src/components.rs index a49b337d2..a2590f9ec 100644 --- a/openapi/src/components.rs +++ b/openapi/src/components.rs @@ -16,7 +16,6 @@ use crate::requests::parse_requests; use crate::rust_object::RustObject; use crate::rust_type::{Container, PathToType, RustType}; use crate::spec::Spec; -use crate::spec_inference::infer_id_name; use crate::stripe_object::{ parse_stripe_schema_as_rust_object, CrateInfo, OperationType, RequestSpec, StripeObject, StripeOperation, StripeResource, @@ -102,11 +101,11 @@ impl Components { self.construct_printable_type_from_path(path) } RustType::Path { path: PathToType::ObjectId(path), is_ref } => { - let ident = infer_id_name(path); + let obj = self.get(path); let path_info = self.resolve_path(path); PrintableType::QualifiedPath { path: Some(path_info), - ident, + ident: obj.id_type_ident(), is_ref: *is_ref, has_ref: false, } diff --git a/openapi/src/ids.rs b/openapi/src/ids.rs index c6b04c91c..4f30b0d6d 100644 --- a/openapi/src/ids.rs +++ b/openapi/src/ids.rs @@ -5,13 +5,15 @@ use std::fs::File; use lazy_static::lazy_static; use serde::Deserialize; -use crate::spec_inference::infer_id_name; -use crate::types::ComponentPath; +use crate::types::{ComponentPath, RustIdent}; +/// The kind of prefix an id is required to follow #[derive(Deserialize)] #[serde(untagged)] enum IdPrefix { + /// Must start with given prefix Single(String), + /// Must start with any of the given prefixes Multi(Vec), } @@ -21,13 +23,13 @@ fn load_id_prefixes() -> anyhow::Result> { } lazy_static! { + /// Map of component_path to what the prefix for this id should be. static ref ID_PREFIXES: HashMap = load_id_prefixes().expect("Invalid id prefix file"); } -pub fn write_object_id(out: &mut String, path: &ComponentPath) { +pub fn write_object_id(out: &mut String, path: &ComponentPath, ident: &RustIdent) { let crate_name = "stripe_types"; - let ident = infer_id_name(path); match ID_PREFIXES.get(path.as_ref()) { Some(IdPrefix::Single(prefix)) => { let _ = writeln!(out, r#"{crate_name}::def_id!({ident}, "{prefix}_");"#); diff --git a/openapi/src/object_writing.rs b/openapi/src/object_writing.rs index 541c4e584..4ebd5e43a 100644 --- a/openapi/src/object_writing.rs +++ b/openapi/src/object_writing.rs @@ -135,7 +135,7 @@ pub fn gen_obj( // `DeletedAccount`, we don't want to duplicate `AccountId` since `DeletedAccount` // uses that same id if path == comp.path() { - write_object_id(&mut out, path) + write_object_id(&mut out, path, &comp.id_type_ident()) } } } diff --git a/openapi/src/spec_inference.rs b/openapi/src/spec_inference.rs index 5c7fffd94..78819d475 100644 --- a/openapi/src/spec_inference.rs +++ b/openapi/src/spec_inference.rs @@ -454,7 +454,3 @@ pub fn infer_doc_comment(schema: &Schema, doc_url: Option<&str>) -> String { } doc_comment } - -pub fn infer_id_name(obj_name: &str) -> RustIdent { - RustIdent::create(format!("{obj_name}_id")) -} diff --git a/openapi/src/stripe_object.rs b/openapi/src/stripe_object.rs index bfe203515..cece343e9 100644 --- a/openapi/src/stripe_object.rs +++ b/openapi/src/stripe_object.rs @@ -1,3 +1,5 @@ +use std::collections::HashMap; + use heck::ToSnakeCase; use indexmap::IndexMap; use openapiv3::Schema; @@ -75,29 +77,6 @@ impl StripeObject { self.krate = Some(CrateInfo::new(new_krate)); } - pub fn visit<'a, V: Visit<'a>>(&'a self, visitor: &mut V) { - visitor.visit_obj(&self.data.obj, None); - 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); - for req in &mut self.requests { - visitor.visit_req_mut(req); - } - } -} - -#[derive(Debug, Clone)] -pub struct StripeObjectData { - pub obj: RustObject, - pub object_name: Option, - pub id_type: Option, -} - -impl StripeObject { pub fn mod_path(&self) -> String { self.resource.mod_path() } @@ -110,6 +89,10 @@ impl StripeObject { self.resource.ident() } + pub fn id_type_ident(&self) -> RustIdent { + RustIdent::create(format!("{}Id", self.ident())) + } + pub fn id_type(&self) -> Option<&RustType> { self.data.id_type.as_ref() } @@ -127,6 +110,27 @@ impl StripeObject { r.req_path.starts_with(&start) }) } + + pub fn visit<'a, V: Visit<'a>>(&'a self, visitor: &mut V) { + visitor.visit_obj(&self.data.obj, None); + 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); + for req in &mut self.requests { + visitor.visit_req_mut(req); + } + } +} + +#[derive(Debug, Clone)] +pub struct StripeObjectData { + pub obj: RustObject, + pub object_name: Option, + pub id_type: Option, } pub fn parse_stripe_schema_as_rust_object( @@ -251,8 +255,21 @@ impl StripeResource { } } +fn object_renames() -> HashMap<&'static str, &'static str> { + return HashMap::from([ + ("invoiceitem", "invoice_item"), + ("item", "checkout_session_item"), + ("line_item", "invoice_line_item"), + ("fee_refund", "application_fee_refund"), + ]); +} + fn infer_object_ident(path: &ComponentPath) -> RustIdent { - RustIdent::create(path) + if let Some(renamed) = object_renames().get(path.as_ref()) { + RustIdent::create(renamed) + } else { + RustIdent::create(path) + } } #[derive(Debug, Clone)] diff --git a/stripe_types/src/generated/application_fee/mod.rs b/stripe_types/src/generated/application_fee/mod.rs index a5f1e0ad1..980afdf5f 100644 --- a/stripe_types/src/generated/application_fee/mod.rs +++ b/stripe_types/src/generated/application_fee/mod.rs @@ -32,7 +32,7 @@ pub struct ApplicationFee { /// If the fee is only partially refunded, this attribute will still be false. pub refunded: bool, /// A list of refunds that have been applied to the fee. - pub refunds: stripe_types::List, + pub refunds: stripe_types::List, } impl stripe_types::Object for ApplicationFee { type Id = stripe_types::application_fee::ApplicationFeeId; diff --git a/stripe_types/src/generated/fee_refund/mod.rs b/stripe_types/src/generated/application_fee_refund/mod.rs similarity index 84% rename from stripe_types/src/generated/fee_refund/mod.rs rename to stripe_types/src/generated/application_fee_refund/mod.rs index 122ba2b1d..6602395b6 100644 --- a/stripe_types/src/generated/fee_refund/mod.rs +++ b/stripe_types/src/generated/application_fee_refund/mod.rs @@ -3,7 +3,7 @@ /// /// Funds will be refunded to the Stripe account from which the fee was originally collected. 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)] -pub struct FeeRefund { +pub struct ApplicationFeeRefund { /// Amount, in cents (or local equivalent). pub amount: i64, /// Balance transaction that describes the impact on your account balance. @@ -19,16 +19,16 @@ pub struct FeeRefund { /// ID of the application fee that was refunded. pub fee: stripe_types::Expandable, /// Unique identifier for the object. - pub id: stripe_types::fee_refund::FeeRefundId, + pub id: stripe_types::application_fee_refund::ApplicationFeeRefundId, /// 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>, } -impl stripe_types::Object for FeeRefund { - type Id = stripe_types::fee_refund::FeeRefundId; +impl stripe_types::Object for ApplicationFeeRefund { + type Id = stripe_types::application_fee_refund::ApplicationFeeRefundId; fn id(&self) -> Option<&str> { Some(self.id.as_str()) } } -stripe_types::def_id!(FeeRefundId, "fr_"); +stripe_types::def_id!(ApplicationFeeRefundId, "fr_"); diff --git a/stripe_types/src/generated/balance_transaction_source/mod.rs b/stripe_types/src/generated/balance_transaction_source/mod.rs index 8d75dc235..14e1a8795 100644 --- a/stripe_types/src/generated/balance_transaction_source/mod.rs +++ b/stripe_types/src/generated/balance_transaction_source/mod.rs @@ -13,7 +13,7 @@ pub enum BalanceTransactionSource { #[serde(rename = "dispute")] Dispute(stripe_types::Dispute), #[serde(rename = "fee_refund")] - FeeRefund(stripe_types::FeeRefund), + ApplicationFeeRefund(stripe_types::ApplicationFeeRefund), #[serde(rename = "issuing.authorization")] IssuingAuthorization(stripe_types::IssuingAuthorization), #[serde(rename = "issuing.dispute")] @@ -46,7 +46,7 @@ impl stripe_types::Object for BalanceTransactionSource { Self::ConnectCollectionTransfer(v) => Some(v.id.as_str()), Self::CustomerCashBalanceTransaction(v) => Some(v.id.as_str()), Self::Dispute(v) => Some(v.id.as_str()), - Self::FeeRefund(v) => Some(v.id.as_str()), + Self::ApplicationFeeRefund(v) => Some(v.id.as_str()), Self::IssuingAuthorization(v) => Some(v.id.as_str()), Self::IssuingDispute(v) => Some(v.id.as_str()), Self::IssuingTransaction(v) => Some(v.id.as_str()), diff --git a/stripe_types/src/generated/item/mod.rs b/stripe_types/src/generated/checkout_session_item/mod.rs similarity index 84% rename from stripe_types/src/generated/item/mod.rs rename to stripe_types/src/generated/checkout_session_item/mod.rs index efb5064fc..c9027549d 100644 --- a/stripe_types/src/generated/item/mod.rs +++ b/stripe_types/src/generated/checkout_session_item/mod.rs @@ -1,6 +1,6 @@ /// A line item. #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct Item { +pub struct CheckoutSessionItem { /// Total discount amount applied. /// /// If no discounts were applied, defaults to 0. @@ -26,7 +26,7 @@ pub struct Item { #[serde(skip_serializing_if = "Option::is_none")] pub discounts: Option>, /// Unique identifier for the object. - pub id: stripe_types::item::ItemId, + pub id: stripe_types::checkout_session_item::CheckoutSessionItemId, /// The price used to generate the line item. pub price: Option, /// The quantity of products being purchased. @@ -35,10 +35,10 @@ pub struct Item { #[serde(skip_serializing_if = "Option::is_none")] pub taxes: Option>, } -impl stripe_types::Object for Item { - type Id = stripe_types::item::ItemId; +impl stripe_types::Object for CheckoutSessionItem { + type Id = stripe_types::checkout_session_item::CheckoutSessionItemId; fn id(&self) -> Option<&str> { Some(self.id.as_str()) } } -stripe_types::def_id!(ItemId, "li_"); +stripe_types::def_id!(CheckoutSessionItemId, "li_"); diff --git a/stripe_types/src/generated/deleted_invoiceitem/mod.rs b/stripe_types/src/generated/deleted_invoiceitem/mod.rs index e207a9664..1e42490d4 100644 --- a/stripe_types/src/generated/deleted_invoiceitem/mod.rs +++ b/stripe_types/src/generated/deleted_invoiceitem/mod.rs @@ -3,10 +3,10 @@ pub struct DeletedInvoiceitem { /// Always true for a deleted object. deleted: stripe_types::AlwaysTrue, /// Unique identifier for the object. - pub id: stripe_types::invoiceitem::InvoiceitemId, + pub id: stripe_types::invoice_item::InvoiceItemId, } impl stripe_types::Object for DeletedInvoiceitem { - type Id = stripe_types::invoiceitem::InvoiceitemId; + type Id = stripe_types::invoice_item::InvoiceItemId; fn id(&self) -> Option<&str> { Some(self.id.as_str()) } diff --git a/stripe_types/src/generated/invoice/mod.rs b/stripe_types/src/generated/invoice/mod.rs index 6005f3ab5..b2cef6780 100644 --- a/stripe_types/src/generated/invoice/mod.rs +++ b/stripe_types/src/generated/invoice/mod.rs @@ -186,7 +186,7 @@ pub struct Invoice { /// The individual line items that make up the invoice. /// /// `lines` is sorted as follows: (1) pending invoice items (including prorations) in reverse chronological order, (2) subscription items in reverse chronological order, and (3) invoice items added after invoice creation in chronological order. - pub lines: stripe_types::List, + pub lines: stripe_types::List, /// 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. diff --git a/stripe_types/src/generated/invoiceitem/mod.rs b/stripe_types/src/generated/invoice_item/mod.rs similarity index 95% rename from stripe_types/src/generated/invoiceitem/mod.rs rename to stripe_types/src/generated/invoice_item/mod.rs index 3825b214f..e89921cd9 100644 --- a/stripe_types/src/generated/invoiceitem/mod.rs +++ b/stripe_types/src/generated/invoice_item/mod.rs @@ -5,7 +5,7 @@ /// Sometimes you want to add a charge or credit to a customer, but actually charge or credit the customer’s card only at the end of a regular billing cycle. /// This is useful for combining several charges (to minimize per-transaction fees), or for having Stripe tabulate your usage-based billing totals. 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)] -pub struct Invoiceitem { +pub struct InvoiceItem { /// Amount (in the `currency` specified) of the invoice item. /// /// This should always be equal to `unit_amount * quantity`. @@ -34,7 +34,7 @@ pub struct Invoiceitem { /// Use `expand[]=discounts` to expand each discount. pub discounts: Option>>, /// Unique identifier for the object. - pub id: stripe_types::invoiceitem::InvoiceitemId, + pub id: stripe_types::invoice_item::InvoiceItemId, /// The ID of the invoice this invoice item belongs to. 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. @@ -70,10 +70,10 @@ pub struct Invoiceitem { /// Same as `unit_amount`, but contains a decimal value with at most 12 decimal places. pub unit_amount_decimal: Option, } -impl stripe_types::Object for Invoiceitem { - type Id = stripe_types::invoiceitem::InvoiceitemId; +impl stripe_types::Object for InvoiceItem { + type Id = stripe_types::invoice_item::InvoiceItemId; fn id(&self) -> Option<&str> { Some(self.id.as_str()) } } -stripe_types::def_id!(InvoiceitemId, "ii_"); +stripe_types::def_id!(InvoiceItemId, "ii_"); diff --git a/stripe_types/src/generated/line_item/mod.rs b/stripe_types/src/generated/invoice_line_item/mod.rs similarity index 85% rename from stripe_types/src/generated/line_item/mod.rs rename to stripe_types/src/generated/invoice_line_item/mod.rs index de5bf802f..ae8f979ca 100644 --- a/stripe_types/src/generated/line_item/mod.rs +++ b/stripe_types/src/generated/invoice_line_item/mod.rs @@ -1,5 +1,5 @@ #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct LineItem { +pub struct InvoiceLineItem { /// The amount, in cents (or local equivalent). pub amount: i64, /// The integer amount in cents (or local equivalent) representing the amount for this line item, excluding all tax and discounts. @@ -24,10 +24,10 @@ pub struct LineItem { /// Use `expand[]=discounts` to expand each discount. pub discounts: Option>>, /// Unique identifier for the object. - pub id: stripe_types::line_item::LineItemId, + pub id: stripe_types::invoice_line_item::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>, + 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, /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. @@ -61,19 +61,19 @@ pub struct LineItem { 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")] - pub type_: LineItemType, + 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, } /// 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 LineItemType { +pub enum InvoiceLineItemType { Invoiceitem, Subscription, } -impl LineItemType { +impl InvoiceLineItemType { pub fn as_str(self) -> &'static str { - use LineItemType::*; + use InvoiceLineItemType::*; match self { Invoiceitem => "invoiceitem", Subscription => "subscription", @@ -81,10 +81,10 @@ impl LineItemType { } } -impl std::str::FromStr for LineItemType { +impl std::str::FromStr for InvoiceLineItemType { type Err = (); fn from_str(s: &str) -> Result { - use LineItemType::*; + use InvoiceLineItemType::*; match s { "invoiceitem" => Ok(Invoiceitem), "subscription" => Ok(Subscription), @@ -92,23 +92,23 @@ impl std::str::FromStr for LineItemType { } } } -impl AsRef for LineItemType { +impl AsRef for InvoiceLineItemType { fn as_ref(&self) -> &str { self.as_str() } } -impl std::fmt::Display for LineItemType { +impl std::fmt::Display for InvoiceLineItemType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl std::fmt::Debug for LineItemType { +impl std::fmt::Debug for InvoiceLineItemType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(self.as_str()) } } -impl serde::Serialize for LineItemType { +impl serde::Serialize for InvoiceLineItemType { fn serialize(&self, serializer: S) -> Result where S: serde::Serializer, @@ -116,17 +116,18 @@ impl serde::Serialize for LineItemType { serializer.serialize_str(self.as_str()) } } -impl<'de> serde::Deserialize<'de> for LineItemType { +impl<'de> serde::Deserialize<'de> for InvoiceLineItemType { fn deserialize>(deserializer: D) -> Result { use std::str::FromStr; let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?; - Self::from_str(&s).map_err(|_| serde::de::Error::custom("Unknown value for LineItemType")) + Self::from_str(&s) + .map_err(|_| serde::de::Error::custom("Unknown value for InvoiceLineItemType")) } } -impl stripe_types::Object for LineItem { - type Id = stripe_types::line_item::LineItemId; +impl stripe_types::Object for InvoiceLineItem { + type Id = stripe_types::invoice_line_item::InvoiceLineItemId; fn id(&self) -> Option<&str> { Some(self.id.as_str()) } } -stripe_types::def_id!(LineItemId); +stripe_types::def_id!(InvoiceLineItemId); diff --git a/stripe_types/src/generated/mod.rs b/stripe_types/src/generated/mod.rs index 1fb8e6023..1ba40c9ca 100644 --- a/stripe_types/src/generated/mod.rs +++ b/stripe_types/src/generated/mod.rs @@ -195,8 +195,8 @@ pub mod external_account_requirements; pub use external_account_requirements::ExternalAccountRequirements; pub mod fee; pub use fee::Fee; -pub mod fee_refund; -pub use fee_refund::FeeRefund; +pub mod application_fee_refund; +pub use application_fee_refund::ApplicationFeeRefund; pub mod file; pub use file::File; pub mod file_link; @@ -269,8 +269,8 @@ pub mod invoice_threshold_reason; pub use invoice_threshold_reason::InvoiceThresholdReason; pub mod invoice_transfer_data; pub use invoice_transfer_data::InvoiceTransferData; -pub mod invoiceitem; -pub use invoiceitem::Invoiceitem; +pub mod invoice_item; +pub use invoice_item::InvoiceItem; pub mod invoices_from_invoice; pub use invoices_from_invoice::InvoicesFromInvoice; pub mod invoices_invoice_rendering; @@ -403,8 +403,8 @@ pub mod issuing_transaction_receipt_data; pub use issuing_transaction_receipt_data::IssuingTransactionReceiptData; pub mod issuing_transaction_treasury; pub use issuing_transaction_treasury::IssuingTransactionTreasury; -pub mod item; -pub use item::Item; +pub mod checkout_session_item; +pub use checkout_session_item::CheckoutSessionItem; pub mod legal_entity_company; pub use legal_entity_company::LegalEntityCompany; pub mod legal_entity_company_verification; @@ -425,8 +425,8 @@ pub mod level3; pub use level3::Level3; pub mod level3_line_items; pub use level3_line_items::Level3LineItems; -pub mod line_item; -pub use line_item::LineItem; +pub mod invoice_line_item; +pub use invoice_line_item::InvoiceLineItem; pub mod line_items_discount_amount; pub use line_items_discount_amount::LineItemsDiscountAmount; pub mod line_items_tax_amount; diff --git a/stripe_types/src/generated/payment_link/mod.rs b/stripe_types/src/generated/payment_link/mod.rs index 1a867ff75..6f17f98e4 100644 --- a/stripe_types/src/generated/payment_link/mod.rs +++ b/stripe_types/src/generated/payment_link/mod.rs @@ -39,7 +39,7 @@ pub struct PaymentLink { pub invoice_creation: Option, /// The line items representing what is being sold. #[serde(default)] - pub line_items: stripe_types::List, + pub line_items: stripe_types::List, /// 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. diff --git a/stripe_types/src/generated/quote/mod.rs b/stripe_types/src/generated/quote/mod.rs index 92163a9f3..d51839695 100644 --- a/stripe_types/src/generated/quote/mod.rs +++ b/stripe_types/src/generated/quote/mod.rs @@ -67,7 +67,7 @@ pub struct Quote { pub invoice_settings: Option, /// A list of items the customer is being quoted for. #[serde(default)] - pub line_items: stripe_types::List, + pub line_items: stripe_types::List, /// 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. diff --git a/stripe_types/src/generated/quotes_resource_upfront/mod.rs b/stripe_types/src/generated/quotes_resource_upfront/mod.rs index ff111b917..cc3589967 100644 --- a/stripe_types/src/generated/quotes_resource_upfront/mod.rs +++ b/stripe_types/src/generated/quotes_resource_upfront/mod.rs @@ -8,6 +8,6 @@ pub struct QuotesResourceUpfront { /// /// This does not include pending invoice items that exist on the customer but may still be included in the next invoice. #[serde(default)] - pub line_items: stripe_types::List, + pub line_items: stripe_types::List, pub total_details: stripe_types::QuotesResourceTotalDetails, } diff --git a/stripe_webhook/src/generated/mod.rs b/stripe_webhook/src/generated/mod.rs index 3bbaa6716..6f5ddce2f 100644 --- a/stripe_webhook/src/generated/mod.rs +++ b/stripe_webhook/src/generated/mod.rs @@ -11,7 +11,7 @@ pub enum EventObject { #[serde(rename = "application_fee")] ApplicationFee(stripe_types::ApplicationFee), #[serde(rename = "fee_refund")] - FeeRefund(stripe_types::FeeRefund), + ApplicationFeeRefund(stripe_types::ApplicationFeeRefund), #[cfg(feature = "stripe_core")] #[serde(rename = "balance")] Balance(stripe_core::Balance), @@ -38,7 +38,7 @@ pub enum EventObject { #[serde(rename = "invoice")] Invoice(stripe_types::Invoice), #[serde(rename = "invoiceitem")] - Invoiceitem(stripe_types::Invoiceitem), + InvoiceItem(stripe_types::InvoiceItem), #[serde(rename = "issuing.authorization")] IssuingAuthorization(stripe_types::IssuingAuthorization), #[serde(rename = "issuing.card")]