Class: Pagseguro::Charge::Summary
- Inherits:
-
Object
- Object
- Pagseguro::Charge::Summary
- Defined in:
- lib/pagseguro/charge/summary.rb
Overview
Credit card data
Instance Attribute Summary collapse
-
#paid ⇒ Object
Returns the value of attribute paid.
-
#refunded ⇒ Object
Returns the value of attribute refunded.
-
#total ⇒ Object
Returns the value of attribute total.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#initialize(args = {}) ⇒ Summary
constructor
A new instance of Summary.
- #to_json(*options) ⇒ Object
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
#paid ⇒ Object
Returns the value of attribute paid.
6 7 8 |
# File 'lib/pagseguro/charge/summary.rb', line 6 def paid @paid end |
#refunded ⇒ Object
Returns the value of attribute refunded.
6 7 8 |
# File 'lib/pagseguro/charge/summary.rb', line 6 def refunded @refunded end |
#total ⇒ Object
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(={}) { 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(*) hash = as_json(*) hash.reject! {|k,v| v.nil?} hash.to_json(*) end |