From 88c1ef6cbe9990d380927d4f77c16a81c3a87520 Mon Sep 17 00:00:00 2001 From: Francisca Otero Date: Fri, 6 Nov 2026 12:04:36 +0000 Subject: [PATCH] feat(organizations): add update to correct the founder email Co-authored-by: fin-compose[bot] <255610621+fin-compose[bot]@users.noreply.github.com> --- README.md | 14 ++++++-- fintoc/managers/organizations_manager.py | 2 +- tests/test_integration.py | 44 ++++++++++++++++++++++-- 3 files changed, 55 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ed34a6a..b450404 100644 --- a/README.md +++ b/README.md @@ -310,8 +310,8 @@ charges = client.payouts.resources.list( #### Organizations -Partnerships can create an organization for a company they refer. This endpoint only -supports `live` mode and requires the [JWS Signature](#generate-the-jws-signature): +Partnerships can create an organization for a company they refer. In `test` mode, the +API returns a mock organization: ```python organization = client.organizations.create( @@ -327,6 +327,16 @@ organization = client.organizations.create( ) ``` +They can also correct the founder email of an organization they referred: + +```python +organization = client.organizations.update( + "org_0ujsswThIGTUYm2K8FjOOfXtY1K", + previous_founder_email="founder@exmaple.com", + founder_email="founder@example.com", +) +``` + #### Payment methods Mexican direct debit mandates are created with a `multipart/form-data` request, so the diff --git a/fintoc/managers/organizations_manager.py b/fintoc/managers/organizations_manager.py index 1b39027..76ef1f2 100644 --- a/fintoc/managers/organizations_manager.py +++ b/fintoc/managers/organizations_manager.py @@ -8,4 +8,4 @@ class OrganizationsManager(ManagerMixin): """Represents an organizations manager.""" resource = "organization" - methods = ["create"] + methods = ["create", "update"] diff --git a/tests/test_integration.py b/tests/test_integration.py index 66c64cd..2a7c1df 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -1753,10 +1753,50 @@ def test_organization_create(self): ) assert business_accounts.shareholders[0].percentage == 60 - def test_organizations_only_support_create(self): - """Test that organizations only expose the create operation.""" + def test_organization_update(self): + """Test correcting the founder email of a referred organization.""" + organization_id = "org_test_organization_id" + update_data = { + "previous_founder_email": "founder@exmaple.com", + "founder_email": "founder@example.com", + } + + organization = self.fintoc.organizations.update(organization_id, **update_data) + + assert isinstance(organization, Organization) + assert organization.method == "patch" + assert organization.url == f"v1/organizations/{organization_id}" + assert organization.json.previous_founder_email == ( + update_data["previous_founder_email"] + ) + assert organization.json.founder_email == update_data["founder_email"] + + def test_organization_instance_update(self): + """Test updating an organization returned by create.""" + organization = self.fintoc.organizations.create( + name="Empresa SpA", + tax_id="111111111", + founder_email="founder@exmaple.com", + products={"business_accounts": {}}, + ) + organization.id = "org_test_organization_id" + + organization.update( + previous_founder_email="founder@exmaple.com", + founder_email="founder@example.com", + ) + + assert isinstance(organization, Organization) + assert organization.method == "patch" + assert organization.url == "v1/organizations/org_test_organization_id" + assert organization.json.founder_email == "founder@example.com" + + def test_organizations_only_support_create_and_update(self): + """Test that organizations only expose the create and update operations.""" with pytest.raises(AttributeError): self.fintoc.organizations.list() + with pytest.raises(AttributeError): + self.fintoc.organizations.get("org_test_organization_id") @pytest.mark.parametrize( "resource_type,klass",