gitlab.rb 606 B

123456789101112131415161718192021222324252627
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class GitLab
  3. attr_reader :client
  4. def initialize(endpoint, api_token, verify_ssl: true)
  5. @client = GitLab::HttpClient.new(endpoint, api_token, verify_ssl: verify_ssl)
  6. end
  7. def verify!
  8. GitLab::Credentials.new(client).verify!
  9. end
  10. def issues_by_urls(urls)
  11. urls.uniq.each_with_object([]) do |url, result|
  12. issue = issue_by_url(url)
  13. next if issue.blank?
  14. result << issue
  15. end
  16. end
  17. def issue_by_url(url)
  18. issue = GitLab::LinkedIssue.new(client)
  19. issue.find_by(url)&.to_h
  20. end
  21. end