Class: VAProfile::V2::ContactInformation::AddressTransactionResponse

Inherits:
TransactionResponse show all
Defined in:
lib/va_profile/v2/contact_information/transaction_response.rb

Constant Summary

Constants inherited from TransactionResponse

TransactionResponse::ERROR_STATUS

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

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

Instance Attribute Summary

Attributes inherited from TransactionResponse

#response_body

Attributes inherited from Common::Base

#errors_hash, #metadata

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TransactionResponse

error?

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata

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

Class Method Details

.from(*args) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/va_profile/v2/contact_information/transaction_response.rb', line 44

def self.from(*args)
  return_val = super

  log_error

  return_val.response_body = @response_body
  return_val
end

.log_errorObject



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/va_profile/v2/contact_information/transaction_response.rb', line 68

def self.log_error
  if error?
    PersonalInformationLog.create(
      error_class: 'VAProfile::V2::ContactInformation::AddressTransactionResponseError',
      data:
        {
          address: @response_body['tx_push_input'].except(
            'address_id',
            'originating_source_system',
            'source_system_user',
            'effective_start_date',
            'va_profile_id'
          ),
          errors: @response_body['tx_messages']
        }
    )
  end
rescue => e
  log_exception_to_sentry(e)
end

Instance Method Details

#changed_fieldObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/va_profile/v2/contact_information/transaction_response.rb', line 53

def changed_field
  return :address unless response_body['tx_output']

  address_pou = response_body['tx_output'][0]['address_pou']

  case address_pou
  when VAProfile::Models::V3::BaseAddress::RESIDENCE
    :residence_address
  when VAProfile::Models::V3::BaseAddress::CORRESPONDENCE
    :correspondence_address
  else
    :address
  end
end