Skip to content

Commit c950911

Browse files
Deprecated create method from transaction resource
1 parent 0dc20b4 commit c950911

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Given a version number MAJOR.MINOR.PATCH, increment:
1313

1414

1515
## [Unreleased]
16+
### Changed
17+
- create method from Transaction resource. This method is now deprecated
1618

1719
## [2.30.1] - 2025-08-05
1820
### Fixed

starkbank/transaction/__transaction.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from ..utils import rest
22
from starkcore.utils.resource import Resource
33
from starkcore.utils.checks import check_datetime, check_date
4+
from starkbank.error import StarkError
45

56

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

4849

4950
def create(transactions, user=None):
51+
"""
52+
Deprecated: Function deprecated since 2.31.0
53+
"""
5054
"""# Create Transactions
5155
Send a list of Transaction objects for creation in the Stark Bank API
5256
## Parameters (required):
@@ -56,7 +60,7 @@ def create(transactions, user=None):
5660
## Return:
5761
- list of Transaction objects with updated attributes
5862
"""
59-
return rest.post_multi(resource=_resource, entities=transactions, user=user)
63+
raise StarkError([{"code": "deprecated", "message": "Function deprecated since 2.31.0"}])
6064

6165

6266
def get(id, user=None):

tests/sdk/test_transaction.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,32 @@
44
from tests.utils.date import randomPastDate
55
from tests.utils.transaction import generateExampleTransactionsJson
66
from tests.utils.user import exampleProject
7+
from starkbank.error import StarkError
78

89

910
starkbank.user = exampleProject
1011

1112

1213
class TestTransactionPost(TestCase):
1314

14-
def test_success(self):
15-
transactions = starkbank.transaction.create(generateExampleTransactionsJson(n=5))
16-
self.assertEqual(len(transactions), 5)
17-
for transaction in transactions:
18-
print(transaction)
15+
def test_deprecated_error(self):
16+
with self.assertRaises(StarkError):
17+
starkbank.transaction.create(generateExampleTransactionsJson(n=5))
1918

2019

2120
class TestTransactionQuery(TestCase):
2221

2322
def test_success(self):
2423
transactions = list(starkbank.transaction.query(limit=10))
2524
self.assertEqual(len(transactions), 10)
26-
print("Number of transactions:", len(transactions))
2725

2826
def test_success_after_before(self):
2927
after = randomPastDate(days=10)
3028
before = datetime.today()
3129
transactions = list(starkbank.transaction.query(after=after.date(), before=before.date(), limit=10))
3230
self.assertLessEqual(len(transactions), 10)
3331
for transaction in transactions:
34-
print(transaction)
32+
self.assertIsNotNone(transaction.id)
3533

3634

3735
class TestTransactionPage(TestCase):
@@ -42,7 +40,7 @@ def test_success(self):
4240
for _ in range(2):
4341
transactions, cursor = starkbank.transaction.page(limit=2, cursor=cursor)
4442
for transaction in transactions:
45-
print(transaction)
43+
self.assertIsNotNone(transaction.id)
4644
self.assertFalse(transaction.id in transactionIds)
4745
transactionIds.append(transaction.id)
4846
if cursor is None:

0 commit comments

Comments
 (0)