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

Migrate Charging Module services to *.request.js #797

Merged
merged 3 commits into from
Mar 9, 2024

Conversation

Cruikshanks
Copy link
Member

@Cruikshanks Cruikshanks commented Mar 9, 2024

https://eaflood.atlassian.net/browse/WATER-4375

Part of a series of changes related to replacing the create bill run journey to incorporate changes for two-part tariff

We know as part of the 2pT create bill run journey changes that we'll now be responsible for triggering any bill runs in the legacy service. This means we'll need to make a new call to the legacy service.

We already make one to each legacy app's /health/info endpoint and one to the /refresh bill run in water-abstraction-service. We were just going to copy and paste what we'd done before when we realised we had conflicting conventions.

Any calls to the Charging Module API are wrapped in a dedicated module. This removes duplication, simplifies testing and makes the intent much clearer.

All calls using the LegacyRequestLib are being done directly. This means we already have duplication in the billing engines and a conflicting pattern.

We want to make the Legacy stuff consistent with the Charging Module. The problem is, that we're already seeing an explosion in services in the app/services as this is going to add another sub-grouping. Plus, these services are different to the others as they are dedicated to making API requests to other services.

So, rather than moving Legacy to the Charging Module pattern, we're going to move the CHA to a new top-level grouping called app/requests. Files will be renamed from *.service.js to *.request.js and the call will be renamed from go() to send().

Hopefully, that will make the intent of these types of modules clearer.

https://eaflood.atlassian.net/browse/WATER-4375

> Part of a series of changes related to replacing the create bill run journey to incorporate changes for two-part tariff

We know as part of the 2pT create bill run journey changes that we'll now be responsible for triggering any bill runs in the legacy service. This means we'll need to make a new call to the legacy service.

We already make one to each legacy app's `/health/info` endpoint and one to the `/refresh` bill run in[water-abstraction-service](https://github.com/DEFRA/water-abstraction-service). We were just going to copy and paste what we'd done before when we realised we had conflicting conventions.

Any calls to the [Charging Module API](https://github.com/DEFRA/sroc-charging-module.api) are wrapped in their own dedicated module. This removes duplication, simplifies testing and makes the intent much clearer.

All calls using the `LegacyRequestLib` are being done directly. This means we already have duplication in the billing engines and a conflicting pattern.

We want to make the Legacy stuff consistent with the Charging Module. Problem is, we're already seeing an explosion in services in the `app/services` as this is going to add another sub grouping. Plus, these services are different to the others as they are dedicated to making API requests to other services.

So, rather than moving Legacy to the Charging Module pattern, we're going to move the CHA to a new top level grouping called `app/api`. Files will be renamed from `*.service.js` to `*.api.js` and the call will be renamed from `go()` to `send()`.

Hopefully, that will make the intent of these types of modules clearer.
@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label Mar 9, 2024
@Cruikshanks Cruikshanks self-assigned this Mar 9, 2024
@Cruikshanks Cruikshanks changed the title Migrate Charging Module services to *.api.js Migrate Charging Module services to *.request.js Mar 9, 2024
Would have been nice to break this up but it broke so much stuff in the process it was clearer and easier just to do it en-masse and then confirm app was running and tests were passing again.

Also includes some cleanup of the JSDoc comments to bring them all to the same level of consistency.
@Cruikshanks Cruikshanks marked this pull request as ready for review March 9, 2024 14:02
@Cruikshanks Cruikshanks merged commit ecda5dd into main Mar 9, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the move-legacy-callto-module branch March 9, 2024 14:02
Cruikshanks added a commit that referenced this pull request Mar 9, 2024
https://eaflood.atlassian.net/browse/WATER-4375

> Part of a series of changes related to replacing the create bill run journey to incorporate changes for two-part tariff

In [Migrate Charging Module services to *.request.js](#797) we made structural changes to where the code that sends requests to 3rd party apps sit. This was in preparation for this change. For each request type we send to the [Charging Module API](https://github.com/DEFRA/sroc-charging-mdoule-api) we have a module. This removes duplication, centralises how that type of request is made and makes the intent clearer.

But legacy requests we're just using `Legacy.request.js` directly. We want a consistent pattern for how these things are done, especially as we are on the cusp of adding a new legacy request type. So, having moved the Charging Module requests to the pattern we want to adopt, it is now time to move how we are sending requests to the Legacy apps to refresh a bill run.
Cruikshanks added a commit that referenced this pull request Mar 9, 2024
https://eaflood.atlassian.net/browse/WATER-4375

> Part of a series of changes related to replacing the create bill run journey to incorporate changes for two-part tariff

In [Migrate Charging Module services to *.request.js](#797) we made structural changes to where the code that sends requests to 3rd party apps sits. This was in preparation for this change. For each request type, we send to the [Charging Module API](https://github.com/DEFRA/sroc-charging-mdoule-api) we have a module. This removes duplication, centralises how that type of request is made and makes the intent clearer.

But for legacy requests, we're just using `Legacy.request.js` directly. We want a consistent pattern for how these things are done, especially as we are on the cusp of adding a new legacy request type. So, having moved the Charging Module requests to the pattern we want to adopt, it is now time to move how we send requests to the Legacy apps to refresh a bill run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Refactoring, tidying up or other work which supports the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant