Class: WhopSDK::Resources::Transfers

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/resources/transfers.rb

Overview

Transfers

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Transfers

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Transfers.

Parameters:



126
127
128
# File 'lib/whop_sdk/resources/transfers.rb', line 126

def initialize(client:)
  @client = client
end

Instance Method Details

#create(amount:, currency:, destination_id:, origin_id:, idempotence_key: nil, metadata: nil, notes: nil, request_options: {}) ⇒ WhopSDK::Models::Transfer

Some parameter documentations has been truncated, see Models::TransferCreateParams for more details.

Transfer funds between two ledger accounts, such as from a company balance to a user balance.

Required permissions:

  • ‘payout:transfer_funds`

Parameters:

  • amount (Float)

    The amount to transfer in the specified currency. For example, 25.00 for $25.00

  • currency (Symbol, WhopSDK::Models::Currency)

    The currency of the transfer amount, such as ‘usd’.

  • destination_id (String)

    The identifier of the account receiving the funds. Accepts a user ID (‘user_xxx’

  • origin_id (String)

    The identifier of the account sending the funds. Accepts a user ID (‘user_xxx’),

  • idempotence_key (String, nil)

    A unique key to prevent duplicate transfers. Use a UUID or similar unique string

  • metadata (Hash{Symbol=>Object}, nil)

    A JSON object of custom metadata to attach to the transfer for tracking purposes

  • notes (String, nil)

    A short note describing the transfer, up to 50 characters.

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



38
39
40
41
42
43
44
45
46
47
# File 'lib/whop_sdk/resources/transfers.rb', line 38

def create(params)
  parsed, options = WhopSDK::TransferCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "transfers",
    body: parsed,
    model: WhopSDK::Transfer,
    options: options
  )
end

#list(after: nil, before: nil, created_after: nil, created_before: nil, destination_id: nil, direction: nil, first: nil, last: nil, order: nil, origin_id: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::TransferListResponse>

Some parameter documentations has been truncated, see Models::TransferListParams for more details.

Returns a paginated list of fund transfers, filtered by origin or destination account, with optional sorting and date filtering.

Required permissions:

  • ‘payout:transfer:read`

Parameters:

  • after (String, nil)

    Returns the elements in the list that come after the specified cursor.

  • before (String, nil)

    Returns the elements in the list that come before the specified cursor.

  • created_after (Time, nil)

    Only return transfers created after this timestamp.

  • created_before (Time, nil)

    Only return transfers created before this timestamp.

  • destination_id (String, nil)

    Filter to transfers received by this account. Accepts a user, company, or ledger

  • direction (Symbol, WhopSDK::Models::Direction, nil)

    The direction of the sort.

  • first (Integer, nil)

    Returns the first n elements from the list.

  • last (Integer, nil)

    Returns the last n elements from the list.

  • order (Symbol, WhopSDK::Models::TransferListParams::Order, nil)

    Which columns can be used to sort.

  • origin_id (String, nil)

    Filter to transfers sent from this account. Accepts a user, company, or ledger a

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/whop_sdk/resources/transfers.rb', line 110

def list(params = {})
  parsed, options = WhopSDK::TransferListParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "transfers",
    query: query,
    page: WhopSDK::Internal::CursorPage,
    model: WhopSDK::Models::TransferListResponse,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ WhopSDK::Models::Transfer

Retrieves the details of an existing transfer.

Required permissions:

  • ‘payout:transfer:read`

Parameters:

  • id (String)

    The unique identifier of the transfer to retrieve.

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



64
65
66
67
68
69
70
71
# File 'lib/whop_sdk/resources/transfers.rb', line 64

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["transfers/%1$s", id],
    model: WhopSDK::Transfer,
    options: params[:request_options]
  )
end