update.rb 790 B

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Service::Channel::Whatsapp
  3. class Update < Base
  4. attr_reader :channel_id
  5. def initialize(params:, channel_id:)
  6. super()
  7. @channel_id = channel_id
  8. @params = params
  9. end
  10. def options
  11. channel.options.merge(
  12. params.slice(
  13. :business_id, :access_token, :app_secret, :phone_number_id, :welcome, :reminder_active, :reminder_message
  14. )
  15. )
  16. end
  17. def execute
  18. ActiveRecord::Base.transaction do
  19. channel
  20. .tap { |channel| channel.update!(**attributes_hash) }
  21. .tap { |channel| add_metadata(channel:) }
  22. end
  23. end
  24. private
  25. def channel
  26. area_channel_list.find(channel_id)
  27. end
  28. end
  29. end