trabajo-afectivo/lib/gitlab/credentials.rb
2022-01-01 14:38:12 +01:00

29 lines
556 B
Ruby

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