Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions certified_builder/build_url_tech_floripa.py
Original file line number Diff line number Diff line change
@@ -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)}")
9 changes: 8 additions & 1 deletion certified_builder/certified_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', ""),
Expand Down Expand Up @@ -169,3 +171,4 @@ def lambda_handler(event, context):
'message': 'Erro ao gerar certificados'
})
}

1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down