Skip to content

feat: add resources for banks, branches, direct debits, and withdrawals - #1

Open
helloscoopa wants to merge 3 commits into
mainfrom
scoopa/more-resources
Open

helloscoopa wants to merge 3 commits into
mainfrom
scoopa/more-resources

Conversation

@helloscoopa

@helloscoopa helloscoopa commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

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

  • Banks: Add client.banks to list all supported banks (GET /v1/bank/list).
  • Branches: Add client.branches to manage multi-branch merchant operations with full CRUD capabilities (create, list, get, update, deactivate).
  • Direct Debits: Add client.directDebits to allow merchants to create and manage direct debit contracts, sync contract statuses, list scenario codes, and execute on-demand payments.
  • Withdrawals: Add client.withdrawals for merchants to request withdrawals against unsettled balances and monitor their status (create, list, get).
  • Types Definitions: Add comprehensive typescript typings for all new modules (bank.types.ts, branch.types.ts, direct-debit.types.ts, withdrawal.types.ts) and exported them centrally via src/types/index.ts.

Impact

  • Closes missing feature gaps between the JS SDK and the Backend API.
  • Fully backwards compatible (no breaking changes).
  • All changes are statically verified (TypeScript build succeeds).

How to Test

Instantiate the CeyPayClient locally and invoke the newly exposed classes:

const client = new CeyPayClient({ apiKey: 'YOUR_API_KEY' });

// 1. Fetch banks
const banks = await client.banks.list();

// 2. Query branches
const branches = await client.branches.list();

// 3. Initiate a direct debit payment 
const payment = await client.directDebits.executePayment('contract-id', {
  amount: 10,
  currency: 'USDT',
  productName: 'Subscription Plan'
});

Summary by CodeRabbit

  • New Features

    • Added client access for banks, branches, direct debits, and withdrawals.
    • Introduced branch management actions: create, list, view, update, and deactivate.
    • Added direct debit actions for scenario lookup, contract management, payment execution, and contract status sync.
    • Added withdrawal creation, listing, and lookup capabilities.
    • Expanded shared API types and exports to support the new resources.
  • Chores

    • Updated ignore rules for an additional local project directory.

@helloscoopa helloscoopa self-assigned this Jul 6, 2026
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@helloscoopa, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 44 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bc55b896-8a87-445a-b746-0a22be69ce2d

📥 Commits

Reviewing files that changed from the base of the PR and between 867178e and b0848a1.

📒 Files selected for processing (3)
  • README.md
  • src/resources/direct-debits.ts
  • src/types/direct-debit.types.ts
📝 Walkthrough

Walkthrough

This 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.

Changes

New API Resources Cohort

Layer / File(s) Summary
Client wiring
src/client.ts
Imports and instantiates Banks, Branches, DirectDebits, and Withdrawals as public readonly properties initialized with the shared HttpClient.
Banks resource
src/resources/banks.ts, src/types/bank.types.ts
Adds Bank type and Banks class with list() calling GET /v1/bank/list.
Branches resource
src/resources/branches.ts, src/types/branch.types.ts
Adds branch types and Branches class with create, list, get, update, deactivate methods against /v1/branch endpoints.
Direct debits resource
src/resources/direct-debits.ts, src/types/direct-debit.types.ts
Adds direct-debit types and DirectDebits class with scenario listing, contract create/list/get/sync/terminate, and payment execution methods.
Withdrawals resource
src/resources/withdrawals.ts, src/types/withdrawal.types.ts
Adds withdrawal types and Withdrawals class with create, list, get methods against /v1/withdrawal endpoints.
Type exports and config
src/types/index.ts, .gitignore
Re-exports new type modules from the index and ignores CeyPay-BE in gitignore.

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
Loading

Related PRs: None specified.

Suggested labels: enhancement, feature

Suggested reviewers: None specified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the addition of bank, branch, direct debit, and withdrawal resources.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch scoopa/more-resources

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@helloscoopa
helloscoopa requested a review from xbuddhi July 6, 2026 12:08
@helloscoopa helloscoopa assigned rayaanr and unassigned rayaanr Jul 6, 2026
@helloscoopa
helloscoopa requested a review from rayaanr July 6, 2026 12:09

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
src/resources/direct-debits.ts (1)

16-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use named types for scenario list, consistent with other methods.

listScenarios uses 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 adding ListScenariosQuery and a ScenarioListResponse type 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 value

Duplicate status literal union.

The 'INITIATED' | 'SIGNED' | 'TERMINATED' | 'EXPIRED' union is repeated in both DirectDebitContract and ListContractsQuery. Extracting a shared DirectDebitContractStatus type 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 value

Unclear comment # ln.

Consider a clearer comment explaining why CeyPay-BE is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9366c32 and 867178e.

📒 Files selected for processing (11)
  • .gitignore
  • src/client.ts
  • src/resources/banks.ts
  • src/resources/branches.ts
  • src/resources/direct-debits.ts
  • src/resources/withdrawals.ts
  • src/types/bank.types.ts
  • src/types/branch.types.ts
  • src/types/direct-debit.types.ts
  • src/types/index.ts
  • src/types/withdrawal.types.ts

merchantId: string;
amount: number;
currency: string;
status: 'PENDING' | 'APPROVED' | 'REJECTED' | 'PROCESSING' | 'COMPLETED' | 'FAILED';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

}

export interface ListWithdrawalsQuery extends PaginationParams {
status?: 'PENDING' | 'APPROVED' | 'REJECTED' | 'PROCESSING' | 'COMPLETED' | 'FAILED';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread src/resources/banks.ts
* @returns A promise that resolves to an array of Bank objects
*/
async list(): Promise<Bank[]> {
return this.client.request<Bank[]>('GET', '/v1/bank/list');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The older endpoints include the /api/ prefix, while the new ones don't. One of them is wrong.

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.

2 participants