Class: Preneeds::Claimant

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

Overview

Models an Claimant 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

#addressPreneeds::Address

Returns claimant’s address.

Returns:



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
50
51
52
53
54
55
# File 'app/models/preneeds/claimant.rb', line 23

class Claimant < Preneeds::Base
  attribute :date_of_birth, String
  attribute :desired_cemetery, String
  attribute :email, String
  attribute :phone_number, String
  attribute :relationship_to_vet, String
  attribute :ssn, String

  attribute :name, Preneeds::FullName
  attribute :address, Preneeds::Address

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      address: address&.as_eoas, dateOfBirth: date_of_birth, desiredCemetery: desired_cemetery,
      email:, name: name&.as_eoas, phoneNumber: phone_number,
      relationshipToVet: relationship_to_vet, ssn:
    }

    %i[email phoneNumber desiredCemetery].each { |key| hash.delete(key) if hash[key].blank? }
    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    [
      :date_of_birth, :desired_cemetery, :email, :completing_reason, :phone_number, :relationship_to_vet, :ssn,
      { address: Preneeds::Address.permitted_params, name: Preneeds::FullName.permitted_params }
    ]
  end
end

#date_of_birthString

Returns claimant date of birth.

Returns:

  • (String)

    claimant date of birth



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
50
51
52
53
54
55
# File 'app/models/preneeds/claimant.rb', line 23

class Claimant < Preneeds::Base
  attribute :date_of_birth, String
  attribute :desired_cemetery, String
  attribute :email, String
  attribute :phone_number, String
  attribute :relationship_to_vet, String
  attribute :ssn, String

  attribute :name, Preneeds::FullName
  attribute :address, Preneeds::Address

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      address: address&.as_eoas, dateOfBirth: date_of_birth, desiredCemetery: desired_cemetery,
      email:, name: name&.as_eoas, phoneNumber: phone_number,
      relationshipToVet: relationship_to_vet, ssn:
    }

    %i[email phoneNumber desiredCemetery].each { |key| hash.delete(key) if hash[key].blank? }
    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    [
      :date_of_birth, :desired_cemetery, :email, :completing_reason, :phone_number, :relationship_to_vet, :ssn,
      { address: Preneeds::Address.permitted_params, name: Preneeds::FullName.permitted_params }
    ]
  end
end

#desired_cemeteryString

Returns cemetery number.

Returns:

  • (String)

    cemetery number



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
50
51
52
53
54
55
# File 'app/models/preneeds/claimant.rb', line 23

class Claimant < Preneeds::Base
  attribute :date_of_birth, String
  attribute :desired_cemetery, String
  attribute :email, String
  attribute :phone_number, String
  attribute :relationship_to_vet, String
  attribute :ssn, String

  attribute :name, Preneeds::FullName
  attribute :address, Preneeds::Address

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      address: address&.as_eoas, dateOfBirth: date_of_birth, desiredCemetery: desired_cemetery,
      email:, name: name&.as_eoas, phoneNumber: phone_number,
      relationshipToVet: relationship_to_vet, ssn:
    }

    %i[email phoneNumber desiredCemetery].each { |key| hash.delete(key) if hash[key].blank? }
    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    [
      :date_of_birth, :desired_cemetery, :email, :completing_reason, :phone_number, :relationship_to_vet, :ssn,
      { address: Preneeds::Address.permitted_params, name: Preneeds::FullName.permitted_params }
    ]
  end
end

#emailString

Returns claimant email.

Returns:

  • (String)

    claimant email



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
50
51
52
53
54
55
# File 'app/models/preneeds/claimant.rb', line 23

class Claimant < Preneeds::Base
  attribute :date_of_birth, String
  attribute :desired_cemetery, String
  attribute :email, String
  attribute :phone_number, String
  attribute :relationship_to_vet, String
  attribute :ssn, String

  attribute :name, Preneeds::FullName
  attribute :address, Preneeds::Address

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      address: address&.as_eoas, dateOfBirth: date_of_birth, desiredCemetery: desired_cemetery,
      email:, name: name&.as_eoas, phoneNumber: phone_number,
      relationshipToVet: relationship_to_vet, ssn:
    }

    %i[email phoneNumber desiredCemetery].each { |key| hash.delete(key) if hash[key].blank? }
    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    [
      :date_of_birth, :desired_cemetery, :email, :completing_reason, :phone_number, :relationship_to_vet, :ssn,
      { address: Preneeds::Address.permitted_params, name: Preneeds::FullName.permitted_params }
    ]
  end
end

#namePreneeds::FullName

Returns claimant’s full name.

Returns:



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
50
51
52
53
54
55
# File 'app/models/preneeds/claimant.rb', line 23

class Claimant < Preneeds::Base
  attribute :date_of_birth, String
  attribute :desired_cemetery, String
  attribute :email, String
  attribute :phone_number, String
  attribute :relationship_to_vet, String
  attribute :ssn, String

  attribute :name, Preneeds::FullName
  attribute :address, Preneeds::Address

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      address: address&.as_eoas, dateOfBirth: date_of_birth, desiredCemetery: desired_cemetery,
      email:, name: name&.as_eoas, phoneNumber: phone_number,
      relationshipToVet: relationship_to_vet, ssn:
    }

    %i[email phoneNumber desiredCemetery].each { |key| hash.delete(key) if hash[key].blank? }
    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    [
      :date_of_birth, :desired_cemetery, :email, :completing_reason, :phone_number, :relationship_to_vet, :ssn,
      { address: Preneeds::Address.permitted_params, name: Preneeds::FullName.permitted_params }
    ]
  end
end

#phone_numberString

Returns claimant phone number.

Returns:

  • (String)

    claimant phone number



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
50
51
52
53
54
55
# File 'app/models/preneeds/claimant.rb', line 23

class Claimant < Preneeds::Base
  attribute :date_of_birth, String
  attribute :desired_cemetery, String
  attribute :email, String
  attribute :phone_number, String
  attribute :relationship_to_vet, String
  attribute :ssn, String

  attribute :name, Preneeds::FullName
  attribute :address, Preneeds::Address

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      address: address&.as_eoas, dateOfBirth: date_of_birth, desiredCemetery: desired_cemetery,
      email:, name: name&.as_eoas, phoneNumber: phone_number,
      relationshipToVet: relationship_to_vet, ssn:
    }

    %i[email phoneNumber desiredCemetery].each { |key| hash.delete(key) if hash[key].blank? }
    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    [
      :date_of_birth, :desired_cemetery, :email, :completing_reason, :phone_number, :relationship_to_vet, :ssn,
      { address: Preneeds::Address.permitted_params, name: Preneeds::FullName.permitted_params }
    ]
  end
end

#relationship_to_vetString

Returns code representing claimant’s relationship to servicemember; one of ‘1’, ‘2’, ‘3’, or ‘4’.

Returns:

  • (String)

    code representing claimant’s relationship to servicemember; one of ‘1’, ‘2’, ‘3’, or ‘4’



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
50
51
52
53
54
55
# File 'app/models/preneeds/claimant.rb', line 23

class Claimant < Preneeds::Base
  attribute :date_of_birth, String
  attribute :desired_cemetery, String
  attribute :email, String
  attribute :phone_number, String
  attribute :relationship_to_vet, String
  attribute :ssn, String

  attribute :name, Preneeds::FullName
  attribute :address, Preneeds::Address

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      address: address&.as_eoas, dateOfBirth: date_of_birth, desiredCemetery: desired_cemetery,
      email:, name: name&.as_eoas, phoneNumber: phone_number,
      relationshipToVet: relationship_to_vet, ssn:
    }

    %i[email phoneNumber desiredCemetery].each { |key| hash.delete(key) if hash[key].blank? }
    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    [
      :date_of_birth, :desired_cemetery, :email, :completing_reason, :phone_number, :relationship_to_vet, :ssn,
      { address: Preneeds::Address.permitted_params, name: Preneeds::FullName.permitted_params }
    ]
  end
end

#ssnString

Returns claimant’s social security number.

Returns:

  • (String)

    claimant’s social security number



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
50
51
52
53
54
55
# File 'app/models/preneeds/claimant.rb', line 23

class Claimant < Preneeds::Base
  attribute :date_of_birth, String
  attribute :desired_cemetery, String
  attribute :email, String
  attribute :phone_number, String
  attribute :relationship_to_vet, String
  attribute :ssn, String

  attribute :name, Preneeds::FullName
  attribute :address, Preneeds::Address

  # (see Preneeds::BurialForm#as_eoas)
  #
  def as_eoas
    hash = {
      address: address&.as_eoas, dateOfBirth: date_of_birth, desiredCemetery: desired_cemetery,
      email:, name: name&.as_eoas, phoneNumber: phone_number,
      relationshipToVet: relationship_to_vet, ssn:
    }

    %i[email phoneNumber desiredCemetery].each { |key| hash.delete(key) if hash[key].blank? }
    hash
  end

  # (see Preneeds::Applicant.permitted_params)
  #
  def self.permitted_params
    [
      :date_of_birth, :desired_cemetery, :email, :completing_reason, :phone_number, :relationship_to_vet, :ssn,
      { 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



49
50
51
52
53
54
# File 'app/models/preneeds/claimant.rb', line 49

def self.permitted_params
  [
    :date_of_birth, :desired_cemetery, :email, :completing_reason, :phone_number, :relationship_to_vet, :ssn,
    { 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



36
37
38
39
40
41
42
43
44
45
# File 'app/models/preneeds/claimant.rb', line 36

def as_eoas
  hash = {
    address: address&.as_eoas, dateOfBirth: date_of_birth, desiredCemetery: desired_cemetery,
    email:, name: name&.as_eoas, phoneNumber: phone_number,
    relationshipToVet: relationship_to_vet, ssn:
  }

  %i[email phoneNumber desiredCemetery].each { |key| hash.delete(key) if hash[key].blank? }
  hash
end