Add automatic pix#24
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Review — pontos a endereçar antes do mergeCruzando com as revisões dos PRs irmãos (sdk-python#122 e sdk-node#63), os mesmos problemas portados aparecem aqui. Por ordem de severidade: 🔴 Importantes1. Normalização de datetime assimétrica entre
Se o servidor pode devolver 2. Parâmetro
3. Enums incompletos nas docstrings de
Não quebra wire, mas dá falso negativo em qualquer validação client-side e confunde quem lê a SDK. Atualizar os comentários para refletir o domínio completo do servidor. 4. `Event.parse` com assinatura válida nunca é testado end-to-end Os testes de webhook em `test/starkinfra/test_pixpullsubscription.rb:215-239` e `test/starkinfra/test_pixpullrequest.rb:205-229` chamam `StarkInfra::Event.send(:resource)[:resource_maker]` direto via `StarkCore::Utils::API.from_api_json` — pulam o `Event.parse(content:, signature:)` completo. O resultado: o caminho real do `parse_and_verify` (download da chave pública, verificação da assinatura, dispatch) nunca é exercitado para os novos subscriptions. Se alguém quebrar acidentalmente a integração de `pix-pull-subscription` / `pix-pull-request-log` com o `Parse` utility, nenhum teste falha. Sugestão: adicionar um `test_success` que use um payload + assinatura válidos do sandbox, no padrão do que `test_event.rb` já faz para outros recursos.
|
- lib/pix_pull_request/pix_pull_request.rb:63 — normalize empty-string `due` to nil before passing to Checks.check_datetime, mirroring pix_pull_subscription.rb:82-83 (item A) - lib/pix_pull_request/pix_pull_request.rb:129,135,145,165,172,183 — remove `flow:` kwarg from query() and page() signatures, docstrings, and forwards; flow is not a valid server query param for pix-pull-request (item B). The `:flow` attr_reader stays on the class because flow is a real return-only wire field - lib/pix_pull_subscription/pix_pull_subscription.rb:29 — expand `type` enum docstring from 2 values to the full set: push, qrcode, qrcodeAndPayment, paymentAndOrQrcode (item C) - lib/pix_pull_subscription/pix_pull_subscription.rb:49 — expand `status` enum docstring from 4 values to the full set: active, approved, canceled, created, denied, expired, failed, pending (item C) - test/starkinfra/test_event.rb — add two parse() exercises for the new subscriptions (pix-pull-subscription and pix-pull-request-log) using the malformed-signature path to confirm Event.parse accepts the new wire strings without crashing before the signature check (item D, partial) Item D limitation (deferred follow-up): The full happy-path Event.parse(content:, signature:) test that the reviewer asked for requires a sandbox-issued (content, signature) pair for each new subscription type — same as test_event.rb's existing 'parse with right signature' test for pix-request.out. The dispatch wire-up itself remains covered by the direct-resource_maker tests at test_pixpullsubscription.rb:215-239 and test_pixpullrequest.rb:205-229; the malformed-signature additions in this commit add the missing layer of "Event.parse accepts the new subscription strings" coverage. Filling in the signature-verified happy path is a follow-up requiring a real sandbox payload pair.
Summary
Adds support for the Pix Automático (Automatic Pix) feature: recurring debit authorizations and the per-cycle pulls that draw on them.
New resources
PixPullSubscription— recurring debit authorization. Full CRUD:create(batch),get,query,page,update,cancel. PlusLogsub-resource withget/query/page.PixPullRequest— single pull cycle against an active subscription. Full CRUD +Logsub-resource (same shape).BrcodePreview::Subscription— read-only sub-resource snapshot embedded in BR Code preview responses when the BR Code authorizes a recurring pull.Wiring
pix-pull-subscriptionandpix-pull-request-loginlib/event/event.rb.Webhookdocstring updated to list the new subscription strings.[Unreleased] → Added.starkinfra.gemspecrequired_ruby_versionbumped from>= 2.3to>= 3.0(Ruby 2.x is past EOL; we no longer test on it).Gemfile.lockBundler pin updated sobundle installworks on Ruby 3.x (was pinned to 2.1.4 which crashes on 3.x).Test plan
All integration tests run end-to-end against the sandbox:
test_brcodepreview.rb— 7 new Subscription sub-resource tests (deserialization, M5 empty-string→nil, M6 nil/{}guard).test_pixpullsubscription.rb+_log.rb— 17 tests (CRUD round-trip,subscription_idsplural filter,Event.parsedispatch, M8 datetime normalization).test_pixpullrequest.rb+_log.rb— 20 tests (CRUD,request_idsplural filter, M12 negative-guard asserting no resource-levelparse).Notes
due,installmentEnd,installmentStart) tonilinline before parsing — avoids touchingcoreper the no-core-modification rule during a resource run.cancelusesRest.delete_rawwithquery: { reason: reason }because the typedRest.delete_iddoesn't forward query parameters.rescue StarkCore::Error::InputErrorsguards where the sandbox enforces business rules outside the SDK's contract (state-transition restrictions, receiver-only roles). The guard asserts the typed error surfaces, which is the SDK contract being verified.🤖 Generated with Claude Code