sapliyio-fintech 0.0.1__py3-none-any.whl → 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sapliyio_fintech/__init__.py +26 -171
- sapliyio_fintech/api_client.py +804 -0
- sapliyio_fintech/api_response.py +21 -0
- sapliyio_fintech/configuration.py +578 -0
- sapliyio_fintech/exceptions.py +219 -0
- sapliyio_fintech/py.typed +0 -0
- sapliyio_fintech/rest.py +263 -0
- sapliyio_fintech-1.0.0.dist-info/METADATA +254 -0
- sapliyio_fintech-1.0.0.dist-info/RECORD +12 -0
- sapliyio_fintech-0.0.1.dist-info/METADATA +0 -44
- sapliyio_fintech-0.0.1.dist-info/RECORD +0 -6
- {sapliyio_fintech-0.0.1.dist-info → sapliyio_fintech-1.0.0.dist-info}/WHEEL +0 -0
- {sapliyio_fintech-0.0.1.dist-info → sapliyio_fintech-1.0.0.dist-info}/licenses/LICENSE +0 -0
- {sapliyio_fintech-0.0.1.dist-info → sapliyio_fintech-1.0.0.dist-info}/top_level.txt +0 -0
sapliyio_fintech/__init__.py
CHANGED
|
@@ -1,173 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
from
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
from .api_client import ApiClient
|
|
2
|
+
from .configuration import Configuration
|
|
3
|
+
from .api.auth_service_api import AuthServiceApi
|
|
4
|
+
from .api.billing_service_api import BillingServiceApi
|
|
5
|
+
from .api.ledger_service_api import LedgerServiceApi
|
|
6
|
+
from .api.notification_service_api import NotificationServiceApi
|
|
7
|
+
from .api.payment_service_api import PaymentServiceApi
|
|
8
|
+
from .api.wallet_service_api import WalletServiceApi
|
|
9
|
+
# form .api.flow_service_api import FlowServiceApi
|
|
10
|
+
# from .api.zone_service_api import ZoneServiceApi
|
|
11
|
+
|
|
12
|
+
class SapliyClient:
|
|
8
13
|
def __init__(self, api_key: str, base_url: str = "http://localhost:8080"):
|
|
9
|
-
self.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
self.
|
|
13
|
-
"Content-Type": "application/json",
|
|
14
|
-
"X-API-Key": self.api_key
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
def _request(self, method: str, path: str, json: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
|
18
|
-
url = f"{self.base_url}{path}"
|
|
19
|
-
response = self.session.request(method, url, json=json)
|
|
20
|
-
if response.status_code >= 400:
|
|
21
|
-
try:
|
|
22
|
-
error_detail = response.json()
|
|
23
|
-
except:
|
|
24
|
-
error_detail = response.text
|
|
25
|
-
raise Exception(f"Fintech API Error ({response.status_code}): {error_detail}")
|
|
26
|
-
return response.json()
|
|
27
|
-
|
|
28
|
-
@property
|
|
29
|
-
def ledger(self):
|
|
30
|
-
return LedgerService(self)
|
|
31
|
-
|
|
32
|
-
@property
|
|
33
|
-
def auth(self):
|
|
34
|
-
return AuthService(self)
|
|
35
|
-
|
|
36
|
-
@property
|
|
37
|
-
def payments(self):
|
|
38
|
-
return PaymentsService(self)
|
|
39
|
-
|
|
40
|
-
@property
|
|
41
|
-
def wallets(self):
|
|
42
|
-
return WalletsService(self)
|
|
43
|
-
|
|
44
|
-
@property
|
|
45
|
-
def billing(self):
|
|
46
|
-
return BillingService(self)
|
|
47
|
-
|
|
48
|
-
@property
|
|
49
|
-
def connect(self):
|
|
50
|
-
return ConnectService(self)
|
|
51
|
-
|
|
52
|
-
@property
|
|
53
|
-
def webhooks(self):
|
|
54
|
-
return WebhooksService(self)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
class LedgerService:
|
|
58
|
-
def __init__(self, client: FintechClient):
|
|
59
|
-
self.client = client
|
|
60
|
-
|
|
61
|
-
def record_transaction(self, account_id: str, amount: int, currency: str, description: str, reference_id: str) -> Dict[str, Any]:
|
|
62
|
-
payload = {
|
|
63
|
-
"accountId": account_id,
|
|
64
|
-
"amount": amount,
|
|
65
|
-
"currency": currency,
|
|
66
|
-
"description": description,
|
|
67
|
-
"referenceId": reference_id
|
|
68
|
-
}
|
|
69
|
-
return self.client._request("POST", "/v1/ledger/transactions", json=payload)
|
|
70
|
-
|
|
71
|
-
def get_account(self, account_id: str) -> Dict[str, Any]:
|
|
72
|
-
return self.client._request("GET", f"/v1/ledger/accounts/{account_id}")
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
class AuthService:
|
|
76
|
-
def __init__(self, client: FintechClient):
|
|
77
|
-
self.client = client
|
|
78
|
-
|
|
79
|
-
def validate_key(self, key_hash: str) -> Dict[str, Any]:
|
|
80
|
-
return self.client._request("POST", "/v1/auth/validate", json={"keyHash": key_hash})
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
class PaymentsService:
|
|
84
|
-
def __init__(self, client: FintechClient):
|
|
85
|
-
self.client = client
|
|
86
|
-
|
|
87
|
-
def create(self, amount: int, currency: str, source_id: str, description: str) -> Dict[str, Any]:
|
|
88
|
-
payload = {
|
|
89
|
-
"amount": amount,
|
|
90
|
-
"currency": currency,
|
|
91
|
-
"sourceId": source_id,
|
|
92
|
-
"description": description
|
|
93
|
-
}
|
|
94
|
-
return self.client._request("POST", "/v1/payments", json=payload)
|
|
95
|
-
|
|
96
|
-
def get(self, payment_id: str) -> Dict[str, Any]:
|
|
97
|
-
return self.client._request("GET", f"/v1/payments/{payment_id}")
|
|
98
|
-
|
|
99
|
-
def refund(self, payment_id: str, amount: int) -> Dict[str, Any]:
|
|
100
|
-
return self.client._request("POST", f"/v1/payments/{payment_id}/refund", json={"amount": amount})
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
class WalletsService:
|
|
104
|
-
def __init__(self, client: FintechClient):
|
|
105
|
-
self.client = client
|
|
106
|
-
|
|
107
|
-
def create(self, user_id: str, currency: str) -> Dict[str, Any]:
|
|
108
|
-
payload = {"userId": user_id, "currency": currency}
|
|
109
|
-
return self.client._request("POST", "/v1/wallets", json=payload)
|
|
110
|
-
|
|
111
|
-
def get(self, wallet_id: str) -> Dict[str, Any]:
|
|
112
|
-
return self.client._request("GET", f"/v1/wallets/{wallet_id}")
|
|
113
|
-
|
|
114
|
-
def credit(self, wallet_id: str, amount: int, description: str) -> Dict[str, Any]:
|
|
115
|
-
payload = {"amount": amount, "description": description}
|
|
116
|
-
return self.client._request("POST", f"/v1/wallets/{wallet_id}/credit", json=payload)
|
|
117
|
-
|
|
118
|
-
def debit(self, wallet_id: str, amount: int, description: str) -> Dict[str, Any]:
|
|
119
|
-
payload = {"amount": amount, "description": description}
|
|
120
|
-
return self.client._request("POST", f"/v1/wallets/{wallet_id}/debit", json=payload)
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
class BillingService:
|
|
124
|
-
def __init__(self, client: FintechClient):
|
|
125
|
-
self.client = client
|
|
126
|
-
|
|
127
|
-
def create_subscription(self, customer_id: str, price_id: str) -> Dict[str, Any]:
|
|
128
|
-
payload = {"customerId": customer_id, "priceId": price_id}
|
|
129
|
-
return self.client._request("POST", "/v1/billing/subscriptions", json=payload)
|
|
130
|
-
|
|
131
|
-
def get_subscription(self, subscription_id: str) -> Dict[str, Any]:
|
|
132
|
-
return self.client._request("GET", f"/v1/billing/subscriptions/{subscription_id}")
|
|
133
|
-
|
|
134
|
-
def cancel_subscription(self, subscription_id: str) -> Dict[str, Any]:
|
|
135
|
-
return self.client._request("POST", f"/v1/billing/subscriptions/{subscription_id}/cancel")
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
class ConnectService:
|
|
139
|
-
def __init__(self, client: FintechClient):
|
|
140
|
-
self.client = client
|
|
141
|
-
|
|
142
|
-
def create_account(self, type: str, country: str, email: str) -> Dict[str, Any]:
|
|
143
|
-
payload = {"type": type, "country": country, "email": email}
|
|
144
|
-
return self.client._request("POST", "/v1/connect/accounts", json=payload)
|
|
145
|
-
|
|
146
|
-
def get_account(self, account_id: str) -> Dict[str, Any]:
|
|
147
|
-
return self.client._request("GET", f"/v1/connect/accounts/{account_id}")
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
class WebhooksService:
|
|
151
|
-
def __init__(self, client: FintechClient):
|
|
152
|
-
self.client = client
|
|
153
|
-
|
|
154
|
-
def create_endpoint(self, url: str, enabled_events: List[str]) -> Dict[str, Any]:
|
|
155
|
-
payload = {"url": url, "enabledEvents": enabled_events}
|
|
156
|
-
return self.client._request("POST", "/v1/webhooks/endpoints", json=payload)
|
|
157
|
-
|
|
158
|
-
def list_endpoints(self) -> List[Dict[str, Any]]:
|
|
159
|
-
return self.client._request("GET", "/v1/webhooks/endpoints")
|
|
160
|
-
|
|
161
|
-
def construct_event(self, payload: Union[str, bytes], signature: str, secret: str) -> Dict[str, Any]:
|
|
162
|
-
if isinstance(payload, str):
|
|
163
|
-
payload_bytes = payload.encode('utf-8')
|
|
164
|
-
else:
|
|
165
|
-
payload_bytes = payload
|
|
166
|
-
|
|
167
|
-
expected_sig = hmac.new(secret.encode('utf-8'), payload_bytes, hashlib.sha256).hexdigest()
|
|
14
|
+
self.configuration = Configuration(
|
|
15
|
+
host=base_url,
|
|
16
|
+
)
|
|
17
|
+
self.configuration.api_key['X-API-Key'] = api_key
|
|
168
18
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
19
|
+
self.api_client = ApiClient(self.configuration)
|
|
20
|
+
|
|
21
|
+
self.auth = AuthServiceApi(self.api_client)
|
|
22
|
+
self.billing = BillingServiceApi(self.api_client)
|
|
23
|
+
self.ledger = LedgerServiceApi(self.api_client)
|
|
24
|
+
self.notifications = NotificationServiceApi(self.api_client)
|
|
25
|
+
self.payments = PaymentServiceApi(self.api_client)
|
|
26
|
+
self.wallets = WalletServiceApi(self.api_client)
|
|
27
|
+
# self.flows = FlowServiceApi(self.api_client)
|
|
28
|
+
# self.zones = ZoneServiceApi(self.api_client)
|