Class: VAProfile::Models::Email
- Includes:
- Concerns::Defaultable, Concerns::Expirable
- Defined in:
- lib/va_profile/models/email.rb
Constant Summary collapse
- VALID_EMAIL_REGEX =
/.+@.+\..+/i
Constants inherited from Base
Class Method Summary collapse
-
.build_from(body) ⇒ VAProfile::Models::Email
Converts a decoded JSON response from VAProfile to an instance of the Email model.
Instance Method Summary collapse
-
#in_json ⇒ String
Converts an instance of the Email model to a JSON encoded string suitable for use in the body of a request to VAProfile.
-
#in_json_v2 ⇒ Object
Contact Information V2 requests do not need the vet360Id in_json_v2 will replace in_json when Contact Information V1 Service has depreciated.
Methods included from Concerns::Expirable
#effective_end_date_has_passed
Methods included from Concerns::Defaultable
Class Method Details
.build_from(body) ⇒ VAProfile::Models::Email
Converts a decoded JSON response from VAProfile to an instance of the Email model
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/va_profile/models/email.rb', line 71 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'] || body['va_profile_id'], va_profile_id: body['va_profile_id'] || body['vet360_id'] ) end |
Instance Method Details
#in_json ⇒ String
Converts an instance of the Email model to a JSON encoded string suitable for use in the body of a request to VAProfile
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/va_profile/models/email.rb', line 37 def in_json { bio: { emailAddressText: @email_address, emailId: @id, originatingSourceSystem: SOURCE_SYSTEM, sourceSystemUser: @source_system_user, sourceDate: @source_date, vet360Id: @vet360_id || @vaProfileId, effectiveStartDate: @effective_start_date, effectiveEndDate: @effective_end_date } }.to_json end |
#in_json_v2 ⇒ Object
Contact Information V2 requests do not need the vet360Id in_json_v2 will replace in_json when Contact Information V1 Service has depreciated
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/va_profile/models/email.rb', line 54 def in_json_v2 { bio: { emailAddressText: @email_address, emailId: @id, originatingSourceSystem: SOURCE_SYSTEM, sourceSystemUser: @source_system_user, sourceDate: @source_date, effectiveStartDate: @effective_start_date, effectiveEndDate: @effective_end_date } }.to_json end |