Class: Preneeds::BurialForm

Inherits:
Base
  • Object
show all
Defined in:
app/models/preneeds/burial_form.rb

Overview

Models a Preneeds Burial form. This class (and associationed classes) is used to store form details and to generate the XML request for submission to the EOAS service

Constant Summary collapse

FORM =

Preneeds Burial Form official form id

'40-10007'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#as_json

Instance Attribute Details

#applicantPreneeds::Applicant

Returns Applicant object. Applicant is person filling out the form.

Returns:



36
37
38
39
40
41
42
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
# File 'app/models/preneeds/burial_form.rb', line 36

class BurialForm < Preneeds::Base
  # Preneeds Burial Form official form id
  #
  FORM = '40-10007'

  attribute :application_status, String, default: ''
  attribute :preneed_attachments, Array[PreneedAttachmentHash]
  attribute :has_currently_buried, String
  attribute :sending_application, String, default: 'vets.gov'
  attribute :sending_code, String, default: ''
  attribute :sent_time, Common::UTCTime, default: :current_time
  attribute :tracking_number, String, default: :generate_tracking_number
  attribute :applicant, Preneeds::Applicant
  attribute :claimant, Preneeds::Claimant
  attribute :currently_buried_persons, Array[Preneeds::CurrentlyBuriedPerson]
  attribute :veteran, Preneeds::Veteran

  # keeping this name because it matches the previous attribute
  # @return [Boolean]
  #
  # rubocop:disable Naming/PredicateName
  def has_attachments
    preneed_attachments.present?
  end
  # rubocop:enable Naming/PredicateName

  # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment}
  #
  def attachments
    @attachments ||= preneed_attachments.map(&:to_attachment)
  end

  # @return [Time] current UTC time
  #
  def current_time
    Time.now.utc
  end

  # @return [String] randomly generated tracking number
  #
  def generate_tracking_number
    "#{SecureRandom.base64(14).tr('+/=', '0aZ')[0..-3]}VG"
  end

  # Converts object attributes to a hash to be used when constructing a SOAP request body.
  # Hash attributes must correspond to XSD ordering or API call will fail
  #
  # @return [Hash] object attributes and association objects converted to EOAS service compatible hash
  #
  def as_eoas
    hash = {
      applicant: applicant&.as_eoas, applicationStatus: application_status,
      attachments: attachments.map(&:as_eoas),
      claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas),
      hasAttachments: has_attachments, hasCurrentlyBuried: has_currently_buried,
      sendingApplication: sending_application, sendingCode: sending_code || '', sentTime: sent_time.iso8601,
      trackingNumber: tracking_number, veteran: veteran&.as_eoas
    }

    [:currentlyBuriedPersons].each do |key|
      hash.delete(key) if hash[key].blank?
    end

    Common::HashHelpers.deep_compact(hash)
  end

  # @return [Array<String>] array of strings detailing schema validation failures. empty array if form is valid
  #
  def self.validate(schema, form, root = 'application')
    JSON::Validator.fully_validate(schema, { root => form&.as_json }, validate_schema: true)
  end
end

#application_statusString

Returns currently always blank.

Returns:

  • (String)

    currently always blank



36
37
38
39
40
41
42
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
# File 'app/models/preneeds/burial_form.rb', line 36

class BurialForm < Preneeds::Base
  # Preneeds Burial Form official form id
  #
  FORM = '40-10007'

  attribute :application_status, String, default: ''
  attribute :preneed_attachments, Array[PreneedAttachmentHash]
  attribute :has_currently_buried, String
  attribute :sending_application, String, default: 'vets.gov'
  attribute :sending_code, String, default: ''
  attribute :sent_time, Common::UTCTime, default: :current_time
  attribute :tracking_number, String, default: :generate_tracking_number
  attribute :applicant, Preneeds::Applicant
  attribute :claimant, Preneeds::Claimant
  attribute :currently_buried_persons, Array[Preneeds::CurrentlyBuriedPerson]
  attribute :veteran, Preneeds::Veteran

  # keeping this name because it matches the previous attribute
  # @return [Boolean]
  #
  # rubocop:disable Naming/PredicateName
  def has_attachments
    preneed_attachments.present?
  end
  # rubocop:enable Naming/PredicateName

  # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment}
  #
  def attachments
    @attachments ||= preneed_attachments.map(&:to_attachment)
  end

  # @return [Time] current UTC time
  #
  def current_time
    Time.now.utc
  end

  # @return [String] randomly generated tracking number
  #
  def generate_tracking_number
    "#{SecureRandom.base64(14).tr('+/=', '0aZ')[0..-3]}VG"
  end

  # Converts object attributes to a hash to be used when constructing a SOAP request body.
  # Hash attributes must correspond to XSD ordering or API call will fail
  #
  # @return [Hash] object attributes and association objects converted to EOAS service compatible hash
  #
  def as_eoas
    hash = {
      applicant: applicant&.as_eoas, applicationStatus: application_status,
      attachments: attachments.map(&:as_eoas),
      claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas),
      hasAttachments: has_attachments, hasCurrentlyBuried: has_currently_buried,
      sendingApplication: sending_application, sendingCode: sending_code || '', sentTime: sent_time.iso8601,
      trackingNumber: tracking_number, veteran: veteran&.as_eoas
    }

    [:currentlyBuriedPersons].each do |key|
      hash.delete(key) if hash[key].blank?
    end

    Common::HashHelpers.deep_compact(hash)
  end

  # @return [Array<String>] array of strings detailing schema validation failures. empty array if form is valid
  #
  def self.validate(schema, form, root = 'application')
    JSON::Validator.fully_validate(schema, { root => form&.as_json }, validate_schema: true)
  end
end

#claimantPreneeds::Claimant

Returns Claimant object. Claimant is the person applying for the benefit (veteran or relative).

Returns:

  • (Preneeds::Claimant)

    Claimant object. Claimant is the person applying for the benefit (veteran or relative)



36
37
38
39
40
41
42
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
# File 'app/models/preneeds/burial_form.rb', line 36

class BurialForm < Preneeds::Base
  # Preneeds Burial Form official form id
  #
  FORM = '40-10007'

  attribute :application_status, String, default: ''
  attribute :preneed_attachments, Array[PreneedAttachmentHash]
  attribute :has_currently_buried, String
  attribute :sending_application, String, default: 'vets.gov'
  attribute :sending_code, String, default: ''
  attribute :sent_time, Common::UTCTime, default: :current_time
  attribute :tracking_number, String, default: :generate_tracking_number
  attribute :applicant, Preneeds::Applicant
  attribute :claimant, Preneeds::Claimant
  attribute :currently_buried_persons, Array[Preneeds::CurrentlyBuriedPerson]
  attribute :veteran, Preneeds::Veteran

  # keeping this name because it matches the previous attribute
  # @return [Boolean]
  #
  # rubocop:disable Naming/PredicateName
  def has_attachments
    preneed_attachments.present?
  end
  # rubocop:enable Naming/PredicateName

  # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment}
  #
  def attachments
    @attachments ||= preneed_attachments.map(&:to_attachment)
  end

  # @return [Time] current UTC time
  #
  def current_time
    Time.now.utc
  end

  # @return [String] randomly generated tracking number
  #
  def generate_tracking_number
    "#{SecureRandom.base64(14).tr('+/=', '0aZ')[0..-3]}VG"
  end

  # Converts object attributes to a hash to be used when constructing a SOAP request body.
  # Hash attributes must correspond to XSD ordering or API call will fail
  #
  # @return [Hash] object attributes and association objects converted to EOAS service compatible hash
  #
  def as_eoas
    hash = {
      applicant: applicant&.as_eoas, applicationStatus: application_status,
      attachments: attachments.map(&:as_eoas),
      claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas),
      hasAttachments: has_attachments, hasCurrentlyBuried: has_currently_buried,
      sendingApplication: sending_application, sendingCode: sending_code || '', sentTime: sent_time.iso8601,
      trackingNumber: tracking_number, veteran: veteran&.as_eoas
    }

    [:currentlyBuriedPersons].each do |key|
      hash.delete(key) if hash[key].blank?
    end

    Common::HashHelpers.deep_compact(hash)
  end

  # @return [Array<String>] array of strings detailing schema validation failures. empty array if form is valid
  #
  def self.validate(schema, form, root = 'application')
    JSON::Validator.fully_validate(schema, { root => form&.as_json }, validate_schema: true)
  end
end

#currently_buried_personsArray<Preneeds::CurrentlyBuriedPerson>

Returns CurrentlyBuriedPerson objects representing individuals burried in VA national cemeteries under the sponsor’s eligibility.

Returns:

  • (Array<Preneeds::CurrentlyBuriedPerson>)

    CurrentlyBuriedPerson objects representing individuals burried in VA national cemeteries under the sponsor’s eligibility



36
37
38
39
40
41
42
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
# File 'app/models/preneeds/burial_form.rb', line 36

class BurialForm < Preneeds::Base
  # Preneeds Burial Form official form id
  #
  FORM = '40-10007'

  attribute :application_status, String, default: ''
  attribute :preneed_attachments, Array[PreneedAttachmentHash]
  attribute :has_currently_buried, String
  attribute :sending_application, String, default: 'vets.gov'
  attribute :sending_code, String, default: ''
  attribute :sent_time, Common::UTCTime, default: :current_time
  attribute :tracking_number, String, default: :generate_tracking_number
  attribute :applicant, Preneeds::Applicant
  attribute :claimant, Preneeds::Claimant
  attribute :currently_buried_persons, Array[Preneeds::CurrentlyBuriedPerson]
  attribute :veteran, Preneeds::Veteran

  # keeping this name because it matches the previous attribute
  # @return [Boolean]
  #
  # rubocop:disable Naming/PredicateName
  def has_attachments
    preneed_attachments.present?
  end
  # rubocop:enable Naming/PredicateName

  # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment}
  #
  def attachments
    @attachments ||= preneed_attachments.map(&:to_attachment)
  end

  # @return [Time] current UTC time
  #
  def current_time
    Time.now.utc
  end

  # @return [String] randomly generated tracking number
  #
  def generate_tracking_number
    "#{SecureRandom.base64(14).tr('+/=', '0aZ')[0..-3]}VG"
  end

  # Converts object attributes to a hash to be used when constructing a SOAP request body.
  # Hash attributes must correspond to XSD ordering or API call will fail
  #
  # @return [Hash] object attributes and association objects converted to EOAS service compatible hash
  #
  def as_eoas
    hash = {
      applicant: applicant&.as_eoas, applicationStatus: application_status,
      attachments: attachments.map(&:as_eoas),
      claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas),
      hasAttachments: has_attachments, hasCurrentlyBuried: has_currently_buried,
      sendingApplication: sending_application, sendingCode: sending_code || '', sentTime: sent_time.iso8601,
      trackingNumber: tracking_number, veteran: veteran&.as_eoas
    }

    [:currentlyBuriedPersons].each do |key|
      hash.delete(key) if hash[key].blank?
    end

    Common::HashHelpers.deep_compact(hash)
  end

  # @return [Array<String>] array of strings detailing schema validation failures. empty array if form is valid
  #
  def self.validate(schema, form, root = 'application')
    JSON::Validator.fully_validate(schema, { root => form&.as_json }, validate_schema: true)
  end
end

#has_currently_buriedString

Returns ‘1’ for Yes, ‘2’ for No, ‘3’ for Don’t know.

Returns:

  • (String)

    ‘1’ for Yes, ‘2’ for No, ‘3’ for Don’t know



36
37
38
39
40
41
42
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
# File 'app/models/preneeds/burial_form.rb', line 36

class BurialForm < Preneeds::Base
  # Preneeds Burial Form official form id
  #
  FORM = '40-10007'

  attribute :application_status, String, default: ''
  attribute :preneed_attachments, Array[PreneedAttachmentHash]
  attribute :has_currently_buried, String
  attribute :sending_application, String, default: 'vets.gov'
  attribute :sending_code, String, default: ''
  attribute :sent_time, Common::UTCTime, default: :current_time
  attribute :tracking_number, String, default: :generate_tracking_number
  attribute :applicant, Preneeds::Applicant
  attribute :claimant, Preneeds::Claimant
  attribute :currently_buried_persons, Array[Preneeds::CurrentlyBuriedPerson]
  attribute :veteran, Preneeds::Veteran

  # keeping this name because it matches the previous attribute
  # @return [Boolean]
  #
  # rubocop:disable Naming/PredicateName
  def has_attachments
    preneed_attachments.present?
  end
  # rubocop:enable Naming/PredicateName

  # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment}
  #
  def attachments
    @attachments ||= preneed_attachments.map(&:to_attachment)
  end

  # @return [Time] current UTC time
  #
  def current_time
    Time.now.utc
  end

  # @return [String] randomly generated tracking number
  #
  def generate_tracking_number
    "#{SecureRandom.base64(14).tr('+/=', '0aZ')[0..-3]}VG"
  end

  # Converts object attributes to a hash to be used when constructing a SOAP request body.
  # Hash attributes must correspond to XSD ordering or API call will fail
  #
  # @return [Hash] object attributes and association objects converted to EOAS service compatible hash
  #
  def as_eoas
    hash = {
      applicant: applicant&.as_eoas, applicationStatus: application_status,
      attachments: attachments.map(&:as_eoas),
      claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas),
      hasAttachments: has_attachments, hasCurrentlyBuried: has_currently_buried,
      sendingApplication: sending_application, sendingCode: sending_code || '', sentTime: sent_time.iso8601,
      trackingNumber: tracking_number, veteran: veteran&.as_eoas
    }

    [:currentlyBuriedPersons].each do |key|
      hash.delete(key) if hash[key].blank?
    end

    Common::HashHelpers.deep_compact(hash)
  end

  # @return [Array<String>] array of strings detailing schema validation failures. empty array if form is valid
  #
  def self.validate(schema, form, root = 'application')
    JSON::Validator.fully_validate(schema, { root => form&.as_json }, validate_schema: true)
  end
end

#preneed_attachmentsArray<PreneedAttachmentHash>

Returns documents provided by the end user.

Returns:



36
37
38
39
40
41
42
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
# File 'app/models/preneeds/burial_form.rb', line 36

class BurialForm < Preneeds::Base
  # Preneeds Burial Form official form id
  #
  FORM = '40-10007'

  attribute :application_status, String, default: ''
  attribute :preneed_attachments, Array[PreneedAttachmentHash]
  attribute :has_currently_buried, String
  attribute :sending_application, String, default: 'vets.gov'
  attribute :sending_code, String, default: ''
  attribute :sent_time, Common::UTCTime, default: :current_time
  attribute :tracking_number, String, default: :generate_tracking_number
  attribute :applicant, Preneeds::Applicant
  attribute :claimant, Preneeds::Claimant
  attribute :currently_buried_persons, Array[Preneeds::CurrentlyBuriedPerson]
  attribute :veteran, Preneeds::Veteran

  # keeping this name because it matches the previous attribute
  # @return [Boolean]
  #
  # rubocop:disable Naming/PredicateName
  def has_attachments
    preneed_attachments.present?
  end
  # rubocop:enable Naming/PredicateName

  # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment}
  #
  def attachments
    @attachments ||= preneed_attachments.map(&:to_attachment)
  end

  # @return [Time] current UTC time
  #
  def current_time
    Time.now.utc
  end

  # @return [String] randomly generated tracking number
  #
  def generate_tracking_number
    "#{SecureRandom.base64(14).tr('+/=', '0aZ')[0..-3]}VG"
  end

  # Converts object attributes to a hash to be used when constructing a SOAP request body.
  # Hash attributes must correspond to XSD ordering or API call will fail
  #
  # @return [Hash] object attributes and association objects converted to EOAS service compatible hash
  #
  def as_eoas
    hash = {
      applicant: applicant&.as_eoas, applicationStatus: application_status,
      attachments: attachments.map(&:as_eoas),
      claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas),
      hasAttachments: has_attachments, hasCurrentlyBuried: has_currently_buried,
      sendingApplication: sending_application, sendingCode: sending_code || '', sentTime: sent_time.iso8601,
      trackingNumber: tracking_number, veteran: veteran&.as_eoas
    }

    [:currentlyBuriedPersons].each do |key|
      hash.delete(key) if hash[key].blank?
    end

    Common::HashHelpers.deep_compact(hash)
  end

  # @return [Array<String>] array of strings detailing schema validation failures. empty array if form is valid
  #
  def self.validate(schema, form, root = 'application')
    JSON::Validator.fully_validate(schema, { root => form&.as_json }, validate_schema: true)
  end
end

#sending_applicationString

Returns hard coded as ‘va.gov’.

Returns:

  • (String)

    hard coded as ‘va.gov’



36
37
38
39
40
41
42
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
# File 'app/models/preneeds/burial_form.rb', line 36

class BurialForm < Preneeds::Base
  # Preneeds Burial Form official form id
  #
  FORM = '40-10007'

  attribute :application_status, String, default: ''
  attribute :preneed_attachments, Array[PreneedAttachmentHash]
  attribute :has_currently_buried, String
  attribute :sending_application, String, default: 'vets.gov'
  attribute :sending_code, String, default: ''
  attribute :sent_time, Common::UTCTime, default: :current_time
  attribute :tracking_number, String, default: :generate_tracking_number
  attribute :applicant, Preneeds::Applicant
  attribute :claimant, Preneeds::Claimant
  attribute :currently_buried_persons, Array[Preneeds::CurrentlyBuriedPerson]
  attribute :veteran, Preneeds::Veteran

  # keeping this name because it matches the previous attribute
  # @return [Boolean]
  #
  # rubocop:disable Naming/PredicateName
  def has_attachments
    preneed_attachments.present?
  end
  # rubocop:enable Naming/PredicateName

  # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment}
  #
  def attachments
    @attachments ||= preneed_attachments.map(&:to_attachment)
  end

  # @return [Time] current UTC time
  #
  def current_time
    Time.now.utc
  end

  # @return [String] randomly generated tracking number
  #
  def generate_tracking_number
    "#{SecureRandom.base64(14).tr('+/=', '0aZ')[0..-3]}VG"
  end

  # Converts object attributes to a hash to be used when constructing a SOAP request body.
  # Hash attributes must correspond to XSD ordering or API call will fail
  #
  # @return [Hash] object attributes and association objects converted to EOAS service compatible hash
  #
  def as_eoas
    hash = {
      applicant: applicant&.as_eoas, applicationStatus: application_status,
      attachments: attachments.map(&:as_eoas),
      claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas),
      hasAttachments: has_attachments, hasCurrentlyBuried: has_currently_buried,
      sendingApplication: sending_application, sendingCode: sending_code || '', sentTime: sent_time.iso8601,
      trackingNumber: tracking_number, veteran: veteran&.as_eoas
    }

    [:currentlyBuriedPersons].each do |key|
      hash.delete(key) if hash[key].blank?
    end

    Common::HashHelpers.deep_compact(hash)
  end

  # @return [Array<String>] array of strings detailing schema validation failures. empty array if form is valid
  #
  def self.validate(schema, form, root = 'application')
    JSON::Validator.fully_validate(schema, { root => form&.as_json }, validate_schema: true)
  end
end

#sending_codeString

Returns currently always blank.

Returns:

  • (String)

    currently always blank



36
37
38
39
40
41
42
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
# File 'app/models/preneeds/burial_form.rb', line 36

class BurialForm < Preneeds::Base
  # Preneeds Burial Form official form id
  #
  FORM = '40-10007'

  attribute :application_status, String, default: ''
  attribute :preneed_attachments, Array[PreneedAttachmentHash]
  attribute :has_currently_buried, String
  attribute :sending_application, String, default: 'vets.gov'
  attribute :sending_code, String, default: ''
  attribute :sent_time, Common::UTCTime, default: :current_time
  attribute :tracking_number, String, default: :generate_tracking_number
  attribute :applicant, Preneeds::Applicant
  attribute :claimant, Preneeds::Claimant
  attribute :currently_buried_persons, Array[Preneeds::CurrentlyBuriedPerson]
  attribute :veteran, Preneeds::Veteran

  # keeping this name because it matches the previous attribute
  # @return [Boolean]
  #
  # rubocop:disable Naming/PredicateName
  def has_attachments
    preneed_attachments.present?
  end
  # rubocop:enable Naming/PredicateName

  # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment}
  #
  def attachments
    @attachments ||= preneed_attachments.map(&:to_attachment)
  end

  # @return [Time] current UTC time
  #
  def current_time
    Time.now.utc
  end

  # @return [String] randomly generated tracking number
  #
  def generate_tracking_number
    "#{SecureRandom.base64(14).tr('+/=', '0aZ')[0..-3]}VG"
  end

  # Converts object attributes to a hash to be used when constructing a SOAP request body.
  # Hash attributes must correspond to XSD ordering or API call will fail
  #
  # @return [Hash] object attributes and association objects converted to EOAS service compatible hash
  #
  def as_eoas
    hash = {
      applicant: applicant&.as_eoas, applicationStatus: application_status,
      attachments: attachments.map(&:as_eoas),
      claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas),
      hasAttachments: has_attachments, hasCurrentlyBuried: has_currently_buried,
      sendingApplication: sending_application, sendingCode: sending_code || '', sentTime: sent_time.iso8601,
      trackingNumber: tracking_number, veteran: veteran&.as_eoas
    }

    [:currentlyBuriedPersons].each do |key|
      hash.delete(key) if hash[key].blank?
    end

    Common::HashHelpers.deep_compact(hash)
  end

  # @return [Array<String>] array of strings detailing schema validation failures. empty array if form is valid
  #
  def self.validate(schema, form, root = 'application')
    JSON::Validator.fully_validate(schema, { root => form&.as_json }, validate_schema: true)
  end
end

#sent_timeTime

Returns current time.

Returns:

  • (Time)

    current time



36
37
38
39
40
41
42
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
# File 'app/models/preneeds/burial_form.rb', line 36

class BurialForm < Preneeds::Base
  # Preneeds Burial Form official form id
  #
  FORM = '40-10007'

  attribute :application_status, String, default: ''
  attribute :preneed_attachments, Array[PreneedAttachmentHash]
  attribute :has_currently_buried, String
  attribute :sending_application, String, default: 'vets.gov'
  attribute :sending_code, String, default: ''
  attribute :sent_time, Common::UTCTime, default: :current_time
  attribute :tracking_number, String, default: :generate_tracking_number
  attribute :applicant, Preneeds::Applicant
  attribute :claimant, Preneeds::Claimant
  attribute :currently_buried_persons, Array[Preneeds::CurrentlyBuriedPerson]
  attribute :veteran, Preneeds::Veteran

  # keeping this name because it matches the previous attribute
  # @return [Boolean]
  #
  # rubocop:disable Naming/PredicateName
  def has_attachments
    preneed_attachments.present?
  end
  # rubocop:enable Naming/PredicateName

  # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment}
  #
  def attachments
    @attachments ||= preneed_attachments.map(&:to_attachment)
  end

  # @return [Time] current UTC time
  #
  def current_time
    Time.now.utc
  end

  # @return [String] randomly generated tracking number
  #
  def generate_tracking_number
    "#{SecureRandom.base64(14).tr('+/=', '0aZ')[0..-3]}VG"
  end

  # Converts object attributes to a hash to be used when constructing a SOAP request body.
  # Hash attributes must correspond to XSD ordering or API call will fail
  #
  # @return [Hash] object attributes and association objects converted to EOAS service compatible hash
  #
  def as_eoas
    hash = {
      applicant: applicant&.as_eoas, applicationStatus: application_status,
      attachments: attachments.map(&:as_eoas),
      claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas),
      hasAttachments: has_attachments, hasCurrentlyBuried: has_currently_buried,
      sendingApplication: sending_application, sendingCode: sending_code || '', sentTime: sent_time.iso8601,
      trackingNumber: tracking_number, veteran: veteran&.as_eoas
    }

    [:currentlyBuriedPersons].each do |key|
      hash.delete(key) if hash[key].blank?
    end

    Common::HashHelpers.deep_compact(hash)
  end

  # @return [Array<String>] array of strings detailing schema validation failures. empty array if form is valid
  #
  def self.validate(schema, form, root = 'application')
    JSON::Validator.fully_validate(schema, { root => form&.as_json }, validate_schema: true)
  end
end

#tracking_numberString

Returns SecureRandom generated tracking number sent with submission to EOAS.

Returns:

  • (String)

    SecureRandom generated tracking number sent with submission to EOAS



36
37
38
39
40
41
42
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
# File 'app/models/preneeds/burial_form.rb', line 36

class BurialForm < Preneeds::Base
  # Preneeds Burial Form official form id
  #
  FORM = '40-10007'

  attribute :application_status, String, default: ''
  attribute :preneed_attachments, Array[PreneedAttachmentHash]
  attribute :has_currently_buried, String
  attribute :sending_application, String, default: 'vets.gov'
  attribute :sending_code, String, default: ''
  attribute :sent_time, Common::UTCTime, default: :current_time
  attribute :tracking_number, String, default: :generate_tracking_number
  attribute :applicant, Preneeds::Applicant
  attribute :claimant, Preneeds::Claimant
  attribute :currently_buried_persons, Array[Preneeds::CurrentlyBuriedPerson]
  attribute :veteran, Preneeds::Veteran

  # keeping this name because it matches the previous attribute
  # @return [Boolean]
  #
  # rubocop:disable Naming/PredicateName
  def has_attachments
    preneed_attachments.present?
  end
  # rubocop:enable Naming/PredicateName

  # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment}
  #
  def attachments
    @attachments ||= preneed_attachments.map(&:to_attachment)
  end

  # @return [Time] current UTC time
  #
  def current_time
    Time.now.utc
  end

  # @return [String] randomly generated tracking number
  #
  def generate_tracking_number
    "#{SecureRandom.base64(14).tr('+/=', '0aZ')[0..-3]}VG"
  end

  # Converts object attributes to a hash to be used when constructing a SOAP request body.
  # Hash attributes must correspond to XSD ordering or API call will fail
  #
  # @return [Hash] object attributes and association objects converted to EOAS service compatible hash
  #
  def as_eoas
    hash = {
      applicant: applicant&.as_eoas, applicationStatus: application_status,
      attachments: attachments.map(&:as_eoas),
      claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas),
      hasAttachments: has_attachments, hasCurrentlyBuried: has_currently_buried,
      sendingApplication: sending_application, sendingCode: sending_code || '', sentTime: sent_time.iso8601,
      trackingNumber: tracking_number, veteran: veteran&.as_eoas
    }

    [:currentlyBuriedPersons].each do |key|
      hash.delete(key) if hash[key].blank?
    end

    Common::HashHelpers.deep_compact(hash)
  end

  # @return [Array<String>] array of strings detailing schema validation failures. empty array if form is valid
  #
  def self.validate(schema, form, root = 'application')
    JSON::Validator.fully_validate(schema, { root => form&.as_json }, validate_schema: true)
  end
end

#veteranPreneeds::Veteran

Returns Veteran object. Veteran is the person who is the owner of the benefit.

Returns:

  • (Preneeds::Veteran)

    Veteran object. Veteran is the person who is the owner of the benefit.



36
37
38
39
40
41
42
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
# File 'app/models/preneeds/burial_form.rb', line 36

class BurialForm < Preneeds::Base
  # Preneeds Burial Form official form id
  #
  FORM = '40-10007'

  attribute :application_status, String, default: ''
  attribute :preneed_attachments, Array[PreneedAttachmentHash]
  attribute :has_currently_buried, String
  attribute :sending_application, String, default: 'vets.gov'
  attribute :sending_code, String, default: ''
  attribute :sent_time, Common::UTCTime, default: :current_time
  attribute :tracking_number, String, default: :generate_tracking_number
  attribute :applicant, Preneeds::Applicant
  attribute :claimant, Preneeds::Claimant
  attribute :currently_buried_persons, Array[Preneeds::CurrentlyBuriedPerson]
  attribute :veteran, Preneeds::Veteran

  # keeping this name because it matches the previous attribute
  # @return [Boolean]
  #
  # rubocop:disable Naming/PredicateName
  def has_attachments
    preneed_attachments.present?
  end
  # rubocop:enable Naming/PredicateName

  # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment}
  #
  def attachments
    @attachments ||= preneed_attachments.map(&:to_attachment)
  end

  # @return [Time] current UTC time
  #
  def current_time
    Time.now.utc
  end

  # @return [String] randomly generated tracking number
  #
  def generate_tracking_number
    "#{SecureRandom.base64(14).tr('+/=', '0aZ')[0..-3]}VG"
  end

  # Converts object attributes to a hash to be used when constructing a SOAP request body.
  # Hash attributes must correspond to XSD ordering or API call will fail
  #
  # @return [Hash] object attributes and association objects converted to EOAS service compatible hash
  #
  def as_eoas
    hash = {
      applicant: applicant&.as_eoas, applicationStatus: application_status,
      attachments: attachments.map(&:as_eoas),
      claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas),
      hasAttachments: has_attachments, hasCurrentlyBuried: has_currently_buried,
      sendingApplication: sending_application, sendingCode: sending_code || '', sentTime: sent_time.iso8601,
      trackingNumber: tracking_number, veteran: veteran&.as_eoas
    }

    [:currentlyBuriedPersons].each do |key|
      hash.delete(key) if hash[key].blank?
    end

    Common::HashHelpers.deep_compact(hash)
  end

  # @return [Array<String>] array of strings detailing schema validation failures. empty array if form is valid
  #
  def self.validate(schema, form, root = 'application')
    JSON::Validator.fully_validate(schema, { root => form&.as_json }, validate_schema: true)
  end
end

Class Method Details

.validate(schema, form, root = 'application') ⇒ Array<String>

Returns array of strings detailing schema validation failures. empty array if form is valid.

Returns:

  • (Array<String>)

    array of strings detailing schema validation failures. empty array if form is valid



104
105
106
# File 'app/models/preneeds/burial_form.rb', line 104

def self.validate(schema, form, root = 'application')
  JSON::Validator.fully_validate(schema, { root => form&.as_json }, validate_schema: true)
end

Instance Method Details

#as_eoasHash

Converts object attributes to a hash to be used when constructing a SOAP request body. Hash attributes must correspond to XSD ordering or API call will fail

Returns:

  • (Hash)

    object attributes and association objects converted to EOAS service compatible hash



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'app/models/preneeds/burial_form.rb', line 85

def as_eoas
  hash = {
    applicant: applicant&.as_eoas, applicationStatus: application_status,
    attachments: attachments.map(&:as_eoas),
    claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas),
    hasAttachments: has_attachments, hasCurrentlyBuried: has_currently_buried,
    sendingApplication: sending_application, sendingCode: sending_code || '', sentTime: sent_time.iso8601,
    trackingNumber: tracking_number, veteran: veteran&.as_eoas
  }

  [:currentlyBuriedPersons].each do |key|
    hash.delete(key) if hash[key].blank?
  end

  Common::HashHelpers.deep_compact(hash)
end

#attachmentsArray<Preneeds::Attachment>

Returns #preneed_attachments converted to Array of Attachment.

Returns:



64
65
66
# File 'app/models/preneeds/burial_form.rb', line 64

def attachments
  @attachments ||= preneed_attachments.map(&:to_attachment)
end

#current_timeTime

Returns current UTC time.

Returns:

  • (Time)

    current UTC time



70
71
72
# File 'app/models/preneeds/burial_form.rb', line 70

def current_time
  Time.now.utc
end

#generate_tracking_numberString

Returns randomly generated tracking number.

Returns:

  • (String)

    randomly generated tracking number



76
77
78
# File 'app/models/preneeds/burial_form.rb', line 76

def generate_tracking_number
  "#{SecureRandom.base64(14).tr('+/=', '0aZ')[0..-3]}VG"
end

#has_attachmentsBoolean

keeping this name because it matches the previous attribute rubocop:disable Naming/PredicateName

Returns:

  • (Boolean)


57
58
59
# File 'app/models/preneeds/burial_form.rb', line 57

def has_attachments
  preneed_attachments.present?
end