Class: EVSS::GiBillStatus::GiBillStatusResponse
- Inherits:
-
Response
- Object
- Common::Base
- Response
- EVSS::GiBillStatus::GiBillStatusResponse
- Includes:
- SentryLogging
- Defined in:
- lib/evss/gi_bill_status/gi_bill_status_response.rb
Overview
Model for the GIBS status response
Constant Summary collapse
- EVSS_ERROR_KEYS =
[ 'education.chapter33claimant.partner.service.down', 'education.chapter33enrollment.partner.service.down', 'education.partner.service.invalid', 'education.service.error' ].freeze
- KNOWN_ERRORS =
{ evss_error: 'evss_error', vet_not_found: 'vet_not_found', timeout: 'timeout', invalid_auth: 'invalid_auth' }.freeze
Constants included from Common::Client::Concerns::ServiceStatus
Common::Client::Concerns::ServiceStatus::RESPONSE_STATUS
Instance Attribute Summary collapse
-
#active_duty ⇒ Boolean
Is the user on active duty.
-
#date_of_birth ⇒ String
User’s date of birth.
-
#delimiting_date ⇒ String
The date after which benefits cannot be paid.
-
#eligibility_date ⇒ String
The date at which benefits are eligible to be paid.
-
#enrollments ⇒ Array[Enrollment]
An array of the user’s enrollments.
-
#first_name ⇒ String
User’s first name.
-
#last_name ⇒ String
User’s last name.
- #name_suffix ⇒ Object
-
#original_entitlement ⇒ Entitlement
The time span of the user’s original entitlement.
-
#percentage_benefit ⇒ Integer
The amount of the benefit the user is eligible for.
-
#regional_processing_office ⇒ String
Closest processing office to the user.
-
#remaining_entitlement ⇒ Entitlement
The amount of entitlement time the user has remaining.
-
#used_entitlement ⇒ Entitlement
The amount of entitlement time the user has already used.
-
#va_file_number ⇒ String
User’s VA file number.
-
#veteran_is_eligible ⇒ Boolean
Is the user eligbile for the benefit.
Attributes inherited from Common::Base
Instance Method Summary collapse
-
#error_type ⇒ String
The response error type.
-
#initialize(status, response = nil, timeout = false, content_type = 'application/json') ⇒ GiBillStatusResponse
constructor
Create an instance of GiBillStatusResponse.
-
#success? ⇒ Boolean
the expected educational information.
-
#timestamp ⇒ Time
The response timestamp in UTC.
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger
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(status, response = nil, timeout = false, content_type = 'application/json') ⇒ GiBillStatusResponse
Create an instance of GiBillStatusResponse
84 85 86 87 88 89 90 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 84 def initialize(status, response = nil, timeout = false, content_type = 'application/json') @timeout = timeout @response = response @content_type = content_type attributes = contains_education_info? ? response.body['chapter33_education_info'] : {} super(status, attributes) end |
Instance Attribute Details
#active_duty ⇒ Boolean
Returns Is the user on active duty.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 43 class GiBillStatusResponse < EVSS::Response include SentryLogging attribute :first_name, String attribute :last_name, String attribute :name_suffix, String attribute :date_of_birth, String attribute :va_file_number, String attribute :regional_processing_office, String attribute :eligibility_date, String attribute :delimiting_date, String attribute :percentage_benefit, Integer attribute :original_entitlement, Entitlement attribute :used_entitlement, Entitlement attribute :remaining_entitlement, Entitlement attribute :veteran_is_eligible, Boolean attribute :active_duty, Boolean attribute :enrollments, Array[Enrollment] EVSS_ERROR_KEYS = [ 'education.chapter33claimant.partner.service.down', 'education.chapter33enrollment.partner.service.down', 'education.partner.service.invalid', 'education.service.error' ].freeze KNOWN_ERRORS = { evss_error: 'evss_error', vet_not_found: 'vet_not_found', timeout: 'timeout', invalid_auth: 'invalid_auth' }.freeze ## # Create an instance of GiBillStatusResponse # # @param status [Integer] The HTTP status code from the service # @param response [String] The raw endpoint response or error body # @param timeout [Boolean] If the response timed out # @param content_type [String] The content type # def initialize(status, response = nil, timeout = false, content_type = 'application/json') @timeout = timeout @response = response @content_type = content_type attributes = contains_education_info? ? response.body['chapter33_education_info'] : {} super(status, attributes) end ## # @return [Time] The response timestamp in UTC # def Time.parse(@response.response_headers['date']).utc end ## # @return [Boolean] Checks if the response is correctly formatted and contains # the expected educational information def success? contains_education_info? end ## # @return [String] The response error type def error_type KNOWN_ERRORS.each_value do |error_val| return error_val if send("#{error_val}?") end 'unknown' end private def timeout? @timeout end def evss_error? && EVSS_ERROR_KEYS.include?(evss_error_key) end def vet_not_found? return false if @response.nil? || text_response? @response&.body == {} end def invalid_auth? # this one is a text/html response return false if @response.nil? @response&.body&.to_s&.include?('AUTH_INVALID_IDENTITY') || @response&.status == 403 end def contains_education_info? return false if @response.nil? || text_response? !vet_not_found? && @response.body.key?('chapter33_education_info') == true && @response.body['chapter33_education_info'] != {} && !@response.body['chapter33_education_info'].nil? end def return false if @response&.body.nil? || text_response? @response.body.key?('messages') && @response.body['messages'].is_a?(Array) && @response.body['messages'].length.positive? end def evss_error_key return nil if @response&.body.nil? @response.body.dig('messages', 0, 'key') end def text_response? @content_type.include?('text/html') || !@response.body.respond_to?(:key?) end end |
#date_of_birth ⇒ String
Returns User’s date of birth.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 43 class GiBillStatusResponse < EVSS::Response include SentryLogging attribute :first_name, String attribute :last_name, String attribute :name_suffix, String attribute :date_of_birth, String attribute :va_file_number, String attribute :regional_processing_office, String attribute :eligibility_date, String attribute :delimiting_date, String attribute :percentage_benefit, Integer attribute :original_entitlement, Entitlement attribute :used_entitlement, Entitlement attribute :remaining_entitlement, Entitlement attribute :veteran_is_eligible, Boolean attribute :active_duty, Boolean attribute :enrollments, Array[Enrollment] EVSS_ERROR_KEYS = [ 'education.chapter33claimant.partner.service.down', 'education.chapter33enrollment.partner.service.down', 'education.partner.service.invalid', 'education.service.error' ].freeze KNOWN_ERRORS = { evss_error: 'evss_error', vet_not_found: 'vet_not_found', timeout: 'timeout', invalid_auth: 'invalid_auth' }.freeze ## # Create an instance of GiBillStatusResponse # # @param status [Integer] The HTTP status code from the service # @param response [String] The raw endpoint response or error body # @param timeout [Boolean] If the response timed out # @param content_type [String] The content type # def initialize(status, response = nil, timeout = false, content_type = 'application/json') @timeout = timeout @response = response @content_type = content_type attributes = contains_education_info? ? response.body['chapter33_education_info'] : {} super(status, attributes) end ## # @return [Time] The response timestamp in UTC # def Time.parse(@response.response_headers['date']).utc end ## # @return [Boolean] Checks if the response is correctly formatted and contains # the expected educational information def success? contains_education_info? end ## # @return [String] The response error type def error_type KNOWN_ERRORS.each_value do |error_val| return error_val if send("#{error_val}?") end 'unknown' end private def timeout? @timeout end def evss_error? && EVSS_ERROR_KEYS.include?(evss_error_key) end def vet_not_found? return false if @response.nil? || text_response? @response&.body == {} end def invalid_auth? # this one is a text/html response return false if @response.nil? @response&.body&.to_s&.include?('AUTH_INVALID_IDENTITY') || @response&.status == 403 end def contains_education_info? return false if @response.nil? || text_response? !vet_not_found? && @response.body.key?('chapter33_education_info') == true && @response.body['chapter33_education_info'] != {} && !@response.body['chapter33_education_info'].nil? end def return false if @response&.body.nil? || text_response? @response.body.key?('messages') && @response.body['messages'].is_a?(Array) && @response.body['messages'].length.positive? end def evss_error_key return nil if @response&.body.nil? @response.body.dig('messages', 0, 'key') end def text_response? @content_type.include?('text/html') || !@response.body.respond_to?(:key?) end end |
#delimiting_date ⇒ String
Returns The date after which benefits cannot be paid.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 43 class GiBillStatusResponse < EVSS::Response include SentryLogging attribute :first_name, String attribute :last_name, String attribute :name_suffix, String attribute :date_of_birth, String attribute :va_file_number, String attribute :regional_processing_office, String attribute :eligibility_date, String attribute :delimiting_date, String attribute :percentage_benefit, Integer attribute :original_entitlement, Entitlement attribute :used_entitlement, Entitlement attribute :remaining_entitlement, Entitlement attribute :veteran_is_eligible, Boolean attribute :active_duty, Boolean attribute :enrollments, Array[Enrollment] EVSS_ERROR_KEYS = [ 'education.chapter33claimant.partner.service.down', 'education.chapter33enrollment.partner.service.down', 'education.partner.service.invalid', 'education.service.error' ].freeze KNOWN_ERRORS = { evss_error: 'evss_error', vet_not_found: 'vet_not_found', timeout: 'timeout', invalid_auth: 'invalid_auth' }.freeze ## # Create an instance of GiBillStatusResponse # # @param status [Integer] The HTTP status code from the service # @param response [String] The raw endpoint response or error body # @param timeout [Boolean] If the response timed out # @param content_type [String] The content type # def initialize(status, response = nil, timeout = false, content_type = 'application/json') @timeout = timeout @response = response @content_type = content_type attributes = contains_education_info? ? response.body['chapter33_education_info'] : {} super(status, attributes) end ## # @return [Time] The response timestamp in UTC # def Time.parse(@response.response_headers['date']).utc end ## # @return [Boolean] Checks if the response is correctly formatted and contains # the expected educational information def success? contains_education_info? end ## # @return [String] The response error type def error_type KNOWN_ERRORS.each_value do |error_val| return error_val if send("#{error_val}?") end 'unknown' end private def timeout? @timeout end def evss_error? && EVSS_ERROR_KEYS.include?(evss_error_key) end def vet_not_found? return false if @response.nil? || text_response? @response&.body == {} end def invalid_auth? # this one is a text/html response return false if @response.nil? @response&.body&.to_s&.include?('AUTH_INVALID_IDENTITY') || @response&.status == 403 end def contains_education_info? return false if @response.nil? || text_response? !vet_not_found? && @response.body.key?('chapter33_education_info') == true && @response.body['chapter33_education_info'] != {} && !@response.body['chapter33_education_info'].nil? end def return false if @response&.body.nil? || text_response? @response.body.key?('messages') && @response.body['messages'].is_a?(Array) && @response.body['messages'].length.positive? end def evss_error_key return nil if @response&.body.nil? @response.body.dig('messages', 0, 'key') end def text_response? @content_type.include?('text/html') || !@response.body.respond_to?(:key?) end end |
#eligibility_date ⇒ String
Returns The date at which benefits are eligible to be paid.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 43 class GiBillStatusResponse < EVSS::Response include SentryLogging attribute :first_name, String attribute :last_name, String attribute :name_suffix, String attribute :date_of_birth, String attribute :va_file_number, String attribute :regional_processing_office, String attribute :eligibility_date, String attribute :delimiting_date, String attribute :percentage_benefit, Integer attribute :original_entitlement, Entitlement attribute :used_entitlement, Entitlement attribute :remaining_entitlement, Entitlement attribute :veteran_is_eligible, Boolean attribute :active_duty, Boolean attribute :enrollments, Array[Enrollment] EVSS_ERROR_KEYS = [ 'education.chapter33claimant.partner.service.down', 'education.chapter33enrollment.partner.service.down', 'education.partner.service.invalid', 'education.service.error' ].freeze KNOWN_ERRORS = { evss_error: 'evss_error', vet_not_found: 'vet_not_found', timeout: 'timeout', invalid_auth: 'invalid_auth' }.freeze ## # Create an instance of GiBillStatusResponse # # @param status [Integer] The HTTP status code from the service # @param response [String] The raw endpoint response or error body # @param timeout [Boolean] If the response timed out # @param content_type [String] The content type # def initialize(status, response = nil, timeout = false, content_type = 'application/json') @timeout = timeout @response = response @content_type = content_type attributes = contains_education_info? ? response.body['chapter33_education_info'] : {} super(status, attributes) end ## # @return [Time] The response timestamp in UTC # def Time.parse(@response.response_headers['date']).utc end ## # @return [Boolean] Checks if the response is correctly formatted and contains # the expected educational information def success? contains_education_info? end ## # @return [String] The response error type def error_type KNOWN_ERRORS.each_value do |error_val| return error_val if send("#{error_val}?") end 'unknown' end private def timeout? @timeout end def evss_error? && EVSS_ERROR_KEYS.include?(evss_error_key) end def vet_not_found? return false if @response.nil? || text_response? @response&.body == {} end def invalid_auth? # this one is a text/html response return false if @response.nil? @response&.body&.to_s&.include?('AUTH_INVALID_IDENTITY') || @response&.status == 403 end def contains_education_info? return false if @response.nil? || text_response? !vet_not_found? && @response.body.key?('chapter33_education_info') == true && @response.body['chapter33_education_info'] != {} && !@response.body['chapter33_education_info'].nil? end def return false if @response&.body.nil? || text_response? @response.body.key?('messages') && @response.body['messages'].is_a?(Array) && @response.body['messages'].length.positive? end def evss_error_key return nil if @response&.body.nil? @response.body.dig('messages', 0, 'key') end def text_response? @content_type.include?('text/html') || !@response.body.respond_to?(:key?) end end |
#enrollments ⇒ Array[Enrollment]
Returns An array of the user’s enrollments.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 43 class GiBillStatusResponse < EVSS::Response include SentryLogging attribute :first_name, String attribute :last_name, String attribute :name_suffix, String attribute :date_of_birth, String attribute :va_file_number, String attribute :regional_processing_office, String attribute :eligibility_date, String attribute :delimiting_date, String attribute :percentage_benefit, Integer attribute :original_entitlement, Entitlement attribute :used_entitlement, Entitlement attribute :remaining_entitlement, Entitlement attribute :veteran_is_eligible, Boolean attribute :active_duty, Boolean attribute :enrollments, Array[Enrollment] EVSS_ERROR_KEYS = [ 'education.chapter33claimant.partner.service.down', 'education.chapter33enrollment.partner.service.down', 'education.partner.service.invalid', 'education.service.error' ].freeze KNOWN_ERRORS = { evss_error: 'evss_error', vet_not_found: 'vet_not_found', timeout: 'timeout', invalid_auth: 'invalid_auth' }.freeze ## # Create an instance of GiBillStatusResponse # # @param status [Integer] The HTTP status code from the service # @param response [String] The raw endpoint response or error body # @param timeout [Boolean] If the response timed out # @param content_type [String] The content type # def initialize(status, response = nil, timeout = false, content_type = 'application/json') @timeout = timeout @response = response @content_type = content_type attributes = contains_education_info? ? response.body['chapter33_education_info'] : {} super(status, attributes) end ## # @return [Time] The response timestamp in UTC # def Time.parse(@response.response_headers['date']).utc end ## # @return [Boolean] Checks if the response is correctly formatted and contains # the expected educational information def success? contains_education_info? end ## # @return [String] The response error type def error_type KNOWN_ERRORS.each_value do |error_val| return error_val if send("#{error_val}?") end 'unknown' end private def timeout? @timeout end def evss_error? && EVSS_ERROR_KEYS.include?(evss_error_key) end def vet_not_found? return false if @response.nil? || text_response? @response&.body == {} end def invalid_auth? # this one is a text/html response return false if @response.nil? @response&.body&.to_s&.include?('AUTH_INVALID_IDENTITY') || @response&.status == 403 end def contains_education_info? return false if @response.nil? || text_response? !vet_not_found? && @response.body.key?('chapter33_education_info') == true && @response.body['chapter33_education_info'] != {} && !@response.body['chapter33_education_info'].nil? end def return false if @response&.body.nil? || text_response? @response.body.key?('messages') && @response.body['messages'].is_a?(Array) && @response.body['messages'].length.positive? end def evss_error_key return nil if @response&.body.nil? @response.body.dig('messages', 0, 'key') end def text_response? @content_type.include?('text/html') || !@response.body.respond_to?(:key?) end end |
#first_name ⇒ String
Returns User’s first name.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 43 class GiBillStatusResponse < EVSS::Response include SentryLogging attribute :first_name, String attribute :last_name, String attribute :name_suffix, String attribute :date_of_birth, String attribute :va_file_number, String attribute :regional_processing_office, String attribute :eligibility_date, String attribute :delimiting_date, String attribute :percentage_benefit, Integer attribute :original_entitlement, Entitlement attribute :used_entitlement, Entitlement attribute :remaining_entitlement, Entitlement attribute :veteran_is_eligible, Boolean attribute :active_duty, Boolean attribute :enrollments, Array[Enrollment] EVSS_ERROR_KEYS = [ 'education.chapter33claimant.partner.service.down', 'education.chapter33enrollment.partner.service.down', 'education.partner.service.invalid', 'education.service.error' ].freeze KNOWN_ERRORS = { evss_error: 'evss_error', vet_not_found: 'vet_not_found', timeout: 'timeout', invalid_auth: 'invalid_auth' }.freeze ## # Create an instance of GiBillStatusResponse # # @param status [Integer] The HTTP status code from the service # @param response [String] The raw endpoint response or error body # @param timeout [Boolean] If the response timed out # @param content_type [String] The content type # def initialize(status, response = nil, timeout = false, content_type = 'application/json') @timeout = timeout @response = response @content_type = content_type attributes = contains_education_info? ? response.body['chapter33_education_info'] : {} super(status, attributes) end ## # @return [Time] The response timestamp in UTC # def Time.parse(@response.response_headers['date']).utc end ## # @return [Boolean] Checks if the response is correctly formatted and contains # the expected educational information def success? contains_education_info? end ## # @return [String] The response error type def error_type KNOWN_ERRORS.each_value do |error_val| return error_val if send("#{error_val}?") end 'unknown' end private def timeout? @timeout end def evss_error? && EVSS_ERROR_KEYS.include?(evss_error_key) end def vet_not_found? return false if @response.nil? || text_response? @response&.body == {} end def invalid_auth? # this one is a text/html response return false if @response.nil? @response&.body&.to_s&.include?('AUTH_INVALID_IDENTITY') || @response&.status == 403 end def contains_education_info? return false if @response.nil? || text_response? !vet_not_found? && @response.body.key?('chapter33_education_info') == true && @response.body['chapter33_education_info'] != {} && !@response.body['chapter33_education_info'].nil? end def return false if @response&.body.nil? || text_response? @response.body.key?('messages') && @response.body['messages'].is_a?(Array) && @response.body['messages'].length.positive? end def evss_error_key return nil if @response&.body.nil? @response.body.dig('messages', 0, 'key') end def text_response? @content_type.include?('text/html') || !@response.body.respond_to?(:key?) end end |
#last_name ⇒ String
Returns User’s last name.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 43 class GiBillStatusResponse < EVSS::Response include SentryLogging attribute :first_name, String attribute :last_name, String attribute :name_suffix, String attribute :date_of_birth, String attribute :va_file_number, String attribute :regional_processing_office, String attribute :eligibility_date, String attribute :delimiting_date, String attribute :percentage_benefit, Integer attribute :original_entitlement, Entitlement attribute :used_entitlement, Entitlement attribute :remaining_entitlement, Entitlement attribute :veteran_is_eligible, Boolean attribute :active_duty, Boolean attribute :enrollments, Array[Enrollment] EVSS_ERROR_KEYS = [ 'education.chapter33claimant.partner.service.down', 'education.chapter33enrollment.partner.service.down', 'education.partner.service.invalid', 'education.service.error' ].freeze KNOWN_ERRORS = { evss_error: 'evss_error', vet_not_found: 'vet_not_found', timeout: 'timeout', invalid_auth: 'invalid_auth' }.freeze ## # Create an instance of GiBillStatusResponse # # @param status [Integer] The HTTP status code from the service # @param response [String] The raw endpoint response or error body # @param timeout [Boolean] If the response timed out # @param content_type [String] The content type # def initialize(status, response = nil, timeout = false, content_type = 'application/json') @timeout = timeout @response = response @content_type = content_type attributes = contains_education_info? ? response.body['chapter33_education_info'] : {} super(status, attributes) end ## # @return [Time] The response timestamp in UTC # def Time.parse(@response.response_headers['date']).utc end ## # @return [Boolean] Checks if the response is correctly formatted and contains # the expected educational information def success? contains_education_info? end ## # @return [String] The response error type def error_type KNOWN_ERRORS.each_value do |error_val| return error_val if send("#{error_val}?") end 'unknown' end private def timeout? @timeout end def evss_error? && EVSS_ERROR_KEYS.include?(evss_error_key) end def vet_not_found? return false if @response.nil? || text_response? @response&.body == {} end def invalid_auth? # this one is a text/html response return false if @response.nil? @response&.body&.to_s&.include?('AUTH_INVALID_IDENTITY') || @response&.status == 403 end def contains_education_info? return false if @response.nil? || text_response? !vet_not_found? && @response.body.key?('chapter33_education_info') == true && @response.body['chapter33_education_info'] != {} && !@response.body['chapter33_education_info'].nil? end def return false if @response&.body.nil? || text_response? @response.body.key?('messages') && @response.body['messages'].is_a?(Array) && @response.body['messages'].length.positive? end def evss_error_key return nil if @response&.body.nil? @response.body.dig('messages', 0, 'key') end def text_response? @content_type.include?('text/html') || !@response.body.respond_to?(:key?) end end |
#name_suffix ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 43 class GiBillStatusResponse < EVSS::Response include SentryLogging attribute :first_name, String attribute :last_name, String attribute :name_suffix, String attribute :date_of_birth, String attribute :va_file_number, String attribute :regional_processing_office, String attribute :eligibility_date, String attribute :delimiting_date, String attribute :percentage_benefit, Integer attribute :original_entitlement, Entitlement attribute :used_entitlement, Entitlement attribute :remaining_entitlement, Entitlement attribute :veteran_is_eligible, Boolean attribute :active_duty, Boolean attribute :enrollments, Array[Enrollment] EVSS_ERROR_KEYS = [ 'education.chapter33claimant.partner.service.down', 'education.chapter33enrollment.partner.service.down', 'education.partner.service.invalid', 'education.service.error' ].freeze KNOWN_ERRORS = { evss_error: 'evss_error', vet_not_found: 'vet_not_found', timeout: 'timeout', invalid_auth: 'invalid_auth' }.freeze ## # Create an instance of GiBillStatusResponse # # @param status [Integer] The HTTP status code from the service # @param response [String] The raw endpoint response or error body # @param timeout [Boolean] If the response timed out # @param content_type [String] The content type # def initialize(status, response = nil, timeout = false, content_type = 'application/json') @timeout = timeout @response = response @content_type = content_type attributes = contains_education_info? ? response.body['chapter33_education_info'] : {} super(status, attributes) end ## # @return [Time] The response timestamp in UTC # def Time.parse(@response.response_headers['date']).utc end ## # @return [Boolean] Checks if the response is correctly formatted and contains # the expected educational information def success? contains_education_info? end ## # @return [String] The response error type def error_type KNOWN_ERRORS.each_value do |error_val| return error_val if send("#{error_val}?") end 'unknown' end private def timeout? @timeout end def evss_error? && EVSS_ERROR_KEYS.include?(evss_error_key) end def vet_not_found? return false if @response.nil? || text_response? @response&.body == {} end def invalid_auth? # this one is a text/html response return false if @response.nil? @response&.body&.to_s&.include?('AUTH_INVALID_IDENTITY') || @response&.status == 403 end def contains_education_info? return false if @response.nil? || text_response? !vet_not_found? && @response.body.key?('chapter33_education_info') == true && @response.body['chapter33_education_info'] != {} && !@response.body['chapter33_education_info'].nil? end def return false if @response&.body.nil? || text_response? @response.body.key?('messages') && @response.body['messages'].is_a?(Array) && @response.body['messages'].length.positive? end def evss_error_key return nil if @response&.body.nil? @response.body.dig('messages', 0, 'key') end def text_response? @content_type.include?('text/html') || !@response.body.respond_to?(:key?) end end |
#original_entitlement ⇒ Entitlement
Returns The time span of the user’s original entitlement.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 43 class GiBillStatusResponse < EVSS::Response include SentryLogging attribute :first_name, String attribute :last_name, String attribute :name_suffix, String attribute :date_of_birth, String attribute :va_file_number, String attribute :regional_processing_office, String attribute :eligibility_date, String attribute :delimiting_date, String attribute :percentage_benefit, Integer attribute :original_entitlement, Entitlement attribute :used_entitlement, Entitlement attribute :remaining_entitlement, Entitlement attribute :veteran_is_eligible, Boolean attribute :active_duty, Boolean attribute :enrollments, Array[Enrollment] EVSS_ERROR_KEYS = [ 'education.chapter33claimant.partner.service.down', 'education.chapter33enrollment.partner.service.down', 'education.partner.service.invalid', 'education.service.error' ].freeze KNOWN_ERRORS = { evss_error: 'evss_error', vet_not_found: 'vet_not_found', timeout: 'timeout', invalid_auth: 'invalid_auth' }.freeze ## # Create an instance of GiBillStatusResponse # # @param status [Integer] The HTTP status code from the service # @param response [String] The raw endpoint response or error body # @param timeout [Boolean] If the response timed out # @param content_type [String] The content type # def initialize(status, response = nil, timeout = false, content_type = 'application/json') @timeout = timeout @response = response @content_type = content_type attributes = contains_education_info? ? response.body['chapter33_education_info'] : {} super(status, attributes) end ## # @return [Time] The response timestamp in UTC # def Time.parse(@response.response_headers['date']).utc end ## # @return [Boolean] Checks if the response is correctly formatted and contains # the expected educational information def success? contains_education_info? end ## # @return [String] The response error type def error_type KNOWN_ERRORS.each_value do |error_val| return error_val if send("#{error_val}?") end 'unknown' end private def timeout? @timeout end def evss_error? && EVSS_ERROR_KEYS.include?(evss_error_key) end def vet_not_found? return false if @response.nil? || text_response? @response&.body == {} end def invalid_auth? # this one is a text/html response return false if @response.nil? @response&.body&.to_s&.include?('AUTH_INVALID_IDENTITY') || @response&.status == 403 end def contains_education_info? return false if @response.nil? || text_response? !vet_not_found? && @response.body.key?('chapter33_education_info') == true && @response.body['chapter33_education_info'] != {} && !@response.body['chapter33_education_info'].nil? end def return false if @response&.body.nil? || text_response? @response.body.key?('messages') && @response.body['messages'].is_a?(Array) && @response.body['messages'].length.positive? end def evss_error_key return nil if @response&.body.nil? @response.body.dig('messages', 0, 'key') end def text_response? @content_type.include?('text/html') || !@response.body.respond_to?(:key?) end end |
#percentage_benefit ⇒ Integer
Returns The amount of the benefit the user is eligible for.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 43 class GiBillStatusResponse < EVSS::Response include SentryLogging attribute :first_name, String attribute :last_name, String attribute :name_suffix, String attribute :date_of_birth, String attribute :va_file_number, String attribute :regional_processing_office, String attribute :eligibility_date, String attribute :delimiting_date, String attribute :percentage_benefit, Integer attribute :original_entitlement, Entitlement attribute :used_entitlement, Entitlement attribute :remaining_entitlement, Entitlement attribute :veteran_is_eligible, Boolean attribute :active_duty, Boolean attribute :enrollments, Array[Enrollment] EVSS_ERROR_KEYS = [ 'education.chapter33claimant.partner.service.down', 'education.chapter33enrollment.partner.service.down', 'education.partner.service.invalid', 'education.service.error' ].freeze KNOWN_ERRORS = { evss_error: 'evss_error', vet_not_found: 'vet_not_found', timeout: 'timeout', invalid_auth: 'invalid_auth' }.freeze ## # Create an instance of GiBillStatusResponse # # @param status [Integer] The HTTP status code from the service # @param response [String] The raw endpoint response or error body # @param timeout [Boolean] If the response timed out # @param content_type [String] The content type # def initialize(status, response = nil, timeout = false, content_type = 'application/json') @timeout = timeout @response = response @content_type = content_type attributes = contains_education_info? ? response.body['chapter33_education_info'] : {} super(status, attributes) end ## # @return [Time] The response timestamp in UTC # def Time.parse(@response.response_headers['date']).utc end ## # @return [Boolean] Checks if the response is correctly formatted and contains # the expected educational information def success? contains_education_info? end ## # @return [String] The response error type def error_type KNOWN_ERRORS.each_value do |error_val| return error_val if send("#{error_val}?") end 'unknown' end private def timeout? @timeout end def evss_error? && EVSS_ERROR_KEYS.include?(evss_error_key) end def vet_not_found? return false if @response.nil? || text_response? @response&.body == {} end def invalid_auth? # this one is a text/html response return false if @response.nil? @response&.body&.to_s&.include?('AUTH_INVALID_IDENTITY') || @response&.status == 403 end def contains_education_info? return false if @response.nil? || text_response? !vet_not_found? && @response.body.key?('chapter33_education_info') == true && @response.body['chapter33_education_info'] != {} && !@response.body['chapter33_education_info'].nil? end def return false if @response&.body.nil? || text_response? @response.body.key?('messages') && @response.body['messages'].is_a?(Array) && @response.body['messages'].length.positive? end def evss_error_key return nil if @response&.body.nil? @response.body.dig('messages', 0, 'key') end def text_response? @content_type.include?('text/html') || !@response.body.respond_to?(:key?) end end |
#regional_processing_office ⇒ String
Returns Closest processing office to the user.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 43 class GiBillStatusResponse < EVSS::Response include SentryLogging attribute :first_name, String attribute :last_name, String attribute :name_suffix, String attribute :date_of_birth, String attribute :va_file_number, String attribute :regional_processing_office, String attribute :eligibility_date, String attribute :delimiting_date, String attribute :percentage_benefit, Integer attribute :original_entitlement, Entitlement attribute :used_entitlement, Entitlement attribute :remaining_entitlement, Entitlement attribute :veteran_is_eligible, Boolean attribute :active_duty, Boolean attribute :enrollments, Array[Enrollment] EVSS_ERROR_KEYS = [ 'education.chapter33claimant.partner.service.down', 'education.chapter33enrollment.partner.service.down', 'education.partner.service.invalid', 'education.service.error' ].freeze KNOWN_ERRORS = { evss_error: 'evss_error', vet_not_found: 'vet_not_found', timeout: 'timeout', invalid_auth: 'invalid_auth' }.freeze ## # Create an instance of GiBillStatusResponse # # @param status [Integer] The HTTP status code from the service # @param response [String] The raw endpoint response or error body # @param timeout [Boolean] If the response timed out # @param content_type [String] The content type # def initialize(status, response = nil, timeout = false, content_type = 'application/json') @timeout = timeout @response = response @content_type = content_type attributes = contains_education_info? ? response.body['chapter33_education_info'] : {} super(status, attributes) end ## # @return [Time] The response timestamp in UTC # def Time.parse(@response.response_headers['date']).utc end ## # @return [Boolean] Checks if the response is correctly formatted and contains # the expected educational information def success? contains_education_info? end ## # @return [String] The response error type def error_type KNOWN_ERRORS.each_value do |error_val| return error_val if send("#{error_val}?") end 'unknown' end private def timeout? @timeout end def evss_error? && EVSS_ERROR_KEYS.include?(evss_error_key) end def vet_not_found? return false if @response.nil? || text_response? @response&.body == {} end def invalid_auth? # this one is a text/html response return false if @response.nil? @response&.body&.to_s&.include?('AUTH_INVALID_IDENTITY') || @response&.status == 403 end def contains_education_info? return false if @response.nil? || text_response? !vet_not_found? && @response.body.key?('chapter33_education_info') == true && @response.body['chapter33_education_info'] != {} && !@response.body['chapter33_education_info'].nil? end def return false if @response&.body.nil? || text_response? @response.body.key?('messages') && @response.body['messages'].is_a?(Array) && @response.body['messages'].length.positive? end def evss_error_key return nil if @response&.body.nil? @response.body.dig('messages', 0, 'key') end def text_response? @content_type.include?('text/html') || !@response.body.respond_to?(:key?) end end |
#remaining_entitlement ⇒ Entitlement
Returns The amount of entitlement time the user has remaining.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 43 class GiBillStatusResponse < EVSS::Response include SentryLogging attribute :first_name, String attribute :last_name, String attribute :name_suffix, String attribute :date_of_birth, String attribute :va_file_number, String attribute :regional_processing_office, String attribute :eligibility_date, String attribute :delimiting_date, String attribute :percentage_benefit, Integer attribute :original_entitlement, Entitlement attribute :used_entitlement, Entitlement attribute :remaining_entitlement, Entitlement attribute :veteran_is_eligible, Boolean attribute :active_duty, Boolean attribute :enrollments, Array[Enrollment] EVSS_ERROR_KEYS = [ 'education.chapter33claimant.partner.service.down', 'education.chapter33enrollment.partner.service.down', 'education.partner.service.invalid', 'education.service.error' ].freeze KNOWN_ERRORS = { evss_error: 'evss_error', vet_not_found: 'vet_not_found', timeout: 'timeout', invalid_auth: 'invalid_auth' }.freeze ## # Create an instance of GiBillStatusResponse # # @param status [Integer] The HTTP status code from the service # @param response [String] The raw endpoint response or error body # @param timeout [Boolean] If the response timed out # @param content_type [String] The content type # def initialize(status, response = nil, timeout = false, content_type = 'application/json') @timeout = timeout @response = response @content_type = content_type attributes = contains_education_info? ? response.body['chapter33_education_info'] : {} super(status, attributes) end ## # @return [Time] The response timestamp in UTC # def Time.parse(@response.response_headers['date']).utc end ## # @return [Boolean] Checks if the response is correctly formatted and contains # the expected educational information def success? contains_education_info? end ## # @return [String] The response error type def error_type KNOWN_ERRORS.each_value do |error_val| return error_val if send("#{error_val}?") end 'unknown' end private def timeout? @timeout end def evss_error? && EVSS_ERROR_KEYS.include?(evss_error_key) end def vet_not_found? return false if @response.nil? || text_response? @response&.body == {} end def invalid_auth? # this one is a text/html response return false if @response.nil? @response&.body&.to_s&.include?('AUTH_INVALID_IDENTITY') || @response&.status == 403 end def contains_education_info? return false if @response.nil? || text_response? !vet_not_found? && @response.body.key?('chapter33_education_info') == true && @response.body['chapter33_education_info'] != {} && !@response.body['chapter33_education_info'].nil? end def return false if @response&.body.nil? || text_response? @response.body.key?('messages') && @response.body['messages'].is_a?(Array) && @response.body['messages'].length.positive? end def evss_error_key return nil if @response&.body.nil? @response.body.dig('messages', 0, 'key') end def text_response? @content_type.include?('text/html') || !@response.body.respond_to?(:key?) end end |
#used_entitlement ⇒ Entitlement
Returns The amount of entitlement time the user has already used.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 43 class GiBillStatusResponse < EVSS::Response include SentryLogging attribute :first_name, String attribute :last_name, String attribute :name_suffix, String attribute :date_of_birth, String attribute :va_file_number, String attribute :regional_processing_office, String attribute :eligibility_date, String attribute :delimiting_date, String attribute :percentage_benefit, Integer attribute :original_entitlement, Entitlement attribute :used_entitlement, Entitlement attribute :remaining_entitlement, Entitlement attribute :veteran_is_eligible, Boolean attribute :active_duty, Boolean attribute :enrollments, Array[Enrollment] EVSS_ERROR_KEYS = [ 'education.chapter33claimant.partner.service.down', 'education.chapter33enrollment.partner.service.down', 'education.partner.service.invalid', 'education.service.error' ].freeze KNOWN_ERRORS = { evss_error: 'evss_error', vet_not_found: 'vet_not_found', timeout: 'timeout', invalid_auth: 'invalid_auth' }.freeze ## # Create an instance of GiBillStatusResponse # # @param status [Integer] The HTTP status code from the service # @param response [String] The raw endpoint response or error body # @param timeout [Boolean] If the response timed out # @param content_type [String] The content type # def initialize(status, response = nil, timeout = false, content_type = 'application/json') @timeout = timeout @response = response @content_type = content_type attributes = contains_education_info? ? response.body['chapter33_education_info'] : {} super(status, attributes) end ## # @return [Time] The response timestamp in UTC # def Time.parse(@response.response_headers['date']).utc end ## # @return [Boolean] Checks if the response is correctly formatted and contains # the expected educational information def success? contains_education_info? end ## # @return [String] The response error type def error_type KNOWN_ERRORS.each_value do |error_val| return error_val if send("#{error_val}?") end 'unknown' end private def timeout? @timeout end def evss_error? && EVSS_ERROR_KEYS.include?(evss_error_key) end def vet_not_found? return false if @response.nil? || text_response? @response&.body == {} end def invalid_auth? # this one is a text/html response return false if @response.nil? @response&.body&.to_s&.include?('AUTH_INVALID_IDENTITY') || @response&.status == 403 end def contains_education_info? return false if @response.nil? || text_response? !vet_not_found? && @response.body.key?('chapter33_education_info') == true && @response.body['chapter33_education_info'] != {} && !@response.body['chapter33_education_info'].nil? end def return false if @response&.body.nil? || text_response? @response.body.key?('messages') && @response.body['messages'].is_a?(Array) && @response.body['messages'].length.positive? end def evss_error_key return nil if @response&.body.nil? @response.body.dig('messages', 0, 'key') end def text_response? @content_type.include?('text/html') || !@response.body.respond_to?(:key?) end end |
#va_file_number ⇒ String
Returns User’s VA file number.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 43 class GiBillStatusResponse < EVSS::Response include SentryLogging attribute :first_name, String attribute :last_name, String attribute :name_suffix, String attribute :date_of_birth, String attribute :va_file_number, String attribute :regional_processing_office, String attribute :eligibility_date, String attribute :delimiting_date, String attribute :percentage_benefit, Integer attribute :original_entitlement, Entitlement attribute :used_entitlement, Entitlement attribute :remaining_entitlement, Entitlement attribute :veteran_is_eligible, Boolean attribute :active_duty, Boolean attribute :enrollments, Array[Enrollment] EVSS_ERROR_KEYS = [ 'education.chapter33claimant.partner.service.down', 'education.chapter33enrollment.partner.service.down', 'education.partner.service.invalid', 'education.service.error' ].freeze KNOWN_ERRORS = { evss_error: 'evss_error', vet_not_found: 'vet_not_found', timeout: 'timeout', invalid_auth: 'invalid_auth' }.freeze ## # Create an instance of GiBillStatusResponse # # @param status [Integer] The HTTP status code from the service # @param response [String] The raw endpoint response or error body # @param timeout [Boolean] If the response timed out # @param content_type [String] The content type # def initialize(status, response = nil, timeout = false, content_type = 'application/json') @timeout = timeout @response = response @content_type = content_type attributes = contains_education_info? ? response.body['chapter33_education_info'] : {} super(status, attributes) end ## # @return [Time] The response timestamp in UTC # def Time.parse(@response.response_headers['date']).utc end ## # @return [Boolean] Checks if the response is correctly formatted and contains # the expected educational information def success? contains_education_info? end ## # @return [String] The response error type def error_type KNOWN_ERRORS.each_value do |error_val| return error_val if send("#{error_val}?") end 'unknown' end private def timeout? @timeout end def evss_error? && EVSS_ERROR_KEYS.include?(evss_error_key) end def vet_not_found? return false if @response.nil? || text_response? @response&.body == {} end def invalid_auth? # this one is a text/html response return false if @response.nil? @response&.body&.to_s&.include?('AUTH_INVALID_IDENTITY') || @response&.status == 403 end def contains_education_info? return false if @response.nil? || text_response? !vet_not_found? && @response.body.key?('chapter33_education_info') == true && @response.body['chapter33_education_info'] != {} && !@response.body['chapter33_education_info'].nil? end def return false if @response&.body.nil? || text_response? @response.body.key?('messages') && @response.body['messages'].is_a?(Array) && @response.body['messages'].length.positive? end def evss_error_key return nil if @response&.body.nil? @response.body.dig('messages', 0, 'key') end def text_response? @content_type.include?('text/html') || !@response.body.respond_to?(:key?) end end |
#veteran_is_eligible ⇒ Boolean
Returns Is the user eligbile for the benefit.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 43 class GiBillStatusResponse < EVSS::Response include SentryLogging attribute :first_name, String attribute :last_name, String attribute :name_suffix, String attribute :date_of_birth, String attribute :va_file_number, String attribute :regional_processing_office, String attribute :eligibility_date, String attribute :delimiting_date, String attribute :percentage_benefit, Integer attribute :original_entitlement, Entitlement attribute :used_entitlement, Entitlement attribute :remaining_entitlement, Entitlement attribute :veteran_is_eligible, Boolean attribute :active_duty, Boolean attribute :enrollments, Array[Enrollment] EVSS_ERROR_KEYS = [ 'education.chapter33claimant.partner.service.down', 'education.chapter33enrollment.partner.service.down', 'education.partner.service.invalid', 'education.service.error' ].freeze KNOWN_ERRORS = { evss_error: 'evss_error', vet_not_found: 'vet_not_found', timeout: 'timeout', invalid_auth: 'invalid_auth' }.freeze ## # Create an instance of GiBillStatusResponse # # @param status [Integer] The HTTP status code from the service # @param response [String] The raw endpoint response or error body # @param timeout [Boolean] If the response timed out # @param content_type [String] The content type # def initialize(status, response = nil, timeout = false, content_type = 'application/json') @timeout = timeout @response = response @content_type = content_type attributes = contains_education_info? ? response.body['chapter33_education_info'] : {} super(status, attributes) end ## # @return [Time] The response timestamp in UTC # def Time.parse(@response.response_headers['date']).utc end ## # @return [Boolean] Checks if the response is correctly formatted and contains # the expected educational information def success? contains_education_info? end ## # @return [String] The response error type def error_type KNOWN_ERRORS.each_value do |error_val| return error_val if send("#{error_val}?") end 'unknown' end private def timeout? @timeout end def evss_error? && EVSS_ERROR_KEYS.include?(evss_error_key) end def vet_not_found? return false if @response.nil? || text_response? @response&.body == {} end def invalid_auth? # this one is a text/html response return false if @response.nil? @response&.body&.to_s&.include?('AUTH_INVALID_IDENTITY') || @response&.status == 403 end def contains_education_info? return false if @response.nil? || text_response? !vet_not_found? && @response.body.key?('chapter33_education_info') == true && @response.body['chapter33_education_info'] != {} && !@response.body['chapter33_education_info'].nil? end def return false if @response&.body.nil? || text_response? @response.body.key?('messages') && @response.body['messages'].is_a?(Array) && @response.body['messages'].length.positive? end def evss_error_key return nil if @response&.body.nil? @response.body.dig('messages', 0, 'key') end def text_response? @content_type.include?('text/html') || !@response.body.respond_to?(:key?) end end |
Instance Method Details
#error_type ⇒ String
Returns The response error type.
108 109 110 111 112 113 114 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 108 def error_type KNOWN_ERRORS.each_value do |error_val| return error_val if send("#{error_val}?") end 'unknown' end |
#success? ⇒ Boolean
the expected educational information
102 103 104 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 102 def success? contains_education_info? end |
#timestamp ⇒ Time
Returns The response timestamp in UTC.
95 96 97 |
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 95 def Time.parse(@response.response_headers['date']).utc end |