Middle+
Where should the getExternalOrderIdFromCRM method be located? How to structure the project?
sobes.tech AI
Answer from AI
The method getExternalOrderIdFromCRM is responsible for retrieving data from an external system (CRM), so it belongs to the layer of integration with external services.
It is recommended:
- To allocate a package or module in the project responsible for working with CRM, for example
crmorexternal. - To place the
getExternalOrderIdFromCRMfunction in this package, which encapsulates the logic of contacting the CRM (HTTP requests, response processing). - To call this method from business logic through an interface or service to separate integration details from the core logic.
Example structure:
/project
/crm
crm.go // contains getExternalOrderIdFromCRM
/service
order.go // uses crm.getExternalOrderIdFromCRM
main.go
This approach improves readability, testability, and maintainability of the code.