Class: Airwallex::RFI

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

Overview

Represents a Request for Information (RFI) — a compliance question Airwallex raises against your account (KYC, an ongoing KYC review, a cardholder, a transaction, payment enablement, or merchant risk).

Supports retrieving and listing real RFIs, plus the sandbox Simulation endpoints for raising, closing and following up on them (there is no live create — real RFIs originate from Airwallex's own compliance review, same as Dispute). See https://www.airwallex.com/docs/api/risk/request_for_information_rfi and https://www.airwallex.com/docs/api/simulation/request-for-information

Statuses: ACTION_REQUIRED, ANSWERED, CLOSED. Types: KYC, KYC_ONGOING, CARDHOLDER, TRANSACTION, PAYMENT_ENABLEMENT, MERCHANT_RISK.

Reading RFIs requires the API key's "Risk → Request for Information (RFI): Read" permission — without it Airwallex returns 401 (AuthenticationError).

Examples:

Retrieve an RFI for a connected account

rfi = Airwallex::RFI.retrieve("rfi_123", headers: { "x-on-behalf-of" => "acct_123" })
rfi.status                           # => "ACTION_REQUIRED"
rfi.active_request[:questions].first # => { id: ..., title: { en: ... }, ... }

List open RFIs, following every page

Airwallex::RFI.list(
  { statuses: "ACTION_REQUIRED" },
  headers: { "x-on-behalf-of" => "acct_123" }
).auto_paging_each { |rfi| puts rfi.id }

Raise a KYC RFI, then close it

rfi = Airwallex::RFI.simulate_create(
  type: "KYC",
  questions: [{ answer: { type: "TEXT" } }]
)
rfi.simulate_close

Constant Summary collapse

SIMULATION_PATH =
"/api/v1/simulation/rfis"

Instance Attribute Summary

Attributes inherited from APIResource

#attributes, #id

Class Method Summary collapse

Instance Method Summary collapse

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

.list(params = {}, opts = {}) ⇒ ListObject<RFI>

List RFIs. Unlike most resources, RFIs use bookmark pagination: the response carries page_after/page_before instead of has_more/next_cursor, and the next page is requested with page: <page_after>.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/airwallex/resources/rfi.rb', line 62

def self.list(params = {}, opts = {})
  response = Airwallex.client.get(resource_path, params, opts[:headers] || {})
  items = extract_data(response)
  page_after = response.is_a?(Hash) ? response[:page_after] || response["page_after"] : nil

  ListObject.new(
    data: items,
    has_more: !page_after.nil? && !items.empty?,
    next_cursor: page_after,
    cursor_param: :page,
    resource_class: self,
    params: params,
    opts: opts
  )
end

.resource_path ⇒ String



47
48
49
# File 'lib/airwallex/resources/rfi.rb', line 47

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

.simulate_close(rfi_id, opts = {}) ⇒ RFI

Simulate closing an RFI



96
97
98
99
# File 'lib/airwallex/resources/rfi.rb', line 96

def self.simulate_close(rfi_id, opts = {})
  response = Airwallex.client.post("#{SIMULATION_PATH}/#{rfi_id}/close", {}, opts[:headers] || {})
  new(response)
end

.simulate_create(params = {}, opts = {}) ⇒ RFI

Simulate Airwallex raising an RFI



86
87
88
89
# File 'lib/airwallex/resources/rfi.rb', line 86

def self.simulate_create(params = {}, opts = {})
  response = Airwallex.client.post("#{SIMULATION_PATH}/create", params, opts[:headers] || {})
  new(response)
end

.simulate_follow_up(rfi_id, params = {}, opts = {}) ⇒ RFI

Simulate a follow-up on an RFI — reopen an existing answered question (by id) or append a new one



109
110
111
112
# File 'lib/airwallex/resources/rfi.rb', line 109

def self.simulate_follow_up(rfi_id, params = {}, opts = {})
  response = Airwallex.client.post("#{SIMULATION_PATH}/#{rfi_id}/follow_up", params, opts[:headers] || {})
  new(response)
end

Instance Method Details

#simulate_close(opts = {}) ⇒ RFI

Simulate closing this RFI



118
119
120
121
122
# File 'lib/airwallex/resources/rfi.rb', line 118

def simulate_close(opts = {})
  response = Airwallex.client.post("#{SIMULATION_PATH}/#{id}/close", {}, opts[:headers] || {})
  refresh_from(response)
  self
end

#simulate_follow_up(params = {}, opts = {}) ⇒ RFI

Simulate a follow-up on this RFI



129
130
131
132
133
# File 'lib/airwallex/resources/rfi.rb', line 129

def simulate_follow_up(params = {}, opts = {})
  response = Airwallex.client.post("#{SIMULATION_PATH}/#{id}/follow_up", params, opts[:headers] || {})
  refresh_from(response)
  self
end