diff --git a/method/resources/Accounts/Balances.py b/method/resources/Accounts/Balances.py index a132e73..e812f74 100644 --- a/method/resources/Accounts/Balances.py +++ b/method/resources/Accounts/Balances.py @@ -1,6 +1,6 @@ -from typing import TypedDict, Optional, Literal +from typing import List, TypedDict, Optional, Literal -from method.resource import MethodResponse, Resource +from method.resource import MethodResponse, Resource, ResourceListOpts from method.configuration import Configuration from method.errors import ResourceError @@ -28,6 +28,9 @@ def __init__(self, config: Configuration): def retrieve(self, bal_id: str) -> MethodResponse[AccountBalance]: return super(AccountBalancesResource, self)._get_with_id(bal_id) + + def list(self, params: Optional[ResourceListOpts] = None) -> MethodResponse[List[AccountBalance]]: + return super(AccountBalancesResource, self)._list(params) def create(self) -> MethodResponse[AccountBalance]: return super(AccountBalancesResource, self)._create({}) diff --git a/method/resources/Accounts/CardBrands.py b/method/resources/Accounts/CardBrands.py index 12254fc..c15c9b6 100644 --- a/method/resources/Accounts/CardBrands.py +++ b/method/resources/Accounts/CardBrands.py @@ -1,6 +1,6 @@ from typing import TypedDict, Optional, Literal, List -from method.resource import MethodResponse, Resource +from method.resource import MethodResponse, Resource, ResourceListOpts from method.configuration import Configuration from method.errors import ResourceError @@ -32,5 +32,8 @@ def __init__(self, config: Configuration): def retrieve(self, crbd_id: str) -> MethodResponse[AccountCardBrand]: return super(AccountCardBrandsResource, self)._get_with_id(crbd_id) + def list(self, params: Optional[ResourceListOpts] = None) -> MethodResponse[List[AccountCardBrand]]: + return super(AccountCardBrandsResource, self)._list(params) + def create(self) -> MethodResponse[AccountCardBrand]: return super(AccountCardBrandsResource, self)._create({}) diff --git a/method/resources/Accounts/Payoffs.py b/method/resources/Accounts/Payoffs.py index bf7ad43..1b6102c 100644 --- a/method/resources/Accounts/Payoffs.py +++ b/method/resources/Accounts/Payoffs.py @@ -1,6 +1,6 @@ -from typing import TypedDict, Optional, Literal +from typing import List, TypedDict, Optional, Literal -from method.resource import MethodResponse, Resource +from method.resource import MethodResponse, Resource, ResourceListOpts from method.configuration import Configuration from method.errors import ResourceError @@ -32,5 +32,8 @@ def __init__(self, config: Configuration): def retrieve(self, pyf_id: str) -> MethodResponse[AccountPayoff]: return super(AccountPayoffsResource, self)._get_with_id(pyf_id) + def list(self, params: Optional[ResourceListOpts] = None) -> MethodResponse[List[AccountPayoff]]: + return super(AccountPayoffsResource, self)._list(params) + def create(self) -> MethodResponse[AccountPayoff]: return super(AccountPayoffsResource, self)._create({}) diff --git a/method/resources/Accounts/Sensitive.py b/method/resources/Accounts/Sensitive.py index 118356b..1619526 100644 --- a/method/resources/Accounts/Sensitive.py +++ b/method/resources/Accounts/Sensitive.py @@ -1,6 +1,6 @@ from typing import TypedDict, Optional, Literal, List -from method.resource import MethodResponse, Resource +from method.resource import MethodResponse, Resource, ResourceListOpts from method.configuration import Configuration from method.errors import ResourceError @@ -52,6 +52,9 @@ def __init__(self, config: Configuration): def retrieve(self, astv_id: str) -> MethodResponse[AccountSensitive]: return super(AccountSensitiveResource, self)._get_with_id(astv_id) + + def list(self, params: Optional[ResourceListOpts] = None) -> MethodResponse[List[AccountSensitive]]: + return super(AccountSensitiveResource, self)._list(params) def create(self, data: AccountSensitiveCreateOpts) -> MethodResponse[AccountSensitive]: return super(AccountSensitiveResource, self)._create(data) diff --git a/method/resources/Accounts/VerificationSessions.py b/method/resources/Accounts/VerificationSessions.py index 140af58..e18deb2 100644 --- a/method/resources/Accounts/VerificationSessions.py +++ b/method/resources/Accounts/VerificationSessions.py @@ -1,6 +1,6 @@ from typing import TypedDict, Optional, List, Literal, Union -from method.resource import MethodResponse, Resource +from method.resource import MethodResponse, Resource, ResourceListOpts from method.configuration import Configuration from method.errors import ResourceError from method.resources.Accounts.ExternalTypes import PlaidBalance, PlaidTransaction, MXAccount, MXTransaction, TellerBalance, TellerTransaction @@ -157,6 +157,9 @@ def create(self, opts: AccountVerificationSessionCreateOpts) -> MethodResponse[A def retrieve(self, avs_id: str) -> MethodResponse[AccountVerificationSession]: return super(AccountVerificationSessionResource, self)._get_with_id(avs_id) + + def list(self, params: Optional[ResourceListOpts] = None) -> MethodResponse[List[AccountVerificationSession]]: + return super(AccountVerificationSessionResource, self)._list(params) def update(self, avs_id: str, opts: AccountVerificationSessionUpdateOpts) -> MethodResponse[AccountVerificationSession]: return super(AccountVerificationSessionResource, self)._update_with_id(avs_id, opts) diff --git a/method/resources/Entities/Attributes.py b/method/resources/Entities/Attributes.py index 21a063a..a109129 100644 --- a/method/resources/Entities/Attributes.py +++ b/method/resources/Entities/Attributes.py @@ -1,6 +1,6 @@ from typing import TypedDict, Optional, Literal, List -from method.resource import MethodResponse, Resource +from method.resource import MethodResponse, Resource, ResourceListOpts from method.configuration import Configuration from method.errors import ResourceError @@ -51,6 +51,9 @@ def __init__(self, config: Configuration): def retrieve(self, attr_id: str) -> MethodResponse[EntityAttributes]: return super(EntityAttributesResource, self)._get_with_id(attr_id) + + def list(self, params: Optional[ResourceListOpts] = None) -> MethodResponse[List[EntityAttributes]]: + return super(EntityAttributesResource, self)._list(params) def create(self) -> MethodResponse[EntityAttributes]: return super(EntityAttributesResource, self)._create({}) diff --git a/method/resources/Entities/Connect.py b/method/resources/Entities/Connect.py index b9c6d56..9cdb9d2 100644 --- a/method/resources/Entities/Connect.py +++ b/method/resources/Entities/Connect.py @@ -1,6 +1,6 @@ from typing import TypedDict, Optional, Literal, List -from method.resource import MethodResponse, Resource +from method.resource import MethodResponse, Resource, ResourceListOpts from method.configuration import Configuration from method.errors import ResourceError @@ -28,6 +28,9 @@ def __init__(self, config: Configuration): def retrieve(self, cxn_id: str) -> MethodResponse[EntityConnect]: return super(EntityConnectResource, self)._get_with_id(cxn_id) + + def list(self, params: Optional[ResourceListOpts] = None) -> MethodResponse[List[EntityConnect]]: + return super(EntityConnectResource, self)._list(params) def create(self) -> MethodResponse[EntityConnect]: return super(EntityConnectResource, self)._create({}) diff --git a/method/resources/Entities/CreditScores.py b/method/resources/Entities/CreditScores.py index ad57b05..c81faf3 100644 --- a/method/resources/Entities/CreditScores.py +++ b/method/resources/Entities/CreditScores.py @@ -1,6 +1,6 @@ from typing import TypedDict, Optional, List, Literal -from method.resource import MethodResponse, Resource +from method.resource import MethodResponse, Resource, ResourceListOpts from method.configuration import Configuration from method.errors import ResourceError from method.resources.Entities.Types import EntityStatusesLiterals, CreditReportBureausLiterals @@ -42,6 +42,9 @@ def __init__(self, config: Configuration): def retrieve(self, crs_id: str) -> MethodResponse[EntityCreditScores]: return super(EntityCreditScoresResource, self)._get_with_id(crs_id) + + def list(self, params: Optional[ResourceListOpts] = None) -> MethodResponse[List[EntityCreditScores]]: + return super(EntityCreditScoresResource, self)._list(params) def create(self) -> MethodResponse[EntityCreditScores]: return super(EntityCreditScoresResource, self)._create({}) diff --git a/method/resources/Entities/Identities.py b/method/resources/Entities/Identities.py index 376744e..0c422c7 100644 --- a/method/resources/Entities/Identities.py +++ b/method/resources/Entities/Identities.py @@ -1,6 +1,6 @@ from typing import TypedDict, Optional, Literal, List -from method.resource import MethodResponse, Resource +from method.resource import MethodResponse, Resource, ResourceListOpts from method.configuration import Configuration from method.errors import ResourceError from method.resources.Entities.Types import EntityIdentityType @@ -29,6 +29,9 @@ def __init__(self, config: Configuration): def retrieve(self, identity_id: str) -> MethodResponse[EntityIdentity]: return super(EntityIdentityResource, self)._get_with_id(identity_id) + + def list(self, params: Optional[ResourceListOpts] = None) -> MethodResponse[List[EntityIdentity]]: + return super(EntityIdentityResource, self)._list(params) def create(self, opts: Optional[EntityIdentityType] = {}) -> MethodResponse[EntityIdentity]: # pylint: disable=dangerous-default-value return super(EntityIdentityResource, self)._create(opts) diff --git a/method/resources/Entities/Sensitive.py b/method/resources/Entities/Sensitive.py index d733729..454294c 100644 --- a/method/resources/Entities/Sensitive.py +++ b/method/resources/Entities/Sensitive.py @@ -1,6 +1,6 @@ from typing import TypedDict, Optional, List -from method.resource import MethodResponse, Resource +from method.resource import MethodResponse, Resource, ResourceListOpts from method.configuration import Configuration from method.resources.Entities.Types import EntityKYCAddressRecordData, EntityIdentityType @@ -27,3 +27,6 @@ def __init__(self, config: Configuration): def retrieve(self) -> MethodResponse[EntitySensitive]: return super(EntitySensitiveResource, self)._get() + + def list(self, params: Optional[ResourceListOpts] = None) -> MethodResponse[List[EntitySensitive]]: + return super(EntitySensitiveResource, self)._list(params) diff --git a/method/resources/Entities/VerificationSessions.py b/method/resources/Entities/VerificationSessions.py index 80ba8da..fc7a962 100644 --- a/method/resources/Entities/VerificationSessions.py +++ b/method/resources/Entities/VerificationSessions.py @@ -1,6 +1,6 @@ from typing import TypedDict, Optional, List, Literal -from method.resource import MethodResponse, Resource +from method.resource import MethodResponse, Resource, ResourceListOpts from method.configuration import Configuration from method.errors import ResourceError @@ -109,6 +109,9 @@ def __init__(self, config: Configuration): def retrieve(self, verification_session_id: str) -> MethodResponse[EntityVerificationSession]: return super(EntityVerificationSessionResource, self)._get_with_id(verification_session_id) + def list(self, params: Optional[ResourceListOpts] = None) -> MethodResponse[List[EntityVerificationSession]]: + return super(EntityVerificationSessionResource, self)._list(params) + def create(self, opts: Optional[EntityVerificationSessionCreateOpts] = {}) -> MethodResponse[EntityVerificationSession]: # pylint: disable=dangerous-default-value return super(EntityVerificationSessionResource, self)._create(opts) diff --git a/method/resources/Webhook.py b/method/resources/Webhook.py index f3a72ec..320759c 100644 --- a/method/resources/Webhook.py +++ b/method/resources/Webhook.py @@ -74,6 +74,8 @@ class Webhook(TypedDict): created_at: str updated_at: str expand_event: bool + status: str + error: Optional[object] class WebhookCreateOpts(TypedDict): diff --git a/setup.py b/setup.py index 1b930f6..9497393 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='method-python', - version='1.1.2', + version='1.1.3', description='Python library for the Method API', long_description='Python library for the Method API', long_description_content_type='text/x-rst', diff --git a/test/resources/Account_test.py b/test/resources/Account_test.py index be993b3..f6da56a 100644 --- a/test/resources/Account_test.py +++ b/test/resources/Account_test.py @@ -1,4 +1,5 @@ import os +from typing import List import pytest from method import Method from dotenv import load_dotenv @@ -256,6 +257,24 @@ def get_account_balances(): assert balances_retrieve_response == expect_results +@pytest.mark.asyncio +async def test_list_balances(setup): + test_credit_card_account = setup['test_credit_card_account'] + + balances_list_response = method.accounts(test_credit_card_account['id']).balances.list() + + expect_results: AccountBalance = { + 'id': balances_create_response['id'], + 'account_id': test_credit_card_account['id'], + 'status': 'completed', + 'amount': 1866688, + 'error': None, + 'created_at': balances_list_response[0]['created_at'], + 'updated_at': balances_list_response[0]['updated_at'], + } + + assert balances_list_response[0] == expect_results + def test_create_card_brands(setup): global card_brand_create_response test_credit_card_account = setup['test_credit_card_account'] @@ -299,6 +318,27 @@ def test_retrieve_card_brands(setup): assert card_retrieve_response == expect_results +@pytest.mark.asyncio +async def test_list_card_brands(setup): + test_credit_card_account = setup['test_credit_card_account'] + + card_brands_list_response = method.accounts(test_credit_card_account['id']).card_brands.list() + + expect_results: AccountCardBrand = { + 'id': card_brand_create_response['id'], + 'account_id': test_credit_card_account['id'], + 'network': 'visa', + 'status': 'completed', + 'issuer': card_brand_create_response['issuer'], + 'last4': '1580', + 'brands': card_brand_create_response['brands'], + 'shared': False, + 'error': None, + 'created_at': card_brands_list_response[0]['created_at'], + 'updated_at': card_brands_list_response[0]['updated_at'], + } + + assert card_brands_list_response[0] == expect_results def test_create_payoffs(setup): global payoff_create_response @@ -343,6 +383,25 @@ def get_payoff(): assert payoff_retrieve_response == expect_results +@pytest.mark.asyncio +async def test_list_payoffs(setup): + test_auto_loan_account = setup['test_auto_loan_account'] + + payoff_list_response = method.accounts(test_auto_loan_account['id']).payoffs.list() + + expect_results: AccountPayoff = { + 'id': payoff_create_response['id'], + 'account_id': test_auto_loan_account['id'], + 'amount': 6083988, + 'per_diem_amount': None, + 'term': 15, + 'status': 'completed', + 'error': None, + 'created_at': payoff_list_response[0]['created_at'], + 'updated_at': payoff_list_response[0]['updated_at'], + } + + assert payoff_list_response[0] == expect_results def test_create_account_verification_sessions(setup): global verification_session_create @@ -445,6 +504,34 @@ def get_verification_session(): assert verification_session_retrieve_response == expect_results +@pytest.mark.asyncio +async def test_list_account_verification_sessions(setup): + test_credit_card_account = setup['test_credit_card_account'] + + verification_sessions_list_response = method.accounts(test_credit_card_account['id']).verification_sessions.list() + + expect_results: AccountVerificationSession = { + 'id': verification_session_create['id'], + 'account_id': test_credit_card_account['id'], + 'status': 'verified', + 'type': 'pre_auth', + 'error': None, + '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_list_response[0]['created_at'], + 'updated_at': verification_sessions_list_response[0]['updated_at'], + } + + assert verification_sessions_list_response[0] == expect_results def test_create_account_sensitive(setup): global sensitive_data_response @@ -478,6 +565,31 @@ def test_create_account_sensitive(setup): assert sensitive_data_response == expect_results +@pytest.mark.asyncio +async def test_list_account_sensitive(setup): + test_credit_card_account = setup['test_credit_card_account'] + + sensitive_list_response = method.accounts(test_credit_card_account['id']).sensitive.list() + + expect_results: AccountSensitive = { + 'id': sensitive_data_response['id'], + 'account_id': test_credit_card_account['id'], + 'type': 'credit_card', + 'credit_card': { + 'billing_zip_code': None, + 'number': '5555555555551580', + 'exp_month': '03', + 'exp_year': '2028', + 'cvv': None + }, + 'status': 'completed', + 'error': None, + 'created_at': sensitive_list_response[0]['created_at'], + 'updated_at': sensitive_list_response[0]['updated_at'] + } + + assert sensitive_list_response[0] == expect_results + def test_create_transaction_subscription(setup): global create_txn_subscriptions_response test_credit_card_account = setup['test_credit_card_account'] diff --git a/test/resources/Entity_test.py b/test/resources/Entity_test.py index 6f10e87..4bd925b 100644 --- a/test/resources/Entity_test.py +++ b/test/resources/Entity_test.py @@ -1,5 +1,6 @@ from datetime import datetime, timedelta import os +from typing import List from method.resources.Entities.Attributes import EntityAttributes import pytest from method import Method @@ -33,7 +34,8 @@ entities_retrieve_product_list_response = None entities_create_connect_subscription_response = None entities_create_credit_score_subscription_response = None -entities_create_verification_session_response = None +entities_create_individual_verification_response = None +entities_create_phone_verification_response = None # ENTITY CORE METHODS TESTS @@ -240,8 +242,8 @@ def test_update_entity(): def test_list_entities(): global entities_list_response - # list only those entities created in past day, in the format of YYYY-MM-DD - entities_list_response = method.entities.list( {'from_date': (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d')} ) + # list only those entities created in past hour, in the format of YYYY-MM-DD + entities_list_response = method.entities.list( {'from_date': (datetime.now() - timedelta(hours=1)).strftime('%Y-%m-%d')} ) entities_list_response = [entity['id'] for entity in entities_list_response] assert entities_create_response['id'] in entities_list_response @@ -249,7 +251,8 @@ def test_list_entities(): # ENTITY VERIFICATION TESTS def test_create_entity_phone_verification(): - entity_create_phone_verification_response = method.entities(entities_create_response['id']).verification_sessions.create({ + global entities_create_phone_verification_response + entities_create_phone_verification_response = method.entities(entities_create_response['id']).verification_sessions.create({ 'type': 'phone', 'method': 'byo_sms', 'byo_sms': { @@ -258,7 +261,7 @@ def test_create_entity_phone_verification(): }) expect_results: EntityVerificationSession = { - 'id': entity_create_phone_verification_response['id'], + 'id': entities_create_phone_verification_response['id'], 'entity_id': entities_create_response['id'], 'byo_sms': { 'timestamp': '2021-09-01T00:00:00.000Z', @@ -267,22 +270,23 @@ def test_create_entity_phone_verification(): 'status': 'verified', 'type': 'phone', 'error': None, - 'created_at': entity_create_phone_verification_response['created_at'], - 'updated_at': entity_create_phone_verification_response['updated_at'], + 'created_at': entities_create_phone_verification_response['created_at'], + 'updated_at': entities_create_phone_verification_response['updated_at'], } - assert entity_create_phone_verification_response == expect_results + assert entities_create_phone_verification_response == expect_results def test_create_entity_individual_verification(): - entity_create_individual_verification_response = method.entities(entities_create_response['id']).verification_sessions.create({ + global entities_create_individual_verification_response + entities_create_individual_verification_response = method.entities(entities_create_response['id']).verification_sessions.create({ 'type': 'identity', 'method': 'kba', 'kba': {} }) expect_results: EntityVerificationSession = { - 'id': entity_create_individual_verification_response['id'], + 'id': entities_create_individual_verification_response['id'], 'entity_id': entities_create_response['id'], 'kba': { 'authenticated': True, @@ -292,12 +296,20 @@ def test_create_entity_individual_verification(): 'status': 'verified', 'type': 'identity', 'error': None, - 'created_at': entity_create_individual_verification_response['created_at'], - 'updated_at': entity_create_individual_verification_response['updated_at'], + 'created_at': entities_create_individual_verification_response['created_at'], + 'updated_at': entities_create_individual_verification_response['updated_at'], } - assert entity_create_individual_verification_response == expect_results + assert entities_create_individual_verification_response == expect_results +async def test_list_entity_verification_sessions(): + verification_sessions_list_response = method.entities(entities_create_response['id']).verification_sessions.list() + + # Sort both arrays by type to ensure consistent ordering + sorted_response = sorted(verification_sessions_list_response, key=lambda x: x['type']) + sorted_expected = sorted([entities_create_phone_verification_response, entities_create_individual_verification_response], key=lambda x: x['type']) + + assert sorted_response == sorted_expected # ENTITY CONNECT TESTS @@ -338,6 +350,21 @@ def test_retrieve_entity_connect(): assert entities_connect_retrieve_response == expect_results +async def test_list_entity_connect(): + connect_list_response = method.entities(entities_create_response['id']).connect.list() + connect_list_response[0]['accounts'] = connect_list_response[0]['accounts'].sort() + + expect_results: EntityConnect = { + 'id': entities_connect_create_response['id'], + 'entity_id': entities_create_response['id'], + 'status': 'completed', + 'accounts': entities_account_ids, + 'error': None, + 'created_at': entities_connect_create_response['created_at'], + 'updated_at': entities_connect_create_response['updated_at'], + } + + assert connect_list_response[0] == expect_results # ENTITY CREDIT SCORE TESTS @@ -385,6 +412,31 @@ def get_credit_score(): assert credit_score_retrieve_response == expect_results + +async def test_list_entity_credit_score(): + + credit_score_list_response = method.entities(entities_create_response['id']).credit_scores.list() + + expect_results: EntityCreditScores = { + 'id': entities_create_credit_score_response['id'], + 'entity_id': entities_create_response['id'], + 'status': 'completed', + 'scores': [ + { + 'score': credit_score_list_response[0]['scores'][0]['score'], + 'source': 'equifax', + 'model': 'vantage_4', + 'factors': credit_score_list_response[0]['scores'][0]['factors'], + 'created_at': credit_score_list_response[0]['scores'][0]['created_at'] + } + ], + 'error': None, + 'created_at': credit_score_list_response[0]['created_at'], + 'updated_at': credit_score_list_response[0]['updated_at'] + } + + assert credit_score_list_response[0] == expect_results + # ENTITY ATTRIBUTE TESTS def test_create_entity_attribute(): @@ -422,6 +474,21 @@ def get_attribute(): assert attribute_retrieve_response == expect_results +async def test_list_entity_attribute(): + + attribute_list_response = method.entities(entities_create_response['id']).attributes.list() + + expect_results: EntityAttributes = { + 'id': attribute_list_response[0]['id'], + 'entity_id': entities_create_response['id'], + 'status': 'completed', + 'attributes': attribute_list_response[0]['attributes'], + 'error': None, + 'created_at': attribute_list_response[0]['created_at'], + 'updated_at': attribute_list_response[0]['updated_at'] + } + + assert attribute_list_response[0] == expect_results # ENTITY IDENTITY TESTS @@ -526,6 +593,49 @@ def get_identity(): assert identity_retrieve_response == expect_results +async def test_list_entity_identity(): + + identity_list_response = method.entities(entitiy_with_identity_cap['id']).identities.list() + + expect_results: EntityIdentity = { + 'id': entities_create_idenitity_response['id'], + 'entity_id': entitiy_with_identity_cap['id'], + 'status': 'completed', + 'identities': [ + { + 'address': { + 'address': '3300 N INTERSTATE 35', + 'city': 'AUSTIN', + 'postal_code': '78705', + 'state': 'TX' + }, + 'dob': '1997-03-18', + 'first_name': 'KEVIN', + 'last_name': 'DOYLE', + 'phone': '+16505551115', + 'ssn': '111223333' + }, + { + 'address': { + 'address': '3300 N INTERSTATE 35', + 'city': 'AUSTIN', + 'postal_code': '78705', + 'state': 'TX' + }, + 'dob': '1997-03-18', + 'first_name': 'KEVIN', + 'last_name': 'DOYLE', + 'phone': '+16505551115', + 'ssn': '123456789' + } + ], + 'error': None, + 'created_at': identity_list_response[0]['created_at'], + 'updated_at': identity_list_response[0]['updated_at'] + }; + + assert identity_list_response[0] == expect_results + # ENTITY PRODUCT TESTS def test_retrieve_entity_product_list(): diff --git a/test/resources/Event_test.py b/test/resources/Event_test.py index a3d4c14..c97d802 100644 --- a/test/resources/Event_test.py +++ b/test/resources/Event_test.py @@ -52,14 +52,16 @@ def test_simulate_account_closed(setup): 'type': 'account.closed', 'account_id': setup['account_response'][0]['id'] }) - - # Wait for event to be created - sleep(1) - - events_list_response = method.events.list({ - 'resource_id': setup['account_response'][0]['id'] - }) - + + max_retries = 3 + for _ in range(max_retries): + sleep(10) + events_list_response = method.events.list({ + 'resource_id': setup['account_response'][0]['id'] + }) + if events_list_response and len(events_list_response) > 0: + break + event_response = events_list_response[0] event_retrieve_response = method.events.retrieve(event_response['id']) diff --git a/test/resources/Webhook_test.py b/test/resources/Webhook_test.py index ed21739..f0b03e4 100644 --- a/test/resources/Webhook_test.py +++ b/test/resources/Webhook_test.py @@ -17,19 +17,21 @@ def test_create_webhooks(): global webhooks_create_response webhooks_create_response = method.webhooks.create({ - 'type': 'payment.create', + 'type': 'payment.update', 'url': 'https://dev.methodfi.com', 'auth_token': 'test_auth_token' }) expect_results = { 'id': webhooks_create_response['id'], - 'type': 'payment.create', + 'type': 'payment.update', 'url': 'https://dev.methodfi.com', 'metadata': None, 'created_at': webhooks_create_response['created_at'], 'updated_at': webhooks_create_response['updated_at'], - 'expand_event': webhooks_create_response['expand_event'] + 'expand_event': webhooks_create_response['expand_event'], + 'status': webhooks_create_response['status'], + 'error': webhooks_create_response['error'] } assert webhooks_create_response == expect_results @@ -42,12 +44,14 @@ def test_retrieve_webhook(): expect_results = { 'id': webhooks_create_response['id'], - 'type': 'payment.create', + 'type': 'payment.update', 'url': 'https://dev.methodfi.com', 'metadata': None, 'created_at': webhooks_retrieve_response['created_at'], 'updated_at': webhooks_retrieve_response['updated_at'], - 'expand_event': webhooks_retrieve_response['expand_event'] + 'expand_event': webhooks_retrieve_response['expand_event'], + 'status': webhooks_retrieve_response['status'], + 'error': webhooks_retrieve_response['error'] } assert webhooks_retrieve_response == expect_results