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

Is it possible to pull EnsureSuccessStatusCodeAsync into the IApiResponse<T> interface? #1108

Open
rwwilden opened this issue Mar 8, 2021 · 1 comment

Comments

@rwwilden
Copy link

rwwilden commented Mar 8, 2021

Before I create a PR I'd like to know if there's any objection to doing this that I might overlook. I just switched to 6.x and ran into this issue.

Is your feature request related to a problem? Please describe.
For unit testing scenarios it would be much easier if my methods exposed IApiResponse<T> instead of ApiResponse<T>. It would make mocking the response a lot easier.

However, at quite a few locations I call EnsureSuccessStatusCodeAsync on the return value of API calls. This only exists on ApiResponse<T>, meaning it's impossible to switch all my methods to IApiResponse<T>.

Describe the solution you'd like
Pull EnsureSuccessStatusCodeAsync into the IApiResponse<T> interface.

Describe alternatives you've considered
Leave as is, making my unit tests a little more convoluted because creating an ApiResponse<R> there now also requires a RefitSettings.

Describe suggestions on how to achieve the feature
PR to pull method into interface plus maybe a couple tests (haven't looked into that).

@rwwilden
Copy link
Author

rwwilden commented Mar 8, 2021

Ok, I think I found the objection to doing this :)

ApiException depends on HttpResponseMessage which isn't exposed in IApiResponse. Exposing that would probably mean a major departure from what Refit attempts to accomplish?

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