request.rb 833 B

1234567891011121314151617181920212223242526272829303132
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Kayako::Request < Sequencer::Unit::Common::Provider::Attribute
  3. extend ::Sequencer::Unit::Import::Kayako::Requester
  4. uses :object, :request_params
  5. provides :response
  6. private
  7. def response
  8. builder = backend.new(
  9. object: object,
  10. request_params: request_params
  11. )
  12. self.class.request(
  13. api_path: builder.api_path,
  14. params: builder.params,
  15. )
  16. end
  17. def backend
  18. request_class = "::Sequencer::Unit::Import::Kayako::Request::#{object}".safe_constantize
  19. return request_class if request_class.present?
  20. return ::Sequencer::Unit::Import::Kayako::Request::GenericField if object.include?('Field')
  21. ::Sequencer::Unit::Import::Kayako::Request::Generic
  22. end
  23. end