Class: Medivo::LabsController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Medivo::LabsController
- Defined in:
- app/controllers/medivo/labs_controller.rb
Instance Method Summary collapse
- #appointment_error_handler(e) ⇒ Object
- #find_appointment ⇒ Object
- #index ⇒ Object
- #make_appointment ⇒ Object
Instance Method Details
#appointment_error_handler(e) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/medivo/labs_controller.rb', line 24 def appointment_error_handler(e) case e when RestClient::RequestTimeout, RestClient::InternalServerError render :status=> e.http_code, json: {message: "Could be lab_code is wrong, or labcorp server is down"} when RestClient::Exception render :status=> e.http_code, json: {message: e.response} else render :status=> 500, json: {message: e.} end end |
#find_appointment ⇒ Object
9 10 11 12 13 14 15 |
# File 'app/controllers/medivo/labs_controller.rb', line 9 def find_appointment date = Date.strptime(params[:date], "%m/%d/%Y") data = Medivo::Appointment.find(params[:lab_code], date, params[:am_pm]) render :json=> {times: data} rescue => e appointment_error_handler(e) end |
#index ⇒ Object
4 5 6 7 |
# File 'app/controllers/medivo/labs_controller.rb', line 4 def index lab_data = Medivo::Lab.data_for_zip(params[:zip_code]) render :json=> lab_data end |
#make_appointment ⇒ Object
17 18 19 20 21 22 |
# File 'app/controllers/medivo/labs_controller.rb', line 17 def make_appointment data = Medivo::Appointment.make(params[:lab_code], params[:time], params[:user]) render :json=> data rescue Exception => e appointment_error_handler(e) end |