Class: EVSS::GiBillStatus::GiBillStatusResponse

Inherits:
Response show all
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

Attributes inherited from Common::Base

#errors_hash, #metadata

Instance Method Summary collapse

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

Parameters:

  • status (Integer)

    The HTTP status code from the service

  • response (String) (defaults to: nil)

    The raw endpoint response or error body

  • timeout (Boolean) (defaults to: false)

    If the response timed out

  • content_type (String) (defaults to: 'application/json')

    The content type



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_dutyBoolean

Returns Is the user on active duty.

Returns:

  • (Boolean)

    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 timestamp
    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?
    contains_error_messages? && 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 contains_error_messages?
    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_birthString

Returns User’s date of birth.

Returns:

  • (String)

    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 timestamp
    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?
    contains_error_messages? && 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 contains_error_messages?
    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_dateString

Returns The date after which benefits cannot be paid.

Returns:

  • (String)

    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 timestamp
    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?
    contains_error_messages? && 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 contains_error_messages?
    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_dateString

Returns The date at which benefits are eligible to be paid.

Returns:

  • (String)

    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 timestamp
    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?
    contains_error_messages? && 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 contains_error_messages?
    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

#enrollmentsArray[Enrollment]

Returns An array of the user’s enrollments.

Returns:

  • (Array[Enrollment])

    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 timestamp
    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?
    contains_error_messages? && 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 contains_error_messages?
    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_nameString

Returns User’s first name.

Returns:

  • (String)

    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 timestamp
    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?
    contains_error_messages? && 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 contains_error_messages?
    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_nameString

Returns User’s last name.

Returns:

  • (String)

    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 timestamp
    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?
    contains_error_messages? && 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 contains_error_messages?
    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_suffixObject



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 timestamp
    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?
    contains_error_messages? && 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 contains_error_messages?
    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_entitlementEntitlement

Returns The time span of the user’s original entitlement.

Returns:

  • (Entitlement)

    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 timestamp
    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?
    contains_error_messages? && 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 contains_error_messages?
    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_benefitInteger

Returns The amount of the benefit the user is eligible for.

Returns:

  • (Integer)

    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 timestamp
    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?
    contains_error_messages? && 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 contains_error_messages?
    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_officeString

Returns Closest processing office to the user.

Returns:

  • (String)

    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 timestamp
    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?
    contains_error_messages? && 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 contains_error_messages?
    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_entitlementEntitlement

Returns The amount of entitlement time the user has remaining.

Returns:

  • (Entitlement)

    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 timestamp
    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?
    contains_error_messages? && 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 contains_error_messages?
    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_entitlementEntitlement

Returns The amount of entitlement time the user has already used.

Returns:

  • (Entitlement)

    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 timestamp
    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?
    contains_error_messages? && 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 contains_error_messages?
    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_numberString

Returns User’s VA file number.

Returns:

  • (String)

    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 timestamp
    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?
    contains_error_messages? && 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 contains_error_messages?
    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_eligibleBoolean

Returns Is the user eligbile for the benefit.

Returns:

  • (Boolean)

    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 timestamp
    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?
    contains_error_messages? && 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 contains_error_messages?
    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_typeString

Returns The response error type.

Returns:

  • (String)

    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

Returns:

  • (Boolean)

    Checks if the response is correctly formatted and contains



102
103
104
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 102

def success?
  contains_education_info?
end

#timestampTime

Returns The response timestamp in UTC.

Returns:

  • (Time)

    The response timestamp in UTC



95
96
97
# File 'lib/evss/gi_bill_status/gi_bill_status_response.rb', line 95

def timestamp
  Time.parse(@response.response_headers['date']).utc
end