Skip to content

Commit

Permalink
Merge pull request #54 from alice-biometrics/feature/accept-reject-su…
Browse files Browse the repository at this point in the history
…bject

feat: add operator to accept/reject_user
  • Loading branch information
miguel-lorenzo authored Jan 25, 2023
2 parents f9a7895 + 4329229 commit b4f4228
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
16 changes: 13 additions & 3 deletions alice/onboarding/onboarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -1648,14 +1648,16 @@ def get_duplicates_searches(
)

def accept_user(
self, user_id: str, verbose: bool = False
self, user_id: str, operator: str = "auto", verbose: bool = False
) -> Result[bool, OnboardingError]:
"""
Mark a user state as ACCEPTED
Parameters
----------
user_id
User identifier
operator
Who is accepting the user
verbose
Used for print service response as well as the time elapsed
Returns
Expand All @@ -1664,7 +1666,9 @@ def accept_user(
Otherwise, it returns an OnboardingError.
"""
verbose = self.verbose or verbose
response = self.onboarding_client.accept_user(user_id=user_id, verbose=verbose)
response = self.onboarding_client.accept_user(
user_id=user_id, operator=operator, verbose=verbose
)

if response.status_code == 200:
return isSuccess
Expand All @@ -1679,6 +1683,7 @@ def reject_user(
self,
user_id: str,
rejection_reasons: Optional[List[Dict[str, str]]] = None,
operator: str = "auto",
verbose: bool = False,
) -> Result[bool, OnboardingError]:
"""
Expand All @@ -1689,6 +1694,8 @@ def reject_user(
User identifier
rejection_reasons
List of rejection reasons
operator
Who is rejecting the user
verbose
Used for print service response as well as the time elapsed
Returns
Expand All @@ -1698,7 +1705,10 @@ def reject_user(
"""
verbose = self.verbose or verbose
response = self.onboarding_client.reject_user(
user_id=user_id, rejection_reasons=rejection_reasons, verbose=verbose
user_id=user_id,
rejection_reasons=rejection_reasons,
operator=operator,
verbose=verbose,
)

if response.status_code == 200:
Expand Down
19 changes: 16 additions & 3 deletions alice/onboarding/onboarding_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1689,14 +1689,18 @@ def get_duplicates_searches(
return Success(response)

@timeit
def accept_user(self, user_id: str, verbose: bool = False) -> Response:
def accept_user(
self, user_id: str, operator: str = "auto", verbose: bool = False
) -> Response:
"""
Mark a user state as ACCEPTED
Parameters
----------
user_id
User identifier
operator
Who is accepting the user
verbose
Used for print service response as well as the time elapsed
Expand All @@ -1713,7 +1717,13 @@ def accept_user(self, user_id: str, verbose: bool = False) -> Response:
print_token("backend_token_with_user", backend_user_token, verbose=verbose)

headers = self._auth_headers(backend_user_token)
response = requests.post(f"{self.url}/user/state/accept", headers=headers)
response = requests.post(
f"{self.url}/user/state/accept",
headers=headers,
json={
"operator": operator,
},
)

print_response(response=response, verbose=verbose)

Expand All @@ -1724,6 +1734,7 @@ def reject_user(
self,
user_id: str,
rejection_reasons: Optional[List[Dict[str, str]]] = None,
operator: str = "auto",
verbose: bool = False,
) -> Response:
"""
Expand All @@ -1735,6 +1746,8 @@ def reject_user(
User identifier
rejection_reasons
List of rejection reasons
operator
Who is rejecting the user
verbose
Used for print service response as well as the time elapsed
Expand All @@ -1754,7 +1767,7 @@ def reject_user(
response = requests.post(
f"{self.url}/user/state/reject",
headers=headers,
json={"rejection_reasons": rejection_reasons},
json={"operator": operator, "rejection_reasons": rejection_reasons},
)

print_response(response=response, verbose=verbose)
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ filterwarnings =
error
ignore::DeprecationWarning
ignore::pytest.PytestUnraisableExceptionWarning
ignore::ResourceWarning

python_files=test_*.py
python_classes=Test*
Expand Down

0 comments on commit b4f4228

Please sign in to comment.