Last active
August 24, 2022 23:55
-
-
Save hugofcampos/15c380573867749953d8fed4b0876e14 to your computer and use it in GitHub Desktop.
Passo 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ballerina/http; | |
import ballerina/io; | |
type GithubAccount record { | |
int id; | |
string login; | |
int public_repos; | |
}; | |
public function main() returns error? { | |
string[] usernames = ["defunkt", "zenorocha", "tj"]; | |
GithubAccount[] users = []; | |
foreach string login in usernames { | |
http:Client github = check new ("https://api.github.com"); | |
GithubAccount user = check github->get("/users/" + login); | |
users.push(user); | |
} | |
GithubAccount[] sorted = from GithubAccount u in users | |
order by u.public_repos descending | |
select u; | |
io:println(sorted[0].login); | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment