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 Tickets < Sequencer::Unit::Import::Freshdesk::SubSequence::Object
|
2021-08-12 12:04:45 +00:00
|
|
|
|
|
|
|
EXPECTING = %i[action response resources].freeze
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def request_params
|
|
|
|
{
|
|
|
|
page: page,
|
|
|
|
updated_since: updated_since,
|
|
|
|
order_by: 'updated_at',
|
|
|
|
order_type: :asc,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def page
|
|
|
|
page_cycle + 1
|
|
|
|
end
|
|
|
|
|
|
|
|
def page_cycle
|
|
|
|
iteration % 300
|
|
|
|
end
|
|
|
|
|
|
|
|
def updated_since
|
|
|
|
@updated_since ||= '1970-01-01'
|
|
|
|
|
|
|
|
return @updated_since if !new_page_cycle?
|
|
|
|
|
|
|
|
@updated_since = result[:resources].last['updated_at']
|
|
|
|
end
|
|
|
|
|
|
|
|
def skipped_resource_id
|
|
|
|
super
|
|
|
|
|
|
|
|
return @skipped_resource_id if !new_page_cycle?
|
|
|
|
|
|
|
|
@skipped_resource_id = result[:resources].last['id']
|
|
|
|
end
|
|
|
|
|
|
|
|
def new_page_cycle?
|
|
|
|
return false if page_cycle != 0
|
|
|
|
return false if iteration.zero?
|
|
|
|
|
|
|
|
true
|
|
|
|
end
|
2021-05-25 12:30:12 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|