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 IsSuccess Property to ApiResponse #1891

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

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 77.77778% with 4 lines in your changes missing coverage. Please review.

Project coverage is 84.20%. Comparing base (6ebeda5) to head (7c853b6).
Report is 144 commits behind head on main.

Files with missing lines Patch % Lines
Refit/ApiResponse.cs 77.77% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1891      +/-   ##
==========================================
- Coverage   87.73%   84.20%   -3.53%     
==========================================
  Files          33       36       +3     
  Lines        2348     2482     +134     
  Branches      294      348      +54     
==========================================
+ Hits         2060     2090      +30     
- Misses        208      312     +104     
  Partials       80       80              

☔ 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`
if(response.IsSuccessStatusCode)
//Determining if a success status code was received and there wasn't any other error
//(for example, during content deserialization)
if(response.IsSuccessfull)
Copy link
Contributor

@TimothyMakkison TimothyMakkison Oct 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: successful

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

Successfully merging this pull request may close these issues.

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