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

feat: add method to initialize SDK with an httpClient #89

Closed
wants to merge 5 commits into from

Conversation

jpill
Copy link
Member

@jpill jpill commented Jun 10, 2024

  • Adds the ability to initialize SDK with an HttpClient, and to make modifications to subsequent requests
  • Adds cancellation token to client
  • Adds HttpResponseMessage to ShipEngineException
  • Adds missing markdown
  • Redefines several properties as nullable reference types
  • Adds and implements IShipEngine interface with virtual mockable ShipEngine

@jpill jpill self-assigned this Jun 10, 2024
@jpill jpill force-pushed the jpill/HttpClient-update branch 2 times, most recently from 55403e4 to ac8aa05 Compare June 10, 2024 16:29
@ShipEngine ShipEngine deleted a comment from coveralls Jun 10, 2024
@ShipEngine ShipEngine deleted a comment from coveralls Jun 10, 2024
@jpill jpill force-pushed the jpill/HttpClient-update branch 2 times, most recently from ed17c45 to 9c6b2a7 Compare June 10, 2024 16:49
ShipEngine/ShipEngine.cs Outdated Show resolved Hide resolved
ShipEngine/ShipEngine.csproj Show resolved Hide resolved
@ShipEngine ShipEngine deleted a comment from coveralls Jun 11, 2024
@jpill jpill force-pushed the jpill/HttpClient-update branch from 0325572 to 4ec67cd Compare June 20, 2024 15:42
@ShipEngine ShipEngine deleted a comment from coveralls Jun 20, 2024
@ShipEngine ShipEngine deleted a comment from coveralls Jun 20, 2024
@jpill jpill force-pushed the jpill/HttpClient-update branch from 4ec67cd to 9d3ad15 Compare June 20, 2024 19:45
@ShipEngine ShipEngine deleted a comment from coveralls Jun 20, 2024
@jpill jpill requested a review from joshuaflanagan June 24, 2024 14:49
@jpill jpill force-pushed the jpill/HttpClient-update branch from 9d3ad15 to 6a2afce Compare June 24, 2024 19:00
@ShipEngine ShipEngine deleted a comment from coveralls Jun 24, 2024
@jpill jpill force-pushed the jpill/HttpClient-update branch from 6a2afce to e4739f7 Compare June 24, 2024 21:40
@coveralls
Copy link

coveralls commented Jun 24, 2024

Pull Request Test Coverage Report for Build 9652824702

Details

  • 48 of 142 (33.8%) changed or added relevant lines in 8 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-9.7%) to 75.691%

Changes Missing Coverage Covered Lines Changed/Added Lines %
ShipEngine/Models/Dto/GetRatesFromShipmentDetails/Result.cs 19 23 82.61%
ShipEngine/ShipEngineClient.cs 17 32 53.13%
ShipEngine/ShipEngine.cs 2 77 2.6%
Files with Coverage Reduction New Missed Lines %
ShipEngine/ShipEngine.cs 1 56.73%
Totals Coverage Status
Change from base Build 9486504073: -9.7%
Covered Lines: 644
Relevant Lines: 825

💛 - Coveralls

@jpill jpill requested a review from KaseyCantu June 25, 2024 14:41
@jpill jpill marked this pull request as ready for review June 25, 2024 14:41
@jpill jpill force-pushed the jpill/HttpClient-update branch from 0f79f4b to 6c7b334 Compare June 25, 2024 14:46
@coveralls
Copy link

coveralls commented Jun 25, 2024

Pull Request Test Coverage Report for Build 9664624594

Details

  • 48 of 142 (33.8%) changed or added relevant lines in 8 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-9.7%) to 75.691%

Changes Missing Coverage Covered Lines Changed/Added Lines %
ShipEngine/Models/Dto/GetRatesFromShipmentDetails/Result.cs 19 23 82.61%
ShipEngine/ShipEngineClient.cs 17 32 53.13%
ShipEngine/ShipEngine.cs 2 77 2.6%
Files with Coverage Reduction New Missed Lines %
ShipEngine/ShipEngine.cs 1 56.73%
Totals Coverage Status
Change from base Build 9486504073: -9.7%
Covered Lines: 644
Relevant Lines: 825

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jun 25, 2024

Pull Request Test Coverage Report for Build 9664647461

Details

  • 48 of 142 (33.8%) changed or added relevant lines in 8 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-9.7%) to 75.691%

Changes Missing Coverage Covered Lines Changed/Added Lines %
ShipEngine/Models/Dto/GetRatesFromShipmentDetails/Result.cs 19 23 82.61%
ShipEngine/ShipEngineClient.cs 17 32 53.13%
ShipEngine/ShipEngine.cs 2 77 2.6%
Files with Coverage Reduction New Missed Lines %
ShipEngine/ShipEngine.cs 1 56.73%
Totals Coverage Status
Change from base Build 9486504073: -9.7%
Covered Lines: 644
Relevant Lines: 825

💛 - Coveralls

Converters = { new JsonStringEnumMemberConverter() }
};
}
protected Action<HttpRequestMessage>? ModifyRequest { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be protected? We want users to be able to set it. I know we talked about a .WithModifiedRequest() method that would return a new instance with this field set, but is there any reason to force them to use that method? Seems like it should be fine to let people do client.ModifyRequest = r => ... as well

Copy link
Member Author

Choose a reason for hiding this comment

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

fair question - I think likely not, but am just going to remove the modify request bit from this effort while that gets further consideration, so as not to cause more delay with the rest of the functionality I'm looking to deliver here

{
client.DefaultRequestHeaders.Accept.Clear();

var osPlatform = Environment.OSVersion.Platform.ToString();
Copy link
Contributor

Choose a reason for hiding this comment

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

The duplication of all of this logic seems wrong. Can the non-static version invoke the static version?

Copy link
Member Author

Choose a reason for hiding this comment

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

good callout, I have modified this in the updated PR here: #93

@jpill
Copy link
Member Author

jpill commented Jun 27, 2024

closing this PR in favor of #93

@jpill jpill closed this Jun 27, 2024
@jpill jpill deleted the jpill/HttpClient-update branch June 27, 2024 14:26
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