whatsapp.rb 666 B

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Channel::Driver::Whatsapp
  3. def deliver(options, attr, _notification = false)
  4. return true if Setting.get('import_mode')
  5. message = "Whatsapp::Outgoing::Message::#{attr[:message_type].capitalize}".constantize.new(
  6. access_token: options[:access_token],
  7. phone_number_id: options[:phone_number_id],
  8. recipient_number: attr[:recipient_number]
  9. )
  10. if attr[:message_type] == 'text'
  11. return message.deliver(
  12. body: attr[:body]
  13. )
  14. end
  15. message.deliver(
  16. caption: attr[:body],
  17. store: attr[:attachment]
  18. )
  19. end
  20. end