Class: QiwiObserver::PaymentsResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/qiwi_observer/payments/payments_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(success:, body:) ⇒ PaymentsResponse

Returns a new instance of PaymentsResponse.



5
6
7
8
9
10
11
12
13
# 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

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



3
4
5
# File 'lib/qiwi_observer/payments/payments_response.rb', line 3

def error
  @error
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/qiwi_observer/payments/payments_response.rb', line 3

def value
  @value
end

Instance Method Details

#short_infoObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# 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?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/qiwi_observer/payments/payments_response.rb', line 15

def success?
  @success
end