feat: implement bl user icon (GET /api/v2/users/{userId}/icon)#124
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughImplements the Changes
Sequence DiagramsequenceDiagram
actor User
participant CLI as CLI<br/>(main.rs)
participant CmdIcon as icon Module<br/>(cmd/user/icon.rs)
participant API as BacklogClient<br/>(api/user.rs)
participant Server as Backlog Server
participant FS as File System
User->>CLI: Run `bl user icon <id> --output <path>`
CLI->>CmdIcon: icon(UserIconArgs)
CmdIcon->>API: download_user_icon(user_id)
API->>Server: GET /users/{userId}/icon
Server-->>API: Binary data + filename
API-->>CmdIcon: Result<(Vec<u8>, String)>
CmdIcon->>CmdIcon: Derive output path<br/>(use provided or default)
CmdIcon->>FS: Write bytes to file
FS-->>CmdIcon: Success/Error
CmdIcon->>CLI: Result with path & byte count
CLI-->>User: Print success message
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Implements the remaining Backlog API v2 Users-category endpoint for downloading a user icon, exposing it via a new bl user icon <id> CLI subcommand and documenting it in the command reference.
Changes:
- Add
GET /api/v2/users/{userId}/iconsupport in the API layer (download_user_icon). - Add
bl user icon <id>command with--output/-oand default filename fallback behavior. - Update English/Japanese command docs and the endpoint-to-command coverage table.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/api/user.rs |
Adds BacklogClient::download_user_icon(user_id) endpoint wrapper. |
src/api/mod.rs |
Exposes download_user_icon on BacklogApi and forwards it in BacklogClient impl. |
src/cmd/user/icon.rs |
New command implementation, default output-path logic, and unit tests for cmd-layer behavior. |
src/cmd/user/mod.rs |
Wires the new icon subcommand module and re-exports args/entrypoint. |
src/main.rs |
Adds the user icon clap subcommand and dispatch to cmd::user::icon. |
website/docs/commands.md |
Documents bl user icon and marks the endpoint as implemented. |
website/i18n/ja/.../commands.md |
Japanese documentation + coverage table update for bl user icon. |
| pub fn download_user_icon(&self, user_id: u64) -> Result<(Vec<u8>, String)> { | ||
| self.download(&format!("/users/{user_id}/icon")) | ||
| } |
There was a problem hiding this comment.
download_user_icon is a new API endpoint but src/api/user.rs already has httpmock-based coverage for other user endpoints. Please add a unit test that exercises this method (e.g., mock GET /users/{id}/icon returning a binary body and a Content-Disposition filename) and asserts the returned bytes + filename.
| Icon { | ||
| /// User numeric ID | ||
| id: u64, | ||
| /// Output file path (default: server-provided filename, or "user_icon" if none) |
There was a problem hiding this comment.
The CLI help text for --output says the fallback is "user_icon" "if none", but the implementation also falls back when the server-provided filename is a generic attachment placeholder. Please update the help text to match the actual behavior so users aren’t surprised by the default filename choice.
| /// Output file path (default: server-provided filename, or "user_icon" if none) | |
| /// Output file path (default: server-provided filename; if missing or a generic | |
| /// "attachment" placeholder, falls back to "user_icon") |
Checklist
mainwebsite/docs/,website/i18n/ja/,README.md)Summary
bl user icon <id>command to download a user's icon image--output/-oto specify the save path; defaults to the server-provided filename (oruser_iconwhen the filename is missing or a genericattachmentplaceholder)default_output_pathapplies the attachment check on the basename afterfile_name()extraction, consistent with the approach adopted in feat: implement bl project image (GET /api/v2/projects/{projectIdOrKey}/image) #123Reason for change
Implements
GET /api/v2/users/{userId}/iconso all published Backlog API v2 endpoints in the Users category are covered.Changes
src/api/user.rs— adddownload_user_icon(user_id)src/api/mod.rs— adddownload_user_icontoBacklogApitrait andimpl BacklogApi for BacklogClientsrc/cmd/user/icon.rs— new command withicon()/icon_with()/default_output_path()and unit testssrc/cmd/user/mod.rs— re-exportUserIconArgsandiconsrc/main.rs— addUserCommands::Iconvariant and dispatchwebsite/docs/commands.md,website/i18n/ja/.../commands.md— add command docs and mark as implementedNotes
Tested against real Backlog API:
bl user icon 972384→Saved: user_icon (878 bytes).Closes #120