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

Return the HTTP response status and headers #108

Draft
wants to merge 2 commits into
base: 3.0.0
Choose a base branch
from

Conversation

joshuaflanagan
Copy link
Contributor

@joshuaflanagan joshuaflanagan commented Aug 22, 2024

Callers should have access to the response headers - specifically the x-shipengine-request-id.

The significant changes are in ShipEngineClient, ShipEngineResponse and api.mustache. The rest are the result of regeneration.

Callers should have access to the response headers - specifically the x-shipengine-request-id.
@coveralls
Copy link

coveralls commented Aug 22, 2024

Pull Request Test Coverage Report for Build 10512711165

Details

  • 10 of 103 (9.71%) changed or added relevant lines in 21 files are covered.
  • 186 unchanged lines in 19 files lost coverage.
  • Overall coverage increased (+0.2%) to 11.074%

Changes Missing Coverage Covered Lines Changed/Added Lines %
ShipEngineSDK/Api/DownloadsApi.cs 0 1 0.0%
ShipEngineSDK/Api/TokensApi.cs 0 1 0.0%
ShipEngineSDK/Api/AddressesApi.cs 0 2 0.0%
ShipEngineSDK/Api/ServicePointsApi.cs 0 2 0.0%
ShipEngineSDK/Api/TrackingApi.cs 0 3 0.0%
ShipEngineSDK/Api/CarrierAccountsApi.cs 0 4 0.0%
ShipEngineSDK/Api/InsuranceApi.cs 0 4 0.0%
ShipEngineSDK/Api/ManifestsApi.cs 0 4 0.0%
ShipEngineSDK/Api/PackagePickupsApi.cs 0 4 0.0%
ShipEngineSDK/Api/RatesApi.cs 0 4 0.0%
Files with Coverage Reduction New Missed Lines %
ShipEngineSDK/Api/DownloadsApi.cs 2 0.0%
ShipEngineSDK/Api/TokensApi.cs 2 0.0%
ShipEngineSDK/Api/ServicePointsApi.cs 4 0.0%
ShipEngineSDK/Api/AddressesApi.cs 4 0.0%
ShipEngineSDK/Api/TrackingApi.cs 6 0.0%
ShipEngineSDK/Api/TagsApi.cs 8 0.0%
ShipEngineSDK/Api/RatesApi.cs 8 0.0%
ShipEngineSDK/Api/InsuranceApi.cs 8 0.0%
ShipEngineSDK/Api/CarrierAccountsApi.cs 8 0.0%
ShipEngineSDK/Api/ManifestsApi.cs 8 0.0%
Totals Coverage Status
Change from base Build 10202354177: 0.2%
Covered Lines: 1229
Relevant Lines: 11326

💛 - Coveralls

var (data, response) = await GetHttpResponse<GetAccountSettingsImagesResponseBody>(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken);
var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(),
StringComparer.InvariantCultureIgnoreCase);
return new ShipEngineResponse<GetAccountSettingsImagesResponseBody>(data, response.StatusCode, headers);
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I reading this wrong or does this make the data inaccessible? From what I saw, the ShipEngineResponse holds the data in a private field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, you're right. That field should be public. This was late-night sketching, I haven't run any of it yet - just stopped when I got it to compile.

Comment on lines 195 to 198
var (data, response) = await GetHttpResponse<GetAccountSettingsImagesResponseBody>(HttpMethods.Post, requestOptions.FullPath(), requestOptions.Data, methodClient, _config, cancellationToken);
var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value.FirstOrDefault(),
StringComparer.InvariantCultureIgnoreCase);
return new ShipEngineResponse<GetAccountSettingsImagesResponseBody>(data, response.StatusCode, headers);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would all this be worth doing inside the client? I know this is autogenerated code so the repetition isn't a big deal, but it seems like core functionality that all consumers do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it would be better done in the client. Now that I am using a new method GetHttpResponse anyway, that should be possible. (originally tried to do it using the existing SendHttp...)

@@ -0,0 +1,18 @@
namespace ShipEngineSDK;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a formatting beef, but I think most of our code puts the namespace right above the class declaration and after the using statements (even though I know some tools don't like doing this)

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.

3 participants