Class: VAProfile::Models::PreferredName

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

Constant Summary

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::PreferredName

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

Parameters:

  • body (Hash)

    the decoded response body from VAProfile

Returns:



41
42
43
44
45
46
47
# File 'lib/va_profile/models/preferred_name.rb', line 41

def self.build_from(body)
  return nil unless body

  VAProfile::Models::PreferredName.new(
    text: body['preferred_name']
  )
end

Instance Method Details

#in_jsonString

Converts an instance of the PreferredName 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



27
28
29
30
31
32
33
34
35
36
# File 'lib/va_profile/models/preferred_name.rb', line 27

def in_json
  {
    bio: {
      preferredName: @text,
      originatingSourceSystem: SOURCE_SYSTEM,
      sourceDate: @source_date,
      sourceSystemUser: @source_system_user
    }
  }.to_json
end