From 339dabec2c6dd68530e4c03dc99957f1bae5c97e Mon Sep 17 00:00:00 2001 From: mamunozcar Date: Tue, 19 May 2026 11:45:06 -0400 Subject: [PATCH 1/2] feat: add support for disputes endpoints --- fintoc/core.py | 2 ++ fintoc/managers/__init__.py | 2 ++ fintoc/managers/dispute_documents_manager.py | 10 ++++++ fintoc/managers/disputes_manager.py | 36 ++++++++++++++++++++ fintoc/resources/__init__.py | 2 ++ fintoc/resources/dispute.py | 12 +++++++ fintoc/resources/dispute_document.py | 7 ++++ tests/test_integration.py | 36 ++++++++++++++++++++ 8 files changed, 107 insertions(+) create mode 100644 fintoc/managers/dispute_documents_manager.py create mode 100644 fintoc/managers/disputes_manager.py create mode 100644 fintoc/resources/dispute.py create mode 100644 fintoc/resources/dispute_document.py diff --git a/fintoc/core.py b/fintoc/core.py index 44ab0a7..f032832 100644 --- a/fintoc/core.py +++ b/fintoc/core.py @@ -8,6 +8,7 @@ AccountsManager, ChargesManager, CheckoutSessionsManager, + DisputesManager, InvoicesManager, LinksManager, PaymentIntentsManager, @@ -68,6 +69,7 @@ def __init__(self, api_key, api_version=None, jws_private_key=None): ) self.tax_returns = TaxReturnsManager("/v1/tax_returns", self._client) self.invoices = InvoicesManager("/v1/invoices", self._client) + self.disputes = DisputesManager("/v1/disputes", self._client) self.v2 = _FintocV2(self._client) diff --git a/fintoc/managers/__init__.py b/fintoc/managers/__init__.py index 6d5d663..44e3397 100644 --- a/fintoc/managers/__init__.py +++ b/fintoc/managers/__init__.py @@ -3,6 +3,8 @@ from .accounts_manager import AccountsManager from .charges_manager import ChargesManager from .checkout_sessions_manager import CheckoutSessionsManager +from .dispute_documents_manager import DisputeDocumentsManager +from .disputes_manager import DisputesManager from .invoices_manager import InvoicesManager from .links_manager import LinksManager from .movements_manager import MovementsManager diff --git a/fintoc/managers/dispute_documents_manager.py b/fintoc/managers/dispute_documents_manager.py new file mode 100644 index 0000000..035ccd9 --- /dev/null +++ b/fintoc/managers/dispute_documents_manager.py @@ -0,0 +1,10 @@ +"""Module to hold the dispute documents manager.""" + +from fintoc.mixins import ManagerMixin + + +class DisputeDocumentsManager(ManagerMixin): + """Represents a dispute documents manager.""" + + resource = "dispute_document" + methods = ["create"] diff --git a/fintoc/managers/disputes_manager.py b/fintoc/managers/disputes_manager.py new file mode 100644 index 0000000..ee8dc57 --- /dev/null +++ b/fintoc/managers/disputes_manager.py @@ -0,0 +1,36 @@ +"""Module to hold the disputes manager.""" + +from fintoc.managers.dispute_documents_manager import DisputeDocumentsManager +from fintoc.mixins import ManagerMixin + + +# pylint: disable=duplicate-code +class DisputesManager(ManagerMixin): + + """Represents a disputes manager.""" + + resource = "dispute" + methods = ["list", "get", "submit_for_review"] + + def __init__(self, path, client): + super().__init__(path, client) + self.__documents_manager = None + + def _submit_for_review(self, identifier, **kwargs): + """Submit a dispute for review.""" + path = f"{self._build_path(**kwargs)}/{identifier}/submit_for_review" + return self._create(path_=path, **kwargs) + + @property + def documents(self): + """Proxies the dispute documents manager.""" + if self.__documents_manager is None: + self.__documents_manager = DisputeDocumentsManager( + "/v1/disputes/{dispute_id}/documents", + self._client, + ) + return self.__documents_manager + + @documents.setter + def documents(self, new_value): # pylint: disable=no-self-use + raise NameError("Attribute name corresponds to a manager") diff --git a/fintoc/resources/__init__.py b/fintoc/resources/__init__.py index ad8effa..8053539 100644 --- a/fintoc/resources/__init__.py +++ b/fintoc/resources/__init__.py @@ -4,6 +4,8 @@ from .balance import Balance from .charge import Charge from .checkout_session import CheckoutSession +from .dispute import Dispute +from .dispute_document import DisputeDocument from .generic_fintoc_resource import GenericFintocResource from .income import Income from .institution import Institution diff --git a/fintoc/resources/dispute.py b/fintoc/resources/dispute.py new file mode 100644 index 0000000..2517662 --- /dev/null +++ b/fintoc/resources/dispute.py @@ -0,0 +1,12 @@ +"""Module to hold the Dispute resource.""" + +from fintoc.mixins import ResourceMixin + + +class Dispute(ResourceMixin): + + """Represents a Fintoc Dispute.""" + + mappings = { + "documents": "dispute_document", + } diff --git a/fintoc/resources/dispute_document.py b/fintoc/resources/dispute_document.py new file mode 100644 index 0000000..eec8947 --- /dev/null +++ b/fintoc/resources/dispute_document.py @@ -0,0 +1,7 @@ +"""Module to hold the DisputeDocument resource.""" + +from fintoc.mixins import ResourceMixin + + +class DisputeDocument(ResourceMixin): + """Represents a Fintoc Dispute Document.""" diff --git a/tests/test_integration.py b/tests/test_integration.py index d60a056..ed39e0e 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -882,6 +882,42 @@ def test_checkout_session_expire(self): assert result.method == "post" assert result.url == f"v1/checkout_sessions/{checkout_session_id}/expire" + def test_disputes_list(self): + """Test getting all disputes.""" + disputes = list(self.fintoc.disputes.list()) + + assert len(disputes) > 0 + for dispute in disputes: + assert dispute.method == "get" + assert dispute.url == "v1/disputes" + + def test_dispute_get(self): + """Test getting a specific dispute.""" + dispute_id = "test_dispute_id" + + dispute = self.fintoc.disputes.get(dispute_id) + + assert dispute.method == "get" + assert dispute.url == f"v1/disputes/{dispute_id}" + + def test_dispute_submit_for_review(self): + """Test submitting a dispute for review.""" + dispute_id = "test_dispute_id" + + result = self.fintoc.disputes.submit_for_review(dispute_id) + + assert result.method == "post" + assert result.url == f"v1/disputes/{dispute_id}/submit_for_review" + + def test_dispute_document_create(self): + """Test creating a document for a dispute.""" + dispute_id = "test_dispute_id" + + document = self.fintoc.disputes.documents.create(dispute_id=dispute_id) + + assert document.method == "post" + assert document.url == f"v1/disputes/{dispute_id}/documents" + def test_v2_transfer_return(self): """Test returning a transfer using v2 API.""" transfer_id = "test_transfer_id" From db915575a8401b019a22bd1f67dd214fd3d3890b Mon Sep 17 00:00:00 2001 From: mamunozcar Date: Tue, 19 May 2026 12:14:11 -0400 Subject: [PATCH 2/2] fixup! feat: add support for disputes endpoints --- fintoc/managers/disputes_manager.py | 1 - fintoc/resources/dispute.py | 1 - 2 files changed, 2 deletions(-) diff --git a/fintoc/managers/disputes_manager.py b/fintoc/managers/disputes_manager.py index ee8dc57..55f3c63 100644 --- a/fintoc/managers/disputes_manager.py +++ b/fintoc/managers/disputes_manager.py @@ -6,7 +6,6 @@ # pylint: disable=duplicate-code class DisputesManager(ManagerMixin): - """Represents a disputes manager.""" resource = "dispute" diff --git a/fintoc/resources/dispute.py b/fintoc/resources/dispute.py index 2517662..b1defe0 100644 --- a/fintoc/resources/dispute.py +++ b/fintoc/resources/dispute.py @@ -4,7 +4,6 @@ class Dispute(ResourceMixin): - """Represents a Fintoc Dispute.""" mappings = {