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

Add IsSuccessful property to ApiResponse #1891

Merged
merged 13 commits into from
Oct 29, 2024

Conversation

marcominerva
Copy link
Contributor

@marcominerva marcominerva commented Oct 24, 2024

What kind of change does this PR introduce?

This PR adds a new IsSuccessful property to ApiResponse, that tells if the HTTP call has succeeded and there wasn't any other error (for example, during response deserialization).

What is the current behavior?
See #1694

What might this PR break?
Nothing, this a new feature that does not impact the existing applications.

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Other information:
Closes #1694

Introduce IsSuccess property to ApiResponse<T> and related interfaces to indicate request success. Add EnsureSuccessAsync method to handle errors, including deserialization issues. Refactor EnsureSuccessStatusCodeAsync to use ThrowsApiExceptionAsync. Update Dispose method for exception handling. Add unit tests to verify new behavior.
Copy link

codecov bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.

Project coverage is 84.32%. Comparing base (6ebeda5) to head (be5de70).
Report is 147 commits behind head on main.

Files with missing lines Patch % Lines
Refit/ApiResponse.cs 88.88% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1891      +/-   ##
==========================================
- Coverage   87.73%   84.32%   -3.41%     
==========================================
  Files          33       36       +3     
  Lines        2348     2482     +134     
  Branches      294      348      +54     
==========================================
+ Hits         2060     2093      +33     
- Misses        208      310     +102     
+ Partials       80       79       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

marcominerva and others added 3 commits October 24, 2024 15:52
Renamed properties and methods related to the success status of an API response in the `Refit` library:
- `IsSuccess` to `IsSuccessful`
- `EnsureSuccessAsync` to `EnsureSuccessfulAsync`
README.md Outdated Show resolved Hide resolved
Added a new test method `When_SerializationErrorOnSuccessStatusCode_EnsureSuccesStatusCodeAsync_DoNotThrowApiException` to verify that `EnsureSuccessStatusCodeAsync` does not throw an `ApiException` on deserialization error with a success status code. Included assertions to check response status and error presence. Enhanced existing test method `When_SerializationErrorOnSuccessStatusCode_EnsureSuccessfulAsync_ThrowsApiException` with additional assertions.
@marcominerva marcominerva changed the title Add IsSuccess Property to ApiResponse Add IsSuccessful property to ApiResponse Oct 29, 2024
@ChrisPulman ChrisPulman merged commit dc74700 into reactiveui:main Oct 29, 2024
2 of 3 checks passed
@marcominerva marcominerva deleted the is_success branch October 30, 2024 08:37
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: IsSuccessStatusCode is true, but Error is non-null
3 participants