class QiwiObserver::PaymentsResponse
Attributes
error[R]
value[R]
Public Class Methods
new(success:, body:)
click to toggle source
# File lib/qiwi_observer/payments/payments_response.rb, line 5 def initialize(success:, body:) @success = success if @success @value = parse_body(body) else @error = error_description(body) end end
Public Instance Methods
short_info()
click to toggle source
# File lib/qiwi_observer/payments/payments_response.rb, line 19 def short_info output = [] hash = @value hash[:data].each do |tran| output << { account_id: tran[:account], amount: tran[:total][:amount], date: tran[:date], comment: tran[:comment] } end output end
success?()
click to toggle source
# File lib/qiwi_observer/payments/payments_response.rb, line 15 def success? @success end
Private Instance Methods
error_description(body)
click to toggle source
# File lib/qiwi_observer/payments/payments_response.rb, line 39 def error_description(body) 'Error ' + body.join(' ') end
parse_body(body)
click to toggle source
# File lib/qiwi_observer/payments/payments_response.rb, line 35 def parse_body(body) JSON.parse(body, symbolize_names: true) end