Class: VAProfile::Models::PreferredName

Inherits:
Base
  • Object
show all
Includes:
ActiveModel::Validations::Callbacks, 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:



44
45
46
47
48
49
50
# File 'lib/va_profile/models/preferred_name.rb', line 44

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



30
31
32
33
34
35
36
37
38
39
# File 'lib/va_profile/models/preferred_name.rb', line 30

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

#strip_blanksObject (protected)



54
55
56
# File 'lib/va_profile/models/preferred_name.rb', line 54

def strip_blanks
  self.text = text.strip if text
end