Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add balance transactions service #120

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading