diff --git a/app/controllers/call_events_controller.rb b/app/controllers/call_events_controller.rb new file mode 100644 index 0000000..3da60fe --- /dev/null +++ b/app/controllers/call_events_controller.rb @@ -0,0 +1,18 @@ +# app/controllers/call_events_controller.rb +class CallEventsController < ApplicationController + # We disable CSRF for this webhook call + skip_before_action :verify_authenticity_token + + def create + if params[:uuid] + Call.where(uuid: params[:uuid]) + .first_or_create + .update( + status: params[:status], + conversation_uuid: params[:conversation_uuid] + ) + end + + head :ok + end +end diff --git a/app/controllers/inbound_calls_controller.rb b/app/controllers/inbound_calls_controller.rb new file mode 100644 index 0000000..57bf990 --- /dev/null +++ b/app/controllers/inbound_calls_controller.rb @@ -0,0 +1,26 @@ +# app/controllers/inbound_calls_controller.rb +class InboundCallsController < ApplicationController + # We disable CSRF for this webhook call + skip_before_action :verify_authenticity_token + + def create + Call.where(conversation_uuid: params[:conversation_uuid]) + .first_or_create + .update( + to: params[:to], + from: params[:from], + uuid: params[:uuid], + conversation_uuid: params[:conversation_uuid], + is_inbound: true + + ) + + render json: [ + { + action: 'talk', + voiceName: 'Jennifer', + text: 'Hello, thank you for calling. This is Jennifer from Vonage. Ciao.' + } + ] + end +end diff --git a/app/helpers/call_events_helper.rb b/app/helpers/call_events_helper.rb new file mode 100644 index 0000000..abb67a4 --- /dev/null +++ b/app/helpers/call_events_helper.rb @@ -0,0 +1,2 @@ +module CallEventsHelper +end diff --git a/app/helpers/inbound_calls_helper.rb b/app/helpers/inbound_calls_helper.rb new file mode 100644 index 0000000..eec487b --- /dev/null +++ b/app/helpers/inbound_calls_helper.rb @@ -0,0 +1,2 @@ +module InboundCallsHelper +end diff --git a/app/views/inbound_sms/create.html.erb b/app/views/inbound_sms/create.html.erb deleted file mode 100644 index d3447c9..0000000 --- a/app/views/inbound_sms/create.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -
Find me in app/views/inbound_sms/create.html.erb
diff --git a/app/views/sms_message_status/create.html.erb b/app/views/sms_message_status/create.html.erb deleted file mode 100644 index f164d85..0000000 --- a/app/views/sms_message_status/create.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/sms_message_status/create.html.erb
diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc index a87a2a8..c254bbe 100644 --- a/config/credentials.yml.enc +++ b/config/credentials.yml.enc @@ -1 +1 @@ -2lcax3RF4GiKVDTOz34V7q8g1LVIHIVnB/iJJ22nCdQ5ufXCkObPpmoeRjwuS2gjf/AXSCGI2jJBIsRevsrhinIr+Cxv3IIuDAzpJ9ccFefHCwh7/xivb5vkR9M9B7uBTJDZEUua/Klsta3gdWuMhDmFWS2vVnaYQagsc22AZ7SuCBMBL613PwU3ayHl7kru1Ul0vKKVFmnkMXWWtnDkQjmjNjU8r76qqbKnj8qXlqQYgTlXASAlEtO+NofgRvkCBJ4epSdxZ1QZpYB5xkdTovi6/SOYJJHRXPUJLkJNWCqwMBxQnKYZpdZ+T/Zi/hyiwsxawI+vMOO3lRYR+qCs3NcF49GNOyiy7nL2OBDO1e1R6jNal0t6c5rimcEpRoV1DB7rbbPjWIx30ZGXyRy5ksfcBthuQx9x6PzayWU1lMdN/msh2eKskBBNxOg3WchHfwrxs8Pmb7LWEeeb+xu4eC9vU8Q7Of4HQ6DwS0SmaajQnuWCSGc6EOy1--om7fEulVdYgAjk2F--HvQtviBJk3FU1Ozc4qbONQ== \ No newline at end of file +ZpVxnnWvtlkJqhBwrWVi8PMvzvT7/BY+yQh9VJJo6ysrgYmcWuyI3UPKrbCy6sfxCBtdgO7IKFrkTxRpyHedR0i4MDwGgUFJTK8ez6iXtoM4dBnf23usoFvAEuogM1+AAeyqBMAJUdtghY08u8/r5UtNmxgtapJp+Oc3DIiPnYtgvgJ2xFwInuk/VZqFnrHyQOKfqzJ7DGCsPJOuWJqauf6a9BJx67k6hrxzDRze2ybySL1rn/gkfpltkCIPYjebMriDZBi8Wa8Em1/LwvzO9JwadFaPwagrK3d3TCMKsyWsiup8gGOLxABpsTmzLvw2zzeRBEo5SxKiVCabRgBdHrGfTNiFOKjWNzBmLZXT9eJ03Wnakbe3z40h8Y/jDyIJ3PEGOzdQOlG7YtH6JNqyWvfa8AUOgjW8P90uRJr7RwkAC+UgFCgWnuih0JEyRRCybkHOHwu1/dmE2z65GADRbzUyAQfOygR8KCEAk1UW0s3V3TeLOA72amiY--oHceahh7YS8vvw8m--Vfr3zSnGh6xNf+gYox+lzw== \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index d08d6a6..bdafae7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,4 +12,10 @@ # For OutboundCall controller, new & create & show resources :outbound_calls, only: [:new, :create, :show] + + # For CallEvents controller, create + resources :call_events, only: [:create] + + # For InboundCalls controller, create + resources :inbound_calls, only: [:create] end diff --git a/test/controllers/call_events_controller_test.rb b/test/controllers/call_events_controller_test.rb new file mode 100644 index 0000000..c8650d1 --- /dev/null +++ b/test/controllers/call_events_controller_test.rb @@ -0,0 +1,8 @@ +require "test_helper" + +class CallEventsControllerTest < ActionDispatch::IntegrationTest + test "should get create" do + get call_events_create_url + assert_response :success + end +end diff --git a/test/controllers/inbound_calls_controller_test.rb b/test/controllers/inbound_calls_controller_test.rb new file mode 100644 index 0000000..cd3bf24 --- /dev/null +++ b/test/controllers/inbound_calls_controller_test.rb @@ -0,0 +1,8 @@ +require "test_helper" + +class InboundCallsControllerTest < ActionDispatch::IntegrationTest + test "should get create" do + get inbound_calls_create_url + assert_response :success + end +end