Class: Monri::Transactions::TransactionResponse
- Inherits:
-
Response
- Object
- Hash
- Response
- Monri::Transactions::TransactionResponse
show all
- Defined in:
- lib/monri/transactions/transaction_response.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Response
#exception, exception, #exception=
Constructor Details
Returns a new instance of TransactionResponse.
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/monri/transactions/transaction_response.rb', line 6
def initialize(params)
if params.has_key?(:errors)
self[:errors] = params.delete(:errors)
end
if params.has_key?(:transaction)
self[:transaction] = Monri::Transactions::Transaction.new(params.delete(:transaction))
end
if params.has_key?(:secure_message)
self[:secure_message] = Monri::Transactions::SecureMessage.new(params.delete(:secure_message))
end
super(params)
end
|
Class Method Details
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/monri/transactions/transaction_response.rb', line 42
def self.create
raise ArgumentError, 'Provide a block' unless block_given?
begin
TransactionResponse.new(yield)
rescue StandardError => e
params = { exception: e }
if e.is_a?(Monri::Errors::HttpRequestError) && e.body != nil
body = JSON.parse(e.body, symbolize_names: true) rescue {}
params.merge!(body)
end
TransactionResponse.new(params)
end
end
|
Instance Method Details
#errors ⇒ Array
27
28
29
|
# File 'lib/monri/transactions/transaction_response.rb', line 27
def errors
self[:errors]
end
|
#failed? ⇒ TrueClass, FalseClass
22
23
24
|
# File 'lib/monri/transactions/transaction_response.rb', line 22
def failed?
errors != nil && errors.length > 0 || super
end
|
37
38
39
|
# File 'lib/monri/transactions/transaction_response.rb', line 37
def secure_message
self[:secure_message]
end
|
32
33
34
|
# File 'lib/monri/transactions/transaction_response.rb', line 32
def transaction
self[:transaction]
end
|