I am new to DDD and I am trying to apply it with Hexagonal architecture. I have the following scenario:
- A user aggregate
- application service
and third party REST API that I need to call before persisting the user to the repository
So I am trying to implement it using ports and adapters, so I have an interface in my application service layer that represents the third party functionality and I have the concrete implementation of that API calling exist in infrastructure
layer
as the following image
As you know this interface should take some params and returns specific type, my question is where should I put the types of these params and returned type, should be exist in the infrastructure layer or inside the application service layer?
for example I have the following interface:
class GetSomeDataInput{
customerId string;
userName string;
}
class GetSomeDataResult {
userBlocked boolean;
userAvailable boolean;
}
interface IThirdPartyAPI {
getSomeInfo(GetSomeDataInput input): GetSomeDataResult;
}
As you can see the method should take specific param with specific type and return also specific type, and these classes should be implemented in both the caller side which is application service
and also on the receiver side which is the concrete implementation
so where should I put these types in infrastructure
layer or inside the application layer
or put them in a shared directory that could be accessed by both
Sorry I just wrote some pseudo code to explain my question, thank you.