You have been asked to find the top x billionaires by net worth in a given set of countries (number of countries = N). To implement that, you have been given access to an API that returns the details of the billionaires by country.
To simplify accessing the API, you can use the ims/billionairehub client connector to connect to the API which returns details of the billionaires by country.
import ims/billionairehub;
# Client ID and Client Secret to connect to the billionaire API
configurable string clientId = ?;
configurable string clientSecret = ?;
public function getTopXBillionaires(string[] countries, int x) returns string[]|error {
// Create the client connector
billionairehub:Client cl = check new ({auth: {clientId, clientSecret}});
// TODO Write your logic here
return [];
}Input
Countries: ["United States"]
Limit: 3Output
["Elon Musk", "Jeff Bezos", "Bill Gates"]Input
Countries: ["China", "India"]
Limit: 5Output
["Mukesh Ambani", "Gautam Adani & family", "Zhong Shanshan", "Zhang Yiming", "Ma Huateng"]tests/Config.toml. You can use them to initialize the client.bal test to run and test your implementation.ims/billionairehub package's client can be used to invoke the get billionaires by country API. You can use the getBillionaires("<country>") remote method specifically.xYou have been asked to find the top x billionaires by net worth in a given set of countries (number of countries = N). To implement that, you have been given access to an API that returns the details of the billionaires by country.
To simplify accessing the API, you can use the ims/billionairehub client connector to connect to the API which returns details of the billionaires by country.
import ims/billionairehub;
# Client ID and Client Secret to connect to the billionaire API
configurable string clientId = ?;
configurable string clientSecret = ?;
public function getTopXBillionaires(string[] countries, int x) returns string[]|error {
// Create the client connector
billionairehub:Client cl = check new ({auth: {clientId, clientSecret}});
// TODO Write your logic here
return [];
}Input
Countries: ["United States"]
Limit: 3Output
["Elon Musk", "Jeff Bezos", "Bill Gates"]Input
Countries: ["China", "India"]
Limit: 5Output
["Mukesh Ambani", "Gautam Adani & family", "Zhong Shanshan", "Zhang Yiming", "Ma Huateng"]tests/Config.toml. You can use them to initialize the client.bal test to run and test your implementation.ims/billionairehub package's client can be used to invoke the get billionaires by country API. You can use the getBillionaires("<country>") remote method specifically.x