Class: Paggi::Payment
- Includes:
- Rest::GetAll
- Defined in:
- lib/paggi/payment.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#amount_raw ⇒ Object
Returns the value of attribute amount_raw.
-
#compensated_at ⇒ Object
Returns the value of attribute compensated_at.
-
#expected_compensation ⇒ Object
Returns the value of attribute expected_compensation.
-
#status ⇒ Object
Returns the value of attribute status.
-
#total ⇒ Object
Returns the value of attribute total.
Attributes inherited from Resource
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Payment
constructor
A new instance of Payment.
- #to_json ⇒ Object
Methods included from Rest::GetAll
Methods inherited from Resource
build, class_name, opts, request, url, #valid?
Constructor Details
#initialize(attributes = {}) ⇒ Payment
Returns a new instance of Payment.
34 35 36 |
# File 'lib/paggi/payment.rb', line 34 def initialize(attributes = {}) super(attributes) end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
5 6 7 |
# File 'lib/paggi/payment.rb', line 5 def amount @amount end |
#amount_raw ⇒ Object
Returns the value of attribute amount_raw.
5 6 7 |
# File 'lib/paggi/payment.rb', line 5 def amount_raw @amount_raw end |
#compensated_at ⇒ Object
Returns the value of attribute compensated_at.
5 6 7 |
# File 'lib/paggi/payment.rb', line 5 def compensated_at @compensated_at end |
#expected_compensation ⇒ Object
Returns the value of attribute expected_compensation.
5 6 7 |
# File 'lib/paggi/payment.rb', line 5 def expected_compensation @expected_compensation end |
#status ⇒ Object
Returns the value of attribute status.
5 6 7 |
# File 'lib/paggi/payment.rb', line 5 def status @status end |
#total ⇒ Object
Returns the value of attribute total.
5 6 7 |
# File 'lib/paggi/payment.rb', line 5 def total @total end |
Class Method Details
.all(params = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/paggi/payment.rb', line 20 def all(params = {}) url = params[:customer].nil? ? '' : "#{params[:customer]}/" parameters = [] parameters << "start_date=#{params[:start_date].to_s(:db)}" if params[:start_date] parameters << "end_date=#{params[:end_date].to_s(:db)}" if params[:end_date] parameters << "page=#{params[:page]}" if params[:page] parameters << "page_size=#{params[:page_size]}" if params[:page_size] url += "?#{parameters.join('&')}" if parameters.length result = request(url, {}, :GET, {}) raise result if result.kind_of? StandardError result end |
.consolidated(customer = nil, start_date = nil, end_date = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/paggi/payment.rb', line 8 def consolidated(customer = nil, start_date = nil, end_date = nil) url = customer.nil? ? '' : "#{customer}/" url += 'consolidated' params = [] params << "start_date=#{start_date.strftime('%Y-%m-%d %H:%M:%S')}" if start_date params << "end_date=#{end_date.strftime('%Y-%m-%d %H:%M:%S')}" if end_date url += "?#{params.join('&')}" if params.length result = request(url, {}, :GET, {}) raise result if result.kind_of? StandardError result.total end |
Instance Method Details
#to_json ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/paggi/payment.rb', line 38 def to_json super.merge!(super([ :status, :expected_compensation, :compensated_at, :amount, :amount_raw, ])) end |