request.rb 783 B

1234567891011121314151617181920212223242526272829
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Freshdesk::Request < Sequencer::Unit::Common::Provider::Attribute
  3. extend ::Sequencer::Unit::Import::Freshdesk::Requester
  4. prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action
  5. skip_action :skipped, :failed
  6. uses :object, :request_params
  7. provides :response
  8. private
  9. def response
  10. builder = backend.new(
  11. object: object,
  12. request_params: request_params
  13. )
  14. self.class.request(
  15. api_path: builder.api_path,
  16. params: builder.params,
  17. )
  18. end
  19. def backend
  20. "::Sequencer::Unit::Import::Freshdesk::Request::#{object}".safe_constantize || ::Sequencer::Unit::Import::Freshdesk::Request::Generic
  21. end
  22. end