Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alexviquez committed Feb 6, 2024
1 parent 78a53e0 commit 9183549
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 39 deletions.
55 changes: 17 additions & 38 deletions mati/types/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ class PageType(SerializableEnum):
back = 'back'


@dataclass
class BaseModel:
@classmethod
def _filter_excess_fields(cls, obj_dict: Dict) -> None:
excess = set(obj_dict.keys()) - {f.name for f in fields(cls)}
for f in excess:
del obj_dict[f]

@classmethod
def _from_dict(cls, obj_dict: Dict[str, Any]) -> 'BaseModel':
cls._filter_excess_fields(obj_dict)
return cls(**obj_dict)


class ValidationInputType(SerializableEnum):
document_photo = 'document-photo'
selfie_photo = 'selfie-photo'
Expand All @@ -28,25 +42,12 @@ class ValidationType(SerializableEnum):


@dataclass
class VerificationDocumentStep:
class VerificationDocumentStep(BaseModel):
id: str
status: int
error: Optional[Dict] = None
data: Optional[Dict] = field(default_factory=dict)

@classmethod
def _filter_excess_fields(cls, obj_dict: Dict) -> None:
excess = set(obj_dict.keys()) - {f.name for f in fields(cls)}
for f in excess:
del obj_dict[f]

@classmethod
def _from_dict(
cls, obj_dict: Dict[str, Any]
) -> 'VerificationDocumentStep':
cls._filter_excess_fields(obj_dict)
return cls(**obj_dict)


@dataclass
class Errors:
Expand All @@ -57,7 +58,7 @@ class Errors:


@dataclass
class VerificationDocument:
class VerificationDocument(BaseModel):
country: str
region: str
photos: List[str]
Expand All @@ -66,17 +67,6 @@ class VerificationDocument:
subtype: Optional[str] = None
fields: Optional[dict] = None

@classmethod
def _filter_excess_fields(cls, obj_dict: Dict) -> None:
excess = set(obj_dict.keys()) - {f.name for f in fields(cls)}
for f in excess:
del obj_dict[f]

@classmethod
def _from_dict(cls, obj_dict: Dict[str, Any]) -> 'VerificationDocument':
cls._filter_excess_fields(obj_dict)
return cls(**obj_dict)

@property
def errors(self) -> List[Errors]:
if not self.steps:
Expand Down Expand Up @@ -200,23 +190,12 @@ class LivenessMedia:


@dataclass
class Liveness:
class Liveness(BaseModel):
status: int
id: str
data: Optional[LivenessMedia] = None
error: Optional[Dict] = None

@classmethod
def _filter_excess_fields(cls, obj_dict: Dict) -> None:
excess = set(obj_dict.keys()) - {f.name for f in fields(cls)}
for f in excess:
del obj_dict[f]

@classmethod
def _from_dict(cls, obj_dict: Dict[str, Any]) -> 'Liveness':
cls._filter_excess_fields(obj_dict)
return cls(**obj_dict)


@dataclass
class DocumentScore:
Expand Down
2 changes: 1 addition & 1 deletion mati/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.0.6.dev4'
__version__ = '2.0.6.dev5'

0 comments on commit 9183549

Please sign in to comment.