resources.rb 747 B

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Freshdesk::Resources < Sequencer::Unit::Common::Provider::Named
  3. include ::Sequencer::Unit::Import::Common::Model::Mixin::HandleFailure
  4. prepend ::Sequencer::Unit::Import::Common::Model::Mixin::Skip::Action
  5. skip_action :skipped, :failed
  6. uses :response, :skipped_resource_id
  7. private
  8. def resources
  9. body = JSON.parse(response.body)
  10. return body if skipped_resource_id.nil?
  11. # Remove the skipped resource id from the received resources.
  12. body.reject { |item| item['id'] == skipped_resource_id }
  13. rescue => e
  14. logger.error "Won't be continued, because no response is available."
  15. handle_failure(e)
  16. end
  17. end