Sha256: b5344c760e758af26c2c0321b500fbb35a2edde241e269a562ef0f22590e96f0
Contents?: true
Size: 784 Bytes
Versions: 1
Compression:
Stored size: 784 Bytes
Contents
module QiwiObserver class PaymentsResponse < Response attr_reader :value, :error def initialize(success:, body:) @success = success if @success @value = parse_body(body) else @error = error_description(body) end end def success? @success end 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 private def parse_body(body) JSON.parse(body, symbolize_names: true) end def error_description(body) 'Error ' + body.join(' ') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
qiwi_observer-0.2.1 | lib/qiwi_observer/payments/payments_response.rb |