Class: Pagseguro::Charge::Summary

Inherits:
Object
  • Object
show all
Defined in:
lib/pagseguro/charge/summary.rb

Overview

Credit card data

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Summary

Returns a new instance of Summary.



10
11
12
13
14
# File 'lib/pagseguro/charge/summary.rb', line 10

def initialize(args = {})
  @total = args[:total]
  @paid = args[:paid]
  @refunded = args[:refunded]
end

Instance Attribute Details

Returns the value of attribute paid.



6
7
8
# File 'lib/pagseguro/charge/summary.rb', line 6

def paid
  @paid
end

#refundedObject

Returns the value of attribute refunded.



6
7
8
# File 'lib/pagseguro/charge/summary.rb', line 6

def refunded
  @refunded
end

#totalObject

Returns the value of attribute total.



6
7
8
# File 'lib/pagseguro/charge/summary.rb', line 6

def total
  @total
end

Class Method Details

.fill_from_json(data) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/pagseguro/charge/summary.rb', line 22

def self.fill_from_json(data)
  return if data.nil?

  summary = new
  summary.total = data["total"]
  summary.paid = data["paid"]
  summary.refunded = data["refunded"]
  summary
end

Instance Method Details

#as_json(options = {}) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/pagseguro/charge/summary.rb', line 32

def as_json(options={})
  {
    total: @total,
    paid: @paid,
    refunded: @refunded
  }
end

#to_json(*options) ⇒ Object



16
17
18
19
20
# File 'lib/pagseguro/charge/summary.rb', line 16

def to_json(*options)
  hash = as_json(*options)
  hash.reject! {|k,v| v.nil?}
  hash.to_json(*options)
end