Skip to content
Closed
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Given a version number MAJOR.MINOR.PATCH, increment:


## [Unreleased]
### Changed
- create method from Transaction resource. This method is now deprecated

## [2.30.1] - 2025-08-05
### Fixed
Expand Down
6 changes: 5 additions & 1 deletion starkbank/transaction/__transaction.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from ..utils import rest
from starkcore.utils.resource import Resource
from starkcore.utils.checks import check_datetime, check_date
from starkbank.error import StarkError


class Transaction(Resource):
Expand Down Expand Up @@ -47,6 +48,9 @@ def __init__(self, amount, description, external_id, receiver_id, sender_id=None


def create(transactions, user=None):
"""
Deprecated: Function deprecated since 2.31.0
"""
"""# Create Transactions
Send a list of Transaction objects for creation in the Stark Bank API
## Parameters (required):
Expand All @@ -56,7 +60,7 @@ def create(transactions, user=None):
## Return:
- list of Transaction objects with updated attributes
"""
return rest.post_multi(resource=_resource, entities=transactions, user=user)
raise StarkError([{"code": "deprecated", "message": "Function deprecated since 2.31.0"}])


def get(id, user=None):
Expand Down
12 changes: 5 additions & 7 deletions tests/sdk/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from tests.utils.date import randomPastDate
from tests.utils.transaction import generateExampleTransactionsJson
from tests.utils.user import exampleProject
from starkbank.error import StarkError


starkbank.user = exampleProject
Expand All @@ -12,26 +13,23 @@
class TestTransactionPost(TestCase):

def test_success(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

o nome do teste nao esta fazendo mais sentido com o que esta acontecendo dentro do teste

transactions = starkbank.transaction.create(generateExampleTransactionsJson(n=5))
self.assertEqual(len(transactions), 5)
for transaction in transactions:
print(transaction)
with self.assertRaises(StarkError):
starkbank.transaction.create(generateExampleTransactionsJson(n=5))


class TestTransactionQuery(TestCase):

def test_success(self):
transactions = list(starkbank.transaction.query(limit=10))
self.assertEqual(len(transactions), 10)
print("Number of transactions:", len(transactions))

def test_success_after_before(self):
after = randomPastDate(days=10)
before = datetime.today()
transactions = list(starkbank.transaction.query(after=after.date(), before=before.date(), limit=10))
self.assertLessEqual(len(transactions), 10)
for transaction in transactions:
print(transaction)
self.assertIsNotNone(transaction.id)


class TestTransactionPage(TestCase):
Expand All @@ -42,7 +40,7 @@ def test_success(self):
for _ in range(2):
transactions, cursor = starkbank.transaction.page(limit=2, cursor=cursor)
for transaction in transactions:
print(transaction)
self.assertIsNotNone(transaction.id)
self.assertFalse(transaction.id in transactionIds)
transactionIds.append(transaction.id)
if cursor is None:
Expand Down
Loading