Closed bitcanon closed 2 years ago
Here are the responses returned by the API when user_code
, app_id
, panel_id
, email
and/or password
is erroneous. These should raise exceptions upon identification.
If email
is missing:
{'error': 10001, 'error_message': 'Bad Request Params', 'error_reason_code': 'BadRequestParams', 'extras': [{'key': 'email', 'value': 'required'}]}
If password
is missing:
{'error': 10001, 'error_message': 'Bad Request Params', 'error_reason_code': 'BadRequestParams', 'extras': [{'key': 'password', 'value': 'required'}]}
If email
and password
is missing:
{'error': 10001, 'error_message': 'Bad Request Params', 'error_reason_code': 'BadRequestParams', 'extras': [{'key': 'email', 'value': 'required'}, {'key': 'password', 'value': 'required'}]}
If email
or password
is incorrect:
{'error': 10004, 'error_message': 'Wrong combination', 'error_reason_code': 'WrongCombination', 'extras': [{'key': 'email', 'value': 'wrong_combination'}, {'key': 'password', 'value': 'wrong_combination'}]}
If panel_id
is missing:
{'error': 10001, 'error_message': 'Bad Request Params', 'error_reason_code': 'BadRequestParams', 'extras': [{'key': 'panel_serial', 'value': 'required'}]}
If panel_id
is incorrect:
{'error': 10001, 'error_message': 'Bad Request Params', 'error_reason_code': 'BadRequestParams', 'extras': [{'key': 'panel_serial', 'value': 'incorrect'}]}
If app_id
is missing:
{'error': 10001, 'error_message': 'Bad Request Params', 'error_reason_code': 'BadRequestParams', 'extras': [{'key': 'app_id', 'value': 'required'}]}
If user_code
is missing:
{'error': 10001, 'error_message': 'Bad Request Params', 'error_reason_code': 'BadRequestParams', 'extras': [{'key': 'user_code', 'value': 'required'}]}
If user_code
is incorrect:
{'error': 10021, 'error_message': 'Wrong user code', 'error_reason_code': 'WrongUserCode', 'extras': [{'key': 'attempts_left', 'value': 2}]}
Exception handling has to be rebuilt as well. If calling login() with faulty credentials, panel_ids and so on, we get a BadRequestError that can be parsed into multiple sub exception:
For example (calling
login()
using an email that doesn't exist):visonic.exceptions.BadRequestError: b'{"error":10004,"error_message":"Wrong combination","error_reason_code":"WrongCombination","extras":[{"key":"email","value":"wrong_combination"},{"key":"password","value":"wrong_combination"}]}'
Or a
panel_id
that doesn't exist:b'{"error":10001,"error_message":"Bad Request Params","error_reason_code":"BadRequestParams","extras":[{"key":"panel_serial","value":"incorrect"}]}'