2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
2021-03-10 16:11:14 +00:00
|
|
|
|
|
|
|
class GitLab
|
|
|
|
attr_reader :client
|
|
|
|
|
2021-03-24 16:41:05 +00:00
|
|
|
def initialize(endpoint, api_token)
|
|
|
|
@client = GitLab::HttpClient.new(endpoint, api_token)
|
|
|
|
end
|
2021-03-10 16:11:14 +00:00
|
|
|
|
2021-03-24 16:41:05 +00:00
|
|
|
def verify!
|
|
|
|
GitLab::Credentials.new(client).verify!
|
2021-03-10 16:11:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def issues_by_urls(urls)
|
|
|
|
urls.uniq.each_with_object([]) do |url, result|
|
|
|
|
issue = issue_by_url(url)
|
|
|
|
next if issue.blank?
|
|
|
|
|
|
|
|
result << issue
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def issue_by_url(url)
|
|
|
|
issue = GitLab::LinkedIssue.new(client)
|
|
|
|
issue.find_by(url)&.to_h
|
|
|
|
end
|
|
|
|
end
|