From 43559b213ecae516b9bb291e4f197921fc7d8efb Mon Sep 17 00:00:00 2001 From: Bilal Hussain Date: Tue, 3 Dec 2024 14:25:40 -0600 Subject: [PATCH 01/10] list endpoints for products + tests --- package-lock.json | 4 +- package.json | 2 +- src/resources/Account/Balances.ts | 19 +-- src/resources/Account/CardBrands.ts | 12 +- src/resources/Account/Payoffs.ts | 19 +-- src/resources/Account/Sensitive.ts | 12 +- src/resources/Account/VerificationSessions.ts | 12 +- src/resources/Entity/Attributes.ts | 12 +- src/resources/Entity/Connect.ts | 12 +- src/resources/Entity/CreditScores.ts | 12 +- src/resources/Entity/Identities.ts | 12 +- src/resources/Entity/VerificationSessions.ts | 12 +- test/resources/Account.tests.ts | 156 ++++++++++++------ test/resources/Entity.tests.ts | 98 ++++++++++- 14 files changed, 314 insertions(+), 80 deletions(-) diff --git a/package-lock.json b/package-lock.json index 10b4054..6c94fbe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "method-node", - "version": "1.1.3", + "version": "1.1.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "method-node", - "version": "1.1.3", + "version": "1.1.4", "license": "ISC", "dependencies": { "axios": "^1.7.4", diff --git a/package.json b/package.json index 865b335..b768be7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "method-node", - "version": "1.1.3", + "version": "1.1.4", "description": "Node.js library for the Method API", "main": "dist/index.ts", "module": "dist/index.mjs", diff --git a/src/resources/Account/Balances.ts b/src/resources/Account/Balances.ts index 32f0f0b..35e8142 100644 --- a/src/resources/Account/Balances.ts +++ b/src/resources/Account/Balances.ts @@ -1,4 +1,4 @@ -import Resource from '../../resource'; +import Resource, { IResourceListOpts } from '../../resource'; import Configuration, { IResponse } from '../../configuration'; import type { IAccountBalance } from './types'; @@ -18,16 +18,15 @@ export default class AccountBalances extends Resource { return super._getWithId>(bal_id); } - // TODO: Add back in when we have a list endpoint - // /** - // * Retrieves a list of Balance objects for an account. - // * - // * @returns Returns a list of Balances. - // */ + /** + * Retrieves a list of Balance objects for an account. + * + * @returns Returns a list of Balances. + */ - // async list(opts?: IResourceListOpts) { - // return super._list(opts); - // } + async list(opts?: IResourceListOpts) { + return super._list>(opts); + } /** * Creates a new Balance request to retrieve the Account’s balance from the financial institution. diff --git a/src/resources/Account/CardBrands.ts b/src/resources/Account/CardBrands.ts index b56cd42..350c206 100644 --- a/src/resources/Account/CardBrands.ts +++ b/src/resources/Account/CardBrands.ts @@ -1,4 +1,4 @@ -import Resource from '../../resource'; +import Resource, { IResourceListOpts } from '../../resource'; import Configuration, { IResponse } from '../../configuration'; import type { IAccountCardBrand } from './types'; @@ -18,6 +18,16 @@ export default class AccountCardBrand extends Resource { return super._getWithId>(cbrd_id); } + /** + * Retrieves a list of CardBrand objects for an account. + * + * @returns Returns a list of CardBrand objects. + */ + + async list(opts?: IResourceListOpts) { + return super._list>(opts); + } + /** * Creates a new CardBrand request to retrieve the Account’s card brand. * diff --git a/src/resources/Account/Payoffs.ts b/src/resources/Account/Payoffs.ts index f4801cb..1b563c4 100644 --- a/src/resources/Account/Payoffs.ts +++ b/src/resources/Account/Payoffs.ts @@ -1,4 +1,4 @@ -import Resource from '../../resource'; +import Resource, { IResourceListOpts } from '../../resource'; import Configuration, { IResponse } from '../../configuration'; import type { IAccountPayoff } from './types'; @@ -18,16 +18,15 @@ export default class AccountPayoffs extends Resource { return super._getWithId>(pyf_id); } - // TODO: Add back in when we have a list endpoint - // /** - // * Retrieves a list of Payoff requests for a specific account. - // * - // * @returns Returns a list of Payoffs. - // */ + /** + * Retrieves a list of Payoff requests for a specific account. + * + * @returns Returns a list of Payoffs. + */ - // async list(opts?: IResourceListOpts) { - // return super._list(opts); - // } + async list(opts?: IResourceListOpts) { + return super._list>(opts); + } /** * Creates a new Payoff request to retrieve a payoff quote from the Account’s financial institution / lender. diff --git a/src/resources/Account/Sensitive.ts b/src/resources/Account/Sensitive.ts index e75ba2c..abf8242 100644 --- a/src/resources/Account/Sensitive.ts +++ b/src/resources/Account/Sensitive.ts @@ -1,4 +1,4 @@ -import Resource from '../../resource'; +import Resource, { IResourceListOpts } from '../../resource'; import Configuration, { IResponse } from '../../configuration'; import type { IAccountSensitive, IAccountSensitiveCreateOpts } from './types'; @@ -18,6 +18,16 @@ export default class AccountSensitive extends Resource { return super._getWithId>(astv_id); } + /** + * Retrieves a list of Sensitive objects for an account. + * + * @returns Returns a list of Sensitive objects. + */ + + async list(opts?: IResourceListOpts) { + return super._list>(opts); + } + /** * Creates a new Sensitive request to retrieve sensitive Account information. * diff --git a/src/resources/Account/VerificationSessions.ts b/src/resources/Account/VerificationSessions.ts index bc9a1b1..e8b04d9 100644 --- a/src/resources/Account/VerificationSessions.ts +++ b/src/resources/Account/VerificationSessions.ts @@ -1,4 +1,4 @@ -import Resource from '../../resource'; +import Resource, { IResourceListOpts } from '../../resource'; import Configuration, { IResponse } from '../../configuration'; import type { IAccountVerificationSession, @@ -22,6 +22,16 @@ export default class AccountVerificationSession extends Resource { return super._getWithId>(avf_id); } + /** + * Retrieves a list of AccountVerificationSession objects for an account. + * + * @returns Returns a list of AccountVerificationSession objects. + */ + + async list(opts?: IResourceListOpts) { + return super._list>(opts); + } + /** * Creates an AccountVerificationSession of the provided type. * diff --git a/src/resources/Entity/Attributes.ts b/src/resources/Entity/Attributes.ts index b1ba32d..00b851f 100644 --- a/src/resources/Entity/Attributes.ts +++ b/src/resources/Entity/Attributes.ts @@ -1,4 +1,4 @@ -import Resource from '../../resource'; +import Resource, { IResourceListOpts } from '../../resource'; import Configuration, { IResponse } from '../../configuration'; import type { IEntityAttributes } from './types'; @@ -18,6 +18,16 @@ export default class EntityAttributes extends Resource { return super._getWithId>(attr_id); } + /** + * Retrieves a list of Attributes objects for an entity. + * + * @returns Returns a list of Attributes objects. + */ + + async list(opts?: IResourceListOpts) { + return super._list>(opts); + } + /** * Creates a new Attributes request to retrieve the Entity’s attributes. * diff --git a/src/resources/Entity/Connect.ts b/src/resources/Entity/Connect.ts index 6dc5dd6..35a3a4e 100644 --- a/src/resources/Entity/Connect.ts +++ b/src/resources/Entity/Connect.ts @@ -1,4 +1,4 @@ -import Resource from '../../resource'; +import Resource, { IResourceListOpts } from '../../resource'; import Configuration, { IResponse } from '../../configuration'; import type { IEntityConnect } from './types'; @@ -18,6 +18,16 @@ export default class EntityConnect extends Resource { return super._getWithId>(cxn_id); } + /** + * Retrieves a list of Connect objects for an entity. + * + * @returns Returns a list of Connect objects. + */ + + async list(opts?: IResourceListOpts) { + return super._list>(opts); + } + /** * Creates a new Connect request to connect all liability accounts for the Entity. * diff --git a/src/resources/Entity/CreditScores.ts b/src/resources/Entity/CreditScores.ts index ad9be28..a906a16 100644 --- a/src/resources/Entity/CreditScores.ts +++ b/src/resources/Entity/CreditScores.ts @@ -1,4 +1,4 @@ -import Resource from '../../resource'; +import Resource, { IResourceListOpts } from '../../resource'; import Configuration, { IResponse } from '../../configuration'; import type { IEntityCreditScores } from './types'; @@ -18,6 +18,16 @@ export default class EntityCreditScores extends Resource { return super._getWithId>(crs_id); } + /** + * Retrieves a list of CreditScore objects for an entity. + * + * @returns Returns a list of CreditScore objects. + */ + + async list(opts?: IResourceListOpts) { + return super._list>(opts); + } + /** * Creates a new Credit Score request to retrieve the Entity’s credit score. * diff --git a/src/resources/Entity/Identities.ts b/src/resources/Entity/Identities.ts index 024cd64..770db79 100644 --- a/src/resources/Entity/Identities.ts +++ b/src/resources/Entity/Identities.ts @@ -1,4 +1,4 @@ -import Resource from '../../resource'; +import Resource, { IResourceListOpts } from '../../resource'; import Configuration, { IResponse } from '../../configuration'; import type { IEntityIdentity } from './types'; @@ -18,6 +18,16 @@ export default class EntityIdentities extends Resource { return super._getWithId>(idn_id); } + /** + * Retrieves a list of Identity objects for an entity. + * + * @returns Returns a list of Identity objects. + */ + + async list(opts?: IResourceListOpts) { + return super._list>(opts); + } + /** * Creates a new Identity request to retrieve the identity of an Entity, based off the PII that has been passed in to Method so far. * diff --git a/src/resources/Entity/VerificationSessions.ts b/src/resources/Entity/VerificationSessions.ts index 2396e38..c27bb8a 100644 --- a/src/resources/Entity/VerificationSessions.ts +++ b/src/resources/Entity/VerificationSessions.ts @@ -1,4 +1,4 @@ -import Resource from '../../resource'; +import Resource, { IResourceListOpts } from '../../resource'; import Configuration, { IResponse } from '../../configuration'; import type { IEntityVerificationSession, @@ -22,6 +22,16 @@ export default class EntityVerificationSession extends Resource { return super._getWithId>(evf_id); } + /** + * Retrieves a list of VerificationSession objects for an entity. + * + * @returns Returns a list of VerificationSession objects. + */ + + async list(opts?: IResourceListOpts) { + return super._list>(opts); + } + /** * Create a verification session. * diff --git a/test/resources/Account.tests.ts b/test/resources/Account.tests.ts index 9e5857a..7828663 100644 --- a/test/resources/Account.tests.ts +++ b/test/resources/Account.tests.ts @@ -245,29 +245,29 @@ describe('Accounts - core methods tests', () => { account_balances.should.be.eql(expect_results); }); - // TODO: Add back once this is live in API - // it('should successfully list balances for an account.', async () => { - // const listAccountBalances = async () => { - // return client - // .accounts(test_credit_card_account.id) - // .balances - // .list(); - // }; - - // const account_balances = await awaitResults(listAccountBalances); - - // const expect_results = { - // id: balances_create_response.id, - // account_id: test_credit_card_account.id, - // status: 'completed', - // amount: 1866688, - // error: null, - // created_at: account_balances[0].created_at, - // updated_at: account_balances[0].updated_at - // }; - - // account_balances[0].should.be.eql(expect_results); - // }); + + it('should successfully list balances for an account.', async () => { + const listAccountBalances = async () => { + return client + .accounts(test_credit_card_account.id) + .balances + .list(); + }; + + const account_balances = await awaitResults(listAccountBalances); + + const expect_results = { + id: balances_create_response.id, + account_id: test_credit_card_account.id, + status: 'completed', + amount: 1866688, + error: null, + created_at: account_balances[0].created_at, + updated_at: account_balances[0].updated_at + }; + + account_balances[0].should.be.eql(expect_results); + }); }); describe('accounts.cardBrands', () => { @@ -316,6 +316,19 @@ describe('Accounts - core methods tests', () => { card_retrieve_response.should.be.eql(expect_results); }); + + it('should successfully list card brands for an account.', async () => { + const listCardBrands = async () => { + return client + .accounts(test_credit_card_account.id) + .cardBrands + .list(); + }; + + const card_brands = await awaitResults(listCardBrands); + + card_brands[0].should.be.eql(card_create_response); + }); }); describe('accounts.payoffs', () => { @@ -364,31 +377,31 @@ describe('Accounts - core methods tests', () => { payoff_quote.should.be.eql(expect_results); }); - // TODO: Add back once this is live in API - // it('should successfully list payoffs for an account.', async () => { - // const listPayoffQuotes = async () => { - // return await client - // .accounts(test_auto_loan_account.id) - // .payoffs - // .list(); - // }; - - // const payoffs = await awaitResults(listPayoffQuotes); - - // const expect_results = { - // id: payoff_create_response.id, - // account_id: test_auto_loan_account.id, - // amount: 6083988, - // per_diem_amount: null, - // term: 15, - // status: 'completed', - // error: null, - // created_at: payoffs[0].created_at, - // updated_at: payoffs[0].updated_at - // }; - - // payoffs[0].should.be.eql(expect_results); - // }); + + it('should successfully list payoffs for an account.', async () => { + const listPayoffQuotes = async () => { + return await client + .accounts(test_auto_loan_account.id) + .payoffs + .list(); + }; + + const payoffs = await awaitResults(listPayoffQuotes); + + const expect_results = { + id: payoff_create_response.id, + account_id: test_auto_loan_account.id, + amount: 6083988, + per_diem_amount: null, + term: 15, + status: 'completed', + error: null, + created_at: payoffs[0].created_at, + updated_at: payoffs[0].updated_at + }; + + payoffs[0].should.be.eql(expect_results); + }); }); describe('accounts.verificationSessions', () => { @@ -495,6 +508,40 @@ describe('Accounts - core methods tests', () => { verification_session.should.be.eql(expect_results); }); + + it('should successfully list verification sessions for an account.', async () => { + const listVerificationSessions = async () => { + return await client + .accounts(test_credit_card_account.id) + .verificationSessions + .list(); + }; + + const verification_sessions = await awaitResults(listVerificationSessions); + + const expect_results: IAccountVerificationSession = { + id: verification_session_update.id, + account_id: test_credit_card_account.id, + status: 'verified', + type: 'pre_auth', + error: null, + pre_auth: { + billing_zip_code: 'xxxxx', + billing_zip_code_check: 'pass', + cvv: 'xxx', + cvv_check: 'pass', + exp_check: "pass", + exp_month: "xx", + exp_year: "xxxx", + number: "xxxxxxxxxxxxxxxx", + pre_auth_check: "pass" + }, + created_at: verification_sessions[0].created_at, + updated_at: verification_sessions[0].updated_at + }; + + verification_sessions[0].should.be.eql(expect_results); + }); }); describe('accounts.sensitive', () => { @@ -528,6 +575,19 @@ describe('Accounts - core methods tests', () => { sensitive_data_response.should.be.eql(expect_results); }); + + it('should successfully list sensitive data for an account.', async () => { + const listSensitiveData = async () => { + return await client + .accounts(test_credit_card_account.id) + .sensitive + .list(); + }; + + const sensitive_data = await awaitResults(listSensitiveData); + + sensitive_data[0].should.be.eql(sensitive_data_response); + }); }); describe('accounts.subscriptions', () => { diff --git a/test/resources/Entity.tests.ts b/test/resources/Entity.tests.ts index 92f0db4..d50f172 100644 --- a/test/resources/Entity.tests.ts +++ b/test/resources/Entity.tests.ts @@ -37,6 +37,7 @@ describe('Entities - core methods tests', () => { let entities_create_connect_subscription_response: IResponse; let entities_create_credit_score_subscription_response: IResponse; let entities_create_verification_session_response: IResponse; + let entities_create_phone_verification_session_response: IResponse; describe('entities.create', () => { it('should successfully create an entity.', async () => { @@ -258,7 +259,7 @@ describe('Entities - core methods tests', () => { describe('entities.verification_sessions', () => { it('should create a phone verification session for an entity', async () => { - const entities_create_phone_verification_session_response = await client.entities(entities_create_response.id).verificationSessions.create({ + entities_create_phone_verification_session_response = await client.entities(entities_create_response.id).verificationSessions.create({ type: 'phone', method: 'byo_sms', byo_sms: { @@ -307,6 +308,20 @@ describe('Entities - core methods tests', () => { entities_create_verification_session_response.should.be.eql(expect_results); }); + + it('should successfully list verification sessions for an entity', async () => { + const listVerificationSessions = async () => { + return await client + .entities(entities_create_response.id) + .verificationSessions + .list(); + }; + + const verification_sessions = await awaitResults(listVerificationSessions); + + verification_sessions[0].should.be.eql(entities_create_phone_verification_session_response); + verification_sessions[1].should.be.eql(entities_create_verification_session_response); + }); }); describe('entities.connect', () => { @@ -345,6 +360,30 @@ describe('Entities - core methods tests', () => { entities_connect_results_response.should.be.eql(expect_results); }); + + it('should successfully list connections for an entity', async () => { + const listConnections = async () => { + return await client + .entities(entities_create_response.id) + .connect + .list(); + }; + + const connections = await awaitResults(listConnections); + connections[0].accounts = connections[0].accounts?.sort() || null; + + const expect_results: IEntityConnect = { + id: entities_connect_create_response.id, + entity_id: entities_create_response.id, + status: 'completed', + accounts: entities_account_ids, + error: null, + created_at: entities_connect_create_response.created_at, + updated_at: entities_connect_create_response.updated_at, + }; + + connections[0].should.be.eql(expect_results); + }); }); describe('entities.credit_scores', () => { @@ -394,6 +433,37 @@ describe('Entities - core methods tests', () => { credit_scores.should.be.eql(expect_results); }); + + it('should successfully list credit scores for an entity', async () => { + const listCreditScores = async () => { + return await client + .entities(entities_create_response.id) + .creditScores + .list(); + }; + + const credit_scores = await awaitResults(listCreditScores); + + const expect_results: IEntityCreditScores = { + id: entities_create_credit_score_response.id, + entity_id: entities_create_response.id, + status: 'completed', + scores: [ + { + score: credit_scores[0].scores[0].score, + source: 'equifax', + model: 'vantage_4', + factors: credit_scores[0].scores[0].factors, + created_at: credit_scores[0].scores[0].created_at, + } + ], + error: null, + created_at: entities_create_credit_score_response.created_at, + updated_at: credit_scores[0].updated_at, + }; + + credit_scores[0].should.be.eql(expect_results); + }); }); describe('entities.attributes', () => { @@ -435,6 +505,19 @@ describe('Entities - core methods tests', () => { attributes.should.be.eql(expect_results); }); + + it('should successfully list attributes for an entity', async () => { + const listAttributes = async () => { + return await client + .entities(entities_create_response.id) + .attributes + .list(); + }; + + const attributes = await awaitResults(listAttributes); + + attributes[0].should.be.eql(entities_create_attribute_response); + }); }); describe('entities.identites', () => { @@ -539,6 +622,19 @@ describe('Entities - core methods tests', () => { identities.should.be.eql(expect_results); }); + + it('should successfully list identities for an entity', async () => { + const listIdentities = async () => { + return await client + .entities(entitiy_with_identity_cap.id) + .identities + .list(); + }; + + const identities = await awaitResults(listIdentities); + + identities[0].should.be.eql(entities_create_idenitity_response); + }); }); describe('entities.products', () => { From 91e206a3056a4439722726b62fa410a78ab99278 Mon Sep 17 00:00:00 2001 From: Bilal Hussain Date: Tue, 3 Dec 2024 18:56:13 -0600 Subject: [PATCH 02/10] fix webhook tests --- test/resources/Entity.tests.ts | 12 +++--------- test/resources/Webhook.tests.ts | 2 ++ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/test/resources/Entity.tests.ts b/test/resources/Entity.tests.ts index d50f172..aebfe07 100644 --- a/test/resources/Entity.tests.ts +++ b/test/resources/Entity.tests.ts @@ -310,15 +310,9 @@ describe('Entities - core methods tests', () => { }); it('should successfully list verification sessions for an entity', async () => { - const listVerificationSessions = async () => { - return await client - .entities(entities_create_response.id) - .verificationSessions - .list(); - }; - - const verification_sessions = await awaitResults(listVerificationSessions); - + const verification_sessions = await client.entities(entities_create_response.id).verificationSessions.list({ + from_date: new Date(Date.now() - 5 * 60 * 1000).toISOString(), + }); verification_sessions[0].should.be.eql(entities_create_phone_verification_session_response); verification_sessions[1].should.be.eql(entities_create_verification_session_response); }); diff --git a/test/resources/Webhook.tests.ts b/test/resources/Webhook.tests.ts index e12a567..63c407b 100644 --- a/test/resources/Webhook.tests.ts +++ b/test/resources/Webhook.tests.ts @@ -29,6 +29,8 @@ describe('Webhooks - core methods tests', () => { created_at: webhooks_create_response.created_at, updated_at: webhooks_create_response.updated_at, expand_event: false, + error: webhooks_create_response.error, + status: webhooks_create_response.status, }; webhooks_create_response.should.be.eql(expect_results); From 112caccc71c99bc0986257d49d9322cf71f5fb4a Mon Sep 17 00:00:00 2001 From: Bilal Hussain Date: Tue, 3 Dec 2024 18:59:00 -0600 Subject: [PATCH 03/10] webhook type fix --- src/resources/Webhook/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/resources/Webhook/index.ts b/src/resources/Webhook/index.ts index 8af0c3a..7d2647d 100644 --- a/src/resources/Webhook/index.ts +++ b/src/resources/Webhook/index.ts @@ -72,6 +72,8 @@ export interface IWebhook { created_at: string; updated_at: string; expand_event: boolean; + error: object | null; + status: string | null; }; export interface IWebhookCreateOpts { From 03184eacaeb9c97629b0367082353760c0635b9c Mon Sep 17 00:00:00 2001 From: Bilal Hussain Date: Tue, 3 Dec 2024 19:00:37 -0600 Subject: [PATCH 04/10] fix webhook tests --- test/resources/Webhook.tests.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/resources/Webhook.tests.ts b/test/resources/Webhook.tests.ts index 63c407b..cecbd4b 100644 --- a/test/resources/Webhook.tests.ts +++ b/test/resources/Webhook.tests.ts @@ -49,6 +49,8 @@ describe('Webhooks - core methods tests', () => { created_at: webhooks_retrieve_response.created_at, updated_at: webhooks_retrieve_response.updated_at, expand_event: false, + error: webhooks_retrieve_response.error, + status: webhooks_retrieve_response.status, }; webhooks_retrieve_response.should.be.eql(expect_results); From 02b4859ef246b00d6f2bde9e7b2660acbb1bd390 Mon Sep 17 00:00:00 2001 From: Bilal Hussain Date: Tue, 3 Dec 2024 19:14:12 -0600 Subject: [PATCH 05/10] trying something new --- test/resources/Entity.tests.ts | 5 ++++- test/resources/Webhook.tests.ts | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test/resources/Entity.tests.ts b/test/resources/Entity.tests.ts index aebfe07..d5e523e 100644 --- a/test/resources/Entity.tests.ts +++ b/test/resources/Entity.tests.ts @@ -310,8 +310,11 @@ describe('Entities - core methods tests', () => { }); it('should successfully list verification sessions for an entity', async () => { + const date = new Date(Date.now() - 5 * 60 * 1000); + const formattedDate = `${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}-${date.getFullYear()}`; + const verification_sessions = await client.entities(entities_create_response.id).verificationSessions.list({ - from_date: new Date(Date.now() - 5 * 60 * 1000).toISOString(), + from_date: formattedDate, }); verification_sessions[0].should.be.eql(entities_create_phone_verification_session_response); verification_sessions[1].should.be.eql(entities_create_verification_session_response); diff --git a/test/resources/Webhook.tests.ts b/test/resources/Webhook.tests.ts index cecbd4b..ae8fe2d 100644 --- a/test/resources/Webhook.tests.ts +++ b/test/resources/Webhook.tests.ts @@ -16,14 +16,14 @@ describe('Webhooks - core methods tests', () => { describe('webhooks.create', () => { it('should successfully create a webhook.', async () => { webhooks_create_response = await client.webhooks.create({ - type: 'payment.create', + type: 'payment.update', url: 'https://dev.methodfi.com', auth_token: Math.random().toString(), }); const expect_results: IWebhook = { id: webhooks_create_response.id, - type: 'payment.create', + type: 'payment.update', url: 'https://dev.methodfi.com', metadata: null, created_at: webhooks_create_response.created_at, From 6a960dbcbc66f09d37f474944e35147022d950e2 Mon Sep 17 00:00:00 2001 From: Bilal Hussain Date: Tue, 3 Dec 2024 19:30:10 -0600 Subject: [PATCH 06/10] sort verif sessions --- test/resources/Entity.tests.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/test/resources/Entity.tests.ts b/test/resources/Entity.tests.ts index d5e523e..d8aa118 100644 --- a/test/resources/Entity.tests.ts +++ b/test/resources/Entity.tests.ts @@ -310,12 +310,9 @@ describe('Entities - core methods tests', () => { }); it('should successfully list verification sessions for an entity', async () => { - const date = new Date(Date.now() - 5 * 60 * 1000); - const formattedDate = `${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}-${date.getFullYear()}`; - - const verification_sessions = await client.entities(entities_create_response.id).verificationSessions.list({ - from_date: formattedDate, - }); + const verification_sessions = await client.entities(entities_create_response.id).verificationSessions.list(); + verification_sessions.sort((a, b) => a.type.localeCompare(b.type)); + [entities_create_phone_verification_session_response, entities_create_verification_session_response].sort((a, b) => a.type.localeCompare(b.type)); verification_sessions[0].should.be.eql(entities_create_phone_verification_session_response); verification_sessions[1].should.be.eql(entities_create_verification_session_response); }); From e0221dbd1419bc7304c5296b1d1f5991e9d57709 Mon Sep 17 00:00:00 2001 From: Bilal Hussain Date: Wed, 4 Dec 2024 14:55:51 -0600 Subject: [PATCH 07/10] better sorting --- test/resources/Entity.tests.ts | 405 ++++++++++++++++++++------------- 1 file changed, 247 insertions(+), 158 deletions(-) diff --git a/test/resources/Entity.tests.ts b/test/resources/Entity.tests.ts index d8aa118..1fad60d 100644 --- a/test/resources/Entity.tests.ts +++ b/test/resources/Entity.tests.ts @@ -59,35 +59,27 @@ describe('Entities - core methods tests', () => { dob: null, email: null, ssn: null, - ssn_4: null + ssn_4: null, }, address: { line1: null, line2: null, city: null, state: null, - zip: null + zip: null, }, verification: { identity: { verified: false, matched: false, latest_verification_session: null, - methods: [ - 'element', - 'kba' - ] + methods: ['element', 'kba'], }, phone: { verified: false, latest_verification_session: null, - methods: [ - 'element', - 'sna', - 'sms', - 'byo_sms' - ] - } + methods: ['element', 'sna', 'sms', 'byo_sms'], + }, }, connect: null, credit_score: null, @@ -96,7 +88,10 @@ describe('Entities - core methods tests', () => { restricted_products: entities_create_response.restricted_products, subscriptions: [], available_subscriptions: [], - restricted_subscriptions: [ 'connect', 'credit_score' ].sort() as TEntitySubscriptionNames[], + restricted_subscriptions: [ + 'connect', + 'credit_score', + ].sort() as TEntitySubscriptionNames[], status: 'incomplete', error: null, metadata: {}, @@ -110,7 +105,9 @@ describe('Entities - core methods tests', () => { describe('entities.retrieve', () => { it('should successfully retrieve an entity by id.', async () => { - entities_retrieve_response = await client.entities.retrieve(entities_create_response.id); + entities_retrieve_response = await client.entities.retrieve( + entities_create_response.id + ); entities_retrieve_response.restricted_products?.sort(); entities_retrieve_response.restricted_subscriptions?.sort(); @@ -124,44 +121,44 @@ describe('Entities - core methods tests', () => { dob: null, email: null, ssn: null, - ssn_4: null + ssn_4: null, }, address: { line1: null, line2: null, city: null, state: null, - zip: null + zip: null, }, verification: { identity: { verified: false, matched: false, latest_verification_session: null, - methods: [ - 'element', - 'kba' - ] + methods: ['element', 'kba'], }, phone: { verified: false, latest_verification_session: null, - methods: [ - 'element', - 'sna', - 'sms', - 'byo_sms' - ] - } + methods: ['element', 'sna', 'sms', 'byo_sms'], + }, }, connect: null, credit_score: null, attribute: null, products: [], - restricted_products: [ 'connect', 'identity', 'credit_score', 'attribute' ].sort() as TEntityProductType[], + restricted_products: [ + 'connect', + 'identity', + 'credit_score', + 'attribute', + ].sort() as TEntityProductType[], subscriptions: [], available_subscriptions: [], - restricted_subscriptions: [ 'connect', 'credit_score' ].sort() as TEntitySubscriptionNames[], + restricted_subscriptions: [ + 'connect', + 'credit_score', + ].sort() as TEntitySubscriptionNames[], status: 'incomplete', error: null, metadata: {}, @@ -183,12 +180,12 @@ describe('Entities - core methods tests', () => { last_name: 'Doyle', phone: '+15121231111', }, - }, + } ); entities_update_response.restricted_subscriptions?.sort(); entities_update_response.restricted_products?.sort(); - + const expect_results: IEntity = { id: entities_create_response.id, type: 'individual', @@ -199,44 +196,47 @@ describe('Entities - core methods tests', () => { dob: null, email: null, ssn: null, - ssn_4: null + ssn_4: null, }, address: { line1: null, line2: null, city: null, state: null, - zip: null + zip: null, }, verification: { identity: { verified: false, matched: true, - latest_verification_session: entities_update_response.verification?.identity?.latest_verification_session || null, - methods: [ - 'element', - 'kba' - ] + latest_verification_session: + entities_update_response.verification?.identity + ?.latest_verification_session || null, + methods: ['element', 'kba'], }, phone: { verified: false, - latest_verification_session: entities_update_response.verification?.phone?.latest_verification_session || null, - methods: [ - 'element', - 'sna', - 'sms', - 'byo_sms' - ] - } + latest_verification_session: + entities_update_response.verification?.phone + ?.latest_verification_session || null, + methods: ['element', 'sna', 'sms', 'byo_sms'], + }, }, connect: null, credit_score: null, attribute: null, - products: [ 'identity' ], - restricted_products: ['connect', 'credit_score', 'attribute'].sort() as TEntityProductType[], + products: ['identity'], + restricted_products: [ + 'connect', + 'credit_score', + 'attribute', + ].sort() as TEntityProductType[], subscriptions: [], available_subscriptions: [], - restricted_subscriptions: [ 'connect', 'credit_score' ].sort() as TEntitySubscriptionNames[], + restricted_subscriptions: [ + 'connect', + 'credit_score', + ].sort() as TEntitySubscriptionNames[], status: 'incomplete', error: null, metadata: {}, @@ -259,13 +259,15 @@ describe('Entities - core methods tests', () => { describe('entities.verification_sessions', () => { it('should create a phone verification session for an entity', async () => { - entities_create_phone_verification_session_response = await client.entities(entities_create_response.id).verificationSessions.create({ - type: 'phone', - method: 'byo_sms', - byo_sms: { - timestamp: '2021-09-01T00:00:00.000Z', - }, - }); + entities_create_phone_verification_session_response = await client + .entities(entities_create_response.id) + .verificationSessions.create({ + type: 'phone', + method: 'byo_sms', + byo_sms: { + timestamp: '2021-09-01T00:00:00.000Z', + }, + }); const expect_results: IEntityVerificationSession = { id: entities_create_phone_verification_session_response.id, @@ -277,26 +279,32 @@ describe('Entities - core methods tests', () => { status: 'verified', type: 'phone', error: null, - created_at: entities_create_phone_verification_session_response.created_at, - updated_at: entities_create_phone_verification_session_response.updated_at, + created_at: + entities_create_phone_verification_session_response.created_at, + updated_at: + entities_create_phone_verification_session_response.updated_at, }; - entities_create_phone_verification_session_response.should.be.eql(expect_results); + entities_create_phone_verification_session_response.should.be.eql( + expect_results + ); }); it('should successfully create an identity verification session for an entity', async () => { - entities_create_verification_session_response = await client.entities(entities_create_response.id).verificationSessions.create({ - type: 'identity', - method: 'kba', - kba: {}, - }); + entities_create_verification_session_response = await client + .entities(entities_create_response.id) + .verificationSessions.create({ + type: 'identity', + method: 'kba', + kba: {}, + }); const expect_results: IEntityVerificationSession = { id: entities_create_verification_session_response.id, entity_id: entities_create_response.id, kba: { authenticated: true, - questions: [] + questions: [], }, method: 'kba', status: 'verified', @@ -306,25 +314,46 @@ describe('Entities - core methods tests', () => { updated_at: entities_create_verification_session_response.updated_at, }; - entities_create_verification_session_response.should.be.eql(expect_results); + entities_create_verification_session_response.should.be.eql( + expect_results + ); }); it('should successfully list verification sessions for an entity', async () => { - const verification_sessions = await client.entities(entities_create_response.id).verificationSessions.list(); - verification_sessions.sort((a, b) => a.type.localeCompare(b.type)); - [entities_create_phone_verification_session_response, entities_create_verification_session_response].sort((a, b) => a.type.localeCompare(b.type)); - verification_sessions[0].should.be.eql(entities_create_phone_verification_session_response); - verification_sessions[1].should.be.eql(entities_create_verification_session_response); + const verification_sessions = await client + .entities(entities_create_response.id) + .verificationSessions.list(); + + // Sort both arrays by type to ensure consistent ordering + const sorted_verification_sessions = verification_sessions.sort((a, b) => + a.type.localeCompare(b.type) + ); + const sorted_expected_responses = [ + entities_create_phone_verification_session_response, + entities_create_verification_session_response, + ].sort((a, b) => a.type.localeCompare(b.type)); + + sorted_verification_sessions.should.be.eql( + sorted_expected_responses + ); }); }); describe('entities.connect', () => { it('should create a connection for an entity', async () => { - entities_connect_create_response = await client.entities(entities_create_response.id).connect.create(); - entities_connect_create_response.accounts = entities_connect_create_response.accounts?.sort() || null; - entities_account_list_response = await client.accounts.list({ holder_id: entities_create_response.id, type: 'liability' }); - entities_account_ids = entities_account_list_response.map(account => account.id).sort(); - + entities_connect_create_response = await client + .entities(entities_create_response.id) + .connect.create(); + entities_connect_create_response.accounts = + entities_connect_create_response.accounts?.sort() || null; + entities_account_list_response = await client.accounts.list({ + holder_id: entities_create_response.id, + type: 'liability', + }); + entities_account_ids = entities_account_list_response + .map((account) => account.id) + .sort(); + const expect_results: IEntityConnect = { id: entities_connect_create_response.id, entity_id: entities_create_response.id, @@ -339,8 +368,11 @@ describe('Entities - core methods tests', () => { }); it('should retrieve results of a connection for an entity', async () => { - let entities_connect_results_response = await client.entities(entities_create_response.id).connect.retrieve(entities_connect_create_response.id); - entities_connect_results_response.accounts = entities_connect_results_response.accounts?.sort() || null; + let entities_connect_results_response = await client + .entities(entities_create_response.id) + .connect.retrieve(entities_connect_create_response.id); + entities_connect_results_response.accounts = + entities_connect_results_response.accounts?.sort() || null; const expect_results: IEntityConnect = { id: entities_connect_create_response.id, @@ -359,8 +391,7 @@ describe('Entities - core methods tests', () => { const listConnections = async () => { return await client .entities(entities_create_response.id) - .connect - .list(); + .connect.list(); }; const connections = await awaitResults(listConnections); @@ -382,7 +413,9 @@ describe('Entities - core methods tests', () => { describe('entities.credit_scores', () => { it('should successfully create a credit score request for an entity', async () => { - entities_create_credit_score_response = await client.entities(entities_create_response.id).creditScores.create(); + entities_create_credit_score_response = await client + .entities(entities_create_response.id) + .creditScores.create(); const expect_results: IEntityCreditScores = { id: entities_create_credit_score_response.id, @@ -401,8 +434,7 @@ describe('Entities - core methods tests', () => { const getCreditScores = async () => { return await client .entities(entities_create_response.id) - .creditScores - .retrieve(entities_create_credit_score_response.id); + .creditScores.retrieve(entities_create_credit_score_response.id); }; const credit_scores = await awaitResults(getCreditScores); @@ -418,7 +450,7 @@ describe('Entities - core methods tests', () => { model: 'vantage_4', factors: credit_scores.scores[0].factors, created_at: credit_scores.scores[0].created_at, - } + }, ], error: null, created_at: entities_create_credit_score_response.created_at, @@ -432,8 +464,7 @@ describe('Entities - core methods tests', () => { const listCreditScores = async () => { return await client .entities(entities_create_response.id) - .creditScores - .list(); + .creditScores.list(); }; const credit_scores = await awaitResults(listCreditScores); @@ -449,7 +480,7 @@ describe('Entities - core methods tests', () => { model: 'vantage_4', factors: credit_scores[0].scores[0].factors, created_at: credit_scores[0].scores[0].created_at, - } + }, ], error: null, created_at: entities_create_credit_score_response.created_at, @@ -462,7 +493,9 @@ describe('Entities - core methods tests', () => { describe('entities.attributes', () => { it('should successfully create an attributes request for an entity', async () => { - entities_create_attribute_response = await client.entities(entities_create_response.id).attributes.create(); + entities_create_attribute_response = await client + .entities(entities_create_response.id) + .attributes.create(); const expect_results: IEntityAttributes = { id: entities_create_attribute_response.id, @@ -481,8 +514,7 @@ describe('Entities - core methods tests', () => { const getAttributes = async () => { return await client .entities(entities_create_response.id) - .attributes - .retrieve(entities_create_attribute_response.id); + .attributes.retrieve(entities_create_attribute_response.id); }; const attributes = await awaitResults(getAttributes); @@ -504,8 +536,7 @@ describe('Entities - core methods tests', () => { const listAttributes = async () => { return await client .entities(entities_create_response.id) - .attributes - .list(); + .attributes.list(); }; const attributes = await awaitResults(listAttributes); @@ -525,7 +556,9 @@ describe('Entities - core methods tests', () => { }, }); - entities_create_idenitity_response = await client.entities(entitiy_with_identity_cap.id).identities.create(); + entities_create_idenitity_response = await client + .entities(entitiy_with_identity_cap.id) + .identities.create(); const expect_results: IEntityIdentity = { id: entities_create_idenitity_response.id, @@ -537,27 +570,27 @@ describe('Entities - core methods tests', () => { address: '3300 N INTERSTATE 35', city: 'AUSTIN', postal_code: '78705', - state: 'TX' + state: 'TX', }, dob: '1997-03-18', first_name: 'KEVIN', last_name: 'DOYLE', phone: '+16505551115', - ssn: '111223333' + ssn: '111223333', }, { address: { address: '3300 N INTERSTATE 35', city: 'AUSTIN', postal_code: '78705', - state: 'TX' + state: 'TX', }, dob: '1997-03-18', first_name: 'KEVIN', last_name: 'DOYLE', phone: '+16505551115', - ssn: '123456789' - } + ssn: '123456789', + }, ], error: null, created_at: entities_create_idenitity_response.created_at, @@ -571,8 +604,7 @@ describe('Entities - core methods tests', () => { const getIdentities = async () => { return await client .entities(entitiy_with_identity_cap.id) - .identities - .retrieve(entities_create_idenitity_response.id); + .identities.retrieve(entities_create_idenitity_response.id); }; const identities = await awaitResults(getIdentities); @@ -587,27 +619,27 @@ describe('Entities - core methods tests', () => { address: '3300 N INTERSTATE 35', city: 'AUSTIN', postal_code: '78705', - state: 'TX' + state: 'TX', }, dob: '1997-03-18', first_name: 'KEVIN', last_name: 'DOYLE', phone: '+16505551115', - ssn: '111223333' + ssn: '111223333', }, { address: { address: '3300 N INTERSTATE 35', city: 'AUSTIN', postal_code: '78705', - state: 'TX' + state: 'TX', }, dob: '1997-03-18', first_name: 'KEVIN', last_name: 'DOYLE', phone: '+16505551115', - ssn: '123456789' - } + ssn: '123456789', + }, ], error: null, created_at: entities_create_idenitity_response.created_at, @@ -621,8 +653,7 @@ describe('Entities - core methods tests', () => { const listIdentities = async () => { return await client .entities(entitiy_with_identity_cap.id) - .identities - .list(); + .identities.list(); }; const identities = await awaitResults(listIdentities); @@ -633,7 +664,9 @@ describe('Entities - core methods tests', () => { describe('entities.products', () => { it('should successfully list products for an entity', async () => { - entities_retrieve_product_list_response = await client.entities(entities_create_response.id).products.list(); + entities_retrieve_product_list_response = await client + .entities(entities_create_response.id) + .products.list(); const expect_results: IEntityProductListResponse = { connect: { @@ -641,52 +674,86 @@ describe('Entities - core methods tests', () => { name: 'connect', status: 'available', status_error: null, - latest_request_id: entities_retrieve_product_list_response.connect?.latest_request_id || null, + latest_request_id: + entities_retrieve_product_list_response.connect + ?.latest_request_id || null, is_subscribable: true, - created_at: entities_retrieve_product_list_response.connect?.created_at || '', - updated_at: entities_retrieve_product_list_response.connect?.updated_at || '', + created_at: + entities_retrieve_product_list_response.connect?.created_at || '', + updated_at: + entities_retrieve_product_list_response.connect?.updated_at || '', }, credit_score: { id: entities_retrieve_product_list_response.credit_score?.id || '', name: 'credit_score', status: 'available', status_error: null, - latest_request_id: entities_retrieve_product_list_response.credit_score?.latest_request_id || null, + latest_request_id: + entities_retrieve_product_list_response.credit_score + ?.latest_request_id || null, is_subscribable: true, - created_at: entities_retrieve_product_list_response.credit_score?.created_at || '', - updated_at: entities_retrieve_product_list_response.credit_score?.updated_at || '', + created_at: + entities_retrieve_product_list_response.credit_score?.created_at || + '', + updated_at: + entities_retrieve_product_list_response.credit_score?.updated_at || + '', }, identity: { id: entities_retrieve_product_list_response.identity?.id || '', name: 'identity', status: 'available', status_error: null, - latest_request_id: entities_retrieve_product_list_response.identity?.latest_request_id || null, + latest_request_id: + entities_retrieve_product_list_response.identity + ?.latest_request_id || null, is_subscribable: false, - created_at: entities_retrieve_product_list_response.identity?.created_at || '', - updated_at: entities_retrieve_product_list_response.identity?.updated_at || '', + created_at: + entities_retrieve_product_list_response.identity?.created_at || '', + updated_at: + entities_retrieve_product_list_response.identity?.updated_at || '', }, attribute: { id: entities_retrieve_product_list_response.attribute?.id || '', name: 'attribute', status: 'available', status_error: null, - latest_request_id: entities_retrieve_product_list_response.attribute?.latest_request_id || null, + latest_request_id: + entities_retrieve_product_list_response.attribute + ?.latest_request_id || null, is_subscribable: false, - created_at: entities_retrieve_product_list_response.attribute?.created_at || '', - updated_at: entities_retrieve_product_list_response.attribute?.updated_at || '', - } + created_at: + entities_retrieve_product_list_response.attribute?.created_at || '', + updated_at: + entities_retrieve_product_list_response.attribute?.updated_at || '', + }, }; entities_retrieve_product_list_response.should.be.eql(expect_results); }); it('should retrieve a specific product for an entity', async () => { - const entity_connect_product = await client.entities(entities_create_response.id).products.retrieve(entities_retrieve_product_list_response.connect?.id || ''); - const entity_credit_score_product = await client.entities(entities_create_response.id).products.retrieve(entities_retrieve_product_list_response.credit_score?.id || ''); - const entity_identity_product = await client.entities(entities_create_response.id).products.retrieve(entities_retrieve_product_list_response.identity?.id || ''); - const entity_attribute_product = await client.entities(entities_create_response.id).products.retrieve(entities_retrieve_product_list_response.attribute?.id || ''); - + const entity_connect_product = await client + .entities(entities_create_response.id) + .products.retrieve( + entities_retrieve_product_list_response.connect?.id || '' + ); + const entity_credit_score_product = await client + .entities(entities_create_response.id) + .products.retrieve( + entities_retrieve_product_list_response.credit_score?.id || '' + ); + const entity_identity_product = await client + .entities(entities_create_response.id) + .products.retrieve( + entities_retrieve_product_list_response.identity?.id || '' + ); + const entity_attribute_product = await client + .entities(entities_create_response.id) + .products.retrieve( + entities_retrieve_product_list_response.attribute?.id || '' + ); + const expect_connect_results: IEntityProduct = { id: entities_retrieve_product_list_response.connect?.id || '', name: 'connect', @@ -740,7 +807,9 @@ describe('Entities - core methods tests', () => { describe('entities.subscriptions', () => { it('should create a connect subscription for an entity', async () => { - entities_create_connect_subscription_response = await client.entities(entities_create_response.id).subscriptions.create('connect'); + entities_create_connect_subscription_response = await client + .entities(entities_create_response.id) + .subscriptions.create('connect'); const expect_connect_results: IEntitySubscription = { id: entities_create_connect_subscription_response.id, @@ -751,43 +820,53 @@ describe('Entities - core methods tests', () => { updated_at: entities_create_connect_subscription_response.updated_at, }; - entities_create_connect_subscription_response.should.be.eql(expect_connect_results, 'connect'); + entities_create_connect_subscription_response.should.be.eql( + expect_connect_results, + 'connect' + ); }); it('should create a credit_score subscription for an entity', async () => { entities_create_credit_score_subscription_response = await client .entities(entities_create_response.id) - .subscriptions - .create('credit_score'); + .subscriptions.create('credit_score'); const expect_credit_score_results: IEntitySubscription = { id: entities_create_credit_score_subscription_response.id, name: 'credit_score', status: 'active', latest_request_id: null, - created_at: entities_create_credit_score_subscription_response.created_at, - updated_at: entities_create_credit_score_subscription_response.updated_at, + created_at: + entities_create_credit_score_subscription_response.created_at, + updated_at: + entities_create_credit_score_subscription_response.updated_at, }; - entities_create_credit_score_subscription_response.should.be.eql(expect_credit_score_results, 'credit_score'); + entities_create_credit_score_subscription_response.should.be.eql( + expect_credit_score_results, + 'credit_score' + ); }); it('should retrieve a subscription for an entity', async () => { const entities_connect_subscription_response = await client .entities(entities_create_response.id) - .subscriptions - .retrieve(entities_create_connect_subscription_response.id); + .subscriptions.retrieve( + entities_create_connect_subscription_response.id + ); const entities_credit_score_subscription_response = await client .entities(entities_create_response.id) - .subscriptions - .retrieve(entities_create_credit_score_subscription_response.id); + .subscriptions.retrieve( + entities_create_credit_score_subscription_response.id + ); const expect_connect_results: IEntitySubscription = { id: entities_create_connect_subscription_response.id, name: 'connect', status: 'active', - latest_request_id: entities_connect_subscription_response.latest_request_id, + latest_request_id: + entities_connect_subscription_response.latest_request_id, created_at: entities_connect_subscription_response.created_at, updated_at: entities_connect_subscription_response.updated_at, }; @@ -796,37 +875,49 @@ describe('Entities - core methods tests', () => { id: entities_create_credit_score_subscription_response.id, name: 'credit_score', status: 'active', - latest_request_id: entities_credit_score_subscription_response.latest_request_id, + latest_request_id: + entities_credit_score_subscription_response.latest_request_id, created_at: entities_credit_score_subscription_response.created_at, updated_at: entities_credit_score_subscription_response.updated_at, - } + }; - entities_connect_subscription_response.should.be.eql(expect_connect_results); - entities_credit_score_subscription_response.should.be.eql(expect_credit_score_results); + entities_connect_subscription_response.should.be.eql( + expect_connect_results + ); + entities_credit_score_subscription_response.should.be.eql( + expect_credit_score_results + ); }); it('should list subscriptions for an entity', async () => { const entities_subscription_list_response = await client .entities(entities_create_response.id) - .subscriptions - .list(); + .subscriptions.list(); const expect_results: IEntitySubscriptionResponse = { connect: { id: entities_create_connect_subscription_response.id, name: 'connect', status: 'active', - latest_request_id: entities_subscription_list_response.connect?.latest_request_id || null, - created_at: entities_subscription_list_response.connect?.created_at || '', - updated_at: entities_subscription_list_response.connect?.updated_at || '', + latest_request_id: + entities_subscription_list_response.connect?.latest_request_id || + null, + created_at: + entities_subscription_list_response.connect?.created_at || '', + updated_at: + entities_subscription_list_response.connect?.updated_at || '', }, credit_score: { id: entities_create_credit_score_subscription_response.id, name: 'credit_score', status: 'active', - latest_request_id: entities_subscription_list_response.credit_score?.latest_request_id || null, - created_at: entities_subscription_list_response.credit_score?.created_at || '', - updated_at: entities_subscription_list_response.credit_score?.updated_at || '', + latest_request_id: + entities_subscription_list_response.credit_score + ?.latest_request_id || null, + created_at: + entities_subscription_list_response.credit_score?.created_at || '', + updated_at: + entities_subscription_list_response.credit_score?.updated_at || '', }, }; @@ -836,8 +927,7 @@ describe('Entities - core methods tests', () => { it('should delete a subscription for an entity', async () => { const entities_subscription_delete_response = await client .entities(entities_create_response.id) - .subscriptions - .delete(entities_create_connect_subscription_response.id); + .subscriptions.delete(entities_create_connect_subscription_response.id); const expect_results: IEntitySubscription = { id: entities_create_connect_subscription_response.id, @@ -847,16 +937,15 @@ describe('Entities - core methods tests', () => { created_at: entities_subscription_delete_response.created_at, updated_at: entities_subscription_delete_response.updated_at, }; - + entities_subscription_delete_response.should.be.eql(expect_results); }); }); describe('entities.withdrawConsent', async () => { it('should successfully withdraw consent for an entity', async () => { - const entities_withdraw_consent_response = await client - .entities - .withdrawConsent(entities_create_response.id); + const entities_withdraw_consent_response = + await client.entities.withdrawConsent(entities_create_response.id); const expect_results: IEntity = { id: entities_create_response.id, @@ -867,7 +956,7 @@ describe('Entities - core methods tests', () => { type: 'ENTITY_DISABLED', sub_type: 'ENTITY_CONSENT_WITHDRAWN', code: 12004, - message: 'Entity was disabled due to consent withdrawal.' + message: 'Entity was disabled due to consent withdrawal.', }, address: {}, status: 'disabled', From b8600fc9d58e57d1763854d49ab0a6d42ce55c18 Mon Sep 17 00:00:00 2001 From: Bilal Hussain Date: Wed, 4 Dec 2024 15:04:22 -0600 Subject: [PATCH 08/10] corrected webhook type --- test/resources/Webhook.tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/resources/Webhook.tests.ts b/test/resources/Webhook.tests.ts index ae8fe2d..2eddc27 100644 --- a/test/resources/Webhook.tests.ts +++ b/test/resources/Webhook.tests.ts @@ -43,7 +43,7 @@ describe('Webhooks - core methods tests', () => { const expect_results: IWebhook = { id: webhooks_create_response.id, - type: 'payment.create', + type: 'payment.update', url: 'https://dev.methodfi.com', metadata: null, created_at: webhooks_retrieve_response.created_at, From 829eaaf830f485aa5abdc4c9ba2112e6970b0d39 Mon Sep 17 00:00:00 2001 From: Bilal Hussain Date: Wed, 4 Dec 2024 15:09:55 -0600 Subject: [PATCH 09/10] commenting out fields that are not currently being surfaced --- test/resources/Webhook.tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/resources/Webhook.tests.ts b/test/resources/Webhook.tests.ts index 2eddc27..53a0507 100644 --- a/test/resources/Webhook.tests.ts +++ b/test/resources/Webhook.tests.ts @@ -46,8 +46,8 @@ describe('Webhooks - core methods tests', () => { type: 'payment.update', url: 'https://dev.methodfi.com', metadata: null, - created_at: webhooks_retrieve_response.created_at, - updated_at: webhooks_retrieve_response.updated_at, + // created_at: webhooks_retrieve_response.created_at, + // updated_at: webhooks_retrieve_response.updated_at, expand_event: false, error: webhooks_retrieve_response.error, status: webhooks_retrieve_response.status, From 9574bb47c3e21f5cc90cc42b6786f7fe86c8df79 Mon Sep 17 00:00:00 2001 From: Bilal Hussain Date: Wed, 4 Dec 2024 16:33:54 -0600 Subject: [PATCH 10/10] this better work --- test/resources/Webhook.tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/resources/Webhook.tests.ts b/test/resources/Webhook.tests.ts index 53a0507..2eddc27 100644 --- a/test/resources/Webhook.tests.ts +++ b/test/resources/Webhook.tests.ts @@ -46,8 +46,8 @@ describe('Webhooks - core methods tests', () => { type: 'payment.update', url: 'https://dev.methodfi.com', metadata: null, - // created_at: webhooks_retrieve_response.created_at, - // updated_at: webhooks_retrieve_response.updated_at, + created_at: webhooks_retrieve_response.created_at, + updated_at: webhooks_retrieve_response.updated_at, expand_event: false, error: webhooks_retrieve_response.error, status: webhooks_retrieve_response.status,