organization.rb 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. # https://developer.zendesk.com/rest_api/docs/core/organizations
  2. module Import
  3. module Zendesk
  4. class Organization
  5. include Import::Zendesk::Helper
  6. attr_reader :zendesk_id, :id
  7. def initialize(organization)
  8. local_organization = ::Organization.create_if_not_exists(local_organization_fields(organization))
  9. @zendesk_id = organization.id
  10. @id = local_organization.id
  11. end
  12. private
  13. def local_organization_fields(organization)
  14. {
  15. name: organization.name,
  16. note: organization.note,
  17. shared: organization.shared_tickets,
  18. # shared: organization.shared_comments, # TODO, not yet implemented
  19. # }.merge(organization.organization_fields) # TODO
  20. updated_by_id: 1,
  21. created_by_id: 1
  22. }.merge(custom_fields(organization))
  23. end
  24. def custom_fields(organization)
  25. get_fields(organization.organization_fields)
  26. end
  27. end
  28. end
  29. end