Skip to content

Feat/bill control#64

Open
inqus637 wants to merge 7 commits intoIlyaChichkov:developfrom
inqus637:feat/bill-control
Open

Feat/bill control#64
inqus637 wants to merge 7 commits intoIlyaChichkov:developfrom
inqus637:feat/bill-control

Conversation

@inqus637
Copy link
Copy Markdown

Summary

This PR introduces complete Bill management functionality to RIMAPI, including CRUD operations, reordering capabilities, material filtering, and work table discovery. The implementation includes full test coverage via Bruno API collections.

Changes Overview

1️⃣ feat: Add Bill management API (61ec3c2)
New Controller: BillController.cs - REST endpoints for bill operations
Service Layer: BillService.cs - Business logic with 320 lines of implementation
DTOs: Complete data transfer objects in BillDto.cs
Helper: BillHelper.cs - Game object to DTO conversion utilities
Endpoints Added:
Method Endpoint Description
GET /api/v1/buildings/bills?building_id={id} List all bills for a building
POST /api/v1/buildings/bills?building_id={id} Create new bill with full configuration
GET /api/v1/buildings/bill?building_id={id}&bill_id={id} Get specific bill details
PUT /api/v1/buildings/bill?building_id={id}&bill_id={id} Update existing bill
DELETE /api/v1/buildings/bills?building_id={id} Clear all bills from building
PUT /api/v1/buildings/bill/reorder Reorder recipes in queue
GET /api/v1/map/work-tables?map_id={id} Discover work tables on map
2️⃣ feat(bill-control): Add material management (ddcd694)
Added allowed_materials filter to bill creation/update operations
Supports filtering by specific material definitions (e.g., "Cloth", "WoolBison")
Enables precise control over which materials bills will use
3️⃣ fix(bill-control): NRE and reorder bounds checking (b88c8f2)
Fixed NullReferenceException in bill operations
Added proper bounds validation for reorder offset values
Updated configuration settings for stability
4️⃣ feat: Add Bruno API test collection (1eca554)
Complete test suite with 10+ endpoints covering all bill operations

Technical Details

Files Modified:

Source/RIMAPI/RimworldRestApi/BaseControllers/BillController.cs (+118 lines)
Source/RIMAPI/RimworldRestApi/Services/BillService.cs (+320 lines)
Source/RIMAPI/RimworldRestApi/Models/BillDto.cs (+126 lines)
Source/RIMAPI/RimworldRestApi/Helpers/BillHelper.cs (+117 lines)
tests/bruno_api_collection/Bills/*.yml (10 test files)
Total New Code: ~700+ lines of production code + comprehensive test coverage

Testing Notes
All endpoints have been tested via Bruno API collections located in:

Apply
tests/bruno_api_collection/Bills/
├── Create Bill.yml
├── Delete Bill.yml
├── Get Bill.yml
├── List Bills.yml
├── Update Bill.yml
├── Suspend Bill.yml
├── Reorder Bill.yml
├── Clear Bills.yml
├── Available Recipes.yml
└── Work Tables.yml

Related Documentation

API conventions remain consistent with existing patterns (snake_case, response envelopes)
No breaking changes to existing endpoints
All new endpoints follow established error handling and validation rules

@inqus637 inqus637 marked this pull request as draft March 29, 2026 08:36
@inqus637 inqus637 changed the base branch from master to develop March 29, 2026 08:37
@inqus637 inqus637 marked this pull request as ready for review March 29, 2026 08:37
- Added `only_researched` query parameter to `GET /api/v1/buildings/recipes` to filter by currently available research.
- BillController.yml: Created new file detailing bill endpoints
@jkbennitt
Copy link
Copy Markdown

Nice work @inqus637 — this is a solid addition. We'll definitely use the bill endpoints in RLE for automated crafting management.

A few things I noticed while reading through:

Material filter does a double DefDatabase lookupApplyMaterialFilter validates all materials in the first loop, then looks them up again in the second loop to apply them. You could cache the resolved ThingDef objects from the validation pass and reuse them. Trivial perf impact for typical bill sizes, but easy to clean up.

FindBill returns null if LoadIDField reflection fails — the lambda on line 662 returns false when LoadIDField == null, which means every bill lookup silently fails if that private field ever gets renamed. Might be worth logging a warning once on startup if the field isn't found, so it doesn't fail silently in production.

Bruno YAML trailing spaces for route disambiguation ("/api/v1/buildings/bills " vs "/api/v1/buildings/bills ") — works but editors love to strip trailing whitespace. Not sure if there's a better way in the docs framework.

Everything else looks clean. Error handling is thorough, bounds checking on reorder is good, and the only_researched filter on recipes is a nice touch.

@IlyaChichkov
Copy link
Copy Markdown
Owner

@inqus637 fixed the branch by removing "Merge branch 'IlyaChichkov:master' into feat/bill-control" and force-pushing it

@inqus637
Copy link
Copy Markdown
Author

Thanks for your review!

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.

3 participants