Class: Roqua::Healthy::A19::ResponseValidator
- Inherits:
-
Object
- Object
- Roqua::Healthy::A19::ResponseValidator
- Defined in:
- lib/roqua/healthy/a19/response_validator.rb
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
-
#patient_id ⇒ Object
readonly
Returns the value of attribute patient_id.
-
#response_code ⇒ Object
readonly
Returns the value of attribute response_code.
Instance Method Summary collapse
-
#initialize(response_code, parser, patient_id) ⇒ ResponseValidator
constructor
A new instance of ResponseValidator.
- #validate ⇒ Object
- #validate_200 ⇒ Object
- #validate_403 ⇒ Object
- #validate_404 ⇒ Object
- #validate_500 ⇒ Object
Constructor Details
#initialize(response_code, parser, patient_id) ⇒ ResponseValidator
Returns a new instance of ResponseValidator.
14 15 16 17 18 |
# File 'lib/roqua/healthy/a19/response_validator.rb', line 14 def initialize(response_code, parser, patient_id) @response_code = response_code @parser = parser @patient_id = patient_id end |
Instance Attribute Details
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
11 12 13 |
# File 'lib/roqua/healthy/a19/response_validator.rb', line 11 def parser @parser end |
#patient_id ⇒ Object (readonly)
Returns the value of attribute patient_id.
12 13 14 |
# File 'lib/roqua/healthy/a19/response_validator.rb', line 12 def patient_id @patient_id end |
#response_code ⇒ Object (readonly)
Returns the value of attribute response_code.
10 11 12 |
# File 'lib/roqua/healthy/a19/response_validator.rb', line 10 def response_code @response_code end |
Instance Method Details
#validate ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/roqua/healthy/a19/response_validator.rb', line 20 def validate case response_code when '200' validate_200 when '401', '403' validate_403 when '404' validate_404 when '500' validate_500 else raise ::Roqua::Healthy::UnknownFailure, "Unexpected HTTP response code #{response_code}." end end |
#validate_200 ⇒ Object
35 36 37 38 39 40 |
# File 'lib/roqua/healthy/a19/response_validator.rb', line 35 def validate_200 = parser.fetch("HL7Message") ensure_patient_found() ensure_correct_patient() true end |
#validate_403 ⇒ Object
42 43 44 |
# File 'lib/roqua/healthy/a19/response_validator.rb', line 42 def validate_403 raise ::Roqua::Healthy::AuthenticationFailure end |
#validate_404 ⇒ Object
46 47 48 |
# File 'lib/roqua/healthy/a19/response_validator.rb', line 46 def validate_404 raise ::Roqua::Healthy::PatientNotFound end |