trabajo-afectivo/lib/sequencer/unit/import/freshdesk/tickets.rb

56 lines
1.2 KiB
Ruby

# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
class Sequencer
class Unit
module Import
module Freshdesk
class Tickets < Sequencer::Unit::Import::Freshdesk::SubSequence::Object
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
end
end
end
end
end