Class: AbacatePay::Clients::PixClient

Inherits:
Client
  • Object
show all
Defined in:
lib/abacate_pay/clients/pix_client.rb

Overview

Client for outbound PIX transfers in the AbacatePay API.

Transfers are sent to a PIX key; see Enums::Pix::KeyTypes for the accepted key formats.

Constant Summary collapse

URI =
"pix"

Instance Method Summary collapse

Constructor Details

#initialize(client = nil) ⇒ PixClient

Returns a new instance of PixClient.



12
13
14
# File 'lib/abacate_pay/clients/pix_client.rb', line 12

def initialize(client = nil)
  super(URI, client)
end

Instance Method Details

#get(id) ⇒ Resources::PixTransfers

Parameters:

  • id (String)

    PIX transfer ID

Returns:



25
26
27
28
# File 'lib/abacate_pay/clients/pix_client.rb', line 25

def get(id)
  response = request("GET", "get", params: { id: id })
  Resources::PixTransfers.new(response)
end

#list(**params) ⇒ Array<Resources::PixTransfers>

Parameters:

  • params (Hash)

    Optional pagination params (after, before, limit)

Returns:



18
19
20
21
# File 'lib/abacate_pay/clients/pix_client.rb', line 18

def list(**params)
  response = request("GET", "list", params: params.empty? ? nil : params)
  Array(response).map { |data| Resources::PixTransfers.new(data) }
end

#send_pix(data) ⇒ Resources::PixTransfers

Sends a PIX transfer to an external key. Named send_pix to avoid conflict with Ruby's Object#send.

Parameters:

Returns:



35
36
37
38
39
40
41
42
43
44
# File 'lib/abacate_pay/clients/pix_client.rb', line 35

def send_pix(data)
  response = request("POST", "send", json: {
                       amount: data.amount,
                       externalId: data.external_id,
                       description: data.description,
                       key: data.key,
                       keyType: data.key_type
                     })
  Resources::PixTransfers.new(response)
end