feat: add docs and custom exc
This commit is contained in:
@@ -3,7 +3,7 @@ from typing import Any
|
||||
import aiohttp
|
||||
from src.application.contracts import IBeorgService
|
||||
from src.application.domain.dto import BeorgKycCreateResponse,BeorgKycResultResponse
|
||||
from src.application.domain.exceptions import ApplicationException
|
||||
from src.application.domain.exceptions import BeorgConfigException,BeorgRejectedException,BeorgUnavailableException
|
||||
|
||||
|
||||
class BeorgService(IBeorgService):
|
||||
@@ -49,11 +49,11 @@ class BeorgService(IBeorgService):
|
||||
data = await response.json(content_type=None)
|
||||
|
||||
if response.status >= 500:
|
||||
raise ApplicationException(status_code=502,message='Beorg service unavailable')
|
||||
raise BeorgUnavailableException()
|
||||
|
||||
result = BeorgKycCreateResponse.model_validate(data)
|
||||
if not result.status:
|
||||
raise ApplicationException(status_code=400,message=result.error or 'Beorg rejected kyc request')
|
||||
raise BeorgRejectedException(result.error or 'Beorg rejected kyc request')
|
||||
|
||||
return result
|
||||
|
||||
@@ -73,11 +73,11 @@ class BeorgService(IBeorgService):
|
||||
data = await response.json(content_type=None)
|
||||
|
||||
if response.status >= 500:
|
||||
raise ApplicationException(status_code=502,message='Beorg service unavailable')
|
||||
raise BeorgUnavailableException()
|
||||
|
||||
return BeorgKycResultResponse.model_validate(data)
|
||||
|
||||
|
||||
def _ensure_configured(self) -> None:
|
||||
if not self._project_id or not self._machine_uid or not self._token or not self._process_info:
|
||||
raise ApplicationException(status_code=500,message='Beorg service is not configured')
|
||||
raise BeorgConfigException()
|
||||
|
||||
Reference in New Issue
Block a user