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

Builder patterns #591

Closed
antonio-hickey opened this issue Aug 15, 2024 · 2 comments
Closed

Builder patterns #591

antonio-hickey opened this issue Aug 15, 2024 · 2 comments

Comments

@antonio-hickey
Copy link

antonio-hickey commented Aug 15, 2024

Is your feature request related to a problem? Please describe.

I don't like writing code like this

let mut create_billing_portal = CreateBillingPortalSession::new(users_stripe_cust_id);
create_billing_portal.return_url = Some("https://someurl.com"); 
 
let billing_portal =
        BillingPortalSession::create(&stripe_client, create_billing_portal).await?;

Describe the solution you'd like

I would love to use a builder pattern like so:

let billing_portal = BillingPortalSession::create(
    &stripe_client, 
    BillingPortalSessionBuilder::new(users_stripe_cust_id)
        .set_return_url(Some("https://someurl.com"))
        .build()
 ).await?;

Describe alternatives you've considered

No response

Additional context

Willing to work on this myself if it's something we'd be interested in adding :)

@augustoccesar
Copy link
Contributor

augustoccesar commented Aug 15, 2024

Hello! This is being implemented on the next branch (tracking PR)!

pub struct BillingPortalSessionBuilder {
configuration: Option<stripe_types::Expandable<stripe_billing::BillingPortalConfiguration>>,
created: Option<stripe_types::Timestamp>,
customer: Option<String>,
flow: Option<Option<stripe_billing::PortalFlowsFlow>>,
id: Option<stripe_billing::BillingPortalSessionId>,
livemode: Option<bool>,
locale: Option<Option<stripe_billing::BillingPortalSessionLocale>>,
on_behalf_of: Option<Option<String>>,
return_url: Option<Option<String>>,
url: Option<String>,
}

@antonio-hickey
Copy link
Author

Ahh ok cool thanks, sorry I did a search on existing issues and didn't see anything related.

Will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants