From bd85015f9357a16bb46406ebb3f72e5f308e5efe Mon Sep 17 00:00:00 2001 From: Bilal Hussain Date: Tue, 8 Apr 2025 19:07:37 -0500 Subject: [PATCH 1/4] simulate credit scores --- src/resource.ts | 6 +++- .../Simulate/Entities/CreditScores.ts | 35 +++++++++++++++++++ src/resources/Simulate/Entities/index.ts | 26 ++++++++++++++ src/resources/Simulate/index.ts | 4 +++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 src/resources/Simulate/Entities/CreditScores.ts create mode 100644 src/resources/Simulate/Entities/index.ts diff --git a/src/resource.ts b/src/resource.ts index 41f7e13..5a5a447 100644 --- a/src/resource.ts +++ b/src/resource.ts @@ -9,12 +9,16 @@ import { AccountSubResources } from './resources/Account'; import { PaymentSubResources } from './resources/Payment'; import { EntitySubResources } from './resources/Entity'; import { SimulateAccountsSubResources } from './resources/Simulate/Accounts'; +import { SimulateEntitiesSubResources } from './resources/Simulate/Entities'; +import { SimulateCreditScoresInstance } from './resources/Simulate/Entities/CreditScores'; type TSubResources = | AccountSubResources | PaymentSubResources | EntitySubResources - | SimulateAccountsSubResources; + | SimulateAccountsSubResources + | SimulateEntitiesSubResources + | SimulateCreditScoresInstance; export interface IRequestConfig { idempotency_key?: string; diff --git a/src/resources/Simulate/Entities/CreditScores.ts b/src/resources/Simulate/Entities/CreditScores.ts new file mode 100644 index 0000000..90f070e --- /dev/null +++ b/src/resources/Simulate/Entities/CreditScores.ts @@ -0,0 +1,35 @@ +import Resource from '../../../resource'; +import Configuration, { IResponse } from '../../../configuration'; +import type { + IEntityCreditScores, + IEntityCreditScoresType, +} from '../../Entity'; + +export class SimulateCreditScoresInstance extends Resource { + constructor(crs_id: string, config: Configuration) { + super(config.addPath(crs_id)); + } + + /** + * For Entities that have been successfully verified, you may simulate Credit Scores in the dev environment. + * + * @returns Returns the created Credit Score. + */ + async create(opts: { scores: IEntityCreditScoresType[] }) { + return super._create, { scores: IEntityCreditScoresType[] }>(opts); + } +} + +export default interface SimulateCreditScores { + (crs_id: string): SimulateCreditScoresInstance; +} + +export default class SimulateCreditScores extends Resource { + constructor(config: Configuration) { + super(config.addPath('credit_scores')); + } + + protected _call(crs_id: string): SimulateCreditScoresInstance { + return new SimulateCreditScoresInstance(crs_id, this.config); + } +} diff --git a/src/resources/Simulate/Entities/index.ts b/src/resources/Simulate/Entities/index.ts new file mode 100644 index 0000000..fc0b384 --- /dev/null +++ b/src/resources/Simulate/Entities/index.ts @@ -0,0 +1,26 @@ +import Resource from '../../../resource'; +import Configuration from '../../../configuration'; +import SimulateCreditScores from './CreditScores'; + +export class SimulateEntitiesSubResources { + creditScores: SimulateCreditScores; + constructor(entity_id: string, config: Configuration) { + this.creditScores = new SimulateCreditScores(config.addPath(entity_id)); + } +} + +export interface SimulateEntities { + (entity_id: string): SimulateEntitiesSubResources; +} + +export class SimulateEntities extends Resource { + constructor(config: Configuration) { + super(config.addPath('entities')); + } + + protected _call(entity_id: string): SimulateEntitiesSubResources { + return new SimulateEntitiesSubResources(entity_id, this.config); + } +} + +export default SimulateEntities; diff --git a/src/resources/Simulate/index.ts b/src/resources/Simulate/index.ts index 22d57c0..9e4c475 100644 --- a/src/resources/Simulate/index.ts +++ b/src/resources/Simulate/index.ts @@ -2,23 +2,27 @@ import Resource from '../../resource'; import Configuration from '../../configuration'; import SimulatePayments from './Payments'; import SimulateAccounts from './Accounts'; +import SimulateEntities from './Entities'; import SimulateEvents from './Events'; export interface Simulate { payments: SimulatePayments; accounts: SimulateAccounts; + entities: SimulateEntities; events: SimulateEvents; }; export class Simulate extends Resource { payments: SimulatePayments; accounts: SimulateAccounts; + entities: SimulateEntities; events: SimulateEvents; constructor(config: Configuration) { const _config = config.addPath('simulate'); super(_config); this.payments = new SimulatePayments(_config); this.accounts = new SimulateAccounts(_config); + this.entities = new SimulateEntities(_config); this.events = new SimulateEvents(_config); } }; From 29597958eaf735ae72c3b1a8f502153a857fa48d Mon Sep 17 00:00:00 2001 From: Bilal Hussain Date: Tue, 8 Apr 2025 19:07:55 -0500 Subject: [PATCH 2/4] transactions + payment instruments --- src/resources/Account/PaymentInstruments.ts | 40 +++++++ src/resources/Account/index.ts | 3 + src/resources/Account/types.ts | 112 +++++++++++++------- 3 files changed, 115 insertions(+), 40 deletions(-) create mode 100644 src/resources/Account/PaymentInstruments.ts diff --git a/src/resources/Account/PaymentInstruments.ts b/src/resources/Account/PaymentInstruments.ts new file mode 100644 index 0000000..67ec579 --- /dev/null +++ b/src/resources/Account/PaymentInstruments.ts @@ -0,0 +1,40 @@ +import Resource, { IResourceListOpts } from '../../resource'; +import Configuration, { IResponse } from '../../configuration'; +import type { IAccountPaymentInstrument, IPaymentInstrumentCreateOpts } from './types'; + +export default class AccountPaymentInstruments extends Resource { + constructor(config: Configuration) { + super(config.addPath('payment_instruments')); + } + + /** + * Retrieves a Payment Instrument record for an Account. + * + * @param pmt_inst_id ID of the Payment Instrument + * @returns Returns an Account’s Payment Instrument object. + */ + + async retrieve(pmt_inst_id: string) { + return super._getWithId>(pmt_inst_id); + } + + /** + * Retrieves a list of Payment Instrument objects for an account. + * + * @returns Returns a list of Payment Instrument objects. + */ + + async list(opts?: IResourceListOpts) { + return super._list>(opts); + } + + /** + * Creates a new Payment Instrument request to retrieve the Account’s payment instruments. + * + * @returns Returns an Account’s Payment Instrument object. + */ + + async create(data: IPaymentInstrumentCreateOpts) { + return super._create, IPaymentInstrumentCreateOpts>(data); + } +}; diff --git a/src/resources/Account/index.ts b/src/resources/Account/index.ts index b86a0c5..da13925 100644 --- a/src/resources/Account/index.ts +++ b/src/resources/Account/index.ts @@ -8,6 +8,7 @@ import AccountBalances from './Balances'; import AccountSensitive from './Sensitive'; import AccountTransactions from './Transactions'; import AccountSubscriptions from './Subscriptions'; +import AccountPaymentInstruments from './PaymentInstruments'; import AccountVerificationSession from './VerificationSessions'; import AccountProducts from './Products'; import type { @@ -29,6 +30,7 @@ export class AccountSubResources { transactions: AccountTransactions; updates: AccountUpdates; attributes: AccountAttributes; + paymentInstruments: AccountPaymentInstruments; verificationSessions: AccountVerificationSession; constructor(acc_id: string, config: Configuration) { @@ -41,6 +43,7 @@ export class AccountSubResources { this.transactions = new AccountTransactions(config.addPath(acc_id)); this.updates = new AccountUpdates(config.addPath(acc_id)); this.attributes = new AccountAttributes(config.addPath(acc_id)); + this.paymentInstruments = new AccountPaymentInstruments(config.addPath(acc_id)); this.verificationSessions = new AccountVerificationSession(config.addPath(acc_id)); } }; diff --git a/src/resources/Account/types.ts b/src/resources/Account/types.ts index c9d87e8..df0dcdb 100644 --- a/src/resources/Account/types.ts +++ b/src/resources/Account/types.ts @@ -36,6 +36,7 @@ export const AccountProducts = { update: 'update', attribute: 'attribute', transactions: 'transactions', + payment_instrument: 'payment_instrument', } as const; export type TAccountProducts = keyof typeof AccountProducts; @@ -67,11 +68,12 @@ export interface IAccountProductListResponse { payoff?: IAccountProduct; update?: IAccountProduct; attribute?: IAccountProduct; - transactions?: IAccountProduct; + transaction?: IAccountProduct; + payment_instrument?: IAccountProduct; }; export const AccountSubscriptionTypes = { - transactions: 'transactions', + transaction: 'transaction', update: 'update', update_snapshot: 'update.snapshot', } as const; @@ -384,7 +386,7 @@ export interface IAccountSubscription { }; export interface IAccountSubscriptionsResponse { - transactions?: IAccountSubscription; + transaction?: IAccountSubscription; update?: IAccountSubscription; 'update.snapshot'?: IAccountSubscription; }; @@ -416,52 +418,32 @@ export interface IAccountUpdate { updated_at: string; }; -export const AccountCurrencyTypes = { - USD: 'USD', -}; - -export type TAccountCurrencyTypes = keyof typeof AccountCurrencyTypes; - export const AccountTransactionStatuses = { - cleared: 'cleared', - auth: 'auth', - refund: 'refund', - unknown: 'unknown', + pending: 'pending', + posted: 'posted', + voided: 'voided', } as const; export type TAccountTransactionStatuses = keyof typeof AccountTransactionStatuses; -export interface IAccountTransactionMerchant { - name: string; - category_code: string; - city: string; - state: string; - country: string; - acquirer_bin: string; - acquirer_card_acceptor_id: string; -}; - -export interface IAccountTransactionNetworkData { - visa_merchant_id: string | null; - visa_merchant_name: string | null; - visa_store_id: string | null; - visa_store_name: string | null; -}; - export interface IAccountTransaction { id: string; account_id: string; - merchant: IAccountTransactionMerchant; - network: string; - network_data: IAccountTransactionNetworkData | null; + descriptor: string; amount: number; - currency: TAccountCurrencyTypes; - billing_amount: number; - billing_currency: TAccountCurrencyTypes; + auth_amount: number; + currency_code: string; + transaction_amount: number; + transaction_auth_amount: number; + transaction_currency_code: string; + merchant_category_code: string; status: TAccountTransactionStatuses; - error: IResourceError | null; - created_at: string; - updated_at: string; + transacted_at: Date; + posted_at: Date | null; + voided_at: Date | null; + original_txn_id: string | null; + created_at: Date; + updated_at: Date; }; export const AccountVerificationSessionStatuses = { @@ -481,6 +463,7 @@ export const AccountVerificationSessionTypes = { standard: 'standard', instant: 'instant', pre_auth: 'pre_auth', + network: 'network', } as const; export type TAccountVerificaionSessionTypes = keyof typeof AccountVerificationSessionTypes; @@ -536,6 +519,14 @@ export interface IAccountVerificationSessionPreAuth extends IAccountVerification pre_auth_check?: TAccountVerificationPassFail | null; }; +export interface IAccountVerificationSessionNetwork extends IAccountVerificationSessionInstant { + cvv?: string | null; + cvv_check?: TAccountVerificationPassFail | null; + billing_zip_code?: string | null; + billing_zip_code_check?: TAccountVerificationPassFail | null; + network_check?: TAccountVerificationPassFail | null; +}; + export interface IAccountVerificationSessionCreateOpts { type: TAccountVerificaionSessionTypes; }; @@ -568,6 +559,10 @@ export interface IAccountVerificationSessionPreAuthUpdateOpts { pre_auth: IAccountVerificationSessionPreAuth }; +export interface IAccountVerificationSessionNetworkUpdateOpts { + network: IAccountVerificationSessionNetwork; +}; + export type IAccountVerificationSessionUpdateOpts = | IAccountVerificationSessionMicroDepositsUpdateOpts | IAccountVerificationSessionPlaidUpdateOpts @@ -575,7 +570,8 @@ export type IAccountVerificationSessionUpdateOpts = | IAccountVerificationSessionTellerUpdateOpts | IAccountVerificationSessionStandardUpdateOpts | IAccountVerificationSessionInstantUpdateOpts - | IAccountVerificationSessionPreAuthUpdateOpts; + | IAccountVerificationSessionPreAuthUpdateOpts + | IAccountVerificationSessionNetworkUpdateOpts; export interface IAccountVerificationSession { id: string; @@ -592,6 +588,7 @@ export interface IAccountVerificationSession { standard?: IAccountVerificationSessionStandard | null; instant?: IAccountVerificationSessionInstant | null; pre_auth?: IAccountVerificationSessionPreAuth | null; + network?: IAccountVerificationSessionNetwork | null; three_ds?: IAccountVerificationSessionThreeDS | null; issuer?: IAccountVerificationSessionIssuer | null; created_at: string; @@ -657,6 +654,40 @@ export interface IAccountAttributes { updated_at: string; } +export const PaymentInstrumentTypes = { + card: 'card', + network_token: 'network_token' +} as const; + +export type TPaymentInstrumentTypes = keyof typeof PaymentInstrumentTypes; + +export interface IPaymentInstrumentCreateOpts { + type: TPaymentInstrumentTypes; +} + +export interface IPaymentInstrumentCard { + number: string; + exp_month: number; + exp_year: number; +} + +export interface IPaymentInstrumentNetworkToken { + token: string; +} + +export interface IAccountPaymentInstrument { + id: string; + account_id: string; + type: TPaymentInstrumentTypes; + network_token?: IPaymentInstrumentNetworkToken | null; + card?: IPaymentInstrumentCard | null; + chargeable: boolean; + status: TResourceStatus; + error: IResourceError | null; + created_at: Date; + updated_at: Date; +} + export interface IAccount { id: string; holder_id: string; @@ -676,6 +707,7 @@ export interface IAccount { transactions?: string | IAccountTransaction[] | null; update?: string | IAccountUpdate | null; attribute?: string | IAccountAttributes | null; + payment_instrument?: string | IAccountPaymentInstrument | null; latest_verification_session?: string | IAccountVerificationSession | null; error: IResourceError | null; created_at: string; From 602409d5c173d0af1f004729d16ec81188d3ca21 Mon Sep 17 00:00:00 2001 From: Bilal Hussain Date: Tue, 8 Apr 2025 19:08:04 -0500 Subject: [PATCH 3/4] tests --- test/resources/Account.tests.ts | 178 +++++++++++++++++++++----------- test/resources/Entity.tests.ts | 90 ++++++++++++++-- test/resources/Event.tests.ts | 30 ------ 3 files changed, 197 insertions(+), 101 deletions(-) diff --git a/test/resources/Account.tests.ts b/test/resources/Account.tests.ts index d42b6d1..fdd2137 100644 --- a/test/resources/Account.tests.ts +++ b/test/resources/Account.tests.ts @@ -3,21 +3,22 @@ import { describe } from 'mocha'; import { client } from '../config'; import { awaitResults } from '../utils'; import type { IEntity, IEntityConnect } from '../../src/resources/Entity'; -import type { - IAccount, - IAccountBalance, - IAccountCardBrand, - IAccountPayoff, - IAccountSensitive, - IAccountTransaction, - IAccountSubscription, - IAccountSubscriptionsResponse, - IAccountVerificationSession, - IAccountUpdate, - TAccountProducts, - IAccountAttributes, - IAccountProduct, - IAccountProductListResponse, +import { + type IAccount, + type IAccountBalance, + type IAccountCardBrand, + type IAccountPayoff, + type IAccountSensitive, + type IAccountTransaction, + type IAccountSubscription, + type IAccountSubscriptionsResponse, + type IAccountVerificationSession, + type IAccountUpdate, + type TAccountProducts, + type IAccountAttributes, + type IAccountProduct, + type IAccountProductListResponse, + type IAccountPaymentInstrument, } from '../../src/resources/Account'; import { IResponse } from '../../src/configuration'; @@ -32,6 +33,7 @@ describe('Accounts - core methods tests', () => { let accounts_list_response: IResponse[]; let balances_create_response: IResponse; let test_credit_card_account: IResponse; + let test_credit_card_account_2: IResponse; let test_auto_loan_account: IResponse; let card_create_response: IResponse; let payoff_create_response: IResponse; @@ -79,10 +81,17 @@ describe('Accounts - core methods tests', () => { "status": "active", }))[0]; + test_credit_card_account_2 = (await client.accounts.list({ + holder_id: holder_1_response.id, + "liability.type": 'credit_card', + "liability.mch_id": "mch_311289", + "status": "active", + }))[0]; + test_auto_loan_account = (await client.accounts.list({ holder_id: holder_1_response.id, "liability.type": 'auto_loan', - "liability.mch_id": "mch_2347", + "liability.mch_id": "mch_311130", "status": "active", }))[0]; }); @@ -144,6 +153,7 @@ describe('Accounts - core methods tests', () => { attribute: null, update: accounts_create_liability_response.update, card_brand: null, + payment_instrument: null, products: accounts_create_liability_response.products, restricted_products: accounts_create_liability_response.restricted_products, subscriptions: accounts_create_liability_response.subscriptions, @@ -600,14 +610,33 @@ describe('Accounts - core methods tests', () => { describe('accounts.subscriptions', () => { it('should successfully create a transactions subscription.', async () => { + const network_verification_session = await client + .accounts(test_credit_card_account_2.id) + .verificationSessions + .create({ + type: 'network' + }); + + await client + .accounts(test_credit_card_account_2.id) + .verificationSessions + .update(network_verification_session.id, { + network: { + exp_month: '09', + exp_year: '2028', + billing_zip_code: '78758', + cvv: '539' + } + }); + create_txn_subscriptions_response = await client - .accounts(test_credit_card_account.id) + .accounts(test_credit_card_account_2.id) .subscriptions - .create('transactions'); + .create('transaction'); const expect_results: IAccountSubscription = { id: create_txn_subscriptions_response.id, - name: 'transactions', + name: 'transaction', status: 'active', latest_request_id: null, created_at: create_txn_subscriptions_response.created_at, @@ -663,16 +692,13 @@ describe('Accounts - core methods tests', () => { .accounts(test_auto_loan_account.id) .subscriptions .list(); + + const subscriptions_transactions_response = await client + .accounts(test_credit_card_account_2.id) + .subscriptions + .list(); const expect_results_card: IAccountSubscriptionsResponse = { - transactions: { - id: create_txn_subscriptions_response.id, - name: 'transactions', - status: 'active', - latest_request_id: null, - created_at: subscriptions_response.transactions?.created_at || '', - updated_at: subscriptions_response.transactions?.updated_at || '' - }, update: { id: create_update_subscriptions_response.id, name: 'update', @@ -683,6 +709,17 @@ describe('Accounts - core methods tests', () => { } }; + const expect_results_transactions: IAccountSubscriptionsResponse = { + transaction: { + id: create_txn_subscriptions_response.id, + name: 'transaction', + status: 'active', + latest_request_id: null, + created_at: subscriptions_transactions_response.transaction?.created_at || '', + updated_at: subscriptions_transactions_response.transaction?.updated_at || '' + } + }; + const expect_results_snapshot: IAccountSubscriptionsResponse = { 'update.snapshot': { id: create_update_snapshot_subscriptions_response.id, @@ -696,17 +733,18 @@ describe('Accounts - core methods tests', () => { subscriptions_response.should.be.eql(expect_results_card); subscriptions_update_snapshot_response.should.be.eql(expect_results_snapshot); + subscriptions_transactions_response.should.be.eql(expect_results_transactions); }); it('should successfully retrieve a transactions subscription.', async () => { const retrieve_subscriptions_response = await client - .accounts(test_credit_card_account.id) + .accounts(test_credit_card_account_2.id) .subscriptions .retrieve(create_txn_subscriptions_response.id); const expect_results: IAccountSubscription = { id: create_txn_subscriptions_response.id, - name: 'transactions', + name: 'transaction', status: 'active', latest_request_id: null, created_at: retrieve_subscriptions_response.created_at, @@ -773,9 +811,9 @@ describe('Accounts - core methods tests', () => { describe('accounts.transactions', () => { it('should successfully list transactions for an account.', async () => { - const { amount, billing_amount, merchant } = await client.simulate.accounts(test_credit_card_account.id).transactions.create(); + const { amount, descriptor, transacted_at, posted_at } = await client.simulate.accounts(test_credit_card_account_2.id).transactions.create(); const res = await client - .accounts(test_credit_card_account.id) + .accounts(test_credit_card_account_2.id) .transactions .list(); @@ -783,16 +821,20 @@ describe('Accounts - core methods tests', () => { const expect_results: IAccountTransaction = { id: transactions_response.id, - account_id: test_credit_card_account.id, - merchant, - network: 'visa', - network_data: null, + account_id: test_credit_card_account_2.id, + status: 'posted', + descriptor, amount, - currency: 'USD', - billing_amount, - billing_currency: 'USD', - status: 'cleared', - error: null, + auth_amount: amount, + currency_code: 'USD', + transaction_amount: amount, + transaction_auth_amount: amount, + transaction_currency_code: 'USD', + merchant_category_code: '5182', + transacted_at, + posted_at, + voided_at: null, + original_txn_id: null, created_at: transactions_response.created_at, updated_at: transactions_response.updated_at }; @@ -802,24 +844,28 @@ describe('Accounts - core methods tests', () => { it('should successfully retrieve a transaction for an account.', async () => { const retrieve_transaction_response = await client - .accounts(test_credit_card_account.id) + .accounts(test_credit_card_account_2.id) .transactions .retrieve(transactions_response.id); const expect_results: IAccountTransaction = { id: transactions_response.id, - account_id: test_credit_card_account.id, - merchant: transactions_response.merchant, - network: 'visa', - network_data: null, - amount: transactions_response.amount, - currency: 'USD', - billing_amount: transactions_response.billing_amount, - billing_currency: 'USD', - status: 'cleared', - error: null, - created_at: transactions_response.created_at, - updated_at: transactions_response.updated_at + account_id: test_credit_card_account_2.id, + status: 'posted', + descriptor: retrieve_transaction_response.descriptor, + amount: retrieve_transaction_response.amount, + auth_amount: retrieve_transaction_response.auth_amount, + currency_code: 'USD', + transaction_amount: retrieve_transaction_response.transaction_amount, + transaction_auth_amount: retrieve_transaction_response.transaction_auth_amount, + transaction_currency_code: 'USD', + merchant_category_code: '5182', + transacted_at: retrieve_transaction_response.transacted_at, + posted_at: retrieve_transaction_response.posted_at, + voided_at: null, + original_txn_id: null, + created_at: retrieve_transaction_response.created_at, + updated_at: retrieve_transaction_response.updated_at }; retrieve_transaction_response.should.be.eql(expect_results); @@ -1048,15 +1094,15 @@ describe('Accounts - core methods tests', () => { created_at: accounts_retrieve_product_list_response.attribute?.created_at || '', updated_at: accounts_retrieve_product_list_response.attribute?.updated_at || '' }, - transactions: { - id: accounts_retrieve_product_list_response.transactions?.id || '', - name: 'transactions', - status: 'available', - status_error: null, - latest_request_id: accounts_retrieve_product_list_response.transactions?.latest_request_id || null, + transaction: { + id: accounts_retrieve_product_list_response.transaction?.id || '', + name: 'transaction', + status: 'unavailable', + status_error: accounts_retrieve_product_list_response.transaction?.status_error || null, + latest_request_id: accounts_retrieve_product_list_response.transaction?.latest_request_id || null, is_subscribable: true, - created_at: accounts_retrieve_product_list_response.transactions?.created_at || '', - updated_at: accounts_retrieve_product_list_response.transactions?.updated_at || '' + created_at: accounts_retrieve_product_list_response.transaction?.created_at || '', + updated_at: accounts_retrieve_product_list_response.transaction?.updated_at || '' }, card_brand: { id: accounts_retrieve_product_list_response.card_brand?.id || '', @@ -1077,6 +1123,16 @@ describe('Accounts - core methods tests', () => { is_subscribable: false, created_at: accounts_retrieve_product_list_response.payoff?.created_at || '', updated_at: accounts_retrieve_product_list_response.payoff?.updated_at || '' + }, + payment_instrument: { + id: accounts_retrieve_product_list_response.payment_instrument?.id || '', + name: 'payment_instrument', + status: 'restricted', + status_error: accounts_retrieve_product_list_response.payment_instrument?.status_error || null, + latest_request_id: accounts_retrieve_product_list_response.payment_instrument?.latest_request_id || null, + is_subscribable: true, + created_at: accounts_retrieve_product_list_response.payment_instrument?.created_at || '', + updated_at: accounts_retrieve_product_list_response.payment_instrument?.updated_at || '' } }; diff --git a/test/resources/Entity.tests.ts b/test/resources/Entity.tests.ts index 0494948..620e18a 100644 --- a/test/resources/Entity.tests.ts +++ b/test/resources/Entity.tests.ts @@ -31,6 +31,7 @@ describe('Entities - core methods tests', () => { let entities_account_list_response: IResponse[]; let entities_account_ids: string[]; let entities_create_credit_score_response: IResponse; + let entities_simulate_credit_score_response: IResponse; let entities_create_attribute_response: IResponse; let entities_create_idenitity_response: IResponse; let entities_create_vehicle_response: IResponse; @@ -416,6 +417,49 @@ describe('Entities - core methods tests', () => { entities_create_credit_score_response.should.be.eql(expect_results); }); + it('should successfully simulate a credit score request for an entity', async () => { + entities_simulate_credit_score_response = await client + .simulate + .entities(entities_create_response.id) + .creditScores(entities_create_credit_score_response.id) + .create({ + scores: [ + { + score: 800, + source: "equifax", + model: "vantage_4", + factors: [ + { + code: "00034", + description: "Total of all balances on bankcard or revolving accounts is too high" + }, + { + code: "00012", + description: "The date that you opened your oldest account is too recent" + }, + { + code: "00063", + description: "Lack of sufficient relevant real estate account information" + } + ], + created_at: new Date().toISOString(), + } + ] + }); + + const expect_results: IEntityCreditScores = { + id: entities_simulate_credit_score_response.id, + entity_id: entities_create_response.id, + status: 'completed', + scores: entities_simulate_credit_score_response.scores, + error: null, + created_at: entities_simulate_credit_score_response.created_at, + updated_at: entities_simulate_credit_score_response.updated_at, + }; + + entities_simulate_credit_score_response.should.be.eql(expect_results); + }); + it('should successfully retrieve the results of a credit score request for an entity', async () => { const getCreditScores = async () => { return await client @@ -431,12 +475,25 @@ describe('Entities - core methods tests', () => { status: 'completed', scores: [ { - score: credit_scores.scores[0].score, - source: 'equifax', - model: 'vantage_4', - factors: credit_scores.scores[0].factors, + score: 800, + source: "equifax", + model: "vantage_4", + factors: [ + { + code: "00034", + description: "Total of all balances on bankcard or revolving accounts is too high" + }, + { + code: "00012", + description: "The date that you opened your oldest account is too recent" + }, + { + code: "00063", + description: "Lack of sufficient relevant real estate account information" + } + ], created_at: credit_scores.scores[0].created_at, - }, + } ], error: null, created_at: entities_create_credit_score_response.created_at, @@ -461,12 +518,25 @@ describe('Entities - core methods tests', () => { status: 'completed', scores: [ { - score: credit_scores[0].scores[0].score, - source: 'equifax', - model: 'vantage_4', - factors: credit_scores[0].scores[0].factors, + score: 800, + source: "equifax", + model: "vantage_4", + factors: [ + { + code: "00034", + description: "Total of all balances on bankcard or revolving accounts is too high" + }, + { + code: "00012", + description: "The date that you opened your oldest account is too recent" + }, + { + code: "00063", + description: "Lack of sufficient relevant real estate account information" + } + ], created_at: credit_scores[0].scores[0].created_at, - }, + } ], error: null, created_at: entities_create_credit_score_response.created_at, diff --git a/test/resources/Event.tests.ts b/test/resources/Event.tests.ts index 5c2ff6a..357da8f 100644 --- a/test/resources/Event.tests.ts +++ b/test/resources/Event.tests.ts @@ -58,36 +58,6 @@ describe('Events - core methods tests', () => { }); describe('simulate.events', () => { - it('should simulate an account closed event', async () => { - await client.simulate.events.create({ - type: 'account.closed', - account_id: account_response[0].id, - }); - - // timeout to allow event to be created - await new Promise((resolve) => { setTimeout(resolve, 5000); }); - - const events_list_response = await client.events.list({ - resource_id: account_response[0].id, - }); - - [event_response] = events_list_response; - - const response = await client.events.retrieve(event_response.id); - - const expect_results: IEvent = { - id: event_response.id, - created_at: event_response.created_at, - updated_at: event_response.updated_at, - type: 'account.closed', - resource_id: account_response[0].id, - resource_type: 'account', - data: event_response.data, - diff: event_response.diff, - }; - - response.should.be.eql(expect_results); - }); it('should simulate an account opened event', async () => { await client.simulate.events.create({ From 043c83befa5f2b0f88a903e1593e09145e387cc0 Mon Sep 17 00:00:00 2001 From: Bilal Hussain Date: Tue, 8 Apr 2025 19:09:52 -0500 Subject: [PATCH 4/4] bump version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 21434db..36e23cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "method-node", - "version": "1.1.11", + "version": "1.1.12", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "method-node", - "version": "1.1.11", + "version": "1.1.12", "license": "ISC", "dependencies": { "axios": "^1.7.4", diff --git a/package.json b/package.json index 90afb39..1cae57f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "method-node", - "version": "1.1.11", + "version": "1.1.12", "description": "Node.js library for the Method API", "main": "dist/index.ts", "module": "dist/index.mjs",