Skip to content

Commit 7dfac1f

Browse files
committed
Fix code style issues with Black
1 parent 0c5952f commit 7dfac1f

File tree

4 files changed

+29
-14
lines changed

4 files changed

+29
-14
lines changed

kkiapay/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33

44
class Kkiapay(KkiapayBase):
5-
def __init__(self, public_key: str, private_key: str, secret: str, sandbox=False) -> None:
5+
def __init__(
6+
self, public_key: str, private_key: str, secret: str, sandbox=False
7+
) -> None:
68
r"""Initialize Kkiapay client.
79
:param public_key: Public key from https://app.kkiapay.me/dashboard/developers/keys.
810
:param private_key: Provate key from https://app.kkiapay.me/dashboard/developers/keys.
@@ -11,14 +13,12 @@ def __init__(self, public_key: str, private_key: str, secret: str, sandbox=False
1113
"""
1214
self._initialize_credentials(public_key, private_key, secret, sandbox)
1315

14-
1516
def verify_transaction(self, transaction_id: str) -> dict:
1617
r"""Verify a transaction.
1718
:param transaction_id: transaction ID
1819
"""
1920
return self._verify_transaction(transaction_id)
2021

21-
2222
def refund_transaction(self, transaction_id: str) -> dict:
2323
r"""Refund a specific transaction.
2424
:param transaction_id: transaction ID

kkiapay/base.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66

77
class KkiapayBase:
8-
def _initialize_credentials(self, public_key: str, private_key: str, secret: str, sandbox: bool) -> None:
9-
self.public_key = public_key
10-
self.private_key = private_key
11-
self.secret = secret
8+
def _initialize_credentials(
9+
self, public_key: str, private_key: str, secret: str, sandbox: bool
10+
) -> None:
11+
self.public_key = public_key
12+
self.private_key = private_key
13+
self.secret = secret
1214
self.is_sandbox_environment = sandbox
1315

1416
def _build_request_headers(self) -> dict:
@@ -20,21 +22,23 @@ def _build_request_headers(self) -> dict:
2022
}
2123

2224
def _build_request_url(self, path: str) -> str:
23-
BASE_URL = SANDBOX_BASE_URL if self.is_sandbox_environment else PRODUCTION_BASE_URL
25+
BASE_URL = (
26+
SANDBOX_BASE_URL if self.is_sandbox_environment else PRODUCTION_BASE_URL
27+
)
2428
return f"{BASE_URL}/{path}"
2529

2630
def _verify_transaction(self, transaction_id: str):
2731
return make_request(
2832
"post",
2933
self._build_request_url("api/v1/transactions/status"),
3034
json={"transactionId": transaction_id},
31-
headers=self._build_request_headers()
35+
headers=self._build_request_headers(),
3236
)
3337

3438
def _refund_transaction(self, transaction_id: str):
3539
return make_request(
3640
"post",
3741
self._build_request_url("api/v1/transactions/revert"),
3842
json={"transactionId": transaction_id},
39-
headers=self._build_request_headers()
43+
headers=self._build_request_headers(),
4044
)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import setuptools
33

4-
with open('requirements.txt') as f:
4+
with open("requirements.txt") as f:
55
required = f.read().splitlines()
66

77
with open("README.md", "r") as fh:

tests/test_kkiapay.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,34 @@ def test_verify_transaction():
88
responses.add(
99
responses.POST,
1010
"https://api-sandbox.kkiapay.me/api/v1/transactions/status",
11-
json={'performed_at': '2023-02-20T17:44:47.842Z', 'received_at': 1676915100302, 'type': 'DEBIT', 'status': 'SUCCESS', 'source': 'MOBILE_MONEY'},
11+
json={
12+
"performed_at": "2023-02-20T17:44:47.842Z",
13+
"received_at": 1676915100302,
14+
"type": "DEBIT",
15+
"status": "SUCCESS",
16+
"source": "MOBILE_MONEY",
17+
},
1218
)
1319

1420
k = Kkiapay("public_key", "private_key", "secret", True)
1521

1622
response = k.verify_transaction("123")
1723
assert response["type"] == "DEBIT"
1824

25+
1926
@responses.activate
2027
def test_refund_transaction():
2128
responses.add(
2229
responses.POST,
2330
"https://api-sandbox.kkiapay.me/api/v1/transactions/revert",
24-
json={'code': 'SUCCESS', 'description': 'REVERTED', 'transactionId': '123'},
31+
json={"code": "SUCCESS", "description": "REVERTED", "transactionId": "123"},
2532
)
2633

2734
k = Kkiapay("public_key", "private_key", "secret", True)
2835

2936
response = k.refund_transaction("123")
30-
assert response == {'code': 'SUCCESS', 'description': 'REVERTED', 'transactionId': '123'}
37+
assert response == {
38+
"code": "SUCCESS",
39+
"description": "REVERTED",
40+
"transactionId": "123",
41+
}

0 commit comments

Comments
 (0)