tickets.rb 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 Tickets < Sequencer::Unit::Import::Freshdesk::SubSequence::Object
  7. EXPECTING = %i[action response resources].freeze
  8. private
  9. def request_params
  10. {
  11. page: page,
  12. updated_since: updated_since,
  13. order_by: 'updated_at',
  14. order_type: :asc,
  15. }
  16. end
  17. def page
  18. page_cycle + 1
  19. end
  20. def page_cycle
  21. iteration % 300
  22. end
  23. def updated_since
  24. @updated_since ||= '1970-01-01'
  25. return @updated_since if !new_page_cycle?
  26. @updated_since = result[:resources].last['updated_at']
  27. end
  28. def skipped_resource_id
  29. super
  30. return @skipped_resource_id if !new_page_cycle?
  31. @skipped_resource_id = result[:resources].last['id']
  32. end
  33. def new_page_cycle?
  34. return false if page_cycle != 0
  35. return false if iteration.zero?
  36. true
  37. end
  38. end
  39. end
  40. end
  41. end
  42. end