Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development enhance code gen #113

Merged
merged 20 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8682905
Trying to get the code compiling again
erichCompSci Nov 10, 2021
9d82edb
Added the shared_objects mutable object to the relevant functions
erichCompSci Nov 10, 2021
a2a9ce4
Refactored pieces of the main generation code for reuse
erichCompSci Nov 10, 2021
e78e4cf
Refactored the shared areas of the code
erichCompSci Nov 10, 2021
d9f3c14
Finished the full refactor, removed the extra unused variables
erichCompSci Nov 10, 2021
5c64537
Added the new generated documents, modified resources and generated m…
erichCompSci Nov 10, 2021
92171c4
Nullable values are not options, they are boxed options
erichCompSci Nov 10, 2021
6c3e1b5
Updated mappings to use the same enum for account holders
erichCompSci Nov 10, 2021
e3a051f
Removed the address from the types for the pregenerated one
erichCompSci Nov 10, 2021
4a48d75
Removed the BillingDetails from the types.rs
erichCompSci Nov 10, 2021
6e4a1a4
Removed the package dimensions from types
erichCompSci Nov 10, 2021
24e73d7
Removed PaymentMethodDetails from the types.rs file
erichCompSci Nov 10, 2021
f2b9985
Removed period from types, correctly generated, and added usage_summa…
erichCompSci Nov 10, 2021
7f38c47
Removed Shipping from the types.rs file
erichCompSci Nov 10, 2021
dc0a763
Removed the ShippingParams mapping, doesn't make sense to me
erichCompSci Nov 10, 2021
5534f95
Removed the SpendingLimit and SpendingLimitInterval from types
erichCompSci Nov 10, 2021
e6d7720
Removed the subscription_billing_thresholds
erichCompSci Nov 10, 2021
a24de27
Removed some more types from types.rs
erichCompSci Nov 11, 2021
8f08e4b
Removed even more types
erichCompSci Nov 11, 2021
8a030a5
Fixed some of the tests that had to change
erichCompSci Nov 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
440 changes: 299 additions & 141 deletions openapi/src/main.rs

Large diffs are not rendered by default.

37 changes: 0 additions & 37 deletions openapi/src/mappings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,10 @@ pub fn field_mappings() -> FieldMap {
[
// Config for object types
(("account", "type"), ("AccountType", "Option<AccountType>")),
(("account", "business_type"), ("BusinessType", "Option<BusinessType>")),
(("balance_transaction", "status"), ("BalanceTransactionStatus", "BalanceTransactionStatus")),
(
("bank_account", "account_holder_type"),
("AccountHolderType", "Option<AccountHolderType>"),
),
(("bank_account", "status"), ("BankAccountStatus", "Option<BankAccountStatus>")),
(("fee", "type"), ("FeeType", "FeeType")),
(("charge", "source"), ("PaymentSource", "Option<PaymentSource>")),
(
("charge_fraud_details", "stripe_report"),
("FraudDetailsReport", "Option<FraudDetailsReport>"),
),
(("customer", "default_source"), ("PaymentSource", "Option<Expandable<PaymentSource>>")),
(("customer", "sources"), ("PaymentSource", "List<PaymentSource>")),
(("invoice", "billing"), ("", "Option<CollectionMethod>")),
Expand Down Expand Up @@ -261,10 +252,6 @@ pub fn field_mappings() -> FieldMap {
("issuing_card_authorization_controls", "blocked_categories"),
("MerchantCategory", "Option<Vec<MerchantCategory>>"),
),
(
("issuing_card_authorization_controls", "spending_limits"),
("SpendingLimit", "Option<Vec<SpendingLimit>>"),
),
(
("issuing_cardholder_authorization_controls", "allowed_categories"),
("MerchantCategory", "Option<Vec<MerchantCategory>>"),
Expand All @@ -273,10 +260,6 @@ pub fn field_mappings() -> FieldMap {
("issuing_cardholder_authorization_controls", "blocked_categories"),
("MerchantCategory", "Option<Vec<MerchantCategory>>"),
),
(
("issuing_cardholder_authorization_controls", "spending_limits"),
("SpendingLimit", "Option<Vec<SpendingLimit>>"),
),
(
("issuing_card_pin", "status"),
("IssuingCardPinStatus", "IssuingCardPinStatus"),
Expand All @@ -303,7 +286,6 @@ pub fn field_mappings() -> FieldMap {
),
(("file", "purpose"), ("", "FilePurpose")),
(("order", "status"), ("", "OrderStatus")),
(("person", "dob"), ("Dob", "Option<Dob>")),
(("recipient", "type"), ("", "Option<RecipientType>")),
(("review", "reason"), ("ReviewReason", "ReviewReason")),
(("sku", "attributes"), ("Metadata", "Option<Metadata>")),
Expand Down Expand Up @@ -356,24 +338,20 @@ pub fn field_mappings() -> FieldMap {
),
(("token", "type"), ("TokenType", "TokenType")),
(("transfer", "source_type"), ("", "Option<TransferSourceType>")),
(("transfer_schedule", "weekly_anchor"), ("Weekday", "Option<Weekday>")),
(("webhook_endpoint", "api_version"), ("ApiVersion", "Option<ApiVersion>")),
(("webhook_endpoint", "enabled_events"), ("", "Option<Vec<EventFilter>>")),
(("webhook_endpoint", "status"), ("WebhookEndpointStatus", "Option<WebhookEndpointStatus>")),

// Config for `account` params
(("create_account", "business_profile"), ("BusinessProfile", "Option<BusinessProfile>")),
(("update_account", "business_profile"), ("BusinessProfile", "Option<BusinessProfile>")),
(("create_account", "business_type"), ("BusinessType", "Option<BusinessType>")),
(("update_account", "business_type"), ("BusinessType", "Option<BusinessType>")),
(("company_params", "address"), ("Address", "Option<Address>")),
(("company_params", "address_kana"), ("Address", "Option<Address>")),
(("company_params", "address_kanji"), ("Address", "Option<Address>")),
// (("company_params", "verification"), ("CompanyVerificationParams", "Option<CompanyVerificationParams>")),
(("person_params", "address"), ("Address", "Option<Address>")),
(("person_params", "address_kana"), ("Address", "Option<Address>")),
(("person_params", "address_kanji"), ("Address", "Option<Address>")),
(("person_params", "dob"), ("Dob", "Option<Dob>")),
(("person_params", "verification"), ("PersonVerificationParams", "Option<PersonVerificationParams>")),
(("company_verification_params", "document"), ("VerificationDocumentParams", "Option<VerificationDocumentParams>")),
// (("person_verification_params", "document"), ("VerificationDocumentParams", "Option<VerificationDocumentParams>")),
Expand All @@ -383,7 +361,6 @@ pub fn field_mappings() -> FieldMap {
(("create_charge", "shipping"), ("Shipping", "Option<Shipping>")),
(("create_charge", "source"), ("ChargeSourceParams", "Option<ChargeSourceParams>")),
(("update_charge", "shipping"), ("Shipping", "Option<Shipping>")),
(("fraud_details_params", "user_report"), ("FraudDetailsReport", "FraudDetailsReport")),

// Config for `customer` params
(("create_customer", "address"), ("Address", "Option<Address>")),
Expand All @@ -396,39 +373,28 @@ pub fn field_mappings() -> FieldMap {
(("update_customer", "default_card"), ("CardId", "Option<CardId>")),
(("create_customer", "default_source"), ("PaymentSourceId", "Option<PaymentSourceId>")),
(("update_customer", "default_source"), ("PaymentSourceId", "Option<PaymentSourceId>")),
(("create_customer", "shipping"), ("ShippingParams", "Option<ShippingParams>")),
(("update_customer", "shipping"), ("ShippingParams", "Option<ShippingParams>")),
(("create_customer", "source"), ("PaymentSourceParams", "Option<PaymentSourceParams>")),
(("update_customer", "source"), ("PaymentSourceParams", "Option<PaymentSourceParams>")),
(("update_customer", "trial_end"), ("Scheduled", "Option<Scheduled>")),
(
("customer_invoice_settings", "custom_fields"),
("CustomField", "Option<Vec<CustomField>>"),
),

// Config for `invoice` params
(("list_invoices", "billing"), ("", "Option<CollectionMethod>")),
(("create_invoice", "billing"), ("", "Option<CollectionMethod>")),
(("create_invoice", "custom_fields"), ("CustomField", "Option<Vec<CustomField>>")),

// Config for `invoiceitem` params
(("create_invoice_item", "period"), ("Period", "Option<Period>")),
(("update_invoice_item", "period"), ("Period", "Option<Period>")),

// Config for `order` params
(("list_orders", "status"), ("OrderStatusFilter", "Option<OrderStatusFilter>")),
(("create_order", "shipping"), ("ShippingParams", "Option<ShippingParams>")),
(("update_order", "shipping"), ("ShippingParams", "Option<ShippingParams>")),

// Config for `payment_intent` params
(("payment_intent", "source"), ("PaymentSource", "Option<Expandable<PaymentSource>>")),
(("payment_intent_next_action", "use_stripe_sdk"), ("", "Option<serde_json::Value>")),
(("create_payment_intent", "shipping"), ("ShippingParams", "Option<ShippingParams>")),
(
("create_payment_intent", "off_session"),
("PaymentIntentOffSession", "Option<PaymentIntentOffSession>"),
),
(("update_payment_intent", "shipping"), ("ShippingParams", "Option<ShippingParams>")),
(("create_setup_intent", "usage"), ("", "Option<SetupIntentUsage>")),
(("setup_intent_next_action", "use_stripe_sdk"), ("", "Option<serde_json::Value>")),

Expand Down Expand Up @@ -566,20 +532,17 @@ pub fn field_mappings() -> FieldMap {
(("create_plan_tiers", "up_to"), ("UpTo", "Option<UpTo>")),
(("create_price_tiers", "up_to"), ("UpTo", "Option<UpTo>")),
(("update_file_link", "expires_at"), ("Scheduled", "Option<Scheduled>")),
(("create_token_account", "business_type"), ("BusinessType", "Option<BusinessType>")),
(("create_token_account", "company"), ("CompanyParams", "Option<CompanyParams>")),
(("create_token_account", "individual"), ("PersonParams", "Option<PersonParams>")),

(("create_token_person", "address"), ("Address", "Option<Address>")),
(("create_token_person", "address_kana"), ("Address", "Option<Address>")),
(("create_token_person", "address_kanji"), ("Address", "Option<Address>")),
(("create_token_person", "dob"), ("Dob", "Option<Dob>")),
(
("create_payment_method", "billing_details"),
("BillingDetails", "Option<BillingDetails>"),
),
(("transfer_schedule_params", "delay_days"), ("DelayDays", "Option<DelayDays>")),
(("transfer_schedule_params", "weekly_anchor"), ("Weekday", "Option<Weekday>")),
(("create_webhook_endpoint", "api_version"), ("ApiVersion", "Option<ApiVersion>")),
]
.iter()
Expand Down
1 change: 1 addition & 0 deletions src/ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ def_id!(
def_id!(TopupId, "tu_");
def_id!(TransferId, "tr_");
def_id!(TransferReversalId, "trr_");
def_id!(UsageRecordSummaryId, "urs_");
def_id!(WebhookEndpointId, "we_");

impl InvoiceId {
Expand Down
16 changes: 15 additions & 1 deletion src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,17 @@ pub use {
token_ext::*,
},
generated::core::{
address::*,
balance::*,
balance_transaction::*,
billing_details::*,
charge::*,
customer::*,
dispute::*,
file::*,
file_link::*,
mandate::*,
package_dimensions::*,
payment_intent::*,
payout::*,
platform_tax_fee::*,
Expand All @@ -102,9 +105,11 @@ pub use {
reserve_transaction::*,
setup_attempt::*,
setup_intent::*,
shipping::*,
tax_code::*,
tax_deducted_at_source::*,
token::*,
api_errors::*,
},

payment::{
Expand All @@ -118,7 +123,9 @@ pub use {
card::*,
bank_account::*,
payment_method::*,
source::*
source::*,
payment_method_options_boleto::*,
payment_method_options_oxxo::*,
},
};

Expand Down Expand Up @@ -150,13 +157,17 @@ pub use {
coupon::*,
discount::*,
invoice::*,
invoice_payment_method_options_acss_debit::*,
invoice_payment_method_options_bancontact::*,
invoice_payment_method_options_card::*,
invoiceitem::*,
line_item::*,
plan::*,
plan::PlanInterval,
price::*,
promotion_code::*,
quote::*,
quotes_resource_total_details::*,
subscription_item::*,
subscription_item::PlanInterval as SubscriptionItemInterval,
subscription_item::SubscriptionItemPriceDataRecurring as SubscriptionItemPriceDataRecurring,
Expand All @@ -166,8 +177,11 @@ pub use {
subscription::PlanInterval as SubscriptionInterval,
subscription::SubscriptionItemPriceDataRecurring as SubscriptionPriceDataRecurring,
subscription_schedule::*,
subscription_billing_thresholds::*,
subscription_item_billing_thresholds::*,
tax_id::*,
tax_rate::*,
usage_record_summary::*,
},
};

Expand Down
14 changes: 14 additions & 0 deletions src/resources/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@

#[path = "generated"]
pub mod core {
pub mod address;
pub mod api_errors;
pub mod balance;
pub mod balance_transaction;
pub mod billing_details;
pub mod charge;
pub mod customer;
pub mod dispute;
pub mod file;
pub mod file_link;
pub mod mandate;
pub mod package_dimensions;
pub mod payment_intent;
pub mod payout;
pub mod platform_tax_fee;
Expand All @@ -27,6 +31,7 @@ pub mod core {
pub mod reserve_transaction;
pub mod setup_attempt;
pub mod setup_intent;
pub mod shipping;
pub mod tax_code;
pub mod tax_deducted_at_source;
pub mod token;
Expand All @@ -38,6 +43,8 @@ pub mod payment {
pub mod bank_account;
pub mod card;
pub mod payment_method;
pub mod payment_method_options_boleto;
pub mod payment_method_options_oxxo;
pub mod source;
}

Expand All @@ -54,17 +61,24 @@ pub mod billing {
pub mod coupon;
pub mod discount;
pub mod invoice;
pub mod invoice_payment_method_options_acss_debit;
pub mod invoice_payment_method_options_bancontact;
pub mod invoice_payment_method_options_card;
pub mod invoiceitem;
pub mod line_item;
pub mod plan;
pub mod price;
pub mod promotion_code;
pub mod quote;
pub mod quotes_resource_total_details;
pub mod subscription;
pub mod subscription_billing_thresholds;
pub mod subscription_item;
pub mod subscription_item_billing_thresholds;
pub mod subscription_schedule;
pub mod tax_id;
pub mod tax_rate;
pub mod usage_record_summary;
}

#[path = "generated"]
Expand Down
Loading