Imagine I have two api's with different resources,
www.api-A.com/consumers
Returns: { consumers: ['mike', 'Anna', 'Danilo'] }
www.api-B.com/clients
Returns: { clients: ['Jack', 'Bruce', 'Mary'] }
I would like to consume these two listing the results in one Rails Controller
My doubt: Do I have to create a wrapper for every api like:
module ApiAWrapper
#code here
end
module ApiBWrapper
#code here
end
and inside my controller I call.
MyController
def index
@clients << ApiAWrapper.most_recent
@clients << ApiBWrapper.most_recent
@clients
end
end
Now @clients
will have
['mike', 'Anna', 'Danilo', 'Jack', 'Bruce', 'Mary']
Aucun commentaire:
Enregistrer un commentaire