Class: VAProfile::V2::Person::Service
- Inherits:
-
Service
- Object
- Common::Client::Base
- Service
- VAProfile::V2::Person::Service
- Includes:
- Common::Client::Concerns::Monitoring, ERB::Util
- Defined in:
- lib/va_profile/v2/person/service.rb
Constant Summary collapse
- STATSD_KEY_PREFIX =
"#{VAProfile::Service::STATSD_KEY_PREFIX}.person".freeze
Instance Method Summary collapse
- #build_icn_with_aaid!(icn) ⇒ Object
- #empty_body ⇒ Object private
- #encode_url!(icn) ⇒ Object
- #icn_with_aaid ⇒ Object private
-
#init_vet360_id(icn = nil) ⇒ VAProfile::V2::ContactInformation::PersonTransactionResponse
Initializes a vet360_id for a user that does not have one.
Methods included from Common::Client::Concerns::Monitoring
#increment, #increment_failure, #increment_total, #with_monitoring
Methods inherited from Service
breakers_service, #final_failure?, #handle_error, #initialize, #log_dates, #parse_messages, #perform, #person_transaction?, #person_transaction_failure?, #raise_backend_exception, #raise_invalid_body, #report_stats_on, #save_error_details
Methods inherited from Common::Client::Base
#config, configuration, #connection, #delete, #get, #perform, #post, #put, #raise_backend_exception, #raise_not_authenticated, #request, #sanitize_headers!, #service_name
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Constructor Details
This class inherits a constructor from VAProfile::Service
Instance Method Details
#build_icn_with_aaid!(icn) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/va_profile/v2/person/service.rb', line 43 def build_icn_with_aaid!(icn) if icn.present? "#{icn}#{Identity::Parsers::GCIdsConstants::ICN_ASSIGNING_AUTHORITY_ID}" elsif @user&.icn_with_aaid.present? @user.icn_with_aaid else raise 'User does not have a valid ICN with an Assigning Authority ID' end end |
#empty_body ⇒ Object (private)
61 62 63 64 65 66 67 |
# File 'lib/va_profile/v2/person/service.rb', line 61 def empty_body { bio: { sourceDate: Time.zone.now.iso8601 } }.to_json end |
#encode_url!(icn) ⇒ Object
37 38 39 40 41 |
# File 'lib/va_profile/v2/person/service.rb', line 37 def encode_url!(icn) encoded_icn_with_aaid = url_encode(build_icn_with_aaid!(icn)) "#{Identity::Parsers::GCIdsConstants::VA_ROOT_OID}/#{encoded_icn_with_aaid}" end |
#icn_with_aaid ⇒ Object (private)
57 58 59 |
# File 'lib/va_profile/v2/person/service.rb', line 57 def icn_with_aaid "#{@user.icn}^NI^200M^USVHA" if @user.icn end |
#init_vet360_id(icn = nil) ⇒ VAProfile::V2::ContactInformation::PersonTransactionResponse
Initializes a vet360_id for a user that does not have one. Can be used when a current user is present, or through a rake task when no user is present (through passing in their ICN). This is an asynchronous process for VAProfile, so it returns VAProfile transaction information.
response wrapper around a transaction object
28 29 30 31 32 33 34 35 |
# File 'lib/va_profile/v2/person/service.rb', line 28 def init_vet360_id(icn = nil) with_monitoring do raw_response = perform(:post, encode_url!(icn), empty_body) VAProfile::V2::ContactInformation::PersonTransactionResponse.from(raw_response, @user) end rescue => e handle_error(e) end |