2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2021-05-25 12:30:12 +00:00
|
|
|
class Sequencer
|
|
|
|
class Unit
|
|
|
|
module Import
|
|
|
|
module Freshdesk
|
|
|
|
class Resources < Sequencer::Unit::Common::Provider::Named
|
2021-07-28 14:40:08 +00:00
|
|
|
include ::Sequencer::Unit::Import::Common::Model::Mixin::HandleFailure
|
2021-05-25 12:30:12 +00:00
|
|
|
|
2021-08-12 12:04:45 +00:00
|
|
|
uses :response, :skipped_resource_id
|
2021-05-25 12:30:12 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def resources
|
2021-08-12 12:04:45 +00:00
|
|
|
body = JSON.parse(response.body)
|
|
|
|
|
|
|
|
return body if skipped_resource_id.nil?
|
|
|
|
|
|
|
|
# Remove the skipped resource id from the received resources.
|
|
|
|
body.reject { |item| item['id'] == skipped_resource_id }
|
2021-07-28 14:40:08 +00:00
|
|
|
rescue => e
|
|
|
|
logger.error "Won't be continued, because no response is available."
|
|
|
|
handle_failure(e)
|
2021-05-25 12:30:12 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|