Class: VAProfile::Models::Transaction

Inherits:
Base
  • Object
show all
Defined in:
lib/va_profile/models/transaction.rb

Constant Summary collapse

STATUSES =
%w[
  REJECTED
  RECEIVED
  RECEIVED_ERROR_QUEUE
  RECEIVED_DEAD_LETTER_QUEUE
  COMPLETED_SUCCESS
  COMPLETED_NO_CHANGES_DETECTED
  COMPLETED_FAILURE
].freeze

Constants inherited from Base

Base::SOURCE_SYSTEM

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build_from(body) ⇒ VAProfile::Models::Transaction

Converts a decoded JSON response from VAProfile to an instance of the Transaction model

Parameters:

  • body (Hash)

    the decoded response body from VAProfile

Returns:



34
35
36
37
38
39
40
41
# File 'lib/va_profile/models/transaction.rb', line 34

def self.build_from(body)
  messages = body['tx_messages']&.map { |m| VAProfile::Models::Message.build_from(m) }
  VAProfile::Models::Transaction.new(
    messages: messages || [],
    id: body['tx_audit_id'],
    status: body['tx_status'] || body['status']
  )
end

Instance Method Details

#completed_success?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/va_profile/models/transaction.rb', line 27

def completed_success?
  status == 'COMPLETED_SUCCESS'
end

#received?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/va_profile/models/transaction.rb', line 23

def received?
  status == 'RECEIVED'
end