Class: VAProfileRedis::ContactInformation
- Inherits:
-
Common::RedisStore
- Object
- Common::RedisStore
- VAProfileRedis::ContactInformation
- Includes:
- Common::CacheAside
- Defined in:
- app/models/va_profile_redis/contact_information.rb
Overview
Facade for VAProfile::ContactInformation::Service. The user_serializer delegates to this class through the User model.
When a person is requested from the serializer, it returns either a cached response in Redis or from the VAProfile::ContactInformation::Service.
Constant Summary
Constants inherited from Common::RedisStore
Common::RedisStore::REQ_CLASS_INSTANCE_VARS
Instance Attribute Summary collapse
-
#user ⇒ User
The user being queried in VA Profile.
Class Method Summary collapse
Instance Method Summary collapse
-
#email ⇒ VAProfile::Models::Email
Returns the user’s email model.
-
#fax_number ⇒ VAProfile::Models::Telephone
Returns the user’s fax number.
-
#home_phone ⇒ VAProfile::Models::Telephone
Returns the user’s home phone.
-
#mailing_address ⇒ VAProfile::Models::Address
Returns the user’s mailing address.
-
#mobile_phone ⇒ VAProfile::Models::Telephone
Returns the user’s mobile phone.
-
#populate_from_redis ⇒ Object
This method allows us to populate the local instance of a VAProfileRedis::ContactInformation object with the uuid necessary to perform subsequent actions on the key such as deletion.
-
#residential_address ⇒ VAProfile::Models::Address
Returns the user’s residence.
-
#response ⇒ VAProfile::ContactInformation::PersonResponse
the redis cache.
-
#status ⇒ Integer <> String
The status of the last VAProfile::ContactInformation::Service response, or not authorized for for users < LOA 3.
-
#temporary_phone ⇒ VAProfile::Models::Telephone
Returns the user’s temporary phone.
-
#text_permission ⇒ VAProfile::Models::Permission
Returns the user’s text permission.
-
#work_phone ⇒ VAProfile::Models::Telephone
Returns the user’s work phone.
Methods included from Common::CacheAside
#cache, #cached?, #do_cached_with
Methods inherited from Common::RedisStore
create, delete, #destroy, #destroyed?, exists?, #expire, find, find_or_build, #initialize, #initialize_dup, keys, #persisted?, pop, redis_key, redis_store, redis_ttl, #save, #save!, #ttl, #update, #update!
Constructor Details
This class inherits a constructor from Common::RedisStore
Instance Attribute Details
#user ⇒ User
Returns the user being queried in VA Profile.
28 29 30 |
# File 'app/models/va_profile_redis/contact_information.rb', line 28 def user @user end |
Class Method Details
.for_user(user) ⇒ Object
30 31 32 33 34 35 36 |
# File 'app/models/va_profile_redis/contact_information.rb', line 30 def self.for_user(user) contact_info = new contact_info.user = user contact_info.populate_from_redis contact_info end |
Instance Method Details
#email ⇒ VAProfile::Models::Email
Returns the user’s email model. In VA Profile, a user can only have one email address.
43 44 45 46 47 |
# File 'app/models/va_profile_redis/contact_information.rb', line 43 def email return unless @user.loa3? value_for('emails')&.first end |
#fax_number ⇒ VAProfile::Models::Telephone
Returns the user’s fax number. In VA Profile, a user can only have one fax number.
120 121 122 123 124 |
# File 'app/models/va_profile_redis/contact_information.rb', line 120 def fax_number return unless @user.loa3? dig_out('telephones', 'phone_type', VAProfile::Models::Telephone::FAX) end |
#home_phone ⇒ VAProfile::Models::Telephone
Returns the user’s home phone. In VA Profile, a user can only have one home phone.
76 77 78 79 80 |
# File 'app/models/va_profile_redis/contact_information.rb', line 76 def home_phone return unless @user.loa3? dig_out('telephones', 'phone_type', VAProfile::Models::Telephone::HOME) end |
#mailing_address ⇒ VAProfile::Models::Address
Returns the user’s mailing address. In VA Profile, a user can only have one mailing address.
65 66 67 68 69 |
# File 'app/models/va_profile_redis/contact_information.rb', line 65 def mailing_address return unless @user.loa3? dig_out('addresses', 'address_pou', VAProfile::Models::Address::CORRESPONDENCE) end |
#mobile_phone ⇒ VAProfile::Models::Telephone
Returns the user’s mobile phone. In VA Profile, a user can only have one mobile phone.
87 88 89 90 91 |
# File 'app/models/va_profile_redis/contact_information.rb', line 87 def mobile_phone return unless @user.loa3? dig_out('telephones', 'phone_type', VAProfile::Models::Telephone::MOBILE) end |
#populate_from_redis ⇒ Object
This method allows us to populate the local instance of a VAProfileRedis::ContactInformation object with the uuid necessary to perform subsequent actions on the key such as deletion.
159 160 161 |
# File 'app/models/va_profile_redis/contact_information.rb', line 159 def populate_from_redis response_from_redis_or_service end |
#residential_address ⇒ VAProfile::Models::Address
Returns the user’s residence. In VA Profile, a user can only have one residence address.
54 55 56 57 58 |
# File 'app/models/va_profile_redis/contact_information.rb', line 54 def residential_address return unless @user.loa3? dig_out('addresses', 'address_pou', VAProfile::Models::Address::RESIDENCE) end |
#response ⇒ VAProfile::ContactInformation::PersonResponse
the redis cache. If that is unavailable, it calls the VAProfile::ContactInformation::Service#get_person endpoint.
152 153 154 |
# File 'app/models/va_profile_redis/contact_information.rb', line 152 def response @response ||= response_from_redis_or_service end |
#status ⇒ Integer <> String
The status of the last VAProfile::ContactInformation::Service response, or not authorized for for users < LOA 3
142 143 144 145 146 |
# File 'app/models/va_profile_redis/contact_information.rb', line 142 def status return VAProfile::ContactInformation::PersonResponse::RESPONSE_STATUS[:not_authorized] unless @user.loa3? response.status end |
#temporary_phone ⇒ VAProfile::Models::Telephone
Returns the user’s temporary phone. In VA Profile, a user can only have one temporary phone.
109 110 111 112 113 |
# File 'app/models/va_profile_redis/contact_information.rb', line 109 def temporary_phone return unless @user.loa3? dig_out('telephones', 'phone_type', VAProfile::Models::Telephone::TEMPORARY) end |
#text_permission ⇒ VAProfile::Models::Permission
Returns the user’s text permission. In VA Profile, a user can only have one text permission.
131 132 133 134 135 |
# File 'app/models/va_profile_redis/contact_information.rb', line 131 def return unless @user.loa3? dig_out('permissions', 'permission_type', VAProfile::Models::Permission::TEXT) end |
#work_phone ⇒ VAProfile::Models::Telephone
Returns the user’s work phone. In VA Profile, a user can only have one work phone.
98 99 100 101 102 |
# File 'app/models/va_profile_redis/contact_information.rb', line 98 def work_phone return unless @user.loa3? dig_out('telephones', 'phone_type', VAProfile::Models::Telephone::WORK) end |