I have two APIs with different resources:
www.api-A.com**/consumers
,which returns:
{consumers: ['mike', 'Anna', 'Danilo']}
www.api-B.com**/clients
,which returns:
{clients: ['Jack', 'Bruce', 'Mary']}
I would like to use these two results in one controller. I want to treat them like if there were just one.
Do I have to create a wrapper for each api like:
module ApiAWrapper
#code here
end
module ApiBWrapper
#code here
end
and call the following inside my controller?
MyController
def index
@clients << ApiAWrapper.most_recent
@clients << ApiBWrapper.most_recent
@clients
end
end
Doing this, @clients
will be:
['mike', 'Anna', 'Danilo', 'Jack', 'Bruce', 'Mary']
Is this the right way to use these different APIs with similar responses? Is there a design pattern that I can use or I should read about to guide me?