99
1010class CertificatesOnSolanaException (Exception ):
1111 """Custom exception for CertificatesOnSolana errors."""
12- def __init__ (self , message : str = "Error registering certificate on Solana" ,
13- details : str = "" ,
14- cause : Exception = None ):
12+
13+ def __init__ (
14+ self ,
15+ message : str = "Error registering certificate on Solana" ,
16+ details : str = "" ,
17+ cause : Exception = None ,
18+ ):
1519 super ().__init__ (message )
1620 self .details = details
1721 self .cause = cause
1822
19- class CertificatesOnSolana :
2023
21- """
24+ class CertificatesOnSolana :
25+ """
2226 A class to manage certificates on the Solana blockchain Service."""
2327
2428 @staticmethod
25- @retry (tries = 3 , delay = 3 , backoff = 2 , exceptions = (httpx .RequestError ,CertificatesOnSolanaException , Exception ), logger = logger )
29+ @retry (
30+ tries = 3 ,
31+ delay = 3 ,
32+ backoff = 2 ,
33+ exceptions = (httpx .RequestError , CertificatesOnSolanaException , Exception ),
34+ logger = logger ,
35+ )
2636 def register_certificate_on_solana (certificate_data : dict ) -> dict :
27- logger .info ("Registering certificate on Solana blockchain with data: %s" , certificate_data )
37+ logger .info (
38+ "Registering certificate on Solana blockchain with data: %s" ,
39+ certificate_data ,
40+ )
2841 """
2942 Registers a certificate on the Solana blockchain.
3043
@@ -37,17 +50,17 @@ def register_certificate_on_solana(certificate_data: dict) -> dict:
3750 try :
3851 with httpx .Client (timeout = 60.0 ) as client :
3952 response = client .post (
40- url = config .SERVICE_URL_REGISTRATION_API_SOLANA ,
53+ url = config .SERVICE_URL_REGISTRATION_API_SOLANA ,
4154 headers = {
4255 "x-api-key" : config .SERVICE_API_KEY_REGISTRATION_API_SOLANA ,
43- "Content-Type" : "application/json"
56+ "Content-Type" : "application/json" ,
4457 },
45- json = certificate_data
58+ json = certificate_data ,
4659 )
47- logger .info (f"Solana response status code: { response .status_code } " )
60+ logger .info (f"Solana response status code: { response .status_code } " )
4861 response .raise_for_status ()
4962 solana_response = response .json ()
50- return solana_response
63+ return solana_response
5164 except Exception as e :
5265 logger .error (f"Error registering certificate on Solana: { str (e )} " )
53- raise CertificatesOnSolanaException (details = str (e ), cause = e )
66+ raise CertificatesOnSolanaException (details = str (e ), cause = e )
0 commit comments