Class: VAProfile::Models::ServiceHistory
- Includes:
- Concerns::Defaultable
- Defined in:
- lib/va_profile/models/service_history.rb
Constant Summary collapse
- MILITARY_SERVICE =
'Military Service'
- MILITARY_SERVICE_EPISODE =
'military_service_episodes'
- ACADEMY_ATTENDANCE =
'Academy Attendance'
- ACADEMY_ATTENDANCE_EPISODE =
'service_academy_episodes'
Constants inherited from Base
Class Method Summary collapse
-
.build_from(episode, episode_type) ⇒ VAProfile::Models::ServiceHistory
Converts a decoded JSON response from VAProfile to an instance of the ServiceHistory model.
- .build_from_academy_episode(episode) ⇒ Object
- .build_from_military_episode(episode) ⇒ Object
- .determine_eligibility(episodes) ⇒ Object
-
.in_json ⇒ String
Converts an instance of the ServicyHistory model to a JSON encoded string suitable for use in the body of a request to VAProfile.
Methods included from Concerns::Defaultable
Class Method Details
.build_from(episode, episode_type) ⇒ VAProfile::Models::ServiceHistory
Converts a decoded JSON response from VAProfile to an instance of the ServiceHistory model
51 52 53 54 55 56 57 |
# File 'lib/va_profile/models/service_history.rb', line 51 def self.build_from(episode, episode_type) return nil unless episode return build_from_military_episode(episode) if episode_type == MILITARY_SERVICE_EPISODE build_from_academy_episode(episode) if episode_type == ACADEMY_ATTENDANCE_EPISODE end |
.build_from_academy_episode(episode) ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/va_profile/models/service_history.rb', line 75 def self.build_from_academy_episode(episode) VAProfile::Models::ServiceHistory.new( service_type: ACADEMY_ATTENDANCE, branch_of_service: episode['branch_of_service_text'], begin_date: episode['academy_begin_date'], end_date: episode['academy_end_date'] ) end |
.build_from_military_episode(episode) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/va_profile/models/service_history.rb', line 59 def self.build_from_military_episode(episode) VAProfile::Models::ServiceHistory.new( service_type: MILITARY_SERVICE, branch_of_service: episode['branch_of_service_text'], branch_of_service_code: episode['branch_of_service_code'], begin_date: episode['period_of_service_begin_date'], deployments: episode['deployments'], character_of_discharge_code: episode['character_of_discharge_code'], end_date: episode['period_of_service_end_date'], period_of_service_type_code: episode['period_of_service_type_code'], period_of_service_type_text: episode['period_of_service_type_text'], termination_reason_code: episode['termination_reason_code'], termination_reason_text: episode['termination_reason_text'] ) end |
.determine_eligibility(episodes) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/va_profile/models/service_history.rb', line 84 def self.determine_eligibility(episodes) = [ 'We’re sorry. There’s a problem with your discharge status records. We can’t provide a Veteran status ' \ 'card for you right now.', 'To fix the problem with your records, call the Defense Manpower Data Center at 800-538-9552 (TTY: 711).' \ ' They’re open Monday through Friday, 8:00 a.m. to 8:00 p.m. ET.' ] = [ 'Our records show that you’re not eligible for a Veteran status card. To get a Veteran status card, you ' \ 'must have received an honorable discharge for at least one period of service.', 'If you think your discharge status is incorrect, call the Defense Manpower Data Center at 800-538-9552 ' \ '(TTY: 711). They’re open Monday through Friday, 8:00 a.m. to 8:00 p.m. ET.' ] return { confirmed: false, message: } if episodes.empty? codes = episodes.map(&:character_of_discharge_code).uniq.compact return { confirmed: true, message: [] } if codes.intersect?(%w[A B H J]) # Honorable discharge # Not honorable discharge return { confirmed: false, message: } if codes.intersect?(%w[D E F K]) || codes.empty? { confirmed: false, message: } # No service history OR unknown (Z) discharge end |
.in_json ⇒ String
Converts an instance of the ServicyHistory model to a JSON encoded string suitable for use in the body of a request to VAProfile
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/va_profile/models/service_history.rb', line 35 def self.in_json { bios: [ { bioPath: 'militaryPerson.militaryServiceHistory', parameters: { scope: 'all' } } ] }.to_json end |