Class: VAProfile::ContactInformation::TransactionResponse

Inherits:
Response show all
Extended by:
SentryLogging
Defined in:
lib/va_profile/contact_information/transaction_response.rb

Constant Summary collapse

ERROR_STATUS =
'COMPLETED_FAILURE'

Constants included from Common::Client::Concerns::ServiceStatus

Common::Client::Concerns::ServiceStatus::RESPONSE_STATUS

Instance Attribute Summary collapse

Attributes inherited from Common::Base

#errors_hash, #metadata

Class Method Summary collapse

Methods included from SentryLogging

log_exception_to_sentry, log_message_to_sentry, non_nil_hash?, normalize_level, rails_logger

Methods inherited from Response

#cache?, #initialize, #metadata, #ok?, #response_status

Methods inherited from Common::Base

#changed, #changed?, #changes, default_sort, filterable_attributes, #initialize, max_per_page, per_page, sortable_attributes

Constructor Details

This class inherits a constructor from VAProfile::Response

Instance Attribute Details

#response_bodyObject (readonly)

Returns the value of attribute response_body.



14
15
16
# File 'lib/va_profile/contact_information/transaction_response.rb', line 14

def response_body
  @response_body
end

Class Method Details

.error?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/va_profile/contact_information/transaction_response.rb', line 34

def self.error?
  @response_body.try(:[], 'tx_status') == ERROR_STATUS
end

.from(raw_response = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/va_profile/contact_information/transaction_response.rb', line 16

def self.from(raw_response = nil)
  @response_body = raw_response&.body

  if error?
    log_message_to_sentry(
      'VAProfile transaction error',
      :error,
      { response_body: @response_body },
      error: :va_profile
    )
  end

  new(
    raw_response&.status,
    transaction: VAProfile::Models::Transaction.build_from(@response_body)
  )
end