mirror of
https://github.com/hoshikawa2/first_contas.git
synced 2026-07-09 18:24:20 +00:00
first commit
This commit is contained in:
53
legacy_reference/workflows/actions/inputs.py
Normal file
53
legacy_reference/workflows/actions/inputs.py
Normal file
@@ -0,0 +1,53 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from pydantic import AliasChoices, BaseModel, ConfigDict, Field, ValidationError
|
||||
|
||||
|
||||
class CancelarVasAvulsoItem(BaseModel):
|
||||
"""Item de entrada do action `cancelamento_vas_avulso_batch`."""
|
||||
|
||||
model_config = ConfigDict(
|
||||
str_strip_whitespace=True,
|
||||
populate_by_name=True,
|
||||
)
|
||||
|
||||
msisdn: str = Field(
|
||||
...,
|
||||
min_length=1,
|
||||
description=(
|
||||
"Numero completo da linha do cliente que possui o "
|
||||
"servico VAS avulso a cancelar."
|
||||
),
|
||||
validation_alias=AliasChoices("msisdn", "Msisdn", "MSISDN"),
|
||||
)
|
||||
|
||||
service: str = Field(
|
||||
...,
|
||||
min_length=1,
|
||||
description=(
|
||||
"Nome do servico VAS avulso a cancelar. "
|
||||
"Ex: 'TIM Fashion Mensal', 'Galinha Pintadinha'."
|
||||
"O nome deve ser fiel ao JSON da fatura SEM regra de vocalização ou modificação"
|
||||
"'Aluguel de filmes 1', 'Aluguel de Filme 3'"
|
||||
),
|
||||
validation_alias=AliasChoices("service", "servico", "name"),
|
||||
)
|
||||
|
||||
value: float = Field(
|
||||
...,
|
||||
description= "Valor do serviço"
|
||||
)
|
||||
|
||||
def parse_cancel_vas_items(raw: Any) -> list[CancelarVasAvulsoItem]:
|
||||
"""Valida cada item via Pydantic, descartando entradas invalidas."""
|
||||
if not isinstance(raw, list):
|
||||
return []
|
||||
parsed: list[CancelarVasAvulsoItem] = []
|
||||
for item in raw:
|
||||
try:
|
||||
parsed.append(CancelarVasAvulsoItem.model_validate(item))
|
||||
except ValidationError:
|
||||
continue
|
||||
return parsed
|
||||
Reference in New Issue
Block a user