Class: VAProfile::Models::GenderIdentity

Inherits:
Base
  • Object
show all
Includes:
Concerns::Defaultable
Defined in:
lib/va_profile/models/gender_identity.rb

Constant Summary collapse

CODES =
%w[M F TM TF B N O].freeze
OPTIONS =
{
  'M' => 'Man',
  'B' => 'Non-binary',
  'TM' => 'Transgender man',
  'TF' => 'Transgender woman',
  'F' => 'Woman',
  'N' => 'Prefer not to answer',
  'O' => 'A gender not listed here'
}.freeze

Constants inherited from Base

Base::SOURCE_SYSTEM

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Concerns::Defaultable

#set_defaults

Class Method Details

.build_from(body) ⇒ VAProfile::Models::GenderIdentity

Converts a decoded JSON response from VAProfile to an instance of the GenderIdentity model

Parameters:

  • body (Hash)

    the decoded response body from VAProfile

Returns:



56
57
58
59
60
61
62
63
# File 'lib/va_profile/models/gender_identity.rb', line 56

def self.build_from(body)
  return nil unless body

  VAProfile::Models::GenderIdentity.new(
    code: body['gender_identity_code'],
    name: body['gender_identity_name']
  )
end

Instance Method Details

#code=(val) ⇒ Object



31
32
33
34
# File 'lib/va_profile/models/gender_identity.rb', line 31

def code=(val)
  @code = val
  @name = OPTIONS[@code]
end

#in_jsonString

Converts an instance of the GenderIdentity model to a JSON encoded string suitable for use in the body of a request to VAProfile

Returns:

  • (String)

    JSON-encoded string suitable for requests to VAProfile



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/va_profile/models/gender_identity.rb', line 40

def in_json
  {
    bio: {
      genderIdentity: [
        genderIdentityCode: @code
      ],
      sourceDate: @source_date,
      originatingSourceSystem: SOURCE_SYSTEM,
      sourceSystemUser: @source_system_user
    }
  }.to_json
end