-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move requestHandler to own file
- Loading branch information
Showing
3 changed files
with
32 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
backend/benefit/applications/services/ahjo/request_handler.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from typing import List, Union | ||
|
||
from applications.enums import AhjoRequestType | ||
from applications.services.ahjo.enums import AhjoSettingName | ||
from applications.services.ahjo.setting_response_handler import AhjoResponseHandler | ||
from applications.services.ahjo_authentication import AhjoToken | ||
from applications.services.ahjo_client import ( | ||
AhjoApiClient, | ||
AhjoDecisionMakerRequest, | ||
AhjoRequest, | ||
) | ||
|
||
|
||
class AhjoRequestHandler: | ||
def __init__(self, ahjo_token: AhjoToken, ahjo_request_type: AhjoRequest): | ||
self.ahjo_token = ahjo_token | ||
self.ahjo_request_type = ahjo_request_type | ||
|
||
def handle_request_without_application(self): | ||
if self.ahjo_request_type == AhjoRequestType.GET_DECISION_MAKER: | ||
self.get_decision_maker_from_ahjo() | ||
|
||
def get_decision_maker_from_ahjo(self) -> Union[List, None]: | ||
ahjo_client = AhjoApiClient(self.ahjo_token, AhjoDecisionMakerRequest()) | ||
_, result = ahjo_client.send_request_to_ahjo() | ||
AhjoResponseHandler.handle_ahjo_query_response( | ||
setting_name=AhjoSettingName.DECISION_MAKER, data=result | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters