Skip to content

Commit

Permalink
feat: generate latest changes from OpenApi spec
Browse files Browse the repository at this point in the history
  • Loading branch information
arlyon committed Jan 24, 2024
1 parent 8893abb commit 9b3a844
Show file tree
Hide file tree
Showing 24 changed files with 1,565 additions and 53 deletions.
1 change: 1 addition & 0 deletions openapi/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ pub fn gen_unions(out: &mut String, unions: &BTreeMap<String, InferredUnion>, me
pub fn gen_variant_name(wire_name: &str, meta: &Metadata) -> String {
match wire_name {
"*" => "All".to_string(),
"self" => "Self_".to_string(),
n => {
if n.chars().next().unwrap().is_digit(10) {
format!("V{}", n.to_string().replace('-', "_").replace('.', "_"))
Expand Down
2 changes: 1 addition & 1 deletion openapi/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "v755"
"version": "v790"
}
1 change: 1 addition & 0 deletions src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ pub use {
balance_transaction::*,
billing_details::*,
charge::*,
connect_account_reference::*,
customer::*,
custom_unit_amount::*,
cash_balance::*,
Expand Down
1 change: 1 addition & 0 deletions src/resources/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub mod core {
pub mod billing_details;
pub mod cash_balance;
pub mod charge;
pub mod connect_account_reference;
pub mod custom_unit_amount;
pub mod customer;
pub mod dispute;
Expand Down
53 changes: 47 additions & 6 deletions src/resources/generated/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ pub struct Account {
pub business_profile: Option<BusinessProfile>,

/// The business type.
///
/// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property is only returned for Custom accounts.
#[serde(skip_serializing_if = "Option::is_none")]
pub business_type: Option<AccountBusinessType>,

Expand Down Expand Up @@ -76,6 +78,8 @@ pub struct Account {
pub email: Option<String>,

/// External accounts (bank accounts and debit cards) currently attached to this account.
///
/// External accounts are only returned for requests where `controller[is_controller]` is true.
#[serde(default)]
pub external_accounts: List<ExternalAccount>,

Expand Down Expand Up @@ -141,8 +145,7 @@ impl Account {
///
/// Any parameters not provided are left unchanged. For Custom accounts, you can update any information on the account.
/// For other accounts, you can update all information until that account has started to go through Connect Onboarding.
/// Once you create an [Account Link](https://stripe.com/docs/api/account_links) for a Standard or Express account, some parameters can no longer be changed.
/// These are marked as **Custom Only** or **Custom and Express** below. To update your own account, use the [Dashboard](https://dashboard.stripe.com/settings/account).
/// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), some properties can only be changed or updated for Custom accounts. To update your own account, use the [Dashboard](https://dashboard.stripe.com/settings/account).
/// Refer to our [Connect](https://stripe.com/docs/connect/updating-accounts) documentation to learn more about updating accounts.
pub fn update(client: &Client, id: &AccountId, params: UpdateAccount<'_>) -> Response<Account> {
client.post_form(&format!("/accounts/{}", id), &params)
Expand Down Expand Up @@ -171,6 +174,14 @@ impl Object for Account {

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct BusinessProfile {
/// The applicant's gross annual revenue for its preceding fiscal year.
pub annual_revenue: Option<AccountAnnualRevenue>,

/// An estimated upper bound of employees, contractors, vendors, etc.
///
/// currently working for the business.
pub estimated_worker_count: Option<u64>,

/// [The merchant category code for the account](https://stripe.com/docs/connect/setting-mcc).
///
/// MCCs are used to classify businesses based on the goods or services they provide.
Expand Down Expand Up @@ -204,6 +215,23 @@ pub struct BusinessProfile {
pub url: Option<String>,
}

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct AccountAnnualRevenue {
/// A non-negative integer representing the amount in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
pub amount: Option<i64>,

/// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
///
/// Must be a [supported currency](https://stripe.com/docs/currencies).
pub currency: Option<Currency>,

/// The close-out date of the preceding fiscal year in ISO 8601 format.
///
/// E.g.
/// 2023-12-31 for the 31st of December, 2023.
pub fiscal_year_end: Option<String>,
}

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct AccountCapabilities {
/// The status of the Canadian pre-authorized debits payments capability of the account, or whether the account can directly process Canadian pre-authorized debits charges.
Expand Down Expand Up @@ -854,6 +882,8 @@ pub struct CreateAccount<'a> {
pub business_profile: Option<BusinessProfile>,

/// The business type.
///
/// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts.
#[serde(skip_serializing_if = "Option::is_none")]
pub business_type: Option<AccountBusinessType>,

Expand All @@ -868,6 +898,7 @@ pub struct CreateAccount<'a> {
/// Information about the company or business.
///
/// This field is available for any `business_type`.
/// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts.
#[serde(skip_serializing_if = "Option::is_none")]
pub company: Option<CompanyParams>,

Expand Down Expand Up @@ -904,13 +935,14 @@ pub struct CreateAccount<'a> {
///
/// You can provide either a token, like the ones returned by [Stripe.js](https://stripe.com/docs/js), or a dictionary, as documented in the `external_account` parameter for [bank account](https://stripe.com/docs/api#account_create_bank_account) creation.
/// By default, providing an external account sets it as the new default external account for its currency, and deletes the old default if one exists.
/// To add additional external accounts without replacing the existing default for the currency, use the [bank account](https://stripe.com/docs/api#account_create_bank_account) or [card creation](https://stripe.com/docs/api#account_create_card) APIs.
/// To add additional external accounts without replacing the existing default for the currency, use the [bank account](https://stripe.com/docs/api#account_create_bank_account) or [card creation](https://stripe.com/docs/api#account_create_card) APIs. Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts.
#[serde(skip_serializing_if = "Option::is_none")]
pub external_account: Option<&'a str>,

/// Information about the person represented by the account.
///
/// This field is null unless `business_type` is set to `individual`.
/// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts.
#[serde(skip_serializing_if = "Option::is_none")]
pub individual: Option<PersonParams>,

Expand All @@ -926,7 +958,7 @@ pub struct CreateAccount<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub settings: Option<AccountSettingsParams>,

/// Details on the account's acceptance of the [Stripe Services Agreement](https://stripe.com/docs/connect/updating-accounts#tos-acceptance).
/// Details on the account's acceptance of the [Stripe Services Agreement](https://stripe.com/docs/connect/updating-accounts#tos-acceptance) This property can only be updated for Custom accounts.
#[serde(skip_serializing_if = "Option::is_none")]
pub tos_acceptance: Option<AcceptTos>,

Expand Down Expand Up @@ -1021,6 +1053,8 @@ pub struct UpdateAccount<'a> {
pub business_profile: Option<BusinessProfile>,

/// The business type.
///
/// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts.
#[serde(skip_serializing_if = "Option::is_none")]
pub business_type: Option<AccountBusinessType>,

Expand All @@ -1035,6 +1069,7 @@ pub struct UpdateAccount<'a> {
/// Information about the company or business.
///
/// This field is available for any `business_type`.
/// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts.
#[serde(skip_serializing_if = "Option::is_none")]
pub company: Option<CompanyParams>,

Expand Down Expand Up @@ -1063,13 +1098,14 @@ pub struct UpdateAccount<'a> {
///
/// You can provide either a token, like the ones returned by [Stripe.js](https://stripe.com/docs/js), or a dictionary, as documented in the `external_account` parameter for [bank account](https://stripe.com/docs/api#account_create_bank_account) creation.
/// By default, providing an external account sets it as the new default external account for its currency, and deletes the old default if one exists.
/// To add additional external accounts without replacing the existing default for the currency, use the [bank account](https://stripe.com/docs/api#account_create_bank_account) or [card creation](https://stripe.com/docs/api#account_create_card) APIs.
/// To add additional external accounts without replacing the existing default for the currency, use the [bank account](https://stripe.com/docs/api#account_create_bank_account) or [card creation](https://stripe.com/docs/api#account_create_card) APIs. Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts.
#[serde(skip_serializing_if = "Option::is_none")]
pub external_account: Option<&'a str>,

/// Information about the person represented by the account.
///
/// This field is null unless `business_type` is set to `individual`.
/// Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions), this property can only be updated for Custom accounts.
#[serde(skip_serializing_if = "Option::is_none")]
pub individual: Option<PersonParams>,

Expand All @@ -1085,7 +1121,7 @@ pub struct UpdateAccount<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub settings: Option<AccountSettingsParams>,

/// Details on the account's acceptance of the [Stripe Services Agreement](https://stripe.com/docs/connect/updating-accounts#tos-acceptance).
/// Details on the account's acceptance of the [Stripe Services Agreement](https://stripe.com/docs/connect/updating-accounts#tos-acceptance) This property can only be updated for Custom accounts.
#[serde(skip_serializing_if = "Option::is_none")]
pub tos_acceptance: Option<AcceptTos>,
}
Expand Down Expand Up @@ -1231,6 +1267,7 @@ pub struct CompanyParams {
/// The category identifying the legal structure of the company or legal entity.
///
/// See [Business structure](https://stripe.com/docs/connect/identity-verification#business-structure) for more details.
/// Pass an empty string to unset this value.
#[serde(skip_serializing_if = "Option::is_none")]
pub structure: Option<CompanyParamsStructure>,

Expand Down Expand Up @@ -4234,6 +4271,7 @@ pub enum CompanyParamsStructure {
PublicCompany,
PublicCorporation,
PublicPartnership,
RegisteredCharity,
SingleMemberLlc,
SoleEstablishment,
SoleProprietorship,
Expand Down Expand Up @@ -4261,6 +4299,7 @@ impl CompanyParamsStructure {
CompanyParamsStructure::PublicCompany => "public_company",
CompanyParamsStructure::PublicCorporation => "public_corporation",
CompanyParamsStructure::PublicPartnership => "public_partnership",
CompanyParamsStructure::RegisteredCharity => "registered_charity",
CompanyParamsStructure::SingleMemberLlc => "single_member_llc",
CompanyParamsStructure::SoleEstablishment => "sole_establishment",
CompanyParamsStructure::SoleProprietorship => "sole_proprietorship",
Expand Down Expand Up @@ -4310,6 +4349,7 @@ pub enum CompanyStructure {
PublicCompany,
PublicCorporation,
PublicPartnership,
RegisteredCharity,
SingleMemberLlc,
SoleEstablishment,
SoleProprietorship,
Expand Down Expand Up @@ -4337,6 +4377,7 @@ impl CompanyStructure {
CompanyStructure::PublicCompany => "public_company",
CompanyStructure::PublicCorporation => "public_corporation",
CompanyStructure::PublicPartnership => "public_partnership",
CompanyStructure::RegisteredCharity => "registered_charity",
CompanyStructure::SingleMemberLlc => "single_member_llc",
CompanyStructure::SoleEstablishment => "sole_establishment",
CompanyStructure::SoleProprietorship => "sole_proprietorship",
Expand Down
92 changes: 89 additions & 3 deletions src/resources/generated/account_link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,16 @@ pub struct CreateAccountLink<'a> {
/// The identifier of the account to create an account link for.
pub account: AccountId,

/// Which information the platform needs to collect from the user.
/// The collect parameter is deprecated.
///
/// One of `currently_due` or `eventually_due`.
/// Default is `currently_due`.
/// Use `collection_options` instead.
#[serde(skip_serializing_if = "Option::is_none")]
pub collect: Option<AccountLinkCollect>,

/// Specifies the requirements that Stripe collects from connected accounts in the Connect Onboarding flow.
#[serde(skip_serializing_if = "Option::is_none")]
pub collection_options: Option<CreateAccountLinkCollectionOptions>,

/// Specifies which fields in the response should be expanded.
#[serde(skip_serializing_if = "Expand::is_empty")]
pub expand: &'a [&'a str],
Expand Down Expand Up @@ -80,6 +83,7 @@ impl<'a> CreateAccountLink<'a> {
CreateAccountLink {
account,
collect: Default::default(),
collection_options: Default::default(),
expand: Default::default(),
refresh_url: Default::default(),
return_url: Default::default(),
Expand All @@ -88,6 +92,20 @@ impl<'a> CreateAccountLink<'a> {
}
}

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct CreateAccountLinkCollectionOptions {
/// Specifies whether the platform collects only currently_due requirements (`currently_due`) or both currently_due and eventually_due requirements (`eventually_due`).
///
/// If you don't specify `collection_options`, the default value is `currently_due`.
pub fields: CreateAccountLinkCollectionOptionsFields,

/// Specifies whether the platform collects future_requirements in addition to requirements in Connect Onboarding.
///
/// The default value is `omit`.
#[serde(skip_serializing_if = "Option::is_none")]
pub future_requirements: Option<CreateAccountLinkCollectionOptionsFutureRequirements>,
}

/// An enum representing the possible values of an `CreateAccountLink`'s `collect` field.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
Expand Down Expand Up @@ -155,3 +173,71 @@ impl std::default::Default for AccountLinkType {
Self::AccountOnboarding
}
}

/// An enum representing the possible values of an `CreateAccountLinkCollectionOptions`'s `fields` field.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum CreateAccountLinkCollectionOptionsFields {
CurrentlyDue,
EventuallyDue,
}

impl CreateAccountLinkCollectionOptionsFields {
pub fn as_str(self) -> &'static str {
match self {
CreateAccountLinkCollectionOptionsFields::CurrentlyDue => "currently_due",
CreateAccountLinkCollectionOptionsFields::EventuallyDue => "eventually_due",
}
}
}

impl AsRef<str> for CreateAccountLinkCollectionOptionsFields {
fn as_ref(&self) -> &str {
self.as_str()
}
}

impl std::fmt::Display for CreateAccountLinkCollectionOptionsFields {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for CreateAccountLinkCollectionOptionsFields {
fn default() -> Self {
Self::CurrentlyDue
}
}

/// An enum representing the possible values of an `CreateAccountLinkCollectionOptions`'s `future_requirements` field.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum CreateAccountLinkCollectionOptionsFutureRequirements {
Include,
Omit,
}

impl CreateAccountLinkCollectionOptionsFutureRequirements {
pub fn as_str(self) -> &'static str {
match self {
CreateAccountLinkCollectionOptionsFutureRequirements::Include => "include",
CreateAccountLinkCollectionOptionsFutureRequirements::Omit => "omit",
}
}
}

impl AsRef<str> for CreateAccountLinkCollectionOptionsFutureRequirements {
fn as_ref(&self) -> &str {
self.as_str()
}
}

impl std::fmt::Display for CreateAccountLinkCollectionOptionsFutureRequirements {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for CreateAccountLinkCollectionOptionsFutureRequirements {
fn default() -> Self {
Self::Include
}
}
Loading

0 comments on commit 9b3a844

Please sign in to comment.