Class: Airwallex::Transfer

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::List, APIOperations::Retrieve
Defined in:
lib/airwallex/resources/transfer.rb

Constant Summary collapse

SIMULATION_PATH =
"/api/v1/simulation/transfers"

Instance Attribute Summary

Attributes inherited from APIResource

#attributes, #id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::Retrieve

retrieve

Methods included from APIOperations::List

list

Methods inherited from APIResource

#changed_attributes, #dirty?, #initialize, #inspect, #method_missing, #refresh, #refresh_from, resource_name, #respond_to_missing?, symbolized_get, symbolized_post, #to_hash, #to_json, #to_s

Constructor Details

This class inherits a constructor from Airwallex::APIResource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Airwallex::APIResource

Class Method Details

.resource_path ⇒ Object



12
13
14
# File 'lib/airwallex/resources/transfer.rb', line 12

def self.resource_path
  "/api/v1/transfers"
end

.simulate_transition(transfer_id, next_status:, failure_type: nil) ⇒ Transfer

Simulate a transfer's status advancing one step

Parameters:

  • transfer_id (String)
  • next_status (String) —

    one of "OVERDUE", "PROCESSING", "SENT", "PAID", "FAILED", "CANCELLED"

  • failure_type (String, nil) (defaults to: nil) —

    failure reason code, only meaningful when next_status is "FAILED"

Returns:



52
53
54
55
56
57
# File 'lib/airwallex/resources/transfer.rb', line 52

def self.simulate_transition(transfer_id, next_status:, failure_type: nil)
  params = { next_status: next_status }
  params[:failure_type] = failure_type if failure_type
  response = Airwallex.client.post("#{SIMULATION_PATH}/#{transfer_id}/transition", params)
  new(response)
end

Instance Method Details

#cancel ⇒ Object

Cancel a pending transfer



17
18
19
20
21
22
23
24
# File 'lib/airwallex/resources/transfer.rb', line 17

def cancel
  response = Airwallex.client.post(
    "#{self.class.resource_path}/#{id}/cancel",
    {}
  )
  refresh_from(response)
  self
end

#simulate_transition(next_status:, failure_type: nil) ⇒ Transfer

Simulate this transfer's status advancing one step. The standard lifecycle is SCHEDULED -> PROCESSING -> SENT -> PAID, progressed one step at a time; OVERDUE, FAILED, and CANCELLED can be jumped to directly.

Parameters:

  • next_status (String) —

    one of "OVERDUE", "PROCESSING", "SENT", "PAID", "FAILED", "CANCELLED"

  • failure_type (String, nil) (defaults to: nil) —

    failure reason code, only meaningful when next_status is "FAILED"

Returns:



36
37
38
39
40
41
42
# File 'lib/airwallex/resources/transfer.rb', line 36

def simulate_transition(next_status:, failure_type: nil)
  params = { next_status: next_status }
  params[:failure_type] = failure_type if failure_type
  response = Airwallex.client.post("#{SIMULATION_PATH}/#{id}/transition", params)
  refresh_from(response)
  self
end