trabajo-afectivo/lib/github/credentials.rb

30 lines
540 B
Ruby
Raw Permalink Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
class GitHub
class Credentials
QUERY = <<-'GRAPHQL'.freeze
query {
viewer {
login
}
}
GRAPHQL
attr_reader :client
def initialize(client)
@client = client
end
def verify!
response = client.perform(
query: GitHub::Credentials::QUERY,
)
return if response.dig('data', 'viewer', 'login').present?
raise __('Invalid GitHub GraphQL API token')
end
end
end