Class: VAProfile::Models::Email

Inherits:
Base
  • Object
show all
Includes:
Concerns::Defaultable, Concerns::Expirable
Defined in:
lib/va_profile/models/email.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::Email

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

Parameters:

  • body (Hash)

    the decoded response body from VAProfile

Returns:



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/va_profile/models/email.rb', line 54

def self.build_from(body)
  VAProfile::Models::Email.new(
    created_at: body['create_date'],
    email_address: body['email_address_text'],
    effective_end_date: body['effective_end_date'],
    effective_start_date: body['effective_start_date'],
    id: body['email_id'],
    source_date: body['source_date'],
    transaction_id: body['tx_audit_id'],
    updated_at: body['update_date'],
    vet360_id: body['vet360_id']
  )
end

Instance Method Details

#in_jsonString

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



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/va_profile/models/email.rb', line 36

def in_json
  {
    bio: {
      emailAddressText: @email_address,
      emailId: @id,
      originatingSourceSystem: SOURCE_SYSTEM,
      sourceSystemUser: @source_system_user,
      sourceDate: @source_date,
      vet360Id: @vet360_id,
      effectiveStartDate: @effective_start_date,
      effectiveEndDate: @effective_end_date
    }
  }.to_json
end