Class: Zspay::Transfer

Inherits:
Resource show all
Defined in:
lib/zspay/resources/transfer.rb

Overview

The Transfer class manages transfer-related actions within the Zspay platform. It provides methods to create, schedule, and remove transfers, extending from Zspay::Resource.

Class Method Summary collapse

Methods inherited from Resource

delete, endpoint, get, headers, parse_body, parse_json, patch, post, put, req, req_form, req_json, success_request?

Class Method Details

.create(transfer, custom_token = nil) ⇒ OpenStruct

Creates a new transfer on the Zspay platform.

This method sends a POST request to create a new transfer with the provided details.

Parameters:

  • transfer (Hash)

    A hash containing the transfer details.

  • custom_token (String, nil) (defaults to: nil)

    An optional custom token to use for the request.

Returns:

  • (OpenStruct)

    A structure containing the newly created transfer’s details if the request is successful.



15
16
17
# File 'lib/zspay/resources/transfer.rb', line 15

def create(transfer, custom_token = nil)
  post("/transferencias", transfer, custom_token)
end

.remove(transfer_id, custom_token = nil) ⇒ OpenStruct

Cancels a scheduled transfer.

This method sends a DELETE request to remove a previously scheduled transfer from the system.

Parameters:

  • transfer_id (String)

    The unique identifier of the transfer to be removed.

  • custom_token (String, nil) (defaults to: nil)

    An optional custom token to use for the request.

Returns:

  • (OpenStruct)

    A structure indicating the result of the cancellation if the request is successful.



37
38
39
# File 'lib/zspay/resources/transfer.rb', line 37

def remove(transfer_id, custom_token = nil)
  delete("/transferencias/agendadas/#{transfer_id}", custom_token)
end

.schedule_transfer(transfer_id, custom_token = nil) ⇒ OpenStruct

Retrieves the details of a scheduled transfer.

This method sends a GET request to obtain details about a transfer that has been scheduled.

Parameters:

  • transfer_id (String)

    The unique identifier of the scheduled transfer.

  • custom_token (String, nil) (defaults to: nil)

    An optional custom token to use for the request.

Returns:

  • (OpenStruct)

    A structure containing the scheduled transfer’s details if the request is successful.



26
27
28
# File 'lib/zspay/resources/transfer.rb', line 26

def schedule_transfer(transfer_id, custom_token = nil)
  get("/transferencias/agendadas/#{transfer_id}", custom_token)
end