Refactor ReportingManager.GetMerchant and extract merchant mapping to ModelFactory#510
Conversation
Co-authored-by: StuartFerguson <[email protected]>
Co-authored-by: StuartFerguson <[email protected]>
ReportingManager.GetMerchant to reduce method length
| Merchant result = new() { | ||
| Balance = merchantState.Balance, | ||
|
|
||
| return Result.Success(MapMerchant(merchantQueryResult.Data, merchantStateQueryResult.Data.Balance)); |
There was a problem hiding this comment.
@copilot can this MapMerchant be added to a new static ModelFactory with the method name ConvertFrom
There was a problem hiding this comment.
Done in b1494d5 — the merchant mapping now lives in a new static ModelFactory as ConvertFrom(...), and ReportingManager.GetMerchant calls that factory.
| public bool IsEnabled { get; init; } | ||
| } | ||
|
|
||
| private sealed class MerchantData { |
There was a problem hiding this comment.
@copilot Move these new classes to a DatabaseModels.cs file please
There was a problem hiding this comment.
Done in 7901a47 — the new merchant projection classes now live in DatabaseModels.cs, with ModelFactory left focused on ConvertFrom(...).
Co-authored-by: StuartFerguson <[email protected]>
ReportingManager.GetMerchant to reduce method lengthReportingManager.GetMerchant and extract merchant mapping to ModelFactory
Co-authored-by: StuartFerguson <[email protected]>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
ReportingManager.GetMerchantexceeded the repository’s method-length threshold, triggering the Codacy complexity warning. This change reduces the method to a small orchestration flow without altering its query or mapping behavior, and follows review feedback by moving the merchant model mapping into a dedicated factory.Method decomposition
BuildMerchantQuery(...)GetMerchant(...)to the request flow:MerchantModel factory extraction
ModelFactoryModelFactory.ConvertFrom(...)for converting the merchant projection plus balance intoModels.MerchantProjection types
MerchantDataMerchantAddressDataMerchantContactDataDatabaseModels.csfile based on PR feedbackBehavior preserved
EstateReportingAPI.BusinessLogic/ReportingManager.csEstateReportingAPI.BusinessLogic/ModelFactory.csEstateReportingAPI.BusinessLogic/DatabaseModels.csOriginal prompt
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.