Class: Revolut::Simulation
- Defined in:
- lib/revolut/resources/simulation.rb
Overview
Class Method Summary collapse
- .resources_name ⇒ Object
-
.top_up_account(id, **data) ⇒ Revolut::Transaction
Adds funds to the specified account in the sandbox environment.
-
.update_transaction(id, action:) ⇒ Revolut::Transaction
Updates a transaction in the sandbox environment.
Methods inherited from Resource
coerce_with, create, delete, http_client, #initialize, list, retrieve, skip_coertion_for, #to_json, to_proc, update
Constructor Details
This class inherits a constructor from Revolut::Resource
Class Method Details
.resources_name ⇒ Object
6 7 8 |
# File 'lib/revolut/resources/simulation.rb', line 6 def self.resources_name "sandbox" end |
.top_up_account(id, **data) ⇒ Revolut::Transaction
Adds funds to the specified account in the sandbox environment.
33 34 35 36 37 38 39 |
# File 'lib/revolut/resources/simulation.rb', line 33 def self.top_up_account(id, **data) raise Revolut::UnsupportedOperationError, "#top_up_account is meant to be run only in sandbox environments" unless Revolut.sandbox? response = http_client.post("/#{resources_name}/topup", data: data.merge(account_id: id)) Revolut::Transaction.new(response.body) end |
.update_transaction(id, action:) ⇒ Revolut::Transaction
Updates a transaction in the sandbox environment.
16 17 18 19 20 21 22 23 |
# File 'lib/revolut/resources/simulation.rb', line 16 def self.update_transaction(id, action:) raise Revolut::UnsupportedOperationError, "#update_transaction is meant to be run only in sandbox environments" unless Revolut.sandbox? raise Revolut::UnsupportedOperationError, "The action `#{action}` is not supported" unless %i[complete revert declined fail].include?(action) response = http_client.post("/#{resources_name}/transactions/#{id}/#{action}") Revolut::Transaction.new(response.body) end |