resources.rb 937 B

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