Class: BGS::People::Service
- Inherits:
-
Object
- Object
- BGS::People::Service
- Includes:
- SentryLogging
- Defined in:
- app/services/bgs/people/service.rb
Defined Under Namespace
Classes: VAFileNumberNotFound
Instance Attribute Summary collapse
-
#common_name ⇒ Object
readonly
Returns the value of attribute common_name.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#icn ⇒ Object
readonly
Returns the value of attribute icn.
-
#participant_id ⇒ Object
readonly
Returns the value of attribute participant_id.
-
#ssn ⇒ Object
readonly
Returns the value of attribute ssn.
Instance Method Summary collapse
- #external_key ⇒ Object private
- #find_person_by_participant_id ⇒ Object
-
#initialize(user) ⇒ Service
constructor
A new instance of Service.
- #service ⇒ Object private
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Constructor Details
#initialize(user) ⇒ Service
Returns a new instance of Service.
16 17 18 19 20 21 22 |
# File 'app/services/bgs/people/service.rb', line 16 def initialize(user) @ssn = user.ssn @participant_id = user.participant_id @common_name = user.common_name @email = user.email @icn = user.icn end |
Instance Attribute Details
#common_name ⇒ Object (readonly)
Returns the value of attribute common_name.
10 11 12 |
# File 'app/services/bgs/people/service.rb', line 10 def common_name @common_name end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
10 11 12 |
# File 'app/services/bgs/people/service.rb', line 10 def email @email end |
#icn ⇒ Object (readonly)
Returns the value of attribute icn.
10 11 12 |
# File 'app/services/bgs/people/service.rb', line 10 def icn @icn end |
#participant_id ⇒ Object (readonly)
Returns the value of attribute participant_id.
10 11 12 |
# File 'app/services/bgs/people/service.rb', line 10 def participant_id @participant_id end |
#ssn ⇒ Object (readonly)
Returns the value of attribute ssn.
10 11 12 |
# File 'app/services/bgs/people/service.rb', line 10 def ssn @ssn end |
Instance Method Details
#external_key ⇒ Object (private)
41 42 43 44 45 46 |
# File 'app/services/bgs/people/service.rb', line 41 def external_key @external_key ||= begin key = common_name.presence || email key.first(Constants::EXTERNAL_KEY_MAX_LENGTH) end end |
#find_person_by_participant_id ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/bgs/people/service.rb', line 24 def find_person_by_participant_id raw_response = service.people.find_person_by_ptcpnt_id(participant_id, ssn) if raw_response.blank? log_exception_to_sentry(VAFileNumberNotFound.new, { icn: }, { team: Constants::SENTRY_REPORTING_TEAM }) end BGS::People::Response.new(raw_response, status: :ok) rescue => e log_exception_to_sentry(e, { icn: }, { team: Constants::SENTRY_REPORTING_TEAM }) BGS::People::Response.new(nil, status: :error) end |
#service ⇒ Object (private)
37 38 39 |
# File 'app/services/bgs/people/service.rb', line 37 def service @service ||= BGS::Services.new(external_uid: icn, external_key:) end |