Skip to content

Commit beaada0

Browse files
Merge pull request #6 from PythonFloripa/dev
Dev
2 parents 1691852 + e44a73c commit beaada0

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from config import config
2+
3+
def build_url_tech_floripa(url_service_solona: str, validation_code: str, order_id: str) -> str:
4+
try:
5+
txid_solana = url_service_solona.split('/')[-1]
6+
full_url = f"{config.TECH_FLORIPA_CERTIFICATE_VALIDATE_URL}?validate_code={validation_code}&hash={txid_solana}&order_id={order_id}"
7+
return full_url
8+
except Exception as e:
9+
raise ValueError(f"Error building Tech Floripa URL: {str(e)}")

certified_builder/certified_builder.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from certified_builder.utils.fetch_file_certificate import fetch_file_certificate
99
from certified_builder.certificates_on_solana import CertificatesOnSolana
1010
from certified_builder.make_qrcode import MakeQRCode
11+
from certified_builder.build_url_tech_floripa import build_url_tech_floripa
1112

1213
FONT_NAME = os.path.join(os.path.dirname(__file__), "fonts/PinyonScript/PinyonScript-Regular.ttf")
1314
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]):
6162
# "verificacao_url": "https://www.google.com"
6263
# }
6364
# }
64-
participant.authenticity_verification_url = solana_response.get("blockchain", {}).get("verificacao_url", "")
65+
participant.validation_code = participant.formated_validation_code()
66+
67+
participant.authenticity_verification_url = build_url_tech_floripa(
68+
solana_response.get("blockchain", {}).get("verificacao_url", ""),
69+
participant.validation_code,
70+
participant.event.order_id
71+
)
6572

6673
if not participant.authenticity_verification_url:
6774
raise RuntimeError("Failed to get authenticity verification URL from Solana response")

config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ class Config(BaseSettings):
99
QUEUE_URL: str
1010
SERVICE_URL_REGISTRATION_API_SOLANA: str
1111
SERVICE_API_KEY_REGISTRATION_API_SOLANA: str
12-
12+
TECH_FLORIPA_CERTIFICATE_VALIDATE_URL: str
13+
1314
class Config:
1415
env_file = ".env"
1516
env_file_encoding = "utf-8"

lambda_function.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ def lambda_handler(event, context):
132132

133133
certificates_results_messagens.append({
134134
"order_id": result.get('participant', {}).get('event', {}).get('order_id', ""),
135+
"validation_code": result.get('participant', {}).get('validation_code', ""),
136+
"authenticity_verification_url": result.get('participant', {}).get('authenticity_verification_url', ""),
135137
"product_id": result.get('participant', {}).get('event', {}).get('product_id', ""),
136138
"product_name": result.get('participant', {}).get('event', {}).get('product_name', ""),
137139
"email": result.get('participant', {}).get('email', ""),
@@ -169,3 +171,4 @@ def lambda_handler(event, context):
169171
'message': 'Erro ao gerar certificados'
170172
})
171173
}
174+

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class MockConfig:
2020
QUEUE_URL = "https://sqs.us-east-1.amazonaws.com/000000000000/test"
2121
SERVICE_URL_REGISTRATION_API_SOLANA = "https://example.test/solana/register"
2222
SERVICE_API_KEY_REGISTRATION_API_SOLANA = "test-api-key"
23+
TECH_FLORIPA_CERTIFICATE_VALIDATE_URL = "https://example.test/validate/certificate"
2324

2425
# comentário: expõe tanto a classe quanto a instância, como o módulo real faria
2526
mock_module.Config = MockConfig

0 commit comments

Comments
 (0)