Repository navigation
Use Currency And UserRole Enums In Responses - #67
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CurrencyandUserRolewere request-only: responses kept plain strings. Every other enum in the spec is used onboth sides, so these now are too, and every output field takes an enum directly instead of unwrapping its raw value.
Currencyis widened from 113 to 124 codes and used on every responsecurrency: bank account, bill, company,credit note, estimate, expense, invoice, project, recurring invoice and task.
User.roleis aUserRole.--currencynow takes all 124 codes. A code a resource refuses reaches FreeAgent, whose refusal passesstraight through.
Why 124 Codes
A response enum has to decode every value FreeAgent stores, or a record and its whole list page fail. The 113 were
the codes every resource accepts. A full probe of all 308 ISO 4217 codes (in the earlier currency work) found more:
and ZMK. That makes 124.
One enum of 124 is used for requests and responses. The invoice, credit note, estimate and expense payloads say which
codes they refuse.
Fields Take Enums Directly
FieldValuegains generic overloads beside its cases, so a field passes the enum itself:textandstatustake anyRawRepresentable<String>and show its raw value.textalso takes aRawRepresentable & CustomStringConvertible, soPermissionLevelshows its name.currency(_:code:)takes aRawRepresentable<String>code.Every
?.rawValueand?.descriptionin a field closure is gone, across all commands. The invoice, credit note,estimate and bill item tables carry a
Currency?.Other Changes
project createreads the company's currency as aCurrency, so its "company currency is not one a projectcan use" error can no longer happen. The error and its test are deleted.
The expense rebill integration test skips integration-test projects. It picked
projects.last, and projectslist alphabetically, so the project lifecycle test's temporary
ZZ Integration Testproject sorted last while itexisted. Running in parallel on this PR's first CI run, the rebill test picked it just before it was deleted and got a
422
Project not found for this company. The race predates this PR; it shows when both suites are selected.Known Trade-Off
A record in a code FreeAgent no longer accepts anywhere would fail to decode, and so would its list page. An old
production account's history could hold one. The sandbox cannot show whether any exist.
Tests
FieldValuetests cover an enum's raw value,nil, a described enum and a currency enum code.The 11 integration suites
changed-suitesselects (bank_accounts, bills, company, credit_notes, estimates, expenses,invoices, projects, recurring_invoices, tasks, users) pass against the sandbox, 63 tests.
148 CLI, 90 API and 11 tools unit tests pass, and format and lint are clean.
The debug CLI was run against the sandbox. That covered:
Every record was deleted afterwards.
🤖 Generated with Claude Code