Merge pull request #7373 from jonchang/sponsors-api

github: add sponsors GraphQL API
This commit is contained in:
Jonathan Chang 2020-04-17 17:35:37 +10:00 committed by GitHub
commit 5f9fee4776
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -480,6 +480,34 @@ module GitHub
artifact.first["archive_download_url"]
end
def sponsors_by_tier(user)
url = "https://api.github.com/graphql"
data = {
query: <<~EOS,
{
organization(login: "#{user}") {
sponsorsListing {
tiers(first: 100) {
nodes {
monthlyPriceInDollars
adminInfo {
sponsorships(first: 100) {
totalCount
nodes {
sponsor { login }
}
}
}
}
}
}
}
}
EOS
}
open_api(url, scopes: ["admin:org", "user"], data: data, request_method: "POST")
end
def api_errors
[GitHub::AuthenticationFailedError, GitHub::HTTPNotFoundError,
GitHub::RateLimitExceededError, GitHub::Error, JSON::ParserError].freeze