Class: Acc::CheckTransactionResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/acc/check_transaction_response.rb

Instance Method Summary collapse

Constructor Details

#initialize(json_response) ⇒ CheckTransactionResponse

Returns a new instance of CheckTransactionResponse.



2
3
4
# File 'lib/acc/check_transaction_response.rb', line 2

def initialize json_response
  @response = json_response
end

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/acc/check_transaction_response.rb', line 14

def complete?
  self.success? && @response['statusCode'] == 'COMPLETE'
end

#dataObject



43
44
45
# File 'lib/acc/check_transaction_response.rb', line 43

def data
  @response
end

#error?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/acc/check_transaction_response.rb', line 6

def error?
  !error_response.nil? || ship_to_error? || order_error?
end

#error_messagesObject



34
35
36
37
# File 'lib/acc/check_transaction_response.rb', line 34

def error_messages
  messages = [ship_to_error_message] + [single_error_message] + multiple_error_messages
  messages.delete_if { |msg| msg.nil? }
end

#in_progress?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/acc/check_transaction_response.rb', line 18

def in_progress?
  error_response.kind_of?(Array) ? in_progress_array_error? : in_progress_error?
end

#in_progress_array_error?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/acc/check_transaction_response.rb', line 22

def in_progress_array_error?
  !error_response.nil? && error_response.first['errorCode'] == 'DEP-ERR-4003'
end

#in_progress_error?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/acc/check_transaction_response.rb', line 26

def in_progress_error?
  !error_response.nil? && error_response['errorCode'] == 'DEP-ERR-4003'
end

#order_error?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/acc/check_transaction_response.rb', line 10

def order_error?
  @response['statusCode'] == 'ERROR' || @response['statusCode'] == 'COMPLETE_WITH_ERRORS'
end

#raw_dataObject



39
40
41
# File 'lib/acc/check_transaction_response.rb', line 39

def raw_data
  @response
end

#success?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/acc/check_transaction_response.rb', line 30

def success?
  !self.error?
end