Skip to content

feat(investment): add missing API fields issueDate, purchaseDate, issuerCNPJ#71

Open
victor-garcia-orbi wants to merge 1 commit into
pluggyai:masterfrom
Orbi-Finance:feat/investment-missing-fields
Open

feat(investment): add missing API fields issueDate, purchaseDate, issuerCNPJ#71
victor-garcia-orbi wants to merge 1 commit into
pluggyai:masterfrom
Orbi-Finance:feat/investment-missing-fields

Conversation

@victor-garcia-orbi

Copy link
Copy Markdown

Problem

The Pluggy REST API returns three Investment fields that are not mapped in the Investment DTO. The SDK uses FieldNamingPolicy.IDENTITY (Gson), which requires exact byte-for-byte field name matches — misnamed or missing Java fields are silently discarded.

Fields affected

API JSON key Current SDK field Effect
issueDate issuerDate (misnamed — extra r) Always null
purchaseDate (not present) Always null
issuerCNPJ (not present) Always null

issuerDate was misnamed when first introduced. Because FieldNamingPolicy.IDENTITY requires an exact match, the API key issueDate never maps to the Java field issuerDate.

Solution

  • Add issueDate (Date) — correct name for the instrument's emission/issue date
  • Add purchaseDate (Date) — date the investor purchased/applied for the investment
  • Add issuerCNPJ (String) — CNPJ of the issuing institution
  • Mark existing issuerDate as @Deprecated with a migration note (kept for backward compatibility — removing it would surface the pre-existing null in callers, not a real regression)

Verified against live API

Tested against two investment types from real API responses:

CDB (NU FINANCEIRA):

"issueDate": "2026-02-06T03:00:00.000Z",
"purchaseDate": "2026-02-06T03:00:00.000Z",
"issuerCNPJ": "30.680.829/0001-43"

Tesouro IPCA+ 2045:

"issueDate": "2022-05-03T03:00:00.000Z",
"purchaseDate": "2022-05-03T03:00:00.000Z",
"issuerCNPJ": null

🤖 Generated with Claude Code

…uerCNPJ

The Pluggy REST API returns three fields in the Investment response that
are not captured by the current DTO, causing Gson (FieldNamingPolicy.IDENTITY
— exact byte-for-byte key matching) to silently discard them.

issuerDate has been misnamed since it was introduced: the API emits
'issueDate' (no trailing 'r'), so Gson never populates the Java field.
It is kept @deprecated for backward compatibility.

Fields added:
- issuerCNPJ (String)  — CNPJ of the issuing institution
- issueDate  (Date)    — emission/issue date of the instrument
- purchaseDate (Date)  — date the investor purchased/applied

Verified against live Pluggy API responses for CDB and Tesouro IPCA+ products.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@Gabrielpanga Gabrielpanga left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — ✅ Approve pending two checks

Diff: +5 −0, 1 file. Right approach: adds the three missing fields and keeps the misnamed issuerDate as @Deprecated rather than renaming it, preserving backward compatibility for any consumer already reading it. The Javadoc pointing to issueDate is a nice touch.

Must verify before merge (this PR is entirely about casing correctness under Gson FieldNamingPolicy.IDENTITY, so the new names have to be byte-for-byte right):

  1. Field casing vs the OpenAPI spec — confirm issueDate, purchaseDate, and especially issuerCNPJ (all-caps CNPJ) match the spec exactly. A single mismatch silently yields null — the very bug this PR fixes. The sync-api command from #76 is purpose-built for this.
  2. The test check is red for a reason unrelated to this diff — it predates a test-setup fix already on master. Rebasing onto current master should turn it green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants