Class: VAProfile::Models::Telephone
- Includes:
- Concerns::Defaultable, Concerns::Expirable
- Defined in:
- lib/va_profile/models/telephone.rb
Constant Summary collapse
- VALID_AREA_CODE_REGEX =
/[0-9]+/
- VALID_PHONE_NUMBER_REGEX =
/[^a-zA-Z]+/
- MOBILE =
'MOBILE'
- HOME =
'HOME'
- WORK =
'WORK'
- FAX =
'FAX'
- TEMPORARY =
'TEMPORARY'
- PHONE_TYPES =
[MOBILE, HOME, WORK, FAX, TEMPORARY].freeze
Constants inherited from Base
Class Method Summary collapse
-
.build_from(body) ⇒ VAProfile::Models::Telephone
Converts a decoded JSON response from VAProfile to an instance of the Telephone model.
Instance Method Summary collapse
- #formatted_phone ⇒ Object
-
#in_json ⇒ String
Converts an instance of the Telphone model to a JSON encoded string suitable for use in the body of a request to VAProfile.
-
#in_json_v2 ⇒ Object
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::Telephone
Converts a decoded JSON response from VAProfile to an instance of the Telephone model
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/va_profile/models/telephone.rb', line 152 def self.build_from(body) # rubocop:disable Metrics/MethodLength VAProfile::Models::Telephone.new( area_code: body['area_code'], country_code: body['country_code'], created_at: body['create_date'], extension: body['phone_number_ext'], id: body['telephone_id'], is_international: body['international_indicator'], is_textable: body['text_message_capable_ind'], is_text_permitted: body['text_message_perm_ind'], is_voicemailable: body['voice_mail_acceptable_ind'], phone_number: body['phone_number'], phone_type: body['phone_type'], source_date: body['source_date'], transaction_id: body['tx_audit_id'], is_tty: body['tty_ind'], updated_at: body['update_date'], vet360_id: body['vet360_id'] || body['va_profile_id'], va_profile_id: body['va_profile_id'] || body['vet360_id'], effective_end_date: body['effective_end_date'], effective_start_date: body['effective_start_date'] ) end |
Instance Method Details
#formatted_phone ⇒ Object
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/va_profile/models/telephone.rb', line 83 def formatted_phone return if phone_number.blank? # TODO: support international numbers return_val = "(#{area_code}) #{phone_number[0..2]}-#{phone_number[3..7]}" return_val += " Ext. #{extension}" if extension.present? return_val end |
#in_json ⇒ String
Converts an instance of the Telphone model to a JSON encoded string suitable for use in the body of a request to VAProfile
rubocop:disable Metrics/MethodLength
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/va_profile/models/telephone.rb', line 100 def in_json { bio: { areaCode: @area_code, countryCode: @country_code, internationalIndicator: @is_international, originatingSourceSystem: SOURCE_SYSTEM, phoneNumber: @phone_number, phoneNumberExt: @extension, phoneType: @phone_type, sourceDate: @source_date, sourceSystemUser: @source_system_user, telephoneId: @id, textMessageCapableInd: @is_textable, textMessagePermInd: @is_text_permitted, ttyInd: @is_tty, vet360Id: @vet360_id || @vaProfileId, voiceMailAcceptableInd: @is_voicemailable, effectiveStartDate: @effective_start_date, effectiveEndDate: @effective_end_date } }.to_json end |
#in_json_v2 ⇒ Object
in_json_v2 will replace in_json when Contact Information V1 Service has depreciated
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/va_profile/models/telephone.rb', line 125 def in_json_v2 { bio: { areaCode: @area_code, countryCode: @country_code, internationalIndicator: @is_international, originatingSourceSystem: SOURCE_SYSTEM, phoneNumber: @phone_number, phoneNumberExt: @extension, phoneType: @phone_type, sourceDate: @source_date, sourceSystemUser: @source_system_user, telephoneId: @id, textMessageCapableInd: @is_textable, textMessagePermInd: @is_text_permitted, ttyInd: @is_tty, voiceMailAcceptableInd: @is_voicemailable, effectiveStartDate: @effective_start_date, effectiveEndDate: @effective_end_date } }.to_json end |