Class: Wompi::Transaction
- Defined in:
- lib/wompi/resources/transaction.rb
Class Method Summary collapse
- .all(params = {}) ⇒ Object
- .all_pages(params = {}) ⇒ Object
- .create(params = {}) ⇒ Object
- .find(id) ⇒ Object
- .void(id, params = {}) ⇒ Object
Methods inherited from Resource
Class Method Details
.all(params = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/wompi/resources/transaction.rb', line 28 def self.all(params = {}) now = DateTime.now defaults = { from_date: (now - 30).strftime('%Y-%m-%dT%H:%M:%S'), until_date: now.strftime('%Y-%m-%dT%H:%M:%S'), page: 1, page_size: 20 } get("transactions", defaults.merge(params), auth_type: :private) end |
.all_pages(params = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/wompi/resources/transaction.rb', line 39 def self.all_pages(params = {}) all_records = [] current_page = 1 loop do response = all(params.merge(page: current_page)) records = response['data'] break if records.empty? all_records.concat(records) current_page += 1 end all_records end |
.create(params = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/wompi/resources/transaction.rb', line 5 def self.create(params = {}) secret = params.delete(:integrity_secret) || Wompi.configuration.integrity_secret if secret params[:signature] = Security::Signature.generate( params[:reference], params[:amount_in_cents], params[:currency], secret ) end post("transactions", params, auth_type: :private) end |
.find(id) ⇒ Object
24 25 26 |
# File 'lib/wompi/resources/transaction.rb', line 24 def self.find(id) get("transactions/#{id}", {}, auth_type: :private) end |
.void(id, params = {}) ⇒ Object
20 21 22 |
# File 'lib/wompi/resources/transaction.rb', line 20 def self.void(id, params = {}) post("transactions/#{id}/void", params, auth_type: :private) end |