I have a RESTful API service that has three layers: Application/Domain, Infrastructure, and Presentation.
Application/Domain contain my interfaces and models. I currently have three different types of models:
- DTO – These are the models my controllers return to the client as well as the models that are passed around all the layers of my application.
- POCO – Domain model that has an instance of the corresponding DTO, it has business rules/validations.
- Entities – Persistence models that mirror database objects.
Now, if my RESTful API makes a request to another API service and the request requires both a body and response, I would want to create models for both the body and the response right? What would this kind of model be called and which layer would I put it in?
I guess it would have to go in the Application/Domain layer because that’s where the interface for my third party API client would also be. But what would I call these models? Are they entities? Are they DTOs?
Hmmm…I guess they could be considered entities. An entity is a model that represents the data in the database and I guess the third party API could also be considered a database of sorts…
I was initially calling the services that connect with dbs repositories and calling services that connect with other APIs ApiClients. But they really are just facade services. So I guess they are the same?
What do you guys think?