Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alexviquez committed Feb 5, 2024
1 parent 458a69b commit 61f0dd2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 28 deletions.
44 changes: 17 additions & 27 deletions mati/types/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ def __str__(self) -> str:
return self.value


@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 PageType(SerializableEnum):
front = 'front'
back = 'back'
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 Down Expand Up @@ -189,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.dev0'
__version__ = '2.0.6.dev1'

0 comments on commit 61f0dd2

Please sign in to comment.