base.rb 823 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Service::Ticket::ExternalReferences::IssueTracker::Base < Service::Base
  3. attr_reader :type
  4. def initialize(type:)
  5. super()
  6. @type = type
  7. end
  8. private
  9. def integration_setting_name
  10. "#{type}_integration"
  11. end
  12. def integration_config
  13. @integration_config ||= begin
  14. config = Setting.get("#{type}_config")
  15. config.symbolize_keys
  16. end
  17. end
  18. def issue_tracker_object
  19. @issue_tracker_object ||= begin
  20. options = {
  21. endpoint: integration_config[:endpoint],
  22. api_token: integration_config[:api_token]
  23. }
  24. options[:verify_ssl] = integration_config[:verify_ssl] if integration_config.key?(:verify_ssl)
  25. "::#{type.camelize}".constantize.new(**options)
  26. end
  27. end
  28. end