Skip to content

Commit

Permalink
feat: add balance transactions service
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNoim committed Jul 17, 2024
1 parent 9aa1d46 commit e8be230
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/services/balance-transactions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type Stripe from "stripe";
import type { FindMethod, ParamsWithStripe, ParamsWithStripeQuery } from "../types";
import { BaseService } from "./base";

export interface IBalanceTransactionService {
_find: FindMethod<ParamsWithStripeQuery<Stripe.BalanceTransactionListParams>, Stripe.BalanceTransaction>;
_get: (id: string, params: ParamsWithStripe) => Promise<Stripe.BalanceTransaction>;
_create: never;
_update: never;
_patch: never;
_remove: never;
}

export class BalanceTransactionService
extends BaseService<IBalanceTransactionService>
implements IBalanceTransactionService
{
_get(id: string, params: ParamsWithStripe) {
let { stripe } = this.filterParams(params);
stripe = Object.assign({}, stripe);
if (id) {
stripe.stripeAccount = id;
}
return this.stripe.balanceTransactions.retrieve(undefined, stripe);
}

_find (params: ParamsWithStripeQuery<Stripe.BalanceTransactionListParams>) {
const filtered = this.filterParams(params);
return this.handlePaginate(
filtered,
this.stripe.balanceTransactions.list(filtered.query, filtered.stripe)
);
}

_create: never;
_update: never;
_patch: never;
_remove: never;
}
1 change: 1 addition & 0 deletions src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export { AccountService } from "./account";
export { AccountLinkService } from "./account-links";
export { ApplicationFeeRefundService } from "./application-fee-refund";
export { BalanceService } from "./balance";
export { BalanceTransactionService } from "./balance-transactions";
export { BankAccountService } from "./bank-account";
export { ExternalAccountService } from "./external-account";
export { CardService } from "./card";
Expand Down
2 changes: 2 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
AccountLinkService,
ApplicationFeeRefundService,
BalanceService,
BalanceTransactionService,
BankAccountService,
ExternalAccountService,
CardService,
Expand Down Expand Up @@ -37,6 +38,7 @@ const services = [
AccountLinkService,
ApplicationFeeRefundService,
BalanceService,
BalanceTransactionService,
BankAccountService,
ExternalAccountService,
CardService,
Expand Down

0 comments on commit e8be230

Please sign in to comment.