feat: add resources for banks, branches, direct debits, and withdrawals - #1
helloscoopa wants to merge 3 commits into
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Warning Review limit reached
Next review available in: 44 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds four new API resource modules (Banks, Branches, DirectDebits, Withdrawals) to the CeyPay SDK, each with corresponding TypeScript type definitions, wires them into CeyPayClient as public readonly properties, re-exports the new types from the types index, and adds a gitignore entry. ChangesNew API Resources Cohort
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant App
participant CeyPayClient
participant Resource as Resource (Banks/Branches/DirectDebits/Withdrawals)
participant HttpClient
participant API as CeyPay API
App->>CeyPayClient: new CeyPayClient(config)
CeyPayClient->>HttpClient: create shared instance
CeyPayClient->>Resource: new Resource(httpClient)
App->>CeyPayClient: client.banks.list() / branches.create() / etc.
CeyPayClient->>Resource: delegate call
Resource->>HttpClient: request(method, path, payload)
HttpClient->>API: HTTP request
API-->>HttpClient: response
HttpClient-->>Resource: typed data
Resource-->>App: Promise resolved
Related PRs: None specified. Suggested labels: enhancement, feature Suggested reviewers: None specified. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
🧹 Nitpick comments (3)
src/resources/direct-debits.ts (1)
16-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse named types for scenario list, consistent with other methods.
listScenariosuses inline anonymous types for both params and the return value, while every other method in this file (and sibling resources) uses named types (ListContractsQuery,ContractListResponse, etc.). Consider addingListScenariosQueryand aScenarioListResponsetype for consistency and better public API ergonomics.♻️ Proposed refactor
- async listScenarios(params?: { provider?: string; active?: boolean }): Promise<{ data: Scenario[] }> { - return this.client.request<{ data: Scenario[] }>('GET', '/v1/direct-debit/scenario-code/list', undefined, params); + async listScenarios(params?: ListScenariosQuery): Promise<ScenarioListResponse> { + return this.client.request<ScenarioListResponse>('GET', '/v1/direct-debit/scenario-code/list', undefined, params); }And in
direct-debit.types.ts:export interface ListScenariosQuery { provider?: string; active?: boolean; } export interface ScenarioListResponse { data: Scenario[]; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/resources/direct-debits.ts` around lines 16 - 24, The listScenarios method currently uses inline anonymous types for its params and response, unlike the other direct-debit resource methods. Add named types in direct-debit.types.ts such as ListScenariosQuery and ScenarioListResponse, then update listScenarios in direct-debits.ts to use those types for its signature and request call so the API stays consistent and easier to reuse.src/types/direct-debit.types.ts (1)
13-27: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDuplicate status literal union.
The
'INITIATED' | 'SIGNED' | 'TERMINATED' | 'EXPIRED'union is repeated in bothDirectDebitContractandListContractsQuery. Extracting a sharedDirectDebitContractStatustype alias would avoid drift if statuses change.♻️ Proposed refactor
+export type DirectDebitContractStatus = 'INITIATED' | 'SIGNED' | 'TERMINATED' | 'EXPIRED'; + export interface DirectDebitContract { ... - status: 'INITIATED' | 'SIGNED' | 'TERMINATED' | 'EXPIRED'; + status: DirectDebitContractStatus; ... } ... export interface ListContractsQuery extends PaginationParams { - status?: 'INITIATED' | 'SIGNED' | 'TERMINATED' | 'EXPIRED'; + status?: DirectDebitContractStatus; ... }Also applies to: 45-51
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/types/direct-debit.types.ts` around lines 13 - 27, The status union is duplicated between DirectDebitContract and ListContractsQuery, so extract it into a shared DirectDebitContractStatus type alias and use that alias in both places. Update the DirectDebitContract status field and the ListContractsQuery status field to reference the new shared type so future status changes stay consistent..gitignore (1)
7-9: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUnclear comment
# ln.Consider a clearer comment explaining why
CeyPay-BEis ignored (e.g., local sibling backend checkout/symlink used during development).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.gitignore around lines 7 - 9, The .gitignore entry has an unclear comment, so update the comment near the CeyPay-BE ignore rule to explain the actual development reason it is excluded, such as a local sibling backend checkout or symlink. Keep the ignore behavior unchanged and make the note descriptive enough that someone reading .gitignore can understand why CeyPay-BE is being ignored.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In @.gitignore:
- Around line 7-9: The .gitignore entry has an unclear comment, so update the
comment near the CeyPay-BE ignore rule to explain the actual development reason
it is excluded, such as a local sibling backend checkout or symlink. Keep the
ignore behavior unchanged and make the note descriptive enough that someone
reading .gitignore can understand why CeyPay-BE is being ignored.
In `@src/resources/direct-debits.ts`:
- Around line 16-24: The listScenarios method currently uses inline anonymous
types for its params and response, unlike the other direct-debit resource
methods. Add named types in direct-debit.types.ts such as ListScenariosQuery and
ScenarioListResponse, then update listScenarios in direct-debits.ts to use those
types for its signature and request call so the API stays consistent and easier
to reuse.
In `@src/types/direct-debit.types.ts`:
- Around line 13-27: The status union is duplicated between DirectDebitContract
and ListContractsQuery, so extract it into a shared DirectDebitContractStatus
type alias and use that alias in both places. Update the DirectDebitContract
status field and the ListContractsQuery status field to reference the new shared
type so future status changes stay consistent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 28521ba3-0532-462b-83da-4281c03fa6d5
📒 Files selected for processing (11)
.gitignoresrc/client.tssrc/resources/banks.tssrc/resources/branches.tssrc/resources/direct-debits.tssrc/resources/withdrawals.tssrc/types/bank.types.tssrc/types/branch.types.tssrc/types/direct-debit.types.tssrc/types/index.tssrc/types/withdrawal.types.ts
| merchantId: string; | ||
| amount: number; | ||
| currency: string; | ||
| status: 'PENDING' | 'APPROVED' | 'REJECTED' | 'PROCESSING' | 'COMPLETED' | 'FAILED'; |
There was a problem hiding this comment.
Currency and Status types are defined in common.types.ts but here it's using string for currency and inline valude for status
| } | ||
|
|
||
| export interface CreateWithdrawalParams { | ||
| currency: string; |
There was a problem hiding this comment.
| } | ||
|
|
||
| export interface ListWithdrawalsQuery extends PaginationParams { | ||
| status?: 'PENDING' | 'APPROVED' | 'REJECTED' | 'PROCESSING' | 'COMPLETED' | 'FAILED'; |
There was a problem hiding this comment.
| * @returns A promise that resolves to an array of Bank objects | ||
| */ | ||
| async list(): Promise<Bank[]> { | ||
| return this.client.request<Bank[]>('GET', '/v1/bank/list'); |
There was a problem hiding this comment.
The older endpoints include the /api/ prefix, while the new ones don't. One of them is wrong.
Description
This PR introduces support for newly added public API features. It exposes all the necessary type definitions, API resource wrappers, and client bindings to give developers full access to these new modules.
Changes Included
client.banksto list all supported banks (GET /v1/bank/list).client.branchesto manage multi-branch merchant operations with full CRUD capabilities (create, list, get, update, deactivate).client.directDebitsto allow merchants to create and manage direct debit contracts, sync contract statuses, list scenario codes, and execute on-demand payments.client.withdrawalsfor merchants to request withdrawals against unsettled balances and monitor their status (create, list, get).bank.types.ts,branch.types.ts,direct-debit.types.ts,withdrawal.types.ts) and exported them centrally viasrc/types/index.ts.Impact
How to Test
Instantiate the
CeyPayClientlocally and invoke the newly exposed classes:Summary by CodeRabbit
New Features
Chores