Class: Preneeds::Applicant

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

Overview

Models an Applicant from a BurialForm form

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#as_json

Methods included from Vets::Model

#attributes, #initialize, #nested_attributes

Methods included from Vets::Attributes

included

Instance Attribute Details

#applicant_emailString

Returns applicant’s email.

Returns:

  • (String)

    applicant’s email

[View on GitHub]

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/preneeds/applicant.rb', line 19

class Applicant < Preneeds::Base
  attribute :applicant_email, String
  attribute :applicant_phone_number, String
  attribute :applicant_relationship_to_claimant, String
  attribute :completing_reason, String, default: 'vets.gov application'

  attribute :mailing_address, Preneeds::Address
  attribute :name, Preneeds::FullName

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    {
      applicantEmail: applicant_email, applicantPhoneNumber: applicant_phone_number,
      applicantRelationshipToClaimant: applicant_relationship_to_claimant,
      completingReason: completing_reason, mailingAddress: mailing_address&.as_eoas,
      name: name&.as_eoas
    }
  end

  # List of permitted params for use with Strong Parameters
  #
  # @return [Array] array of class attributes as symbols
  #
  def self.permitted_params
    [
      :applicant_email, :applicant_phone_number, :applicant_relationship_to_claimant, :completing_reason,
      { mailing_address: Preneeds::Address.permitted_params, name: Preneeds::FullName.permitted_params }
    ]
  end
end

#applicant_phone_numberString

Returns applicant’s phone number.

Returns:

  • (String)

    applicant’s phone number

[View on GitHub]

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/preneeds/applicant.rb', line 19

class Applicant < Preneeds::Base
  attribute :applicant_email, String
  attribute :applicant_phone_number, String
  attribute :applicant_relationship_to_claimant, String
  attribute :completing_reason, String, default: 'vets.gov application'

  attribute :mailing_address, Preneeds::Address
  attribute :name, Preneeds::FullName

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    {
      applicantEmail: applicant_email, applicantPhoneNumber: applicant_phone_number,
      applicantRelationshipToClaimant: applicant_relationship_to_claimant,
      completingReason: completing_reason, mailingAddress: mailing_address&.as_eoas,
      name: name&.as_eoas
    }
  end

  # List of permitted params for use with Strong Parameters
  #
  # @return [Array] array of class attributes as symbols
  #
  def self.permitted_params
    [
      :applicant_email, :applicant_phone_number, :applicant_relationship_to_claimant, :completing_reason,
      { mailing_address: Preneeds::Address.permitted_params, name: Preneeds::FullName.permitted_params }
    ]
  end
end

#applicant_relationship_to_claimantString

Returns applicant’s relationship to claimant.

Returns:

  • (String)

    applicant’s relationship to claimant

[View on GitHub]

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/preneeds/applicant.rb', line 19

class Applicant < Preneeds::Base
  attribute :applicant_email, String
  attribute :applicant_phone_number, String
  attribute :applicant_relationship_to_claimant, String
  attribute :completing_reason, String, default: 'vets.gov application'

  attribute :mailing_address, Preneeds::Address
  attribute :name, Preneeds::FullName

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    {
      applicantEmail: applicant_email, applicantPhoneNumber: applicant_phone_number,
      applicantRelationshipToClaimant: applicant_relationship_to_claimant,
      completingReason: completing_reason, mailingAddress: mailing_address&.as_eoas,
      name: name&.as_eoas
    }
  end

  # List of permitted params for use with Strong Parameters
  #
  # @return [Array] array of class attributes as symbols
  #
  def self.permitted_params
    [
      :applicant_email, :applicant_phone_number, :applicant_relationship_to_claimant, :completing_reason,
      { mailing_address: Preneeds::Address.permitted_params, name: Preneeds::FullName.permitted_params }
    ]
  end
end

#completing_reasonString

Returns completing reason. Currently hard coded.

Returns:

  • (String)

    completing reason. Currently hard coded.

[View on GitHub]

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/preneeds/applicant.rb', line 19

class Applicant < Preneeds::Base
  attribute :applicant_email, String
  attribute :applicant_phone_number, String
  attribute :applicant_relationship_to_claimant, String
  attribute :completing_reason, String, default: 'vets.gov application'

  attribute :mailing_address, Preneeds::Address
  attribute :name, Preneeds::FullName

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    {
      applicantEmail: applicant_email, applicantPhoneNumber: applicant_phone_number,
      applicantRelationshipToClaimant: applicant_relationship_to_claimant,
      completingReason: completing_reason, mailingAddress: mailing_address&.as_eoas,
      name: name&.as_eoas
    }
  end

  # List of permitted params for use with Strong Parameters
  #
  # @return [Array] array of class attributes as symbols
  #
  def self.permitted_params
    [
      :applicant_email, :applicant_phone_number, :applicant_relationship_to_claimant, :completing_reason,
      { mailing_address: Preneeds::Address.permitted_params, name: Preneeds::FullName.permitted_params }
    ]
  end
end

#mailing_addressPreneeds::Address

Returns applicant’s mailing address.

Returns:

[View on GitHub]

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/preneeds/applicant.rb', line 19

class Applicant < Preneeds::Base
  attribute :applicant_email, String
  attribute :applicant_phone_number, String
  attribute :applicant_relationship_to_claimant, String
  attribute :completing_reason, String, default: 'vets.gov application'

  attribute :mailing_address, Preneeds::Address
  attribute :name, Preneeds::FullName

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    {
      applicantEmail: applicant_email, applicantPhoneNumber: applicant_phone_number,
      applicantRelationshipToClaimant: applicant_relationship_to_claimant,
      completingReason: completing_reason, mailingAddress: mailing_address&.as_eoas,
      name: name&.as_eoas
    }
  end

  # List of permitted params for use with Strong Parameters
  #
  # @return [Array] array of class attributes as symbols
  #
  def self.permitted_params
    [
      :applicant_email, :applicant_phone_number, :applicant_relationship_to_claimant, :completing_reason,
      { mailing_address: Preneeds::Address.permitted_params, name: Preneeds::FullName.permitted_params }
    ]
  end
end

#namePreneeds::FullName

Returns applicant’s name.

Returns:

[View on GitHub]

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/preneeds/applicant.rb', line 19

class Applicant < Preneeds::Base
  attribute :applicant_email, String
  attribute :applicant_phone_number, String
  attribute :applicant_relationship_to_claimant, String
  attribute :completing_reason, String, default: 'vets.gov application'

  attribute :mailing_address, Preneeds::Address
  attribute :name, Preneeds::FullName

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    {
      applicantEmail: applicant_email, applicantPhoneNumber: applicant_phone_number,
      applicantRelationshipToClaimant: applicant_relationship_to_claimant,
      completingReason: completing_reason, mailingAddress: mailing_address&.as_eoas,
      name: name&.as_eoas
    }
  end

  # List of permitted params for use with Strong Parameters
  #
  # @return [Array] array of class attributes as symbols
  #
  def self.permitted_params
    [
      :applicant_email, :applicant_phone_number, :applicant_relationship_to_claimant, :completing_reason,
      { mailing_address: Preneeds::Address.permitted_params, name: Preneeds::FullName.permitted_params }
    ]
  end
end

Class Method Details

.permitted_paramsArray

List of permitted params for use with Strong Parameters

Returns:

  • (Array)

    array of class attributes as symbols

[View source] [View on GitHub]

43
44
45
46
47
48
# File 'app/models/preneeds/applicant.rb', line 43

def self.permitted_params
  [
    :applicant_email, :applicant_phone_number, :applicant_relationship_to_claimant, :completing_reason,
    { mailing_address: Preneeds::Address.permitted_params, name: Preneeds::FullName.permitted_params }
  ]
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

[View source] [View on GitHub]

30
31
32
33
34
35
36
37
# File 'app/models/preneeds/applicant.rb', line 30

def as_eoas
  {
    applicantEmail: applicant_email, applicantPhoneNumber: applicant_phone_number,
    applicantRelationshipToClaimant: applicant_relationship_to_claimant,
    completingReason: completing_reason, mailingAddress: mailing_address&.as_eoas,
    name: name&.as_eoas
  }
end