github.rb 564 B

123456789101112131415161718192021222324252627
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. class GitHub
  3. attr_reader :client
  4. def initialize(endpoint, api_token)
  5. @client = GitHub::HttpClient.new(endpoint, api_token)
  6. end
  7. def verify!
  8. GitHub::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 = GitHub::LinkedIssue.new(client)
  19. issue.find_by(url)&.to_h
  20. end
  21. end