Class: Preneeds::BurialForm
- 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
-
#applicant ⇒ Preneeds::Applicant
Applicant object.
-
#application_status ⇒ String
Currently always blank.
-
#claimant ⇒ Preneeds::Claimant
Claimant object.
-
#currently_buried_persons ⇒ Array<Preneeds::CurrentlyBuriedPerson>
CurrentlyBuriedPerson objects representing individuals burried in VA national cemeteries under the sponsor’s eligibility.
-
#has_currently_buried ⇒ String
‘1’ for Yes, ‘2’ for No, ‘3’ for Don’t know.
-
#preneed_attachments ⇒ Array<PreneedAttachmentHash>
Documents provided by the end user.
-
#sending_application ⇒ String
Hard coded as ‘va.gov’.
-
#sending_code ⇒ String
Currently always blank.
-
#sent_time ⇒ Time
Current time.
-
#tracking_number ⇒ String
SecureRandom generated tracking number sent with submission to EOAS.
-
#veteran ⇒ Preneeds::Veteran
Veteran object.
Class Method Summary collapse
-
.validate(schema, form, root = 'application') ⇒ Array<String>
Array of strings detailing schema validation failures.
Instance Method Summary collapse
-
#as_eoas ⇒ Hash
Converts object attributes to a hash to be used when constructing a SOAP request body.
-
#attachments ⇒ Array<Preneeds::Attachment>
#preneed_attachments converted to Array of Attachment.
-
#current_time ⇒ Time
Current UTC time.
-
#generate_tracking_number ⇒ String
Randomly generated tracking number.
-
#has_attachments ⇒ Boolean
keeping this name because it matches the previous attribute rubocop:disable Naming/PredicateName.
Methods inherited from Base
Methods included from Vets::Model
#attributes, #initialize, #nested_attributes
Methods included from Vets::Attributes
Instance Attribute Details
#applicant ⇒ Preneeds::Applicant
Returns Applicant object. Applicant is person filling out the form.
34 35 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 |
# File 'app/models/preneeds/burial_form.rb', line 34 class BurialForm < Preneeds::Base # Preneeds Burial Form official form id # FORM = '40-10007' attribute :application_status, String, default: '' attribute :preneed_attachments, PreneedAttachmentHash, array: true 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, Preneeds::CurrentlyBuriedPerson, array: true attribute :veteran, Preneeds::Veteran # keeping this name because it matches the previous attribute # @return [Boolean] # # rubocop:disable Naming/PredicateName def .present? end # rubocop:enable Naming/PredicateName # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment} # def @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: .map(&:as_eoas), claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas), hasAttachments: , 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_status ⇒ String
Returns currently always blank.
34 35 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 |
# File 'app/models/preneeds/burial_form.rb', line 34 class BurialForm < Preneeds::Base # Preneeds Burial Form official form id # FORM = '40-10007' attribute :application_status, String, default: '' attribute :preneed_attachments, PreneedAttachmentHash, array: true 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, Preneeds::CurrentlyBuriedPerson, array: true attribute :veteran, Preneeds::Veteran # keeping this name because it matches the previous attribute # @return [Boolean] # # rubocop:disable Naming/PredicateName def .present? end # rubocop:enable Naming/PredicateName # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment} # def @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: .map(&:as_eoas), claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas), hasAttachments: , 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 |
#claimant ⇒ Preneeds::Claimant
Returns Claimant object. Claimant is the person applying for the benefit (veteran or relative).
34 35 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 |
# File 'app/models/preneeds/burial_form.rb', line 34 class BurialForm < Preneeds::Base # Preneeds Burial Form official form id # FORM = '40-10007' attribute :application_status, String, default: '' attribute :preneed_attachments, PreneedAttachmentHash, array: true 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, Preneeds::CurrentlyBuriedPerson, array: true attribute :veteran, Preneeds::Veteran # keeping this name because it matches the previous attribute # @return [Boolean] # # rubocop:disable Naming/PredicateName def .present? end # rubocop:enable Naming/PredicateName # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment} # def @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: .map(&:as_eoas), claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas), hasAttachments: , 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_persons ⇒ Array<Preneeds::CurrentlyBuriedPerson>
Returns CurrentlyBuriedPerson objects representing individuals burried in VA national cemeteries under the sponsor’s eligibility.
34 35 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 |
# File 'app/models/preneeds/burial_form.rb', line 34 class BurialForm < Preneeds::Base # Preneeds Burial Form official form id # FORM = '40-10007' attribute :application_status, String, default: '' attribute :preneed_attachments, PreneedAttachmentHash, array: true 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, Preneeds::CurrentlyBuriedPerson, array: true attribute :veteran, Preneeds::Veteran # keeping this name because it matches the previous attribute # @return [Boolean] # # rubocop:disable Naming/PredicateName def .present? end # rubocop:enable Naming/PredicateName # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment} # def @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: .map(&:as_eoas), claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas), hasAttachments: , 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_buried ⇒ String
Returns ‘1’ for Yes, ‘2’ for No, ‘3’ for Don’t know.
34 35 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 |
# File 'app/models/preneeds/burial_form.rb', line 34 class BurialForm < Preneeds::Base # Preneeds Burial Form official form id # FORM = '40-10007' attribute :application_status, String, default: '' attribute :preneed_attachments, PreneedAttachmentHash, array: true 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, Preneeds::CurrentlyBuriedPerson, array: true attribute :veteran, Preneeds::Veteran # keeping this name because it matches the previous attribute # @return [Boolean] # # rubocop:disable Naming/PredicateName def .present? end # rubocop:enable Naming/PredicateName # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment} # def @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: .map(&:as_eoas), claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas), hasAttachments: , 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_attachments ⇒ Array<PreneedAttachmentHash>
Returns documents provided by the end user.
34 35 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 |
# File 'app/models/preneeds/burial_form.rb', line 34 class BurialForm < Preneeds::Base # Preneeds Burial Form official form id # FORM = '40-10007' attribute :application_status, String, default: '' attribute :preneed_attachments, PreneedAttachmentHash, array: true 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, Preneeds::CurrentlyBuriedPerson, array: true attribute :veteran, Preneeds::Veteran # keeping this name because it matches the previous attribute # @return [Boolean] # # rubocop:disable Naming/PredicateName def .present? end # rubocop:enable Naming/PredicateName # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment} # def @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: .map(&:as_eoas), claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas), hasAttachments: , 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_application ⇒ String
Returns hard coded as ‘va.gov’.
34 35 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 |
# File 'app/models/preneeds/burial_form.rb', line 34 class BurialForm < Preneeds::Base # Preneeds Burial Form official form id # FORM = '40-10007' attribute :application_status, String, default: '' attribute :preneed_attachments, PreneedAttachmentHash, array: true 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, Preneeds::CurrentlyBuriedPerson, array: true attribute :veteran, Preneeds::Veteran # keeping this name because it matches the previous attribute # @return [Boolean] # # rubocop:disable Naming/PredicateName def .present? end # rubocop:enable Naming/PredicateName # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment} # def @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: .map(&:as_eoas), claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas), hasAttachments: , 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_code ⇒ String
Returns currently always blank.
34 35 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 |
# File 'app/models/preneeds/burial_form.rb', line 34 class BurialForm < Preneeds::Base # Preneeds Burial Form official form id # FORM = '40-10007' attribute :application_status, String, default: '' attribute :preneed_attachments, PreneedAttachmentHash, array: true 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, Preneeds::CurrentlyBuriedPerson, array: true attribute :veteran, Preneeds::Veteran # keeping this name because it matches the previous attribute # @return [Boolean] # # rubocop:disable Naming/PredicateName def .present? end # rubocop:enable Naming/PredicateName # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment} # def @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: .map(&:as_eoas), claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas), hasAttachments: , 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_time ⇒ Time
Returns current time.
34 35 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 |
# File 'app/models/preneeds/burial_form.rb', line 34 class BurialForm < Preneeds::Base # Preneeds Burial Form official form id # FORM = '40-10007' attribute :application_status, String, default: '' attribute :preneed_attachments, PreneedAttachmentHash, array: true 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, Preneeds::CurrentlyBuriedPerson, array: true attribute :veteran, Preneeds::Veteran # keeping this name because it matches the previous attribute # @return [Boolean] # # rubocop:disable Naming/PredicateName def .present? end # rubocop:enable Naming/PredicateName # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment} # def @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: .map(&:as_eoas), claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas), hasAttachments: , 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_number ⇒ String
Returns SecureRandom generated tracking number sent with submission to EOAS.
34 35 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 |
# File 'app/models/preneeds/burial_form.rb', line 34 class BurialForm < Preneeds::Base # Preneeds Burial Form official form id # FORM = '40-10007' attribute :application_status, String, default: '' attribute :preneed_attachments, PreneedAttachmentHash, array: true 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, Preneeds::CurrentlyBuriedPerson, array: true attribute :veteran, Preneeds::Veteran # keeping this name because it matches the previous attribute # @return [Boolean] # # rubocop:disable Naming/PredicateName def .present? end # rubocop:enable Naming/PredicateName # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment} # def @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: .map(&:as_eoas), claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas), hasAttachments: , 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 |
#veteran ⇒ Preneeds::Veteran
Returns Veteran object. Veteran is the person who is the owner of the benefit.
34 35 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 |
# File 'app/models/preneeds/burial_form.rb', line 34 class BurialForm < Preneeds::Base # Preneeds Burial Form official form id # FORM = '40-10007' attribute :application_status, String, default: '' attribute :preneed_attachments, PreneedAttachmentHash, array: true 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, Preneeds::CurrentlyBuriedPerson, array: true attribute :veteran, Preneeds::Veteran # keeping this name because it matches the previous attribute # @return [Boolean] # # rubocop:disable Naming/PredicateName def .present? end # rubocop:enable Naming/PredicateName # @return [Array<Preneeds::Attachment>] #preneed_attachments converted to Array of {Preneeds::Attachment} # def @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: .map(&:as_eoas), claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas), hasAttachments: , 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.
102 103 104 |
# File 'app/models/preneeds/burial_form.rb', line 102 def self.validate(schema, form, root = 'application') JSON::Validator.fully_validate(schema, { root => form&.as_json }, validate_schema: true) end |
Instance Method Details
#as_eoas ⇒ Hash
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
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'app/models/preneeds/burial_form.rb', line 83 def as_eoas hash = { applicant: applicant&.as_eoas, applicationStatus: application_status, attachments: .map(&:as_eoas), claimant: claimant&.as_eoas, currentlyBuriedPersons: currently_buried_persons.map(&:as_eoas), hasAttachments: , 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 |
#attachments ⇒ Array<Preneeds::Attachment>
Returns #preneed_attachments converted to Array of Attachment.
62 63 64 |
# File 'app/models/preneeds/burial_form.rb', line 62 def @attachments ||= .map(&:to_attachment) end |
#current_time ⇒ Time
Returns current UTC time.
68 69 70 |
# File 'app/models/preneeds/burial_form.rb', line 68 def current_time Time.now.utc end |
#generate_tracking_number ⇒ String
Returns randomly generated tracking number.
74 75 76 |
# File 'app/models/preneeds/burial_form.rb', line 74 def generate_tracking_number "#{SecureRandom.base64(14).tr('+/=', '0aZ')[0..-3]}VG" end |
#has_attachments ⇒ Boolean
keeping this name because it matches the previous attribute rubocop:disable Naming/PredicateName
55 56 57 |
# File 'app/models/preneeds/burial_form.rb', line 55 def .present? end |