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"
Instance Method Summary collapse
- #get(id) ⇒ Resources::PixTransfers
-
#initialize(client = nil) ⇒ PixClient
constructor
A new instance of PixClient.
- #list(**params) ⇒ Array<Resources::PixTransfers>
-
#send_pix(data) ⇒ Resources::PixTransfers
Sends a PIX transfer to an external key.
Constructor Details
Instance Method Details
#get(id) ⇒ Resources::PixTransfers
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>
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.
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 |