Class: Telephony::TransfersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/telephony/transfers_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/telephony/transfers_controller.rb', line 5

def create
  Conversation.find_with_lock params[:conversation_id] do |conversation|
    if conversation.transfer! params[:transfer_id], params[:transfer_type] == 'one_step'
      render json: {}
    else
      errors = ['Transfer failed. Please try again in a few seconds.'] +
        conversation.errors.full_messages

      render json: { errors: errors }, status: :unprocessable_entity
    end
  end
end