Repository navigation
Add Users - #63
Merged
Merged
Add Users#63
Conversation
Users could only be read through /v2/users/me. This adds user list, create, show, update and delete. Show and update target the logged-in user when no ID is given, through GET and PUT /v2/users/me, and --send-invitation defaults to false, shown in help. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
permission_level is a UserPermissionLevel integer enum in the spec, mapped through typeOverrides to a PermissionLevel enum with named cases, since the generator would name them _0 to _8. The CLI names each level in help and output. 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
Users could only be read through
GET /v2/users/me, which--userdefaults and self assessment use. This adds full coverage.user listtakes--view(all,staff,active_staff,advisors,active_advisors). With no view, every user is listed.user show [<id>]shows the logged-in user without an ID, throughGET /v2/users/me, or the given user. It groups details, tax, previous employment pay, dates and IDs.user createneeds--email,--first-name,--last-nameand--role.--send-invitationdefaults tofalse, shown in help as(default: false), and the value is always sent, so no one is emailed unless asked.user update [<id>]changes only the fields passed. Without an ID it updates the logged-in user throughPUT /v2/users/me, which FreeAgent documents as needing only Time access.user delete <id>needs an ID, as there is no documentedDELETE /v2/users/me. FreeAgent's 422 for a user with timeslips, expenses or other records passes straight through (exit 4).--permission-leveltakes 0 to 8. Help lists each level's name, list and show print the name, and anything else is refused before sending.What The Sandbox Showed
Probed under the pinned
X-Api-Version: 2026-09-01, no header and2024-10-01; no shape differs between them. Probe users used@example.comaddresses andsend_invitation: false, and all of them were deleted afterwards. The logged-in user's name was round-tripped throughPUT /v2/users/me. Its email, role and permission level were never changed, and deleting it was never tried.X-Total-Countis sent andpageis respected. An unknown view is a 400.sortandupdated_sinceare ignored.QQ123456C, is a 422, whileAB123456Cworks. A UTR must be 10 digits. Both are omitted from responses until set, andhiddenis undocumented and writable.useris refused: a 422 returning the unchanged user on/users/:id, and a 400 on/users/me.send_invitation: the docs give no default, only "true to send the user an invitation to set their password, false otherwise". Sendingtruewas not probed, as it sends mail.Code
paths/users.yamladdslistUsers,createUser,showUser,updateUser,deleteUserandupdateCurrentUser. This takes the total from 111 to 117 operations.UserCreatePayload,UserUpdatePayload,UserListResponse,UserRoleandUserPermissionLevel. The role is an enum in requests only. Responses keep it as a string, since other company types may return roles the sandbox can't show.permission_levelis an enum.UserPermissionLevelis an integer enum of 0 to 8, used byUserand both payloads. The generator would name its cases_0to_8, soopenapi-generator-config.yamlmaps it to a hand-writtenPermissionLevelinTypeOverrides/, with cases fromnoAccesstofull, asInvoiceViewmaps toViewFilter. The CLI names each level throughCustomStringConvertible, and ArgumentParser lists the names in help.UserProfileOptionsinOptions/holds the fields create and update share.UserOptionsalready names the--useroption group.Tests
PUT /v2/users/meis tested with the current first name, so nothing changes.changed-suitesselectsusers.showandupdatecall themeoperations without an ID, and the ID operations with one;PermissionLeveldecodes every documented level, encodes as an integer and refuses 9.--yes(exit 64), then the delete itself and a repeat 404 (exit 3).🤖 Generated with Claude Code