diff --git a/certified_builder/build_url_tech_floripa.py b/certified_builder/build_url_tech_floripa.py new file mode 100644 index 0000000..6ad600d --- /dev/null +++ b/certified_builder/build_url_tech_floripa.py @@ -0,0 +1,9 @@ +from config import config + +def build_url_tech_floripa(url_service_solona: str, validation_code: str, order_id: str) -> str: + try: + txid_solana = url_service_solona.split('/')[-1] + full_url = f"{config.TECH_FLORIPA_CERTIFICATE_VALIDATE_URL}?validate_code={validation_code}&hash={txid_solana}&order_id={order_id}" + return full_url + except Exception as e: + raise ValueError(f"Error building Tech Floripa URL: {str(e)}") \ No newline at end of file diff --git a/certified_builder/certified_builder.py b/certified_builder/certified_builder.py index 5aaa202..4cd0617 100644 --- a/certified_builder/certified_builder.py +++ b/certified_builder/certified_builder.py @@ -8,6 +8,7 @@ from certified_builder.utils.fetch_file_certificate import fetch_file_certificate from certified_builder.certificates_on_solana import CertificatesOnSolana from certified_builder.make_qrcode import MakeQRCode +from certified_builder.build_url_tech_floripa import build_url_tech_floripa FONT_NAME = os.path.join(os.path.dirname(__file__), "fonts/PinyonScript/PinyonScript-Regular.ttf") VALIDATION_CODE = os.path.join(os.path.dirname(__file__), "fonts/ChakraPetch/ChakraPetch-SemiBold.ttf") @@ -61,7 +62,13 @@ def build_certificates(self, participants: List[Participant]): # "verificacao_url": "https://www.google.com" # } # } - participant.authenticity_verification_url = solana_response.get("blockchain", {}).get("verificacao_url", "") + participant.validation_code = participant.formated_validation_code() + + participant.authenticity_verification_url = build_url_tech_floripa( + solana_response.get("blockchain", {}).get("verificacao_url", ""), + participant.validation_code, + participant.event.order_id + ) if not participant.authenticity_verification_url: raise RuntimeError("Failed to get authenticity verification URL from Solana response") diff --git a/config.py b/config.py index 5279d3f..39bfb47 100644 --- a/config.py +++ b/config.py @@ -9,7 +9,8 @@ class Config(BaseSettings): QUEUE_URL: str SERVICE_URL_REGISTRATION_API_SOLANA: str SERVICE_API_KEY_REGISTRATION_API_SOLANA: str - + TECH_FLORIPA_CERTIFICATE_VALIDATE_URL: str + class Config: env_file = ".env" env_file_encoding = "utf-8" diff --git a/lambda_function.py b/lambda_function.py index 9fc175d..cc4099a 100644 --- a/lambda_function.py +++ b/lambda_function.py @@ -132,6 +132,8 @@ def lambda_handler(event, context): certificates_results_messagens.append({ "order_id": result.get('participant', {}).get('event', {}).get('order_id', ""), + "validation_code": result.get('participant', {}).get('validation_code', ""), + "authenticity_verification_url": result.get('participant', {}).get('authenticity_verification_url', ""), "product_id": result.get('participant', {}).get('event', {}).get('product_id', ""), "product_name": result.get('participant', {}).get('event', {}).get('product_name', ""), "email": result.get('participant', {}).get('email', ""), @@ -169,3 +171,4 @@ def lambda_handler(event, context): 'message': 'Erro ao gerar certificados' }) } + diff --git a/tests/conftest.py b/tests/conftest.py index d7a4a7e..c1cd86c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -20,6 +20,7 @@ class MockConfig: QUEUE_URL = "https://sqs.us-east-1.amazonaws.com/000000000000/test" SERVICE_URL_REGISTRATION_API_SOLANA = "https://example.test/solana/register" SERVICE_API_KEY_REGISTRATION_API_SOLANA = "test-api-key" + TECH_FLORIPA_CERTIFICATE_VALIDATE_URL = "https://example.test/validate/certificate" # comentário: expõe tanto a classe quanto a instância, como o módulo real faria mock_module.Config = MockConfig