Skip to content

Commit 9f88ed6

Browse files
authored
feat: add balance transactions service (#120)
1 parent 9aa1d46 commit 9f88ed6

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

src/services/balance-transactions.ts

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import type Stripe from "stripe";
2+
import type { FindMethod, ParamsWithStripe, ParamsWithStripeQuery } from "../types";
3+
import { BaseService } from "./base";
4+
5+
export interface IBalanceTransactionService {
6+
_find: FindMethod<ParamsWithStripeQuery<Stripe.BalanceTransactionListParams>, Stripe.BalanceTransaction>;
7+
_get: (id: string, params: ParamsWithStripe) => Promise<Stripe.BalanceTransaction>;
8+
_create: never;
9+
_update: never;
10+
_patch: never;
11+
_remove: never;
12+
}
13+
14+
export class BalanceTransactionService
15+
extends BaseService<IBalanceTransactionService>
16+
implements IBalanceTransactionService
17+
{
18+
_get(id: string, params: ParamsWithStripe) {
19+
let { stripe } = this.filterParams(params);
20+
stripe = Object.assign({}, stripe);
21+
if (id) {
22+
stripe.stripeAccount = id;
23+
}
24+
return this.stripe.balanceTransactions.retrieve(undefined, stripe);
25+
}
26+
27+
_find (params: ParamsWithStripeQuery<Stripe.BalanceTransactionListParams>) {
28+
const filtered = this.filterParams(params);
29+
return this.handlePaginate(
30+
filtered,
31+
this.stripe.balanceTransactions.list(filtered.query, filtered.stripe)
32+
);
33+
}
34+
35+
_create: never;
36+
_update: never;
37+
_patch: never;
38+
_remove: never;
39+
}

src/services/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export { AccountService } from "./account";
22
export { AccountLinkService } from "./account-links";
33
export { ApplicationFeeRefundService } from "./application-fee-refund";
44
export { BalanceService } from "./balance";
5+
export { BalanceTransactionService } from "./balance-transactions";
56
export { BankAccountService } from "./bank-account";
67
export { ExternalAccountService } from "./external-account";
78
export { CardService } from "./card";

test/index.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
AccountLinkService,
55
ApplicationFeeRefundService,
66
BalanceService,
7+
BalanceTransactionService,
78
BankAccountService,
89
ExternalAccountService,
910
CardService,
@@ -37,6 +38,7 @@ const services = [
3738
AccountLinkService,
3839
ApplicationFeeRefundService,
3940
BalanceService,
41+
BalanceTransactionService,
4042
BankAccountService,
4143
ExternalAccountService,
4244
CardService,

0 commit comments

Comments
 (0)