Class: AbacatePay::Clients::PixClient
- 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"
Constants inherited from Client
Client::RETRIABLE_EXCEPTIONS, Client::RETRIABLE_METHODS, Client::RETRIABLE_STATUSES
Instance Method Summary collapse
- #get(id) ⇒ Resources::PixTransfers
-
#initialize(client = nil) ⇒ PixClient
constructor
A new instance of PixClient.
-
#list(**params) ⇒ Array<Resources::PixTransfers>
The API requires an
idon this endpoint: a bare call fails with "Expected property 'id' to be string but found: undefined". -
#send_pix(data) ⇒ Resources::PixTransfers
Sends a PIX transfer to an external key.
Methods inherited from Client
Constructor Details
Instance Method Details
#get(id) ⇒ Resources::PixTransfers
29 30 31 32 |
# File 'lib/abacate_pay/clients/pix_client.rb', line 29 def get(id) response = request("GET", "get", params: { id: id }) Resources::PixTransfers.new(response) end |
#list(**params) ⇒ Array<Resources::PixTransfers>
The API requires an id on this endpoint: a bare call fails with
"Expected property 'id' to be string but found: undefined". Despite the
name it filters rather than lists.
22 23 24 25 |
# File 'lib/abacate_pay/clients/pix_client.rb', line 22 def list(**params) response = request("GET", "list", params: params.empty? ? nil : params) build_list(response, Resources::PixTransfers) 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.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/abacate_pay/clients/pix_client.rb', line 39 def send_pix(data) response = request("POST", "send", json: { amount: data.amount, externalId: data.external_id, description: data.description, # The API nests the destination under `pix`, with # `key` and `type`. Sending pixKey/pixKeyType at the # top level fails with "Property 'pix' is missing"; # nesting the wrong names fails with # "Property 'pix.type' is missing". pix: { key: data.key, type: data.key_type } }) Resources::PixTransfers.new(response) end |