Skip to content

Commit

Permalink
feat: add flow_id parameter when creating users
Browse files Browse the repository at this point in the history
  • Loading branch information
fgsalomon committed Aug 21, 2023
1 parent 708c6d9 commit 1e31665
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion alice/onboarding/onboarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def create_user(
self,
user_info: Union[UserInfo, None] = None,
device_info: Union[DeviceInfo, None] = None,
flow_id: Union[str, None] = None,
verbose: Optional[bool] = False,
) -> Result[str, Union[OnboardingError, AuthError]]:
"""
Expand All @@ -109,6 +110,8 @@ def create_user(
Object with optional values with info about the User.
device_info
Object with optional values with info about the User's Device.
flow_id
Optional identifier of the onboarding flow
verbose
Used for print service response as well as the time elapsed
Expand All @@ -120,7 +123,10 @@ def create_user(
"""
verbose = self.verbose or verbose
response = self.onboarding_client.create_user(
user_info=user_info, device_info=device_info, verbose=verbose
user_info=user_info,
device_info=device_info,
flow_id=flow_id,
verbose=verbose,
).unwrap_or_return()

if response.status_code == 200:
Expand Down
6 changes: 6 additions & 0 deletions alice/onboarding/onboarding_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def create_user(
self,
user_info: Union[UserInfo, None] = None,
device_info: Union[DeviceInfo, None] = None,
flow_id: Union[str, None] = None,
verbose: Optional[bool] = False,
) -> Result[Response, Error]:
"""
Expand All @@ -99,6 +100,8 @@ def create_user(
Object with optional values with info about the User.
device_info
Object with optional values with info about the User's Device.
flow_id
Optional identifier of the onboarding flow
verbose
Used for print service response as well as the time elapsed
Expand All @@ -122,6 +125,9 @@ def create_user(
if device_info:
data = data if data is not None else {}
data.update(device_info.dict())
if flow_id:
data = data if data is not None else {}
data.update({"flow_id": flow_id})
try:
response = self.session.post(
f"{self.url}/user", headers=headers, data=data, timeout=self.timeout
Expand Down

0 comments on commit 1e31665

Please sign in to comment.