Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fintoc/managers/organizations_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ class OrganizationsManager(ManagerMixin):
"""Represents an organizations manager."""

resource = "organization"
methods = ["create"]
methods = ["create", "update"]
44 changes: 42 additions & 2 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading