Class: PeopleDoc::ResponseHandlers::V1::HandleBadRequest

Inherits:
BaseHandler
  • Object
show all
Defined in:
lib/people_doc/response_handlers.rb

Defined Under Namespace

Classes: ErrorsResponse, MessageResponse

Instance Method Summary collapse

Methods inherited from BaseHandler

#initialize

Constructor Details

This class inherits a constructor from PeopleDoc::ResponseHandlers::BaseHandler

Instance Method Details

#callObject



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/people_doc/response_handlers.rb', line 59

def call
  return unless @httparty.code == 400

  message = if @httparty.parsed_response['errors']
              ErrorsResponse.new(@httparty).call
            elsif @httparty.parsed_response['message']
              MessageResponse.new(@httparty).call
            else
              @httparty.body
            end

  fail BadRequest.new(message, @httparty.parsed_response)
end