I'm building a web app around a external api. What is the best way to organize the logic? Is ok to do something like this:
class TestService {
public function getItemById($id) {
}
public function getAll() {
}
}
and call these functions inside the controller
You might want to take a look at Saloon.
It allows you to create SDK like integrations with any API and provides the ability to create a wrapper pretty much like what you're doing manually here.
At first, it might seem a little overwhelming (depending on how complex you need the functionality to be), but reading through the docs should make it click.
@lucas27742
If you are a visual learner, you may find the following video useful.
https://www.youtube.com/watch?v=r3AU6uYQGt4