Class: Revolut::Simulation

Inherits:
Resource show all
Defined in:
lib/revolut/resources/simulation.rb

Overview

Class Method Summary collapse

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_nameObject



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.

Parameters:

  • id (String)

    The ID of the account to top up.

  • data (Hash)

    Additional data for the top-up request.

Options Hash (**data):

  • :amount (Float)

    The amount to top up the account by.

  • :currency (String)

    The currency of the top-up amount.

Returns:

Raises:



33
34
35
36
37
38
39
# File 'lib/revolut/resources/simulation.rb', line 33

def self.(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.

Parameters:

  • id (String)

    The ID of the transaction to update.

  • action (Symbol)

    The action to perform on the transaction.

Returns:

Raises:



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