Skip to content

Commit

Permalink
feat(creditCardBills): add endpoint and missing types.
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasMontone committed Sep 16, 2024
1 parent 0a62062 commit da89150
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
PageFilters,
InvestmentsFilters,
} from './types'
import { CreditCardBills } from './types/creditCardBills'
import { ValidationResult } from './types/validation'

/**
Expand Down Expand Up @@ -337,6 +338,26 @@ export class PluggyClient extends BaseApi {
return await this.createGetRequest(`identity?itemId=${itemId}`)
}

/**
* Fetch credit card bills from an accountId
* @returns {PageResponse<CreditCardBills>} an credit card bills object
*/
async fetchCreditCardBills(
accountId: string,
options: PageFilters = {}
): Promise<PageResponse<CreditCardBills>> {
return await this.createGetRequest('bills', { ...options, accountId })
}

/**
* Fetch a single credit card bill by its id
* @param {string} id - the credit card bill id
* @returns {Promise<CreditCardBills>} - credit card bill object, if found
*/
async fetchCreditCardBill(id: string): Promise<CreditCardBills> {
return await this.createGetRequest(`bills/${id}`)
}

/**
* Fetch all available categories
* @returns {Categories[]} an paging response of categories
Expand Down
31 changes: 31 additions & 0 deletions src/types/creditCardBills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { CurrencyCode } from './common'

export const CREDIT_CARD_BILL_FINANCE_CHARGE_TYPES = [
'LATE_PAYMENT_REMUNERATIVE_INTEREST',
'LATE_PAYMENT_FEE',
'LATE_PAYMENT_INTEREST',
'IOF',
'OTHER',
] as const

export type CreditCardBillFinanceChargeType = typeof CREDIT_CARD_BILL_FINANCE_CHARGE_TYPES[number]

export type CreditCardBills = {
id: string
dueDate: Date
totalAmount: number
totalAmountCurrencyCode: CurrencyCode
minimumPaymentAmount: number | null
allowsInstallments: boolean | null
financeCharges: CreditCardBillFinanceChargeResponseItem[]
createdAt: Date
updatedAt: Date
}

export type CreditCardBillFinanceChargeResponseItem = {
id: string
type: CreditCardBillFinanceChargeType
amount: number
currencyCode: CurrencyCode
additionalInfo: string | null
}

0 comments on commit da89150

Please sign in to comment.