@@ -26,11 +26,75 @@ def brand(self):
2626import logging
2727import uuid
2828from abc import ABC , abstractmethod
29+ from typing import Any , Optional
30+
31+ from httpx import Response
2932
30- # Configure logging
3133logger = logging .getLogger ("tillo.contracts" )
3234
3335
36+ class IssueDigitalCodeServiceInterface (ABC ):
37+ @abstractmethod
38+ async def issue_digital_code (
39+ self ,
40+ query_params : Optional [Any ] = None ,
41+ body : Optional [Any ] = None ,
42+ ): ...
43+
44+
45+ class IssueDigitalCodeServiceAsyncInterface (ABC ):
46+ @abstractmethod
47+ async def order_digital_code (
48+ self ,
49+ query_params : Optional [Any ] = None ,
50+ body : Optional [Any ] = None ,
51+ ): ...
52+
53+
54+ class TemplateServiceInterface (ABC ):
55+ @abstractmethod
56+ def download_brand_template (
57+ self ,
58+ query_params : Optional [Any ] = None ,
59+ ) -> Any : ...
60+
61+ @abstractmethod
62+ def get_brand_templates (
63+ self ,
64+ query_params : Optional [Any ] = None ,
65+ ) -> Any : ...
66+
67+
68+ class TemplateServiceAsyncInterface (ABC ):
69+ @abstractmethod
70+ async def download_brand_template (
71+ self ,
72+ query_params : Optional [Any ] = None ,
73+ ) -> Any : ...
74+
75+ @abstractmethod
76+ async def get_brand_templates (
77+ self ,
78+ query_params : Optional [Any ] = None ,
79+ ) -> Any : ...
80+
81+
82+ class FloatServiceAsyncInterface (ABC ):
83+ @abstractmethod
84+ async def check_floats (
85+ self ,
86+ query_params : Optional [Any ] = None ,
87+ ) -> Response : ...
88+
89+
90+ class FloatServiceInterface (ABC ):
91+ @abstractmethod
92+ def check_floats (
93+ self ,
94+ query_params : Optional [Any ] = None ,
95+ ) -> Response : ...
96+
97+
3498class SignatureGeneratorInterface (ABC ):
3599 """Interface for generating secure signatures for Tillo API requests.
36100
@@ -55,8 +119,7 @@ def get_api_key(self) -> str:
55119 Returns:
56120 str: The API key used for Tillo API authentication
57121 """
58- logger .debug ("Getting API key for authentication" )
59- pass
122+ ...
60123
61124 @abstractmethod
62125 def get_secret_key_as_bytes (self ) -> bytearray :
@@ -65,8 +128,7 @@ def get_secret_key_as_bytes(self) -> bytearray:
65128 Returns:
66129 bytearray: The secret key encoded as UTF-8 bytes
67130 """
68- logger .debug ("Getting secret key as bytes for HMAC generation" )
69- pass
131+ ...
70132
71133 @staticmethod
72134 @abstractmethod
@@ -76,8 +138,7 @@ def generate_timestamp() -> str:
76138 Returns:
77139 str: Current timestamp in milliseconds as a string
78140 """
79- logger .debug ("Generating Unix timestamp in milliseconds" )
80- pass
141+ ...
81142
82143 @staticmethod
83144 @abstractmethod
@@ -87,8 +148,7 @@ def generate_unique_client_request_id() -> uuid.UUID:
87148 Returns:
88149 uuid.UUID: A new UUID v4 for request identification
89150 """
90- logger .debug ("Generating unique client request ID" )
91- pass
151+ ...
92152
93153 @abstractmethod
94154 def generate_signature_string (self , endpoint : str , request_type : str , timestamp : str , params : tuple ) -> str :
@@ -103,12 +163,7 @@ def generate_signature_string(self, endpoint: str, request_type: str, timestamp:
103163 Returns:
104164 str: The string to be signed according to Tillo's specification
105165 """
106- logger .debug (
107- "Generating signature string for endpoint: %s, method: %s" ,
108- endpoint ,
109- request_type ,
110- )
111- pass
166+ ...
112167
113168 @abstractmethod
114169 def generate_signature (self , seed : str ) -> str :
@@ -120,8 +175,7 @@ def generate_signature(self, seed: str) -> str:
120175 Returns:
121176 str: The hexadecimal HMAC-SHA256 signature
122177 """
123- logger .debug ("Generating HMAC-SHA256 signature" )
124- pass
178+ ...
125179
126180
127181class SignatureBridgeInterface (ABC ):
@@ -157,12 +211,7 @@ def sign(
157211 Returns:
158212 tuple: A tuple containing (api_key, signature, timestamp)
159213 """
160- logger .debug (
161- "Generating complete signature for endpoint: %s, method: %s" ,
162- endpoint ,
163- method ,
164- )
165- pass
214+ ...
166215
167216
168217class TilloInterface (ABC ):
@@ -185,8 +234,9 @@ def brand(self):
185234 ```
186235 """
187236
237+ @property
188238 @abstractmethod
189- def floats (self ):
239+ def floats (self ) -> FloatServiceInterface :
190240 """Get the floats service instance.
191241
192242 Returns:
@@ -198,10 +248,11 @@ def floats(self):
198248 balance = float_service.get_balance()
199249 ```
200250 """
201- pass
251+ ...
202252
253+ @property
203254 @abstractmethod
204- def floats_async (self ):
255+ def floats_async (self ) -> FloatServiceAsyncInterface :
205256 """Get the asynchronous floats service instance.
206257
207258 Returns:
@@ -213,8 +264,9 @@ def floats_async(self):
213264 balance = float_service.get_balance()
214265 ```
215266 """
216- pass
267+ ...
217268
269+ @property
218270 @abstractmethod
219271 def brands (self ):
220272 """Get the brand service instance.
@@ -228,8 +280,9 @@ def brands(self):
228280 brand_info = brand_service.get_brand_details()
229281 ```
230282 """
231- pass
283+ ...
232284
285+ @property
233286 @abstractmethod
234287 def brands_async (self ):
235288 """Get the brand service instance.
@@ -243,10 +296,11 @@ def brands_async(self):
243296 brand_info = brand_service.get_brand_details()
244297 ```
245298 """
246- pass
299+ ...
247300
301+ @property
248302 @abstractmethod
249- def templates (self ):
303+ def templates (self ) -> TemplateServiceInterface :
250304 """Get the template service instance.
251305
252306 Returns:
@@ -258,10 +312,11 @@ def templates(self):
258312 templates = template_service.list_templates()
259313 ```
260314 """
261- pass
315+ ...
262316
317+ @property
263318 @abstractmethod
264- async def templates_async (self ):
319+ def templates_async (self ) -> TemplateServiceAsyncInterface :
265320 """Get the template service instance.
266321
267322 Returns:
@@ -273,10 +328,11 @@ async def templates_async(self):
273328 templates = template_service.list_templates()
274329 ```
275330 """
276- pass
331+ ...
277332
333+ @property
278334 @abstractmethod
279- def digital_card (self ):
335+ def digital_card (self ) -> IssueDigitalCodeServiceInterface :
280336 """Get the digital card service instance.
281337
282338 Returns:
@@ -288,11 +344,11 @@ def digital_card(self):
288344 card = digital_card_service.issue_card(amount=50.00)
289345 ```
290346 """
291- logger .debug ("Getting digital card service instance" )
292- pass
347+ ...
293348
349+ @property
294350 @abstractmethod
295- def digital_card_async (self ):
351+ def digital_card_async (self ) -> IssueDigitalCodeServiceAsyncInterface :
296352 """Get the digital card service instance.
297353
298354 Returns:
@@ -304,9 +360,9 @@ def digital_card_async(self):
304360 card = digital_card_service.issue_card(amount=50.00)
305361 ```
306362 """
307- logger .debug ("Getting digital card service instance" )
308- pass
363+ ...
309364
365+ @property
310366 @abstractmethod
311367 def physical_card (self ):
312368 """Get the physical card service instance.
@@ -320,9 +376,9 @@ def physical_card(self):
320376 card = physical_card_service.order_card(amount=100.00)
321377 ```
322378 """
323- logger .debug ("Getting physical card service instance" )
324- pass
379+ ...
325380
381+ @property
326382 @abstractmethod
327383 def webhook (self ):
328384 """Get the webhook service instance.
@@ -336,5 +392,4 @@ def webhook(self):
336392 webhooks = webhook_service.list_webhooks()
337393 ```
338394 """
339- logger .debug ("Getting webhook service instance" )
340- pass
395+ ...
0 commit comments