Skip to content

Commit

Permalink
fix(atoss): avoid timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
DlieBG committed May 3, 2024
1 parent 0b646ac commit f0b1054
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
12 changes: 6 additions & 6 deletions api/src/atoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'Gleitzeit',
]

def __init_session() -> Session:
def init_session() -> Session:
init_response = requests.get(
url=__init_url,
)
Expand All @@ -40,6 +40,7 @@ def __init_session() -> Session:
for option in init_response.text.splitlines()
if option.startswith('[\'zul.sel.Option\'') and 'value' in option
},
cookies=init_response.cookies.get_dict(),
)

def __call(session: Session, *arguments: CallItem) -> ResponseDto:
Expand All @@ -59,6 +60,7 @@ def __call(session: Session, *arguments: CallItem) -> ResponseDto:
),
),
},
cookies=session.cookies,
)

if 'Kombination Personalnummer / PIN-Code falsch' in call_response.text:
Expand Down Expand Up @@ -101,9 +103,9 @@ def __call(session: Session, *arguments: CallItem) -> ResponseDto:
flexi_balance=response['Gleitzeit'],
)

def get_balance(personal_number: str, pin: str) -> ResponseDto:
def get_balance(personal_number: str, pin: str, session: Session = init_session()) -> ResponseDto:
return __call(
__init_session(),
session,
CallItem(
command=CommandEnum.on_change,
uuid='badgeno',
Expand All @@ -124,9 +126,7 @@ def get_balance(personal_number: str, pin: str) -> ResponseDto:
),
)

def post_booking(personal_number: str, pin: str, action: ActionEnum, type: TypeEnum) -> dict:
session = __init_session()

def post_booking(personal_number: str, pin: str, action: ActionEnum, type: TypeEnum, session: Session = init_session()) -> dict:
return __call(
session,
CallItem(
Expand Down
1 change: 1 addition & 0 deletions api/src/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Session(BaseModel):
jsession: str
dt: str
selection_uuids: dict
cookies: dict

class CommandEnum(str, Enum):
on_change = 'onChange'
Expand Down

0 comments on commit f0b1054

Please sign in to comment.