29 lines
701 B
Ruby
29 lines
701 B
Ruby
|
require '/data_importer/lib/github_api/github_api.rb'
|
||
|
module GithubApi
|
||
|
class User
|
||
|
UserProfileQuery = GithubApi::Client.parse <<-'GRAPHQL'
|
||
|
query($username: String!) {
|
||
|
user(login: $username) {
|
||
|
id
|
||
|
login
|
||
|
name
|
||
|
avatarUrl
|
||
|
bio
|
||
|
bioHTML
|
||
|
location
|
||
|
}
|
||
|
}
|
||
|
GRAPHQL
|
||
|
|
||
|
def self.find(username)
|
||
|
response = GithubApi::Client.query(UserProfileQuery, variables: { username: username })
|
||
|
if response.errors.any?
|
||
|
raise QueryExecutionError.new(response.errors[:data].join(", "))
|
||
|
else
|
||
|
response.data.user
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
class QueryExecutionError < StandardError; end
|