Add GET /bills/:id endpoint with Bill type aligned to bills.json schema#547
Add GET /bills/:id endpoint with Bill type aligned to bills.json schema#547
Conversation
Co-authored-by: hassidtal <122451381+hassidtal@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This pull request adds support for retrieving bill resources via the /bills/:id endpoint in the Unit Node SDK. The implementation follows established patterns in the codebase for simple resource classes with get methods, similar to Institutions and Disputes resources.
Changes:
- New
Billtype definition with status union type and comprehensive attributes/relationships - New
Billsresource class with a singleget(id)method - Integration with the main
Unitclass to expose the bills resource - Test coverage for both type validation and the get endpoint
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| types/bill.ts | Defines the Bill interface with BillStatus union type, standard attributes (createdAt, status, amount, description, reason, tags), and relationships (account, customer, customers, transaction) |
| resources/bills.ts | Implements Bills resource class extending BaseResource with a get method to retrieve a bill by ID |
| unit.ts | Adds Bills resource to the Unit class constructor and public properties |
| types/index.ts | Exports bill types for external consumption |
| resources/index.ts | Exports Bills resource class for external consumption |
| tests/bills.spec.ts | Adds tests for Bill type structure and get endpoint functionality |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… status Co-authored-by: hassidtal <122451381+hassidtal@users.noreply.github.com>
…schema Co-authored-by: hassidtal <122451381+hassidtal@users.noreply.github.com>
|
@copilot look at the attributes and statuses, the types/bill.ts is not align with https://github.com/unit-finance/unit-finance/blob/master/Unit.Api/schemas/public/bills.json |
The |
Co-authored-by: hassidtal <122451381+hassidtal@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: hassidtal <122451381+hassidtal@users.noreply.github.com>
Co-authored-by: hassidtal <122451381+hassidtal@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
types/bill.ts
Outdated
| /** | ||
| * Optional. The payment method used or scheduled for this bill. | ||
| */ | ||
| paymentMethod?: BillPaymentMethod | null |
There was a problem hiding this comment.
The paymentMethod field is marked as both optional (?) and nullable (| null). In TypeScript, optional properties can already be undefined, so adding | null means this field can be undefined, null, or a BillPaymentMethod value.
This pattern is inconsistent with other readonly resource types in the codebase (e.g., Dispute, Fee) which use only ? for optional fields. The | null pattern is primarily used in update request types where null has a specific semantic meaning (to delete a field).
If the API can return an explicit null value for this field (as opposed to omitting it entirely), then this typing is correct. However, if the field is simply absent when no payment method exists, consider removing | null to be consistent with other resource types.
| paymentMethod?: BillPaymentMethod | null | |
| paymentMethod?: BillPaymentMethod |
There was a problem hiding this comment.
Fixed in ea4b183 — changed paymentMethod?: BillPaymentMethod | null to paymentMethod?: BillPaymentMethod.
Co-authored-by: hassidtal <122451381+hassidtal@users.noreply.github.com>
BillFailureReasonenum, changefailureReasontostringBillPaymentMethod| nullfrompaymentMethod?: BillPaymentMethod | null→paymentMethod?: BillPaymentMethod💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.