Class: Voltron::NotificationController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/voltron/notification_controller.rb

Instance Method Summary collapse

Instance Method Details

#updateObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/voltron/notification_controller.rb', line 5

def update
  if Voltron::Notification::SmsNotification.exists?(sid: params[:MessageSid])
    sms = Voltron::Notification::SmsNotification.find_by(sid: params[:MessageSid])
    update_params = { status: params[:MessageStatus], error_code: params[:ErrorCode] }.compact
    if sms.update(update_params)
      head :ok
    else
      Voltron.log "(SID: #{params[:MessageSid]}) " + sms.errors.full_messages.join(''), 'Notification Update', Voltron::Notify::LOG_COLOR
      head :unprocessable_entity
    end
  else
    Voltron.log "SMS Notification with id #{params[:MessageSid]} not found.", 'Notification Update', Voltron::Notify::LOG_COLOR
    head :not_found
  end
end