Class: Telephony::ConversationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Telephony::ConversationsController
- Defined in:
- app/controllers/telephony/conversations_controller.rb
Instance Method Summary collapse
- #counts ⇒ Object
- #create ⇒ Object
- #hold ⇒ Object
- #index ⇒ Object
- #resume ⇒ Object
- #search ⇒ Object
- #update ⇒ Object
Instance Method Details
#counts ⇒ Object
11 12 13 14 |
# File 'app/controllers/telephony/conversations_controller.rb', line 11 def counts counts = ConversationData.counts params render json: counts end |
#create ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/telephony/conversations_controller.rb', line 25 def create conversation = Conversation.begin! params render json: { id: conversation.id, number: conversation.customer.number } rescue Telephony::Error::Connection => e msg = 'Call failed. Please try again in a few seconds.' Rails.logger.error "#{msg} - #{e.} - #{params}" errors = [msg, e.] render json: { errors: errors }, status: :server_error end |
#hold ⇒ Object
47 48 49 50 51 52 |
# File 'app/controllers/telephony/conversations_controller.rb', line 47 def hold lock_conversation(params['id'], 'Hold failed. Please try again in a few seconds.') do |conversation| conversation.hold! render json: {} end end |
#index ⇒ Object
6 7 8 9 |
# File 'app/controllers/telephony/conversations_controller.rb', line 6 def index conversations = ConversationData.filter params render json: conversations end |
#resume ⇒ Object
54 55 56 57 58 59 |
# File 'app/controllers/telephony/conversations_controller.rb', line 54 def resume lock_conversation(params['id'], 'Resume failed. Please try again in a few seconds.') do |conversation| conversation.resume! render json: {} end end |
#search ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/controllers/telephony/conversations_controller.rb', line 16 def search conversations = ConversationData.search params conversations_presenter = ConversationsPresenter.new conversations render json: { total_count: conversations.total_count, conversations: conversations_presenter } end |
#update ⇒ Object
40 41 42 43 44 45 |
# File 'app/controllers/telephony/conversations_controller.rb', line 40 def update Conversation.find_with_lock params[:id] do |conversation| conversation.update_attributes loan_id: params[:loan_id] render json: conversation end end |