From e8be230679e6070429970c9979be31fd0a9e42a3 Mon Sep 17 00:00:00 2001 From: Nils Bergmann Date: Wed, 17 Jul 2024 14:58:42 +0200 Subject: [PATCH] feat: add balance transactions service --- src/services/balance-transactions.ts | 39 ++++++++++++++++++++++++++++ src/services/index.ts | 1 + test/index.test.ts | 2 ++ 3 files changed, 42 insertions(+) create mode 100644 src/services/balance-transactions.ts diff --git a/src/services/balance-transactions.ts b/src/services/balance-transactions.ts new file mode 100644 index 0000000..ef17e8a --- /dev/null +++ b/src/services/balance-transactions.ts @@ -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, Stripe.BalanceTransaction>; + _get: (id: string, params: ParamsWithStripe) => Promise; + _create: never; + _update: never; + _patch: never; + _remove: never; +} + +export class BalanceTransactionService + extends BaseService + 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) { + 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; +} diff --git a/src/services/index.ts b/src/services/index.ts index 8d2f9bb..3efd3df 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -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"; diff --git a/test/index.test.ts b/test/index.test.ts index 6a15c08..7564f9c 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -4,6 +4,7 @@ import { AccountLinkService, ApplicationFeeRefundService, BalanceService, + BalanceTransactionService, BankAccountService, ExternalAccountService, CardService, @@ -37,6 +38,7 @@ const services = [ AccountLinkService, ApplicationFeeRefundService, BalanceService, + BalanceTransactionService, BankAccountService, ExternalAccountService, CardService,