Skip to content

Comments

Add GET /bills/:id endpoint with Bill type aligned to bills.json schema#547

Merged
hassidtal merged 8 commits intomainfrom
copilot/add-get-bill-endpoint
Feb 24, 2026
Merged

Add GET /bills/:id endpoint with Bill type aligned to bills.json schema#547
hassidtal merged 8 commits intomainfrom
copilot/add-get-bill-endpoint

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

  • Remove BillFailureReason enum, change failureReason to string
  • Strengthen bills endpoint test
  • Fix lint errors in BillPaymentMethod
  • Remove | null from paymentMethod?: BillPaymentMethod | nullpaymentMethod?: BillPaymentMethod

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: hassidtal <122451381+hassidtal@users.noreply.github.com>
Copilot AI changed the title [WIP] Add get bill endpoint to bill router Add get bill endpoint Feb 23, 2026
Copilot AI requested a review from hassidtal February 23, 2026 12:59
@hassidtal hassidtal requested a review from Copilot February 23, 2026 13:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Bill type definition with status union type and comprehensive attributes/relationships
  • New Bills resource class with a single get(id) method
  • Integration with the main Unit class 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>
Copilot AI changed the title Add get bill endpoint Add get bill endpoint and align Bill type with payment schema Feb 23, 2026
…schema

Co-authored-by: hassidtal <122451381+hassidtal@users.noreply.github.com>
Copilot AI changed the title Add get bill endpoint and align Bill type with payment schema Add get bill endpoint with Bill type aligned to bills.json schema Feb 23, 2026
@hassidtal
Copy link
Contributor

@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

Copy link
Contributor Author

Copilot AI commented Feb 23, 2026

@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 unit-finance/unit-finance repository is private and not accessible to me, so I'm unable to read the bills.json schema directly. Could you share the relevant schema content (or a diff of what needs to change) so I can align the attributes and statuses correctly?

Co-authored-by: hassidtal <122451381+hassidtal@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@hassidtal hassidtal requested a review from Copilot February 24, 2026 07:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copilot AI changed the title Add get bill endpoint with Bill type aligned to bills.json schema Add GET /bills/:id endpoint with Bill type aligned to bills.json schema Feb 24, 2026
@hassidtal hassidtal marked this pull request as ready for review February 24, 2026 08:34
Co-authored-by: hassidtal <122451381+hassidtal@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
paymentMethod?: BillPaymentMethod | null
paymentMethod?: BillPaymentMethod

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot fix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in ea4b183 — changed paymentMethod?: BillPaymentMethod | null to paymentMethod?: BillPaymentMethod.

Co-authored-by: hassidtal <122451381+hassidtal@users.noreply.github.com>
Copy link
Collaborator

@YegorZh YegorZh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@hassidtal hassidtal merged commit af16c38 into main Feb 24, 2026
4 checks passed
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