Reputation: 3289
I need to call a third-party API to get data that will eventually be persisted in my database.
When it comes to working with data in my database, I typically declare the repository interfaces in Domain
and I add the actual implementation in Data
.
My question is - should I do the same with these third-party API calls? It's data after all, except that I'm getting it from another source.
Upvotes: 2
Views: 2692
Reputation: 29827
As plaxl said (and expanding a bit more) your Data
package/module sounds like what sometimes is called infrastructure, plugins or adapter (the last if you're using hexagonal architecture).
As you mentioned, you still need to define an interface and the domain object that represents that data. The interface is usually a domain service rather than a Repository.
Alternatively, you can skip the domain interface and have an concrete object that is used directly from the repository implementation.
Upvotes: 2