diff --git a/index.ts b/index.ts index 589c130..fd9420a 100644 --- a/index.ts +++ b/index.ts @@ -5,5 +5,9 @@ export { AccountTypes } from './src/resources/Account'; export { ElementTypes } from './src/resources/Element'; export { EntityTypes, EntityStatuses } from './src/resources/Entity'; export { PaymentFundStatuses, PaymentStatuses } from './src/resources/Payment'; -export { ReportTypes, ReportStatuses } from './src/resources/Report'; +export { + ReportTypes, + ReportRetrieveTypes, + ReportStatuses, +} from './src/resources/Report'; export { WebhookTypes } from './src/resources/Webhook'; diff --git a/src/resources/Report/index.ts b/src/resources/Report/index.ts index f83ae8a..b6caf18 100644 --- a/src/resources/Report/index.ts +++ b/src/resources/Report/index.ts @@ -13,12 +13,18 @@ export const ReportTypes = { ach_pull_nightly: 'ach.pull.nightly', ach_reversals_nightly: 'ach.reversals.nightly', entities_created_previous_day: 'entities.created.previous_day', - ach_debit_daily: 'ach.debit.daily', reserve_fbo_balance_created_previous_day: 'reserve_fbo_balance.created.previous_day', } as const; export type TReportTypes = typeof ReportTypes[keyof typeof ReportTypes]; +export const ReportRetrieveTypes = { + ...ReportTypes, + ach_debit_daily: 'ach.debit.daily', +} as const; + +export type TReportRetrieveTypes = typeof ReportRetrieveTypes[keyof typeof ReportRetrieveTypes]; + export const ReportStatuses = { processing: 'processing', completed: 'completed', @@ -28,7 +34,7 @@ export type TReportStatuses = keyof typeof ReportStatuses; export interface IReport { id: string; - type: TReportTypes; + type: TReportRetrieveTypes; url: string; status: TReportStatuses; metadata: {} | null; diff --git a/test/resources/Report.tests.ts b/test/resources/Report.tests.ts index 1091f75..9f6a10b 100644 --- a/test/resources/Report.tests.ts +++ b/test/resources/Report.tests.ts @@ -1,11 +1,26 @@ import { should } from 'chai'; import { describe } from 'mocha'; import { client } from '../config'; -import type { IReport } from '../../src/resources/Report'; +import { ReportRetrieveTypes, ReportTypes } from '../../src/resources/Report'; +import type { IReport, IReportCreateOpts } from '../../src/resources/Report'; import { IResponse } from '../../src/configuration'; should(); +type Assert = T; +type CreateTypesAreReadable = Assert< + IReportCreateOpts['type'] extends IReport['type'] ? true : false +>; +type ReportTypesAreCreatable = Assert< + typeof ReportTypes[keyof typeof ReportTypes] extends IReportCreateOpts['type'] ? true : false +>; +type AchDebitDailyIsReadable = Assert< + typeof ReportRetrieveTypes.ach_debit_daily extends IReport['type'] ? true : false +>; +type AchDebitDailyIsNotCreatable = Assert< + typeof ReportRetrieveTypes.ach_debit_daily extends IReportCreateOpts['type'] ? false : true +>; + //TODO: Add tests for each report type describe('Reports - core methods tests', () => { let reports_create_response: IResponse;