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
[AC-2313] Add Gateway fields to Provider edit in Admin #4057
[AC-2313] Add Gateway fields to Provider edit in Admin #4057
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4057 +/- ##
==========================================
- Coverage 38.44% 38.43% -0.01%
==========================================
Files 1209 1209
Lines 58545 58557 +12
Branches 5585 5593 +8
==========================================
Hits 22509 22509
- Misses 34991 35002 +11
- Partials 1045 1046 +1 ☔ View full report in Codecov by Sentry. |
New Issues
Fixed Issues
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments, nothing major :)
model.ToProvider(provider); | ||
provider.BillingEmail = model.BillingEmail?.ToLowerInvariant().Trim(); | ||
provider.BillingPhone = model.BillingPhone?.ToLowerInvariant().Trim(); | ||
provider.Gateway = model.Gateway; | ||
provider.GatewayCustomerId = model.GatewayCustomerId; | ||
provider.GatewaySubscriptionId = model.GatewaySubscriptionId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's wrong with model.ToProvider
? :(
To expand slightly - I like putting this kind of mapping/update logic inside models, it makes sense to me from a general OOP perspective, and it removes boilerplate from the controller or service. We also still use it on the CreateProviderModel
, so it's inconsistent to change it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally just find the signature public virtual Provider ToProvider(Provider existingProvider)
and the practice of passing around mutable object properties in general somewhat confusing, but I've reset it back to its original state and added the new Gateway fields to the existing method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's reasonable - do you think it would be better if it was on the object being mutated instead, e.g. existingProvider.Update(editProviderModel)
? That way the object is updating itself and not mutating its argument. (I suspect we've done it the current way to avoid importing api models into the core layer, but you could avoid this by making Update
an api-only extension method on Provider
.)
Anyway - none of that needs to be done here - just thinking aloud.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think that could be a bit more readable. Even just using a different signature for the same approach might make it easier to reason through at first glance as well.
For instance, it makes perfect sense for CreateProviderModel
to have a ToProvider
method that returns a Provider
entity that will be inserted into the DB. But for the EditProviderModel
, we already have an existing Provider
, so if we're going to update in place, there's no reason to return anything and the method name could be more along the lines of EditProviderModel.UpdateEntity(Provider)
or even just EditProviderModel.Update(Provider)
. If AC is open to that, I can definitely start making those changes as we make more Admin updates! Either way, thank you for calling that out and for the review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with EditProviderModel.Update(Provider)
, returning void
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Type of change
Objective
This PR does some refactoring around creating and modifying Pricing Plans in Admin. It also adds input fields to the Provider Edit screen so CS can view and update the Gateway fields for a Provider who has Consolidated Billing.
Screen.Recording.2024-05-06.at.2.26.30.PM.mov