Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
32 changes: 19 additions & 13 deletions nuon/api/accounts/complete_user_journey.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from typing import Any

import httpx

Expand All @@ -22,41 +22,47 @@ def _get_kwargs(


def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[AppAccount, StderrErrResponse]]:
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> AppAccount | StderrErrResponse | None:
if response.status_code == 200:
response_200 = AppAccount.from_dict(response.json())

return response_200

if response.status_code == 400:
response_400 = StderrErrResponse.from_dict(response.json())

return response_400

if response.status_code == 401:
response_401 = StderrErrResponse.from_dict(response.json())

return response_401

if response.status_code == 403:
response_403 = StderrErrResponse.from_dict(response.json())

return response_403

if response.status_code == 404:
response_404 = StderrErrResponse.from_dict(response.json())

return response_404

if response.status_code == 500:
response_500 = StderrErrResponse.from_dict(response.json())

return response_500

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None


def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[AppAccount, StderrErrResponse]]:
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> Response[AppAccount | StderrErrResponse]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
Expand All @@ -69,7 +75,7 @@ def sync_detailed(
journey_name: str,
*,
client: AuthenticatedClient,
) -> Response[Union[AppAccount, StderrErrResponse]]:
) -> Response[AppAccount | StderrErrResponse]:
"""Complete all steps in a specific user journey

Mark all remaining steps in the specified user journey as complete
Expand All @@ -82,7 +88,7 @@ def sync_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[AppAccount, StderrErrResponse]]
Response[AppAccount | StderrErrResponse]
"""

kwargs = _get_kwargs(
Expand All @@ -100,7 +106,7 @@ def sync(
journey_name: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[AppAccount, StderrErrResponse]]:
) -> AppAccount | StderrErrResponse | None:
"""Complete all steps in a specific user journey

Mark all remaining steps in the specified user journey as complete
Expand All @@ -113,7 +119,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Union[AppAccount, StderrErrResponse]
AppAccount | StderrErrResponse
"""

return sync_detailed(
Expand All @@ -126,7 +132,7 @@ async def asyncio_detailed(
journey_name: str,
*,
client: AuthenticatedClient,
) -> Response[Union[AppAccount, StderrErrResponse]]:
) -> Response[AppAccount | StderrErrResponse]:
"""Complete all steps in a specific user journey

Mark all remaining steps in the specified user journey as complete
Expand All @@ -139,7 +145,7 @@ async def asyncio_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[AppAccount, StderrErrResponse]]
Response[AppAccount | StderrErrResponse]
"""

kwargs = _get_kwargs(
Expand All @@ -155,7 +161,7 @@ async def asyncio(
journey_name: str,
*,
client: AuthenticatedClient,
) -> Optional[Union[AppAccount, StderrErrResponse]]:
) -> AppAccount | StderrErrResponse | None:
"""Complete all steps in a specific user journey

Mark all remaining steps in the specified user journey as complete
Expand All @@ -168,7 +174,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Union[AppAccount, StderrErrResponse]
AppAccount | StderrErrResponse
"""

return (
Expand Down
32 changes: 19 additions & 13 deletions nuon/api/accounts/create_user_journey.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from typing import Any

import httpx

Expand Down Expand Up @@ -31,41 +31,47 @@ def _get_kwargs(


def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[AppAccount, StderrErrResponse]]:
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> AppAccount | StderrErrResponse | None:
if response.status_code == 201:
response_201 = AppAccount.from_dict(response.json())

return response_201

if response.status_code == 400:
response_400 = StderrErrResponse.from_dict(response.json())

return response_400

if response.status_code == 401:
response_401 = StderrErrResponse.from_dict(response.json())

return response_401

if response.status_code == 403:
response_403 = StderrErrResponse.from_dict(response.json())

return response_403

if response.status_code == 404:
response_404 = StderrErrResponse.from_dict(response.json())

return response_404

if response.status_code == 500:
response_500 = StderrErrResponse.from_dict(response.json())

return response_500

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None


def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[AppAccount, StderrErrResponse]]:
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> Response[AppAccount | StderrErrResponse]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
Expand All @@ -78,7 +84,7 @@ def sync_detailed(
*,
client: AuthenticatedClient,
body: ServiceCreateUserJourneyRequest,
) -> Response[Union[AppAccount, StderrErrResponse]]:
) -> Response[AppAccount | StderrErrResponse]:
"""Create a new user journey for account

Add a new user journey with steps to track user progress
Expand All @@ -91,7 +97,7 @@ def sync_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[AppAccount, StderrErrResponse]]
Response[AppAccount | StderrErrResponse]
"""

kwargs = _get_kwargs(
Expand All @@ -109,7 +115,7 @@ def sync(
*,
client: AuthenticatedClient,
body: ServiceCreateUserJourneyRequest,
) -> Optional[Union[AppAccount, StderrErrResponse]]:
) -> AppAccount | StderrErrResponse | None:
"""Create a new user journey for account

Add a new user journey with steps to track user progress
Expand All @@ -122,7 +128,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Union[AppAccount, StderrErrResponse]
AppAccount | StderrErrResponse
"""

return sync_detailed(
Expand All @@ -135,7 +141,7 @@ async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: ServiceCreateUserJourneyRequest,
) -> Response[Union[AppAccount, StderrErrResponse]]:
) -> Response[AppAccount | StderrErrResponse]:
"""Create a new user journey for account

Add a new user journey with steps to track user progress
Expand All @@ -148,7 +154,7 @@ async def asyncio_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[AppAccount, StderrErrResponse]]
Response[AppAccount | StderrErrResponse]
"""

kwargs = _get_kwargs(
Expand All @@ -164,7 +170,7 @@ async def asyncio(
*,
client: AuthenticatedClient,
body: ServiceCreateUserJourneyRequest,
) -> Optional[Union[AppAccount, StderrErrResponse]]:
) -> AppAccount | StderrErrResponse | None:
"""Create a new user journey for account

Add a new user journey with steps to track user progress
Expand All @@ -177,7 +183,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Union[AppAccount, StderrErrResponse]
AppAccount | StderrErrResponse
"""

return (
Expand Down
30 changes: 17 additions & 13 deletions nuon/api/accounts/get_current_account.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from typing import Any

import httpx

Expand All @@ -20,33 +20,37 @@ def _get_kwargs() -> dict[str, Any]:


def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[AppAccount, StderrErrResponse]]:
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> AppAccount | StderrErrResponse | None:
if response.status_code == 200:
response_200 = AppAccount.from_dict(response.json())

return response_200

if response.status_code == 401:
response_401 = StderrErrResponse.from_dict(response.json())

return response_401

if response.status_code == 404:
response_404 = StderrErrResponse.from_dict(response.json())

return response_404

if response.status_code == 500:
response_500 = StderrErrResponse.from_dict(response.json())

return response_500

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None


def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[AppAccount, StderrErrResponse]]:
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> Response[AppAccount | StderrErrResponse]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
Expand All @@ -58,7 +62,7 @@ def _build_response(
def sync_detailed(
*,
client: AuthenticatedClient,
) -> Response[Union[AppAccount, StderrErrResponse]]:
) -> Response[AppAccount | StderrErrResponse]:
"""Get current account

Get the current account with user journeys and other data
Expand All @@ -68,7 +72,7 @@ def sync_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[AppAccount, StderrErrResponse]]
Response[AppAccount | StderrErrResponse]
"""

kwargs = _get_kwargs()
Expand All @@ -83,7 +87,7 @@ def sync_detailed(
def sync(
*,
client: AuthenticatedClient,
) -> Optional[Union[AppAccount, StderrErrResponse]]:
) -> AppAccount | StderrErrResponse | None:
"""Get current account

Get the current account with user journeys and other data
Expand All @@ -93,7 +97,7 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Union[AppAccount, StderrErrResponse]
AppAccount | StderrErrResponse
"""

return sync_detailed(
Expand All @@ -104,7 +108,7 @@ def sync(
async def asyncio_detailed(
*,
client: AuthenticatedClient,
) -> Response[Union[AppAccount, StderrErrResponse]]:
) -> Response[AppAccount | StderrErrResponse]:
"""Get current account

Get the current account with user journeys and other data
Expand All @@ -114,7 +118,7 @@ async def asyncio_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[AppAccount, StderrErrResponse]]
Response[AppAccount | StderrErrResponse]
"""

kwargs = _get_kwargs()
Expand All @@ -127,7 +131,7 @@ async def asyncio_detailed(
async def asyncio(
*,
client: AuthenticatedClient,
) -> Optional[Union[AppAccount, StderrErrResponse]]:
) -> AppAccount | StderrErrResponse | None:
"""Get current account

Get the current account with user journeys and other data
Expand All @@ -137,7 +141,7 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Union[AppAccount, StderrErrResponse]
AppAccount | StderrErrResponse
"""

return (
Expand Down
Loading
Loading