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

optionally decouple account id specification from client struct #380

Open
databasedav opened this issue May 12, 2023 · 0 comments
Open

optionally decouple account id specification from client struct #380

databasedav opened this issue May 12, 2023 · 0 comments

Comments

@databasedav
Copy link

databasedav commented May 12, 2023

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

since the account id must be specified on the client struct with fn with_stripe_account(mut self, ..., this means that if one is managing many connected accounts, they need to take ownership of the client that's making the request, which means either (lazily) cloning the client on every request, even though post_form only needs &self, or (eagerly) managing a cache of client struct set to the account id's of the connected they are managing

Describe the solution you'd like

i want to avoid both cloning the client and managing cached client structs by allowing the specification of the account id in an alternative way not tied to the client

one solution (definitely not the best) is to introduce a new function

fn post_form_with(&self, path: &str, form: F, request_transformer: impl Fn(Request) -> Request) -> Response<T> {
    ...
    request = request_transformer(request);
    ...
}

which would allow setting the account id header in the request_transformer although i'm not sure how ergonomic this would be with how the endpoints are currently called or in the new codegen branch e.g.

pub fn post_products(
    client: &crate::Client,
    params: PostProductsParams,
) -> crate::Response<crate::generated::Product> {
    client.post_form("/products", params)
}

which would mean generating an extra _with function for everyone of these functions to expose the lower level request from the high level api, which seems undesirable ...

Describe alternatives you've considered

No response

Additional context

No response

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

1 participant