Sergei
0cc82b24b0
Add deployment_id lookup mechanism
Implement getDeploymentForBeneficiary() method to resolve beneficiary → deployment_id mapping. This extracts the deployment lookup logic into a reusable, testable method.
Changes:
- Add getDeploymentForBeneficiary() in services/api.ts
- Fetches beneficiary from WellNuo API
- Returns deployment_id with proper error handling
- Returns ApiResponse<number> with typed errors
- Refactor attachDeviceToBeneficiary() to use new method
- Reduces code duplication
- Improves separation of concerns
- Add comprehensive test suite
- Tests successful deployment lookup
- Tests authentication errors
- Tests missing deployment scenarios
- Tests network error handling
- Tests edge cases (string IDs, 0 values, empty strings)
Benefits:
- Deployment lookup now reusable across codebase
- Better error handling with specific error codes
- Easier to test and maintain
- Follows DRY principle
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>