|
| 1 | +import datetime as dt |
| 2 | +from typing import ClassVar, Optional |
| 3 | + |
| 4 | +from cuenca_validations.types import VerificationStatus |
| 5 | +from cuenca_validations.types.requests import PasswordResetRequest |
| 6 | +from pydantic import ConfigDict |
| 7 | +from pydantic_extra_types.coordinate import Coordinate |
| 8 | + |
| 9 | +from ..http import Session, session as global_session |
| 10 | +from .base import Creatable, Queryable, Retrievable |
| 11 | + |
| 12 | + |
| 13 | +class PasswordReset(Creatable, Retrievable, Queryable): |
| 14 | + _resource: ClassVar = 'password_resets' |
| 15 | + |
| 16 | + platform_id: str |
| 17 | + verification_id: str |
| 18 | + flow_id: str |
| 19 | + status: VerificationStatus = VerificationStatus.created |
| 20 | + mati_verification_id: Optional[str] = None |
| 21 | + identity_id: Optional[str] = None |
| 22 | + provider_url: Optional[str] = None |
| 23 | + created_at: dt.datetime |
| 24 | + updated_at: Optional[dt.datetime] = None |
| 25 | + deactivated_at: Optional[dt.datetime] = None |
| 26 | + |
| 27 | + model_config = ConfigDict( |
| 28 | + json_schema_extra={ |
| 29 | + 'example': { |
| 30 | + 'id': 'PRNEUInh69SuKXXmK95sROwQ', |
| 31 | + 'platform_id': 'PT-1234567890', |
| 32 | + 'verification_id': 'VENEUInh69SuKXXmK95sROwQ', |
| 33 | + 'flow_id': '123e4567-e89b-12d3-a456-426614174000', |
| 34 | + 'status': 'created', |
| 35 | + 'mati_verification_id': 'metamap-verification-id', |
| 36 | + 'identity_id': 'metamap-identity-id', |
| 37 | + 'created_at': '2026-05-06T14:15:22Z', |
| 38 | + } |
| 39 | + } |
| 40 | + ) |
| 41 | + |
| 42 | + @classmethod |
| 43 | + def create( |
| 44 | + cls, |
| 45 | + verification_id: str, |
| 46 | + location: Coordinate, |
| 47 | + *, |
| 48 | + session: Session = global_session, |
| 49 | + ) -> 'PasswordReset': |
| 50 | + req = PasswordResetRequest( |
| 51 | + verification_id=verification_id, |
| 52 | + location=location, |
| 53 | + ) |
| 54 | + return cls._create(session=session, **req.model_dump()) |
0 commit comments