whatsapp_controller.rb 845 B

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class ChannelsAdmin::WhatsappController < ChannelsAdmin::BaseController
  3. def area
  4. 'WhatsApp::Business'.freeze
  5. end
  6. def create
  7. channel = Service::Channel::Whatsapp::Create
  8. .new(params: params.permit!)
  9. .execute
  10. render json: channel
  11. rescue => e
  12. raise Exceptions::UnprocessableEntity, e.message
  13. end
  14. def update
  15. channel = Service::Channel::Whatsapp::Update
  16. .new(params: params.permit!, channel_id: params[:id])
  17. .execute
  18. render json: channel
  19. rescue => e
  20. raise Exceptions::UnprocessableEntity, e.message
  21. end
  22. def preload
  23. data = Service::Channel::Whatsapp::Preload
  24. .new(business_id: params[:business_id], access_token: params[:access_token])
  25. .execute
  26. render json: { data: }
  27. end
  28. end