Class: VAProfile::Profile::V3::HealthBenefitBioResponse
- Inherits:
-
Response
- Object
- Common::Base
- Response
- VAProfile::Profile::V3::HealthBenefitBioResponse
- Defined in:
- lib/va_profile/profile/v3/health_benefit_bio_response.rb
Constant Summary
Constants included from Common::Client::Concerns::ServiceStatus
Common::Client::Concerns::ServiceStatus::RESPONSE_STATUS
Instance Attribute Summary
Attributes inherited from Common::Base
Instance Method Summary collapse
- #debug_data ⇒ Object
-
#initialize(response) ⇒ HealthBenefitBioResponse
constructor
A new instance of HealthBenefitBioResponse.
- #message ⇒ Object private
- #server_error? ⇒ Boolean
- #valid_contact_types ⇒ Object private
Methods inherited from Response
#cache?, #metadata, #ok?, #response_status
Methods inherited from Common::Base
#changed, #changed?, #changes, default_sort, filterable_attributes, max_per_page, per_page, sortable_attributes
Constructor Details
#initialize(response) ⇒ HealthBenefitBioResponse
Returns a new instance of HealthBenefitBioResponse.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/va_profile/profile/v3/health_benefit_bio_response.rb', line 16 def initialize(response) body = response&.body contacts = body.dig('profile', 'health_benefit', 'associated_persons') &.select { |p| valid_contact_types.include?(p['contact_type']) } &.sort_by { |p| valid_contact_types.index(p['contact_type']) } = body['messages'] code = &.first&.dig('code') va_profile_tx_audit_id = response.response_headers['vaprofiletxauditid'] super(response.status, { code:, contacts:, messages:, va_profile_tx_audit_id: }) end |
Instance Method Details
#debug_data ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/va_profile/profile/v3/health_benefit_bio_response.rb', line 27 def debug_data { code:, status:, message:, va_profile_tx_audit_id: } end |
#message ⇒ Object (private)
46 47 48 49 50 51 |
# File 'lib/va_profile/profile/v3/health_benefit_bio_response.rb', line 46 def m = &.first return '' unless m "#{m.code} #{m.key} #{m.text}" end |
#server_error? ⇒ Boolean
36 37 38 |
# File 'lib/va_profile/profile/v3/health_benefit_bio_response.rb', line 36 def server_error? status >= 500 end |
#valid_contact_types ⇒ Object (private)
42 43 44 |
# File 'lib/va_profile/profile/v3/health_benefit_bio_response.rb', line 42 def valid_contact_types VAProfile::Models::AssociatedPerson::PERSONAL_HEALTH_CARE_CONTACT_TYPES end |