diff --git a/spec/openapi.yaml b/spec/openapi.yaml index 0d6e88b..fc64f24 100644 --- a/spec/openapi.yaml +++ b/spec/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: YAZIO API - version: 0.0.0-dev + version: 0.1.0 description: |- An unofficial description of the private API behind the YAZIO food-diary app, covering version 22 of the API at https://yzapi.yazio.com. diff --git a/src/yazio_sdk/__init__.py b/src/yazio_sdk/__init__.py new file mode 100644 index 0000000..074b2f0 --- /dev/null +++ b/src/yazio_sdk/__init__.py @@ -0,0 +1,11 @@ +"""A client library for accessing YAZIO API""" + +from .client import AuthenticatedClient, Client + +__all__ = ( + "AuthenticatedClient", + "Client", +) + +from ._version import SPEC_VERSION as __spec_version__ # noqa: E402 +from ._version import __version__ # noqa: E402 diff --git a/src/yazio_sdk/_version.py b/src/yazio_sdk/_version.py new file mode 100644 index 0000000..d362d04 --- /dev/null +++ b/src/yazio_sdk/_version.py @@ -0,0 +1,7 @@ +"""Written by scripts/generate.sh from the spec's info.version. Do not edit.""" + +__version__ = "0.1.0" + +# The SDK is versioned as the spec it was generated from, so these are one +# string. See the spec repo's CONTRIBUTING for why. +SPEC_VERSION = __version__ diff --git a/src/yazio_sdk/api/__init__.py b/src/yazio_sdk/api/__init__.py new file mode 100644 index 0000000..81f9fa2 --- /dev/null +++ b/src/yazio_sdk/api/__init__.py @@ -0,0 +1 @@ +"""Contains methods for accessing the API""" diff --git a/src/yazio_sdk/api/activity/__init__.py b/src/yazio_sdk/api/activity/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/yazio_sdk/api/activity/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/yazio_sdk/api/activity/get_daily_exercise_summary.py b/src/yazio_sdk/api/activity/get_daily_exercise_summary.py new file mode 100644 index 0000000..93dd8ca --- /dev/null +++ b/src/yazio_sdk/api/activity/get_daily_exercise_summary.py @@ -0,0 +1,180 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.daily_exercise_summary import DailyExerciseSummary +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + start: str | Unset = UNSET, + end: str | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["start"] = start + + params["end"] = end + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/exercises/summary-daily", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> list[DailyExerciseSummary] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = DailyExerciseSummary.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[DailyExerciseSummary]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + start: str | Unset = UNSET, + end: str | Unset = UNSET, +) -> Response[list[DailyExerciseSummary]]: + """Daily totals of logged exercise + + Args: + start (str | Unset): + end (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[DailyExerciseSummary]] + """ + + kwargs = _get_kwargs( + start=start, + end=end, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + start: str | Unset = UNSET, + end: str | Unset = UNSET, +) -> list[DailyExerciseSummary] | None: + """Daily totals of logged exercise + + Args: + start (str | Unset): + end (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[DailyExerciseSummary] + """ + + return sync_detailed( + client=client, + start=start, + end=end, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + start: str | Unset = UNSET, + end: str | Unset = UNSET, +) -> Response[list[DailyExerciseSummary]]: + """Daily totals of logged exercise + + Args: + start (str | Unset): + end (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[DailyExerciseSummary]] + """ + + kwargs = _get_kwargs( + start=start, + end=end, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + start: str | Unset = UNSET, + end: str | Unset = UNSET, +) -> list[DailyExerciseSummary] | None: + """Daily totals of logged exercise + + Args: + start (str | Unset): + end (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[DailyExerciseSummary] + """ + + return ( + await asyncio_detailed( + client=client, + start=start, + end=end, + ) + ).parsed diff --git a/src/yazio_sdk/api/activity/list_exercises.py b/src/yazio_sdk/api/activity/list_exercises.py new file mode 100644 index 0000000..5687d88 --- /dev/null +++ b/src/yazio_sdk/api/activity/list_exercises.py @@ -0,0 +1,160 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.exercise_log import ExerciseLog +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + date: str | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["date"] = date + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/exercises", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> ExerciseLog | None: + if response.status_code == 200: + response_200 = ExerciseLog.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[ExerciseLog]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> Response[ExerciseLog]: + """List logged exercises for a day + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ExerciseLog] + """ + + kwargs = _get_kwargs( + date=date, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> ExerciseLog | None: + """List logged exercises for a day + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ExerciseLog + """ + + return sync_detailed( + client=client, + date=date, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> Response[ExerciseLog]: + """List logged exercises for a day + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ExerciseLog] + """ + + kwargs = _get_kwargs( + date=date, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> ExerciseLog | None: + """List logged exercises for a day + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ExerciseLog + """ + + return ( + await asyncio_detailed( + client=client, + date=date, + ) + ).parsed diff --git a/src/yazio_sdk/api/activity/log_exercise.py b/src/yazio_sdk/api/activity/log_exercise.py new file mode 100644 index 0000000..e081d10 --- /dev/null +++ b/src/yazio_sdk/api/activity/log_exercise.py @@ -0,0 +1,108 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.exercise_entry import ExerciseEntry +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + body: ExerciseEntry | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/v22/user/exercises", + } + + if not isinstance(body, Unset): + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | None: + if response.status_code == 200: + return None + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + body: ExerciseEntry | Unset = UNSET, +) -> Response[Any]: + """Log an exercise + + Args: + body (ExerciseEntry | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + body: ExerciseEntry | Unset = UNSET, +) -> Response[Any]: + """Log an exercise + + Args: + body (ExerciseEntry | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/yazio_sdk/api/authentication/__init__.py b/src/yazio_sdk/api/authentication/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/yazio_sdk/api/authentication/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/yazio_sdk/api/authentication/create_token.py b/src/yazio_sdk/api/authentication/create_token.py new file mode 100644 index 0000000..1120a18 --- /dev/null +++ b/src/yazio_sdk/api/authentication/create_token.py @@ -0,0 +1,161 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.o_auth_token import OAuthToken +from ...models.o_auth_token_request import OAuthTokenRequest +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + body: OAuthTokenRequest | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/v22/oauth/token", + } + + if not isinstance(body, Unset): + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> OAuthToken | None: + if response.status_code == 200: + response_200 = OAuthToken.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[OAuthToken]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + body: OAuthTokenRequest | Unset = UNSET, +) -> Response[OAuthToken]: + """Exchange credentials or a refresh token for a bearer token + + Args: + body (OAuthTokenRequest | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[OAuthToken] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + body: OAuthTokenRequest | Unset = UNSET, +) -> OAuthToken | None: + """Exchange credentials or a refresh token for a bearer token + + Args: + body (OAuthTokenRequest | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + OAuthToken + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + body: OAuthTokenRequest | Unset = UNSET, +) -> Response[OAuthToken]: + """Exchange credentials or a refresh token for a bearer token + + Args: + body (OAuthTokenRequest | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[OAuthToken] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + body: OAuthTokenRequest | Unset = UNSET, +) -> OAuthToken | None: + """Exchange credentials or a refresh token for a bearer token + + Args: + body (OAuthTokenRequest | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + OAuthToken + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/src/yazio_sdk/api/body_values/__init__.py b/src/yazio_sdk/api/body_values/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/yazio_sdk/api/body_values/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/yazio_sdk/api/body_values/create_body_value.py b/src/yazio_sdk/api/body_values/create_body_value.py new file mode 100644 index 0000000..306ccd7 --- /dev/null +++ b/src/yazio_sdk/api/body_values/create_body_value.py @@ -0,0 +1,108 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.body_value_entry import BodyValueEntry +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + body: BodyValueEntry | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/v22/user/bodyvalues", + } + + if not isinstance(body, Unset): + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | None: + if response.status_code == 200: + return None + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + body: BodyValueEntry | Unset = UNSET, +) -> Response[Any]: + """Record a body value + + Args: + body (BodyValueEntry | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + body: BodyValueEntry | Unset = UNSET, +) -> Response[Any]: + """Record a body value + + Args: + body (BodyValueEntry | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/yazio_sdk/api/body_values/delete_body_value.py b/src/yazio_sdk/api/body_values/delete_body_value.py new file mode 100644 index 0000000..b9db6b7 --- /dev/null +++ b/src/yazio_sdk/api/body_values/delete_body_value.py @@ -0,0 +1,107 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + body: list[str] | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "delete", + "url": "/v22/user/bodyvalues", + } + + if not isinstance(body, Unset): + _kwargs["json"] = body + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | None: + if response.status_code == 200: + return None + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + body: list[str] | Unset = UNSET, +) -> Response[Any]: + """Delete a body value + + Args: + body (list[str] | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + body: list[str] | Unset = UNSET, +) -> Response[Any]: + """Delete a body value + + Args: + body (list[str] | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/yazio_sdk/api/body_values/get_latest_weight.py b/src/yazio_sdk/api/body_values/get_latest_weight.py new file mode 100644 index 0000000..d1cd7f4 --- /dev/null +++ b/src/yazio_sdk/api/body_values/get_latest_weight.py @@ -0,0 +1,160 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.weight_entry import WeightEntry +from ...types import UNSET, Response + + +def _get_kwargs( + *, + date: str, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["date"] = date + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/bodyvalues/weight/last", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> WeightEntry | None: + if response.status_code == 200: + response_200 = WeightEntry.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[WeightEntry]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: str, +) -> Response[WeightEntry]: + """The most recent weight entry on or before a date + + Args: + date (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[WeightEntry] + """ + + kwargs = _get_kwargs( + date=date, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + date: str, +) -> WeightEntry | None: + """The most recent weight entry on or before a date + + Args: + date (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + WeightEntry + """ + + return sync_detailed( + client=client, + date=date, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: str, +) -> Response[WeightEntry]: + """The most recent weight entry on or before a date + + Args: + date (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[WeightEntry] + """ + + kwargs = _get_kwargs( + date=date, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: str, +) -> WeightEntry | None: + """The most recent weight entry on or before a date + + Args: + date (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + WeightEntry + """ + + return ( + await asyncio_detailed( + client=client, + date=date, + ) + ).parsed diff --git a/src/yazio_sdk/api/body_values/update_body_value.py b/src/yazio_sdk/api/body_values/update_body_value.py new file mode 100644 index 0000000..8832309 --- /dev/null +++ b/src/yazio_sdk/api/body_values/update_body_value.py @@ -0,0 +1,118 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.body_value_update import BodyValueUpdate +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + id: str, + *, + body: BodyValueUpdate | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "put", + "url": "/v22/user/bodyvalues/{id}".format( + id=quote(str(id), safe=""), + ), + } + + if not isinstance(body, Unset): + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | None: + if response.status_code == 200: + return None + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: AuthenticatedClient | Client, + body: BodyValueUpdate | Unset = UNSET, +) -> Response[Any]: + """Replace a body value + + Args: + id (str): + body (BodyValueUpdate | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + id=id, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + id: str, + *, + client: AuthenticatedClient | Client, + body: BodyValueUpdate | Unset = UNSET, +) -> Response[Any]: + """Replace a body value + + Args: + id (str): + body (BodyValueUpdate | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + id=id, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/yazio_sdk/api/buddies/__init__.py b/src/yazio_sdk/api/buddies/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/yazio_sdk/api/buddies/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/yazio_sdk/api/buddies/get_buddy.py b/src/yazio_sdk/api/buddies/get_buddy.py new file mode 100644 index 0000000..d46c270 --- /dev/null +++ b/src/yazio_sdk/api/buddies/get_buddy.py @@ -0,0 +1,155 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.buddy import Buddy +from ...types import Response + + +def _get_kwargs( + id: str, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/buddies/{id}".format( + id=quote(str(id), safe=""), + ), + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Buddy | None: + if response.status_code == 200: + response_200 = Buddy.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Buddy]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[Buddy]: + """A buddy's profile and recent activity + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Buddy] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: AuthenticatedClient | Client, +) -> Buddy | None: + """A buddy's profile and recent activity + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Buddy + """ + + return sync_detailed( + id=id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[Buddy]: + """A buddy's profile and recent activity + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Buddy] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: AuthenticatedClient | Client, +) -> Buddy | None: + """A buddy's profile and recent activity + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Buddy + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/buddies/list_buddies.py b/src/yazio_sdk/api/buddies/list_buddies.py new file mode 100644 index 0000000..1c1649f --- /dev/null +++ b/src/yazio_sdk/api/buddies/list_buddies.py @@ -0,0 +1,127 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/buddies", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> list[str] | None: + if response.status_code == 200: + response_200 = cast(list[str], response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[str]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[list[str]]: + """List the user's buddies + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[str]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, +) -> list[str] | None: + """List the user's buddies + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[str] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[list[str]]: + """List the user's buddies + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[str]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, +) -> list[str] | None: + """List the user's buddies + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[str] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/content/__init__.py b/src/yazio_sdk/api/content/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/yazio_sdk/api/content/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/yazio_sdk/api/content/list_featured_recipes.py b/src/yazio_sdk/api/content/list_featured_recipes.py new file mode 100644 index 0000000..3b1d6e6 --- /dev/null +++ b/src/yazio_sdk/api/content/list_featured_recipes.py @@ -0,0 +1,160 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.recipe_index_entry import RecipeIndexEntry +from ...types import Response + + +def _get_kwargs( + country_code: str, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/content/v2/recipes/{country_code}".format( + country_code=quote(str(country_code), safe=""), + ), + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> list[RecipeIndexEntry] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = RecipeIndexEntry.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[RecipeIndexEntry]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + country_code: str, + *, + client: AuthenticatedClient | Client, +) -> Response[list[RecipeIndexEntry]]: + """Editorial recipe collections for a country + + Args: + country_code (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[RecipeIndexEntry]] + """ + + kwargs = _get_kwargs( + country_code=country_code, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + country_code: str, + *, + client: AuthenticatedClient | Client, +) -> list[RecipeIndexEntry] | None: + """Editorial recipe collections for a country + + Args: + country_code (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[RecipeIndexEntry] + """ + + return sync_detailed( + country_code=country_code, + client=client, + ).parsed + + +async def asyncio_detailed( + country_code: str, + *, + client: AuthenticatedClient | Client, +) -> Response[list[RecipeIndexEntry]]: + """Editorial recipe collections for a country + + Args: + country_code (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[RecipeIndexEntry]] + """ + + kwargs = _get_kwargs( + country_code=country_code, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + country_code: str, + *, + client: AuthenticatedClient | Client, +) -> list[RecipeIndexEntry] | None: + """Editorial recipe collections for a country + + Args: + country_code (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[RecipeIndexEntry] + """ + + return ( + await asyncio_detailed( + country_code=country_code, + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/content/list_success_stories.py b/src/yazio_sdk/api/content/list_success_stories.py new file mode 100644 index 0000000..4449118 --- /dev/null +++ b/src/yazio_sdk/api/content/list_success_stories.py @@ -0,0 +1,189 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + locale: str | Unset = UNSET, + sex: str | Unset = UNSET, + goal: str | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["locale"] = locale + + params["sex"] = sex + + params["goal"] = goal + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/content/v2/success-stories", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> list[Any] | None: + if response.status_code == 200: + response_200 = cast(list[Any], response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[Any]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + locale: str | Unset = UNSET, + sex: str | Unset = UNSET, + goal: str | Unset = UNSET, +) -> Response[list[Any]]: + """Editorial success stories + + Args: + locale (str | Unset): + sex (str | Unset): + goal (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[Any]] + """ + + kwargs = _get_kwargs( + locale=locale, + sex=sex, + goal=goal, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + locale: str | Unset = UNSET, + sex: str | Unset = UNSET, + goal: str | Unset = UNSET, +) -> list[Any] | None: + """Editorial success stories + + Args: + locale (str | Unset): + sex (str | Unset): + goal (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[Any] + """ + + return sync_detailed( + client=client, + locale=locale, + sex=sex, + goal=goal, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + locale: str | Unset = UNSET, + sex: str | Unset = UNSET, + goal: str | Unset = UNSET, +) -> Response[list[Any]]: + """Editorial success stories + + Args: + locale (str | Unset): + sex (str | Unset): + goal (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[Any]] + """ + + kwargs = _get_kwargs( + locale=locale, + sex=sex, + goal=goal, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + locale: str | Unset = UNSET, + sex: str | Unset = UNSET, + goal: str | Unset = UNSET, +) -> list[Any] | None: + """Editorial success stories + + Args: + locale (str | Unset): + sex (str | Unset): + goal (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[Any] + """ + + return ( + await asyncio_detailed( + client=client, + locale=locale, + sex=sex, + goal=goal, + ) + ).parsed diff --git a/src/yazio_sdk/api/diary/__init__.py b/src/yazio_sdk/api/diary/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/yazio_sdk/api/diary/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/yazio_sdk/api/diary/add_consumed_items.py b/src/yazio_sdk/api/diary/add_consumed_items.py new file mode 100644 index 0000000..5cdc1b9 --- /dev/null +++ b/src/yazio_sdk/api/diary/add_consumed_items.py @@ -0,0 +1,108 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.consumed_items import ConsumedItems +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + body: ConsumedItems | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/v22/user/consumed-items", + } + + if not isinstance(body, Unset): + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | None: + if response.status_code == 204: + return None + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + body: ConsumedItems | Unset = UNSET, +) -> Response[Any]: + """Log products, recipe portions or simple entries + + Args: + body (ConsumedItems | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + body: ConsumedItems | Unset = UNSET, +) -> Response[Any]: + """Log products, recipe portions or simple entries + + Args: + body (ConsumedItems | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/yazio_sdk/api/diary/delete_consumed_item.py b/src/yazio_sdk/api/diary/delete_consumed_item.py new file mode 100644 index 0000000..520c80c --- /dev/null +++ b/src/yazio_sdk/api/diary/delete_consumed_item.py @@ -0,0 +1,114 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.consumed_items_deletion import ConsumedItemsDeletion +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + body: ConsumedItemsDeletion | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "delete", + "url": "/v22/user/consumed-items", + } + + if not isinstance(body, Unset): + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | None: + if response.status_code == 204: + return None + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + body: ConsumedItemsDeletion | Unset = UNSET, +) -> Response[Any]: + """Remove one logged entry + + Args: + body (ConsumedItemsDeletion | Unset): Body of DELETE /v22/user/consumed-items. Each + property names one entry by id, as a single string rather than a list — passing an array + is rejected with "This value should be of type string". Note that the endpoint also + accepts an `?id=` query parameter, answers 204, and does nothing at all. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + body: ConsumedItemsDeletion | Unset = UNSET, +) -> Response[Any]: + """Remove one logged entry + + Args: + body (ConsumedItemsDeletion | Unset): Body of DELETE /v22/user/consumed-items. Each + property names one entry by id, as a single string rather than a list — passing an array + is rejected with "This value should be of type string". Note that the endpoint also + accepts an `?id=` query parameter, answers 204, and does nothing at all. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/yazio_sdk/api/diary/get_daily_nutrients.py b/src/yazio_sdk/api/diary/get_daily_nutrients.py new file mode 100644 index 0000000..d6fa02c --- /dev/null +++ b/src/yazio_sdk/api/diary/get_daily_nutrients.py @@ -0,0 +1,180 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.daily_nutrients import DailyNutrients +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + end: str | Unset = UNSET, + start: str | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["end"] = end + + params["start"] = start + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/consumed-items/nutrients-daily", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> list[DailyNutrients] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = DailyNutrients.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[DailyNutrients]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + end: str | Unset = UNSET, + start: str | Unset = UNSET, +) -> Response[list[DailyNutrients]]: + """Nutrient totals per day + + Args: + end (str | Unset): + start (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[DailyNutrients]] + """ + + kwargs = _get_kwargs( + end=end, + start=start, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + end: str | Unset = UNSET, + start: str | Unset = UNSET, +) -> list[DailyNutrients] | None: + """Nutrient totals per day + + Args: + end (str | Unset): + start (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[DailyNutrients] + """ + + return sync_detailed( + client=client, + end=end, + start=start, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + end: str | Unset = UNSET, + start: str | Unset = UNSET, +) -> Response[list[DailyNutrients]]: + """Nutrient totals per day + + Args: + end (str | Unset): + start (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[DailyNutrients]] + """ + + kwargs = _get_kwargs( + end=end, + start=start, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + end: str | Unset = UNSET, + start: str | Unset = UNSET, +) -> list[DailyNutrients] | None: + """Nutrient totals per day + + Args: + end (str | Unset): + start (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[DailyNutrients] + """ + + return ( + await asyncio_detailed( + client=client, + end=end, + start=start, + ) + ).parsed diff --git a/src/yazio_sdk/api/diary/get_feeling.py b/src/yazio_sdk/api/diary/get_feeling.py new file mode 100644 index 0000000..b51a79d --- /dev/null +++ b/src/yazio_sdk/api/diary/get_feeling.py @@ -0,0 +1,160 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.feeling import Feeling +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + date: str | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["date"] = date + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/feeling", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Feeling | None: + if response.status_code == 200: + response_200 = Feeling.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Feeling]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> Response[Feeling]: + """The feeling logged for a day + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Feeling] + """ + + kwargs = _get_kwargs( + date=date, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> Feeling | None: + """The feeling logged for a day + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Feeling + """ + + return sync_detailed( + client=client, + date=date, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> Response[Feeling]: + """The feeling logged for a day + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Feeling] + """ + + kwargs = _get_kwargs( + date=date, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> Feeling | None: + """The feeling logged for a day + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Feeling + """ + + return ( + await asyncio_detailed( + client=client, + date=date, + ) + ).parsed diff --git a/src/yazio_sdk/api/diary/get_water_intake.py b/src/yazio_sdk/api/diary/get_water_intake.py new file mode 100644 index 0000000..886fc5e --- /dev/null +++ b/src/yazio_sdk/api/diary/get_water_intake.py @@ -0,0 +1,160 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.water_intake import WaterIntake +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + date: str | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["date"] = date + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/water-intake", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> WaterIntake | None: + if response.status_code == 200: + response_200 = WaterIntake.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[WaterIntake]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> Response[WaterIntake]: + """Water logged for a day + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[WaterIntake] + """ + + kwargs = _get_kwargs( + date=date, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> WaterIntake | None: + """Water logged for a day + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + WaterIntake + """ + + return sync_detailed( + client=client, + date=date, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> Response[WaterIntake]: + """Water logged for a day + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[WaterIntake] + """ + + kwargs = _get_kwargs( + date=date, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> WaterIntake | None: + """Water logged for a day + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + WaterIntake + """ + + return ( + await asyncio_detailed( + client=client, + date=date, + ) + ).parsed diff --git a/src/yazio_sdk/api/diary/list_consumed_items.py b/src/yazio_sdk/api/diary/list_consumed_items.py new file mode 100644 index 0000000..66616e9 --- /dev/null +++ b/src/yazio_sdk/api/diary/list_consumed_items.py @@ -0,0 +1,160 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.consumed_items import ConsumedItems +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + date: str | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["date"] = date + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/consumed-items", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> ConsumedItems | None: + if response.status_code == 200: + response_200 = ConsumedItems.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[ConsumedItems]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> Response[ConsumedItems]: + """Everything logged for a day + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ConsumedItems] + """ + + kwargs = _get_kwargs( + date=date, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> ConsumedItems | None: + """Everything logged for a day + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ConsumedItems + """ + + return sync_detailed( + client=client, + date=date, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> Response[ConsumedItems]: + """Everything logged for a day + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ConsumedItems] + """ + + kwargs = _get_kwargs( + date=date, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> ConsumedItems | None: + """Everything logged for a day + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ConsumedItems + """ + + return ( + await asyncio_detailed( + client=client, + date=date, + ) + ).parsed diff --git a/src/yazio_sdk/api/diary/list_meal_images.py b/src/yazio_sdk/api/diary/list_meal_images.py new file mode 100644 index 0000000..1eec941 --- /dev/null +++ b/src/yazio_sdk/api/diary/list_meal_images.py @@ -0,0 +1,155 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.meal_images import MealImages +from ...types import Response + + +def _get_kwargs( + date: str, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/meal-images/{date}".format( + date=quote(str(date), safe=""), + ), + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> MealImages | None: + if response.status_code == 200: + response_200 = MealImages.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[MealImages]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + date: str, + *, + client: AuthenticatedClient | Client, +) -> Response[MealImages]: + """Meal photos for a day + + Args: + date (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[MealImages] + """ + + kwargs = _get_kwargs( + date=date, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + date: str, + *, + client: AuthenticatedClient | Client, +) -> MealImages | None: + """Meal photos for a day + + Args: + date (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + MealImages + """ + + return sync_detailed( + date=date, + client=client, + ).parsed + + +async def asyncio_detailed( + date: str, + *, + client: AuthenticatedClient | Client, +) -> Response[MealImages]: + """Meal photos for a day + + Args: + date (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[MealImages] + """ + + kwargs = _get_kwargs( + date=date, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + date: str, + *, + client: AuthenticatedClient | Client, +) -> MealImages | None: + """Meal photos for a day + + Args: + date (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + MealImages + """ + + return ( + await asyncio_detailed( + date=date, + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/diary/set_water_intake.py b/src/yazio_sdk/api/diary/set_water_intake.py new file mode 100644 index 0000000..4345fa1 --- /dev/null +++ b/src/yazio_sdk/api/diary/set_water_intake.py @@ -0,0 +1,111 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.water_intake_entry import WaterIntakeEntry +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + body: list[WaterIntakeEntry] | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/v22/user/water-intake", + } + + if not isinstance(body, Unset): + _kwargs["json"] = [] + for body_item_data in body: + body_item = body_item_data.to_dict() + _kwargs["json"].append(body_item) + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | None: + if response.status_code == 200: + return None + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + body: list[WaterIntakeEntry] | Unset = UNSET, +) -> Response[Any]: + """Set the water logged for a day + + Args: + body (list[WaterIntakeEntry] | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + body: list[WaterIntakeEntry] | Unset = UNSET, +) -> Response[Any]: + """Set the water logged for a day + + Args: + body (list[WaterIntakeEntry] | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/yazio_sdk/api/fasting/__init__.py b/src/yazio_sdk/api/fasting/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/yazio_sdk/api/fasting/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/yazio_sdk/api/fasting/get_fasting_countdowns.py b/src/yazio_sdk/api/fasting/get_fasting_countdowns.py new file mode 100644 index 0000000..fb4932f --- /dev/null +++ b/src/yazio_sdk/api/fasting/get_fasting_countdowns.py @@ -0,0 +1,85 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/fasting-countdowns", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | None: + if response.status_code == 200: + return None + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[Any]: + """The user's active fasting countdowns + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[Any]: + """The user's active fasting countdowns + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/yazio_sdk/api/fasting/get_fasting_history.py b/src/yazio_sdk/api/fasting/get_fasting_history.py new file mode 100644 index 0000000..f6b0072 --- /dev/null +++ b/src/yazio_sdk/api/fasting/get_fasting_history.py @@ -0,0 +1,127 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/fasting-countdowns/history", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> list[Any] | None: + if response.status_code == 200: + response_200 = cast(list[Any], response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[Any]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[list[Any]]: + """Completed fasting periods + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[Any]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, +) -> list[Any] | None: + """Completed fasting periods + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[Any] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[list[Any]]: + """Completed fasting periods + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[Any]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, +) -> list[Any] | None: + """Completed fasting periods + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[Any] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/fasting/list_fasting_templates.py b/src/yazio_sdk/api/fasting/list_fasting_templates.py new file mode 100644 index 0000000..154be43 --- /dev/null +++ b/src/yazio_sdk/api/fasting/list_fasting_templates.py @@ -0,0 +1,180 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.fasting_template_category import FastingTemplateCategory +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + energyunit: str | Unset = UNSET, + locale: str | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["energyunit"] = energyunit + + params["locale"] = locale + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/fasting-countdowns/templates", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> list[FastingTemplateCategory] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = FastingTemplateCategory.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[FastingTemplateCategory]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + energyunit: str | Unset = UNSET, + locale: str | Unset = UNSET, +) -> Response[list[FastingTemplateCategory]]: + """Available fasting plans + + Args: + energyunit (str | Unset): + locale (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[FastingTemplateCategory]] + """ + + kwargs = _get_kwargs( + energyunit=energyunit, + locale=locale, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + energyunit: str | Unset = UNSET, + locale: str | Unset = UNSET, +) -> list[FastingTemplateCategory] | None: + """Available fasting plans + + Args: + energyunit (str | Unset): + locale (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[FastingTemplateCategory] + """ + + return sync_detailed( + client=client, + energyunit=energyunit, + locale=locale, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + energyunit: str | Unset = UNSET, + locale: str | Unset = UNSET, +) -> Response[list[FastingTemplateCategory]]: + """Available fasting plans + + Args: + energyunit (str | Unset): + locale (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[FastingTemplateCategory]] + """ + + kwargs = _get_kwargs( + energyunit=energyunit, + locale=locale, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + energyunit: str | Unset = UNSET, + locale: str | Unset = UNSET, +) -> list[FastingTemplateCategory] | None: + """Available fasting plans + + Args: + energyunit (str | Unset): + locale (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[FastingTemplateCategory] + """ + + return ( + await asyncio_detailed( + client=client, + energyunit=energyunit, + locale=locale, + ) + ).parsed diff --git a/src/yazio_sdk/api/goals/__init__.py b/src/yazio_sdk/api/goals/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/yazio_sdk/api/goals/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/yazio_sdk/api/goals/get_goals.py b/src/yazio_sdk/api/goals/get_goals.py new file mode 100644 index 0000000..9a00bad --- /dev/null +++ b/src/yazio_sdk/api/goals/get_goals.py @@ -0,0 +1,160 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.daily_goals import DailyGoals +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + date: str | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["date"] = date + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/goals", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> DailyGoals | None: + if response.status_code == 200: + response_200 = DailyGoals.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[DailyGoals]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> Response[DailyGoals]: + """The user's daily goals + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[DailyGoals] + """ + + kwargs = _get_kwargs( + date=date, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> DailyGoals | None: + """The user's daily goals + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + DailyGoals + """ + + return sync_detailed( + client=client, + date=date, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> Response[DailyGoals]: + """The user's daily goals + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[DailyGoals] + """ + + kwargs = _get_kwargs( + date=date, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> DailyGoals | None: + """The user's daily goals + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + DailyGoals + """ + + return ( + await asyncio_detailed( + client=client, + date=date, + ) + ).parsed diff --git a/src/yazio_sdk/api/goals/get_unmodified_goals.py b/src/yazio_sdk/api/goals/get_unmodified_goals.py new file mode 100644 index 0000000..e4e069c --- /dev/null +++ b/src/yazio_sdk/api/goals/get_unmodified_goals.py @@ -0,0 +1,160 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.daily_goals import DailyGoals +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + date: str | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["date"] = date + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/goals/unmodified", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> DailyGoals | None: + if response.status_code == 200: + response_200 = DailyGoals.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[DailyGoals]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> Response[DailyGoals]: + """Daily goals as calculated, before any manual override + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[DailyGoals] + """ + + kwargs = _get_kwargs( + date=date, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> DailyGoals | None: + """Daily goals as calculated, before any manual override + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + DailyGoals + """ + + return sync_detailed( + client=client, + date=date, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> Response[DailyGoals]: + """Daily goals as calculated, before any manual override + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[DailyGoals] + """ + + kwargs = _get_kwargs( + date=date, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> DailyGoals | None: + """Daily goals as calculated, before any manual override + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + DailyGoals + """ + + return ( + await asyncio_detailed( + client=client, + date=date, + ) + ).parsed diff --git a/src/yazio_sdk/api/insights/__init__.py b/src/yazio_sdk/api/insights/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/yazio_sdk/api/insights/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/yazio_sdk/api/insights/get_meal_summary_tip.py b/src/yazio_sdk/api/insights/get_meal_summary_tip.py new file mode 100644 index 0000000..3369bfa --- /dev/null +++ b/src/yazio_sdk/api/insights/get_meal_summary_tip.py @@ -0,0 +1,155 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.meal_summary_tips import MealSummaryTips +from ...types import Response + + +def _get_kwargs( + id: str, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/insight/meal-summary-tips/{id}".format( + id=quote(str(id), safe=""), + ), + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> MealSummaryTips | None: + if response.status_code == 200: + response_200 = MealSummaryTips.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[MealSummaryTips]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[MealSummaryTips]: + """One meal summary tip by id + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[MealSummaryTips] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: AuthenticatedClient | Client, +) -> MealSummaryTips | None: + """One meal summary tip by id + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + MealSummaryTips + """ + + return sync_detailed( + id=id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[MealSummaryTips]: + """One meal summary tip by id + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[MealSummaryTips] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: AuthenticatedClient | Client, +) -> MealSummaryTips | None: + """One meal summary tip by id + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + MealSummaryTips + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/insights/request_daily_tips.py b/src/yazio_sdk/api/insights/request_daily_tips.py new file mode 100644 index 0000000..0cc2329 --- /dev/null +++ b/src/yazio_sdk/api/insights/request_daily_tips.py @@ -0,0 +1,108 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.daily_tips_request import DailyTipsRequest +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + body: DailyTipsRequest | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/v22/user/insight/daily-tips", + } + + if not isinstance(body, Unset): + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | None: + if response.status_code == 200: + return None + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + body: DailyTipsRequest | Unset = UNSET, +) -> Response[Any]: + """Daily coaching tips + + Args: + body (DailyTipsRequest | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + body: DailyTipsRequest | Unset = UNSET, +) -> Response[Any]: + """Daily coaching tips + + Args: + body (DailyTipsRequest | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/yazio_sdk/api/insights/request_meal_summary_tips.py b/src/yazio_sdk/api/insights/request_meal_summary_tips.py new file mode 100644 index 0000000..1fb7e1c --- /dev/null +++ b/src/yazio_sdk/api/insights/request_meal_summary_tips.py @@ -0,0 +1,108 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.meal_summary_tips_request import MealSummaryTipsRequest +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + body: MealSummaryTipsRequest | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/v22/user/insight/meal-summary-tips", + } + + if not isinstance(body, Unset): + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | None: + if response.status_code == 200: + return None + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + body: MealSummaryTipsRequest | Unset = UNSET, +) -> Response[Any]: + """Coaching tips about a logged meal + + Args: + body (MealSummaryTipsRequest | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + body: MealSummaryTipsRequest | Unset = UNSET, +) -> Response[Any]: + """Coaching tips about a logged meal + + Args: + body (MealSummaryTipsRequest | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/yazio_sdk/api/products/__init__.py b/src/yazio_sdk/api/products/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/yazio_sdk/api/products/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/yazio_sdk/api/products/get_product.py b/src/yazio_sdk/api/products/get_product.py new file mode 100644 index 0000000..3a994ec --- /dev/null +++ b/src/yazio_sdk/api/products/get_product.py @@ -0,0 +1,155 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.product import Product +from ...types import Response + + +def _get_kwargs( + id: str, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/products/{id}".format( + id=quote(str(id), safe=""), + ), + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Product | None: + if response.status_code == 200: + response_200 = Product.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Product]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[Product]: + """A product and its nutrients + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Product] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: AuthenticatedClient | Client, +) -> Product | None: + """A product and its nutrients + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Product + """ + + return sync_detailed( + id=id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[Product]: + """A product and its nutrients + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Product] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: AuthenticatedClient | Client, +) -> Product | None: + """A product and its nutrients + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Product + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/products/get_product_options.py b/src/yazio_sdk/api/products/get_product_options.py new file mode 100644 index 0000000..a928f9f --- /dev/null +++ b/src/yazio_sdk/api/products/get_product_options.py @@ -0,0 +1,102 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs( + id: str, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "options", + "url": "/v22/products/{id}".format( + id=quote(str(id), safe=""), + ), + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | None: + if response.status_code == 200: + return None + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[Any]: + """Allowed methods for a product resource + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[Any]: + """Allowed methods for a product resource + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/yazio_sdk/api/products/list_suggested_products.py b/src/yazio_sdk/api/products/list_suggested_products.py new file mode 100644 index 0000000..521922c --- /dev/null +++ b/src/yazio_sdk/api/products/list_suggested_products.py @@ -0,0 +1,180 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.suggested_product import SuggestedProduct +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + daytime: str | Unset = UNSET, + date: str | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["daytime"] = daytime + + params["date"] = date + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/products/suggested", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> list[SuggestedProduct] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = SuggestedProduct.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[SuggestedProduct]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + daytime: str | Unset = UNSET, + date: str | Unset = UNSET, +) -> Response[list[SuggestedProduct]]: + """Products suggested for a meal slot + + Args: + daytime (str | Unset): + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[SuggestedProduct]] + """ + + kwargs = _get_kwargs( + daytime=daytime, + date=date, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + daytime: str | Unset = UNSET, + date: str | Unset = UNSET, +) -> list[SuggestedProduct] | None: + """Products suggested for a meal slot + + Args: + daytime (str | Unset): + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[SuggestedProduct] + """ + + return sync_detailed( + client=client, + daytime=daytime, + date=date, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + daytime: str | Unset = UNSET, + date: str | Unset = UNSET, +) -> Response[list[SuggestedProduct]]: + """Products suggested for a meal slot + + Args: + daytime (str | Unset): + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[SuggestedProduct]] + """ + + kwargs = _get_kwargs( + daytime=daytime, + date=date, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + daytime: str | Unset = UNSET, + date: str | Unset = UNSET, +) -> list[SuggestedProduct] | None: + """Products suggested for a meal slot + + Args: + daytime (str | Unset): + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[SuggestedProduct] + """ + + return ( + await asyncio_detailed( + client=client, + daytime=daytime, + date=date, + ) + ).parsed diff --git a/src/yazio_sdk/api/products/search_products.py b/src/yazio_sdk/api/products/search_products.py new file mode 100644 index 0000000..b9ec522 --- /dev/null +++ b/src/yazio_sdk/api/products/search_products.py @@ -0,0 +1,222 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.product_search_result import ProductSearchResult +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + query: str, + sex: str, + countries: str, + locales: str | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["query"] = query + + params["sex"] = sex + + params["countries"] = countries + + params["locales"] = locales + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/products/search", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> list[ProductSearchResult] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = ProductSearchResult.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[ProductSearchResult]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + query: str, + sex: str, + countries: str, + locales: str | Unset = UNSET, +) -> Response[list[ProductSearchResult]]: + """Search products by text or barcode + + Free-text or barcode search. Results are ranked by the request's `Accept-Language`, so the same + query answers differently for a German and an English client. + + Args: + query (str): + sex (str): + countries (str): + locales (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[ProductSearchResult]] + """ + + kwargs = _get_kwargs( + query=query, + sex=sex, + countries=countries, + locales=locales, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + query: str, + sex: str, + countries: str, + locales: str | Unset = UNSET, +) -> list[ProductSearchResult] | None: + """Search products by text or barcode + + Free-text or barcode search. Results are ranked by the request's `Accept-Language`, so the same + query answers differently for a German and an English client. + + Args: + query (str): + sex (str): + countries (str): + locales (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[ProductSearchResult] + """ + + return sync_detailed( + client=client, + query=query, + sex=sex, + countries=countries, + locales=locales, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + query: str, + sex: str, + countries: str, + locales: str | Unset = UNSET, +) -> Response[list[ProductSearchResult]]: + """Search products by text or barcode + + Free-text or barcode search. Results are ranked by the request's `Accept-Language`, so the same + query answers differently for a German and an English client. + + Args: + query (str): + sex (str): + countries (str): + locales (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[ProductSearchResult]] + """ + + kwargs = _get_kwargs( + query=query, + sex=sex, + countries=countries, + locales=locales, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + query: str, + sex: str, + countries: str, + locales: str | Unset = UNSET, +) -> list[ProductSearchResult] | None: + """Search products by text or barcode + + Free-text or barcode search. Results are ranked by the request's `Accept-Language`, so the same + query answers differently for a German and an English client. + + Args: + query (str): + sex (str): + countries (str): + locales (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[ProductSearchResult] + """ + + return ( + await asyncio_detailed( + client=client, + query=query, + sex=sex, + countries=countries, + locales=locales, + ) + ).parsed diff --git a/src/yazio_sdk/api/recipes/__init__.py b/src/yazio_sdk/api/recipes/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/yazio_sdk/api/recipes/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/yazio_sdk/api/recipes/create_user_recipe.py b/src/yazio_sdk/api/recipes/create_user_recipe.py new file mode 100644 index 0000000..f960b11 --- /dev/null +++ b/src/yazio_sdk/api/recipes/create_user_recipe.py @@ -0,0 +1,108 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.recipe_draft import RecipeDraft +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + body: RecipeDraft | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/v22/user/recipes", + } + + if not isinstance(body, Unset): + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | None: + if response.status_code == 200: + return None + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + body: RecipeDraft | Unset = UNSET, +) -> Response[Any]: + """Create a recipe + + Args: + body (RecipeDraft | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + body: RecipeDraft | Unset = UNSET, +) -> Response[Any]: + """Create a recipe + + Args: + body (RecipeDraft | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/yazio_sdk/api/recipes/delete_user_recipe.py b/src/yazio_sdk/api/recipes/delete_user_recipe.py new file mode 100644 index 0000000..5d30c88 --- /dev/null +++ b/src/yazio_sdk/api/recipes/delete_user_recipe.py @@ -0,0 +1,102 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs( + id: str, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "delete", + "url": "/v22/user/recipes/{id}".format( + id=quote(str(id), safe=""), + ), + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | None: + if response.status_code == 204: + return None + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[Any]: + """Delete one of the user's recipes + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[Any]: + """Delete one of the user's recipes + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/yazio_sdk/api/recipes/get_recipe.py b/src/yazio_sdk/api/recipes/get_recipe.py new file mode 100644 index 0000000..ce05b3b --- /dev/null +++ b/src/yazio_sdk/api/recipes/get_recipe.py @@ -0,0 +1,155 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.recipe import Recipe +from ...types import Response + + +def _get_kwargs( + id: str, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/recipes/{id}".format( + id=quote(str(id), safe=""), + ), + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Recipe | None: + if response.status_code == 200: + response_200 = Recipe.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Recipe]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[Recipe]: + """A public recipe + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Recipe] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: str, + *, + client: AuthenticatedClient | Client, +) -> Recipe | None: + """A public recipe + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Recipe + """ + + return sync_detailed( + id=id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: str, + *, + client: AuthenticatedClient | Client, +) -> Response[Recipe]: + """A public recipe + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Recipe] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + id: str, + *, + client: AuthenticatedClient | Client, +) -> Recipe | None: + """A public recipe + + Args: + id (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Recipe + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/recipes/list_favorite_recipes.py b/src/yazio_sdk/api/recipes/list_favorite_recipes.py new file mode 100644 index 0000000..82c19e0 --- /dev/null +++ b/src/yazio_sdk/api/recipes/list_favorite_recipes.py @@ -0,0 +1,127 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/favorites/recipe", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> list[Any] | None: + if response.status_code == 200: + response_200 = cast(list[Any], response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[Any]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[list[Any]]: + """Recipes the user favourited + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[Any]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, +) -> list[Any] | None: + """Recipes the user favourited + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[Any] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[list[Any]]: + """Recipes the user favourited + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[Any]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, +) -> list[Any] | None: + """Recipes the user favourited + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[Any] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/recipes/list_user_recipes.py b/src/yazio_sdk/api/recipes/list_user_recipes.py new file mode 100644 index 0000000..c8a10a6 --- /dev/null +++ b/src/yazio_sdk/api/recipes/list_user_recipes.py @@ -0,0 +1,127 @@ +from http import HTTPStatus +from typing import Any, cast + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/recipes", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> list[str] | None: + if response.status_code == 200: + response_200 = cast(list[str], response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[str]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[list[str]]: + """Recipes the user created + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[str]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, +) -> list[str] | None: + """Recipes the user created + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[str] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[list[str]]: + """Recipes the user created + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[str]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, +) -> list[str] | None: + """Recipes the user created + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[str] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/rewards_shop/__init__.py b/src/yazio_sdk/api/rewards_shop/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/yazio_sdk/api/rewards_shop/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/yazio_sdk/api/rewards_shop/autoclaim_rewards.py b/src/yazio_sdk/api/rewards_shop/autoclaim_rewards.py new file mode 100644 index 0000000..8e0c769 --- /dev/null +++ b/src/yazio_sdk/api/rewards_shop/autoclaim_rewards.py @@ -0,0 +1,108 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.autoclaim_request import AutoclaimRequest +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + body: AutoclaimRequest | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/v22/user/claimables/autoclaim", + } + + if not isinstance(body, Unset): + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | None: + if response.status_code == 200: + return None + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + body: AutoclaimRequest | Unset = UNSET, +) -> Response[Any]: + """Claim every outstanding reward + + Args: + body (AutoclaimRequest | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + body: AutoclaimRequest | Unset = UNSET, +) -> Response[Any]: + """Claim every outstanding reward + + Args: + body (AutoclaimRequest | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/yazio_sdk/api/rewards_shop/get_wallet.py b/src/yazio_sdk/api/rewards_shop/get_wallet.py new file mode 100644 index 0000000..14be0ef --- /dev/null +++ b/src/yazio_sdk/api/rewards_shop/get_wallet.py @@ -0,0 +1,128 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.wallet import Wallet +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/wallet", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Wallet | None: + if response.status_code == 200: + response_200 = Wallet.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Wallet]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[Wallet]: + """The user's credit balance + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Wallet] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, +) -> Wallet | None: + """The user's credit balance + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Wallet + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[Wallet]: + """The user's credit balance + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Wallet] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, +) -> Wallet | None: + """The user's credit balance + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Wallet + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/rewards_shop/list_claimables.py b/src/yazio_sdk/api/rewards_shop/list_claimables.py new file mode 100644 index 0000000..aca0d5d --- /dev/null +++ b/src/yazio_sdk/api/rewards_shop/list_claimables.py @@ -0,0 +1,128 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.claimables import Claimables +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/claimables", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Claimables | None: + if response.status_code == 200: + response_200 = Claimables.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Claimables]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[Claimables]: + """Rewards waiting to be claimed + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Claimables] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, +) -> Claimables | None: + """Rewards waiting to be claimed + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Claimables + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[Claimables]: + """Rewards waiting to be claimed + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Claimables] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, +) -> Claimables | None: + """Rewards waiting to be claimed + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Claimables + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/rewards_shop/list_shop_items.py b/src/yazio_sdk/api/rewards_shop/list_shop_items.py new file mode 100644 index 0000000..0fb92ad --- /dev/null +++ b/src/yazio_sdk/api/rewards_shop/list_shop_items.py @@ -0,0 +1,128 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.shop_items import ShopItems +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/shop/items", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> ShopItems | None: + if response.status_code == 200: + response_200 = ShopItems.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[ShopItems]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[ShopItems]: + """Items purchasable with wallet credit + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ShopItems] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, +) -> ShopItems | None: + """Items purchasable with wallet credit + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ShopItems + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[ShopItems]: + """Items purchasable with wallet credit + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ShopItems] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, +) -> ShopItems | None: + """Items purchasable with wallet credit + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ShopItems + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/streaks/__init__.py b/src/yazio_sdk/api/streaks/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/yazio_sdk/api/streaks/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/yazio_sdk/api/streaks/get_streak.py b/src/yazio_sdk/api/streaks/get_streak.py new file mode 100644 index 0000000..f27f090 --- /dev/null +++ b/src/yazio_sdk/api/streaks/get_streak.py @@ -0,0 +1,128 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.streak_calendar import StreakCalendar +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/streak", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> StreakCalendar | None: + if response.status_code == 200: + response_200 = StreakCalendar.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[StreakCalendar]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[StreakCalendar]: + """The user's current logging streak + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[StreakCalendar] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, +) -> StreakCalendar | None: + """The user's current logging streak + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + StreakCalendar + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[StreakCalendar]: + """The user's current logging streak + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[StreakCalendar] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, +) -> StreakCalendar | None: + """The user's current logging streak + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + StreakCalendar + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/streaks/update_streak.py b/src/yazio_sdk/api/streaks/update_streak.py new file mode 100644 index 0000000..680975e --- /dev/null +++ b/src/yazio_sdk/api/streaks/update_streak.py @@ -0,0 +1,118 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.streak_update import StreakUpdate +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + date: str, + *, + body: StreakUpdate | Unset = UNSET, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/v22/user/streak/{date}".format( + date=quote(str(date), safe=""), + ), + } + + if not isinstance(body, Unset): + _kwargs["json"] = body.to_dict() + + headers["Content-Type"] = "application/json" + + _kwargs["headers"] = headers + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | None: + if response.status_code == 200: + return None + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + date: str, + *, + client: AuthenticatedClient | Client, + body: StreakUpdate | Unset = UNSET, +) -> Response[Any]: + """Record streak activity for a date + + Args: + date (str): + body (StreakUpdate | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + date=date, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + date: str, + *, + client: AuthenticatedClient | Client, + body: StreakUpdate | Unset = UNSET, +) -> Response[Any]: + """Record streak activity for a date + + Args: + date (str): + body (StreakUpdate | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs( + date=date, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/yazio_sdk/api/subscriptions/__init__.py b/src/yazio_sdk/api/subscriptions/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/yazio_sdk/api/subscriptions/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/yazio_sdk/api/subscriptions/get_latest_subscription.py b/src/yazio_sdk/api/subscriptions/get_latest_subscription.py new file mode 100644 index 0000000..8439830 --- /dev/null +++ b/src/yazio_sdk/api/subscriptions/get_latest_subscription.py @@ -0,0 +1,128 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.subscription import Subscription +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/subscription/latest", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Subscription | None: + if response.status_code == 200: + response_200 = Subscription.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Subscription]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[Subscription]: + """The most recent subscription record + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Subscription] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, +) -> Subscription | None: + """The most recent subscription record + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Subscription + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[Subscription]: + """The most recent subscription record + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Subscription] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, +) -> Subscription | None: + """The most recent subscription record + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Subscription + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/subscriptions/get_subscription.py b/src/yazio_sdk/api/subscriptions/get_subscription.py new file mode 100644 index 0000000..cfc7253 --- /dev/null +++ b/src/yazio_sdk/api/subscriptions/get_subscription.py @@ -0,0 +1,133 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.subscription import Subscription +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/subscription", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> list[Subscription] | None: + if response.status_code == 200: + response_200 = [] + _response_200 = response.json() + for response_200_item_data in _response_200: + response_200_item = Subscription.from_dict(response_200_item_data) + + response_200.append(response_200_item) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[list[Subscription]]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[list[Subscription]]: + """The user's subscription state + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[Subscription]] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, +) -> list[Subscription] | None: + """The user's subscription state + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[Subscription] + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[list[Subscription]]: + """The user's subscription state + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[list[Subscription]] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, +) -> list[Subscription] | None: + """The user's subscription state + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + list[Subscription] + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/user/__init__.py b/src/yazio_sdk/api/user/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/yazio_sdk/api/user/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/yazio_sdk/api/user/flush_pending_notifications.py b/src/yazio_sdk/api/user/flush_pending_notifications.py new file mode 100644 index 0000000..101390d --- /dev/null +++ b/src/yazio_sdk/api/user/flush_pending_notifications.py @@ -0,0 +1,128 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.pending_notifications import PendingNotifications +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/v22/user/pending-notifications/flush", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> PendingNotifications | None: + if response.status_code == 200: + response_200 = PendingNotifications.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[PendingNotifications]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[PendingNotifications]: + """Deliver and clear queued notifications + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PendingNotifications] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, +) -> PendingNotifications | None: + """Deliver and clear queued notifications + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + PendingNotifications + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[PendingNotifications]: + """Deliver and clear queued notifications + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[PendingNotifications] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, +) -> PendingNotifications | None: + """Deliver and clear queued notifications + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + PendingNotifications + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/user/get_changes_indicator.py b/src/yazio_sdk/api/user/get_changes_indicator.py new file mode 100644 index 0000000..3b1cf1c --- /dev/null +++ b/src/yazio_sdk/api/user/get_changes_indicator.py @@ -0,0 +1,128 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.changes_indicator import ChangesIndicator +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/changes-indicator", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> ChangesIndicator | None: + if response.status_code == 200: + response_200 = ChangesIndicator.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[ChangesIndicator]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[ChangesIndicator]: + """Timestamps telling a client what to re-fetch + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ChangesIndicator] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, +) -> ChangesIndicator | None: + """Timestamps telling a client what to re-fetch + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ChangesIndicator + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[ChangesIndicator]: + """Timestamps telling a client what to re-fetch + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ChangesIndicator] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, +) -> ChangesIndicator | None: + """Timestamps telling a client what to re-fetch + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ChangesIndicator + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/user/get_dietary_preferences.py b/src/yazio_sdk/api/user/get_dietary_preferences.py new file mode 100644 index 0000000..d37784f --- /dev/null +++ b/src/yazio_sdk/api/user/get_dietary_preferences.py @@ -0,0 +1,128 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.dietary_preferences import DietaryPreferences +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/dietary-preferences", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> DietaryPreferences | None: + if response.status_code == 200: + response_200 = DietaryPreferences.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[DietaryPreferences]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[DietaryPreferences]: + """Diet and food preferences + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[DietaryPreferences] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, +) -> DietaryPreferences | None: + """Diet and food preferences + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + DietaryPreferences + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[DietaryPreferences]: + """Diet and food preferences + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[DietaryPreferences] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, +) -> DietaryPreferences | None: + """Diet and food preferences + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + DietaryPreferences + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/user/get_key_value_store.py b/src/yazio_sdk/api/user/get_key_value_store.py new file mode 100644 index 0000000..b292991 --- /dev/null +++ b/src/yazio_sdk/api/user/get_key_value_store.py @@ -0,0 +1,128 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.key_value_store import KeyValueStore +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/key-value-store", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> KeyValueStore | None: + if response.status_code == 200: + response_200 = KeyValueStore.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[KeyValueStore]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[KeyValueStore]: + """Arbitrary client-stored settings + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[KeyValueStore] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, +) -> KeyValueStore | None: + """Arbitrary client-stored settings + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + KeyValueStore + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[KeyValueStore]: + """Arbitrary client-stored settings + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[KeyValueStore] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, +) -> KeyValueStore | None: + """Arbitrary client-stored settings + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + KeyValueStore + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/user/get_settings.py b/src/yazio_sdk/api/user/get_settings.py new file mode 100644 index 0000000..f7085fd --- /dev/null +++ b/src/yazio_sdk/api/user/get_settings.py @@ -0,0 +1,128 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.user_settings import UserSettings +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/settings", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> UserSettings | None: + if response.status_code == 200: + response_200 = UserSettings.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[UserSettings]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[UserSettings]: + """The user's app settings + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[UserSettings] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, +) -> UserSettings | None: + """The user's app settings + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + UserSettings + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[UserSettings]: + """The user's app settings + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[UserSettings] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, +) -> UserSettings | None: + """The user's app settings + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + UserSettings + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/user/get_third_party_integration.py b/src/yazio_sdk/api/user/get_third_party_integration.py new file mode 100644 index 0000000..f16c5a6 --- /dev/null +++ b/src/yazio_sdk/api/user/get_third_party_integration.py @@ -0,0 +1,128 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.third_party_integration import ThirdPartyIntegration +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/third-party-integration", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> ThirdPartyIntegration | None: + if response.status_code == 200: + response_200 = ThirdPartyIntegration.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[ThirdPartyIntegration]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[ThirdPartyIntegration]: + """Connected third-party services + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ThirdPartyIntegration] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, +) -> ThirdPartyIntegration | None: + """Connected third-party services + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ThirdPartyIntegration + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[ThirdPartyIntegration]: + """Connected third-party services + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ThirdPartyIntegration] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, +) -> ThirdPartyIntegration | None: + """Connected third-party services + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ThirdPartyIntegration + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/user/get_unlocked_features.py b/src/yazio_sdk/api/user/get_unlocked_features.py new file mode 100644 index 0000000..bb6842f --- /dev/null +++ b/src/yazio_sdk/api/user/get_unlocked_features.py @@ -0,0 +1,128 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.unlocked_features import UnlockedFeatures +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/unlocked-features", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> UnlockedFeatures | None: + if response.status_code == 200: + response_200 = UnlockedFeatures.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[UnlockedFeatures]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[UnlockedFeatures]: + """Features the account has + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[UnlockedFeatures] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, +) -> UnlockedFeatures | None: + """Features the account has + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + UnlockedFeatures + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[UnlockedFeatures]: + """Features the account has + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[UnlockedFeatures] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, +) -> UnlockedFeatures | None: + """Features the account has + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + UnlockedFeatures + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/user/get_user.py b/src/yazio_sdk/api/user/get_user.py new file mode 100644 index 0000000..e7b2422 --- /dev/null +++ b/src/yazio_sdk/api/user/get_user.py @@ -0,0 +1,128 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.user_profile import UserProfile +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> UserProfile | None: + if response.status_code == 200: + response_200 = UserProfile.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[UserProfile]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[UserProfile]: + """The authenticated user's profile + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[UserProfile] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, +) -> UserProfile | None: + """The authenticated user's profile + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + UserProfile + """ + + return sync_detailed( + client=client, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[UserProfile]: + """The authenticated user's profile + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[UserProfile] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, +) -> UserProfile | None: + """The authenticated user's profile + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + UserProfile + """ + + return ( + await asyncio_detailed( + client=client, + ) + ).parsed diff --git a/src/yazio_sdk/api/user/initialize_crm.py b/src/yazio_sdk/api/user/initialize_crm.py new file mode 100644 index 0000000..66bb85a --- /dev/null +++ b/src/yazio_sdk/api/user/initialize_crm.py @@ -0,0 +1,85 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...types import Response + + +def _get_kwargs() -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/v22/user/crm/initialize", + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Any | None: + if response.status_code == 200: + return None + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[Any]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[Any]: + """Register the client with the CRM + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs() + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, +) -> Response[Any]: + """Register the client with the CRM + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[Any] + """ + + kwargs = _get_kwargs() + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) diff --git a/src/yazio_sdk/api/widgets/__init__.py b/src/yazio_sdk/api/widgets/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/yazio_sdk/api/widgets/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/yazio_sdk/api/widgets/get_daily_summary_widget.py b/src/yazio_sdk/api/widgets/get_daily_summary_widget.py new file mode 100644 index 0000000..35ab1ed --- /dev/null +++ b/src/yazio_sdk/api/widgets/get_daily_summary_widget.py @@ -0,0 +1,160 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.daily_summary_widget import DailySummaryWidget +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + date: str | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["date"] = date + + params = {k: v for k, v in params.items() if v is not UNSET and v is not None} + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/v22/user/widgets/daily-summary", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> DailySummaryWidget | None: + if response.status_code == 200: + response_200 = DailySummaryWidget.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[DailySummaryWidget]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> Response[DailySummaryWidget]: + """The home screen daily summary + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[DailySummaryWidget] + """ + + kwargs = _get_kwargs( + date=date, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> DailySummaryWidget | None: + """The home screen daily summary + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + DailySummaryWidget + """ + + return sync_detailed( + client=client, + date=date, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> Response[DailySummaryWidget]: + """The home screen daily summary + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[DailySummaryWidget] + """ + + kwargs = _get_kwargs( + date=date, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + date: str | Unset = UNSET, +) -> DailySummaryWidget | None: + """The home screen daily summary + + Args: + date (str | Unset): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + DailySummaryWidget + """ + + return ( + await asyncio_detailed( + client=client, + date=date, + ) + ).parsed diff --git a/src/yazio_sdk/client.py b/src/yazio_sdk/client.py new file mode 100644 index 0000000..b862115 --- /dev/null +++ b/src/yazio_sdk/client.py @@ -0,0 +1,272 @@ +import ssl +from typing import Any + +import httpx +from attrs import define, evolve, field + + +@define +class Client: + """A class for keeping track of data related to the API + + The following are accepted as keyword arguments and will be used to construct httpx Clients internally: + + ``base_url``: The base URL for the API, all requests are made to a relative path to this URL + + ``cookies``: A dictionary of cookies to be sent with every request + + ``headers``: A dictionary of headers to be sent with every request + + ``timeout``: The maximum amount of a time a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + + ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + + ``follow_redirects``: Whether or not to follow redirects. Default value is False. + + ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. + + + Attributes: + raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a + status code that was not documented in the source OpenAPI document. Can also be provided as a keyword + argument to the constructor. + """ + + raise_on_unexpected_status: bool = field(default=False, kw_only=True) + _base_url: str = field(alias="base_url") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl") + _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _client: httpx.Client | None = field(default=None, init=False) + _async_client: httpx.AsyncClient | None = field(default=None, init=False) + + def with_headers(self, headers: dict[str, str]) -> "Client": + """Get a new client matching this one with additional headers""" + if self._client is not None: + self._client.headers.update(headers) + if self._async_client is not None: + self._async_client.headers.update(headers) + return evolve(self, headers={**self._headers, **headers}) + + def with_cookies(self, cookies: dict[str, str]) -> "Client": + """Get a new client matching this one with additional cookies""" + if self._client is not None: + self._client.cookies.update(cookies) + if self._async_client is not None: + self._async_client.cookies.update(cookies) + return evolve(self, cookies={**self._cookies, **cookies}) + + def with_timeout(self, timeout: httpx.Timeout) -> "Client": + """Get a new client matching this one with a new timeout configuration""" + if self._client is not None: + self._client.timeout = timeout + if self._async_client is not None: + self._async_client.timeout = timeout + return evolve(self, timeout=timeout) + + def set_httpx_client(self, client: httpx.Client) -> "Client": + """Manually set the underlying httpx.Client + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._client = client + return self + + def get_httpx_client(self) -> httpx.Client: + """Get the underlying httpx.Client, constructing a new one if not previously set""" + if self._client is None: + self._client = httpx.Client( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._client + + def __enter__(self) -> "Client": + """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" + self.get_httpx_client().__enter__() + return self + + def __exit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for internal httpx.Client (see httpx docs)""" + self.get_httpx_client().__exit__(*args, **kwargs) + + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client": + """Manually set the underlying httpx.AsyncClient + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._async_client = async_client + return self + + def get_async_httpx_client(self) -> httpx.AsyncClient: + """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" + if self._async_client is None: + self._async_client = httpx.AsyncClient( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._async_client + + async def __aenter__(self) -> "Client": + """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" + await self.get_async_httpx_client().__aenter__() + return self + + async def __aexit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" + await self.get_async_httpx_client().__aexit__(*args, **kwargs) + + +@define +class AuthenticatedClient: + """A Client which has been authenticated for use on secured endpoints + + The following are accepted as keyword arguments and will be used to construct httpx Clients internally: + + ``base_url``: The base URL for the API, all requests are made to a relative path to this URL + + ``cookies``: A dictionary of cookies to be sent with every request + + ``headers``: A dictionary of headers to be sent with every request + + ``timeout``: The maximum amount of a time a request can take. API functions will raise + httpx.TimeoutException if this is exceeded. + + ``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production, + but can be set to False for testing purposes. + + ``follow_redirects``: Whether or not to follow redirects. Default value is False. + + ``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor. + + + Attributes: + raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a + status code that was not documented in the source OpenAPI document. Can also be provided as a keyword + argument to the constructor. + token: The token to use for authentication + prefix: The prefix to use for the Authorization header + auth_header_name: The name of the Authorization header + """ + + raise_on_unexpected_status: bool = field(default=False, kw_only=True) + _base_url: str = field(alias="base_url") + _cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies") + _headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers") + _timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout") + _verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl") + _follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects") + _httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args") + _client: httpx.Client | None = field(default=None, init=False) + _async_client: httpx.AsyncClient | None = field(default=None, init=False) + + token: str + prefix: str = "Bearer" + auth_header_name: str = "Authorization" + + def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient": + """Get a new client matching this one with additional headers""" + if self._client is not None: + self._client.headers.update(headers) + if self._async_client is not None: + self._async_client.headers.update(headers) + return evolve(self, headers={**self._headers, **headers}) + + def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient": + """Get a new client matching this one with additional cookies""" + if self._client is not None: + self._client.cookies.update(cookies) + if self._async_client is not None: + self._async_client.cookies.update(cookies) + return evolve(self, cookies={**self._cookies, **cookies}) + + def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient": + """Get a new client matching this one with a new timeout configuration""" + if self._client is not None: + self._client.timeout = timeout + if self._async_client is not None: + self._async_client.timeout = timeout + return evolve(self, timeout=timeout) + + def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": + """Manually set the underlying httpx.Client + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._client = client + return self + + def get_httpx_client(self) -> httpx.Client: + """Get the underlying httpx.Client, constructing a new one if not previously set""" + if self._client is None: + self._headers[self.auth_header_name] = ( + f"{self.prefix} {self.token}" if self.prefix else self.token + ) + self._client = httpx.Client( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._client + + def __enter__(self) -> "AuthenticatedClient": + """Enter a context manager for self.client—you cannot enter twice (see httpx docs)""" + self.get_httpx_client().__enter__() + return self + + def __exit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for internal httpx.Client (see httpx docs)""" + self.get_httpx_client().__exit__(*args, **kwargs) + + def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient": + """Manually set the underlying httpx.AsyncClient + + **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. + """ + self._async_client = async_client + return self + + def get_async_httpx_client(self) -> httpx.AsyncClient: + """Get the underlying httpx.AsyncClient, constructing a new one if not previously set""" + if self._async_client is None: + self._headers[self.auth_header_name] = ( + f"{self.prefix} {self.token}" if self.prefix else self.token + ) + self._async_client = httpx.AsyncClient( + base_url=self._base_url, + cookies=self._cookies, + headers=self._headers, + timeout=self._timeout, + verify=self._verify_ssl, + follow_redirects=self._follow_redirects, + **self._httpx_args, + ) + return self._async_client + + async def __aenter__(self) -> "AuthenticatedClient": + """Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)""" + await self.get_async_httpx_client().__aenter__() + return self + + async def __aexit__(self, *args: Any, **kwargs: Any) -> None: + """Exit a context manager for underlying httpx.AsyncClient (see httpx docs)""" + await self.get_async_httpx_client().__aexit__(*args, **kwargs) diff --git a/src/yazio_sdk/errors.py b/src/yazio_sdk/errors.py new file mode 100644 index 0000000..5f92e76 --- /dev/null +++ b/src/yazio_sdk/errors.py @@ -0,0 +1,16 @@ +"""Contains shared errors types that can be raised from API functions""" + + +class UnexpectedStatus(Exception): + """Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True""" + + def __init__(self, status_code: int, content: bytes): + self.status_code = status_code + self.content = content + + super().__init__( + f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}" + ) + + +__all__ = ["UnexpectedStatus"] diff --git a/src/yazio_sdk/models/__init__.py b/src/yazio_sdk/models/__init__.py new file mode 100644 index 0000000..bb7b235 --- /dev/null +++ b/src/yazio_sdk/models/__init__.py @@ -0,0 +1,197 @@ +"""Contains all the data models used in inputs/outputs""" + +from .autoclaim_request import AutoclaimRequest +from .body_value_entry import BodyValueEntry +from .body_value_entry_weight_item import BodyValueEntryWeightItem +from .body_value_update import BodyValueUpdate +from .buddy import Buddy +from .buddy_exercise import BuddyExercise +from .changes_indicator import ChangesIndicator +from .claimables import Claimables +from .consumed_items import ConsumedItems +from .consumed_items_deletion import ConsumedItemsDeletion +from .consumed_items_products_item import ConsumedItemsProductsItem +from .consumed_recipe_portion import ConsumedRecipePortion +from .daily_exercise_summary import DailyExerciseSummary +from .daily_goals import DailyGoals +from .daily_nutrients import DailyNutrients +from .daily_summary_widget import DailySummaryWidget +from .daily_summary_widget_active_fasting_countdown_template_key_type_0 import ( + DailySummaryWidgetActiveFastingCountdownTemplateKeyType0, +) +from .daily_summary_widget_meals import DailySummaryWidgetMeals +from .daily_summary_widget_units import DailySummaryWidgetUnits +from .daily_summary_widget_user import DailySummaryWidgetUser +from .daily_tips_request import DailyTipsRequest +from .daily_tips_request_experiments_item import DailyTipsRequestExperimentsItem +from .dietary_preferences import DietaryPreferences +from .dietary_preferences_restriction_type_0 import DietaryPreferencesRestrictionType0 +from .exercise_entry import ExerciseEntry +from .exercise_entry_activity_item import ExerciseEntryActivityItem +from .exercise_log import ExerciseLog +from .exercise_log_activity import ExerciseLogActivity +from .exercise_log_activity_source_type_0 import ExerciseLogActivitySourceType0 +from .fasting_participants import FastingParticipants +from .fasting_period_boundary import FastingPeriodBoundary +from .fasting_template import FastingTemplate +from .fasting_template_category import FastingTemplateCategory +from .fasting_template_fasting_periods_item import FastingTemplateFastingPeriodsItem +from .fasting_template_group import FastingTemplateGroup +from .fasting_template_group_fasting_calorie_goal_type_0 import ( + FastingTemplateGroupFastingCalorieGoalType0, +) +from .fasting_template_group_teaser_position_type_0 import FastingTemplateGroupTeaserPositionType0 +from .fasting_template_preset_type_0 import FastingTemplatePresetType0 +from .fasting_tip import FastingTip +from .feeling import Feeling +from .feeling_note_type_0 import FeelingNoteType0 +from .key_value_store import KeyValueStore +from .meal_images import MealImages +from .meal_summary import MealSummary +from .meal_summary_tips import MealSummaryTips +from .meal_summary_tips_request import MealSummaryTipsRequest +from .nutrient_summary import NutrientSummary +from .o_auth_token import OAuthToken +from .o_auth_token_request import OAuthTokenRequest +from .pending_notifications import PendingNotifications +from .product import Product +from .product_nutrients import ProductNutrients +from .product_search_result import ProductSearchResult +from .product_servings_item import ProductServingsItem +from .recipe import Recipe +from .recipe_available_since_type_0 import RecipeAvailableSinceType0 +from .recipe_draft import RecipeDraft +from .recipe_draft_nutrients import RecipeDraftNutrients +from .recipe_draft_servings_item import RecipeDraftServingsItem +from .recipe_image_type_0 import RecipeImageType0 +from .recipe_index_entry import RecipeIndexEntry +from .recipe_nutrients import RecipeNutrients +from .recipe_servings_item import RecipeServingsItem +from .recipe_servings_item_note_type_0 import RecipeServingsItemNoteType0 +from .recipe_servings_item_serving_quantity_type_0 import RecipeServingsItemServingQuantityType0 +from .recipe_servings_item_serving_type_0 import RecipeServingsItemServingType0 +from .recipe_yazio_id_type_0 import RecipeYazioIdType0 +from .shop_items import ShopItems +from .shop_items_items_item import ShopItemsItemsItem +from .streak_calendar import StreakCalendar +from .streak_day import StreakDay +from .streak_update import StreakUpdate +from .subscription import Subscription +from .subscription_base_plan_id_type_0 import SubscriptionBasePlanIdType0 +from .suggested_product import SuggestedProduct +from .third_party_integration import ThirdPartyIntegration +from .unlocked_features import UnlockedFeatures +from .unlocked_features_unlocked_features_item import UnlockedFeaturesUnlockedFeaturesItem +from .user_profile import UserProfile +from .user_profile_city_type_0 import UserProfileCityType0 +from .user_profile_diet import UserProfileDiet +from .user_profile_last_name_type_0 import UserProfileLastNameType0 +from .user_profile_profile_image_type_0 import UserProfileProfileImageType0 +from .user_profile_siwa_user_id_type_0 import UserProfileSiwaUserIdType0 +from .user_settings import UserSettings +from .wallet import Wallet +from .wallet_currencies_item import WalletCurrenciesItem +from .water_intake import WaterIntake +from .water_intake_entry import WaterIntakeEntry +from .water_intake_gateway_type_0 import WaterIntakeGatewayType0 +from .water_intake_source_type_0 import WaterIntakeSourceType0 +from .weight_entry import WeightEntry +from .weight_entry_external_id_type_0 import WeightEntryExternalIdType0 +from .weight_entry_source_type_0 import WeightEntrySourceType0 + +__all__ = ( + "AutoclaimRequest", + "BodyValueEntry", + "BodyValueEntryWeightItem", + "BodyValueUpdate", + "Buddy", + "BuddyExercise", + "ChangesIndicator", + "Claimables", + "ConsumedItems", + "ConsumedItemsDeletion", + "ConsumedItemsProductsItem", + "ConsumedRecipePortion", + "DailyExerciseSummary", + "DailyGoals", + "DailyNutrients", + "DailySummaryWidget", + "DailySummaryWidgetActiveFastingCountdownTemplateKeyType0", + "DailySummaryWidgetMeals", + "DailySummaryWidgetUnits", + "DailySummaryWidgetUser", + "DailyTipsRequest", + "DailyTipsRequestExperimentsItem", + "DietaryPreferences", + "DietaryPreferencesRestrictionType0", + "ExerciseEntry", + "ExerciseEntryActivityItem", + "ExerciseLog", + "ExerciseLogActivity", + "ExerciseLogActivitySourceType0", + "FastingParticipants", + "FastingPeriodBoundary", + "FastingTemplate", + "FastingTemplateCategory", + "FastingTemplateFastingPeriodsItem", + "FastingTemplateGroup", + "FastingTemplateGroupFastingCalorieGoalType0", + "FastingTemplateGroupTeaserPositionType0", + "FastingTemplatePresetType0", + "FastingTip", + "Feeling", + "FeelingNoteType0", + "KeyValueStore", + "MealImages", + "MealSummary", + "MealSummaryTips", + "MealSummaryTipsRequest", + "NutrientSummary", + "OAuthToken", + "OAuthTokenRequest", + "PendingNotifications", + "Product", + "ProductNutrients", + "ProductSearchResult", + "ProductServingsItem", + "Recipe", + "RecipeAvailableSinceType0", + "RecipeDraft", + "RecipeDraftNutrients", + "RecipeDraftServingsItem", + "RecipeImageType0", + "RecipeIndexEntry", + "RecipeNutrients", + "RecipeServingsItem", + "RecipeServingsItemNoteType0", + "RecipeServingsItemServingQuantityType0", + "RecipeServingsItemServingType0", + "RecipeYazioIdType0", + "ShopItems", + "ShopItemsItemsItem", + "StreakCalendar", + "StreakDay", + "StreakUpdate", + "Subscription", + "SubscriptionBasePlanIdType0", + "SuggestedProduct", + "ThirdPartyIntegration", + "UnlockedFeatures", + "UnlockedFeaturesUnlockedFeaturesItem", + "UserProfile", + "UserProfileCityType0", + "UserProfileDiet", + "UserProfileLastNameType0", + "UserProfileProfileImageType0", + "UserProfileSiwaUserIdType0", + "UserSettings", + "Wallet", + "WalletCurrenciesItem", + "WaterIntake", + "WaterIntakeEntry", + "WaterIntakeGatewayType0", + "WaterIntakeSourceType0", + "WeightEntry", + "WeightEntryExternalIdType0", + "WeightEntrySourceType0", +) diff --git a/src/yazio_sdk/models/autoclaim_request.py b/src/yazio_sdk/models/autoclaim_request.py new file mode 100644 index 0000000..5c0fffa --- /dev/null +++ b/src/yazio_sdk/models/autoclaim_request.py @@ -0,0 +1,70 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="AutoclaimRequest") + + +@_attrs_define +class AutoclaimRequest: + """ + Attributes: + user_date (str | Unset): + type_ (str | Unset): + """ + + user_date: str | Unset = UNSET + type_: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + user_date = self.user_date + + type_ = self.type_ + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if user_date is not UNSET: + field_dict["user_date"] = user_date + if type_ is not UNSET: + field_dict["type"] = type_ + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + user_date = d.pop("user_date", UNSET) + + type_ = d.pop("type", UNSET) + + autoclaim_request = cls( + user_date=user_date, + type_=type_, + ) + + autoclaim_request.additional_properties = d + return autoclaim_request + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/body_value_entry.py b/src/yazio_sdk/models/body_value_entry.py new file mode 100644 index 0000000..44a26b4 --- /dev/null +++ b/src/yazio_sdk/models/body_value_entry.py @@ -0,0 +1,79 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.body_value_entry_weight_item import BodyValueEntryWeightItem + + +T = TypeVar("T", bound="BodyValueEntry") + + +@_attrs_define +class BodyValueEntry: + """ + Attributes: + weight (list[BodyValueEntryWeightItem] | Unset): + """ + + weight: list[BodyValueEntryWeightItem] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + weight: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.weight, Unset): + weight = [] + for weight_item_data in self.weight: + weight_item = weight_item_data.to_dict() + weight.append(weight_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if weight is not UNSET: + field_dict["weight"] = weight + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.body_value_entry_weight_item import BodyValueEntryWeightItem + + d = dict(src_dict) + _weight = d.pop("weight", UNSET) + weight: list[BodyValueEntryWeightItem] | Unset = UNSET + if _weight is not UNSET: + weight = [] + for weight_item_data in _weight: + weight_item = BodyValueEntryWeightItem.from_dict(weight_item_data) + + weight.append(weight_item) + + body_value_entry = cls( + weight=weight, + ) + + body_value_entry.additional_properties = d + return body_value_entry + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/body_value_entry_weight_item.py b/src/yazio_sdk/models/body_value_entry_weight_item.py new file mode 100644 index 0000000..a5327e2 --- /dev/null +++ b/src/yazio_sdk/models/body_value_entry_weight_item.py @@ -0,0 +1,79 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="BodyValueEntryWeightItem") + + +@_attrs_define +class BodyValueEntryWeightItem: + """ + Attributes: + value (float | Unset): + date (str | Unset): + id (str | Unset): + """ + + value: float | Unset = UNSET + date: str | Unset = UNSET + id: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + value = self.value + + date = self.date + + id = self.id + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if value is not UNSET: + field_dict["value"] = value + if date is not UNSET: + field_dict["date"] = date + if id is not UNSET: + field_dict["id"] = id + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + value = d.pop("value", UNSET) + + date = d.pop("date", UNSET) + + id = d.pop("id", UNSET) + + body_value_entry_weight_item = cls( + value=value, + date=date, + id=id, + ) + + body_value_entry_weight_item.additional_properties = d + return body_value_entry_weight_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/body_value_update.py b/src/yazio_sdk/models/body_value_update.py new file mode 100644 index 0000000..70feb4c --- /dev/null +++ b/src/yazio_sdk/models/body_value_update.py @@ -0,0 +1,61 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="BodyValueUpdate") + + +@_attrs_define +class BodyValueUpdate: + """ + Attributes: + value (float | Unset): + """ + + value: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + value = self.value + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if value is not UNSET: + field_dict["value"] = value + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + value = d.pop("value", UNSET) + + body_value_update = cls( + value=value, + ) + + body_value_update.additional_properties = d + return body_value_update + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/buddy.py b/src/yazio_sdk/models/buddy.py new file mode 100644 index 0000000..b082411 --- /dev/null +++ b/src/yazio_sdk/models/buddy.py @@ -0,0 +1,279 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.buddy_exercise import BuddyExercise + from ..models.streak_calendar import StreakCalendar + + +T = TypeVar("T", bound="Buddy") + + +@_attrs_define +class Buddy: + """ + Attributes: + user_uuid (str | Unset): + name (str | Unset): + energy_goal (float | Unset): + protein_goal (float | Unset): + carb_goal (float | Unset): + fat_goal (float | Unset): + consumed_energy (float | Unset): + consumed_protein (float | Unset): + consumed_carb (float | Unset): + consumed_fat (float | Unset): + water_intake_goal (float | Unset): + goal (str | Unset): + start_weight (float | Unset): + weight_goal (float | Unset): + weight (float | Unset): + date_of_birth (str | Unset): + favorite_recipes (list[str] | Unset): + exercises (list[BuddyExercise] | Unset): + sex (str | Unset): + weight_change_per_week (float | Unset): + consume_activity_calories (bool | Unset): + streak (StreakCalendar | Unset): + """ + + user_uuid: str | Unset = UNSET + name: str | Unset = UNSET + energy_goal: float | Unset = UNSET + protein_goal: float | Unset = UNSET + carb_goal: float | Unset = UNSET + fat_goal: float | Unset = UNSET + consumed_energy: float | Unset = UNSET + consumed_protein: float | Unset = UNSET + consumed_carb: float | Unset = UNSET + consumed_fat: float | Unset = UNSET + water_intake_goal: float | Unset = UNSET + goal: str | Unset = UNSET + start_weight: float | Unset = UNSET + weight_goal: float | Unset = UNSET + weight: float | Unset = UNSET + date_of_birth: str | Unset = UNSET + favorite_recipes: list[str] | Unset = UNSET + exercises: list[BuddyExercise] | Unset = UNSET + sex: str | Unset = UNSET + weight_change_per_week: float | Unset = UNSET + consume_activity_calories: bool | Unset = UNSET + streak: StreakCalendar | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + user_uuid = self.user_uuid + + name = self.name + + energy_goal = self.energy_goal + + protein_goal = self.protein_goal + + carb_goal = self.carb_goal + + fat_goal = self.fat_goal + + consumed_energy = self.consumed_energy + + consumed_protein = self.consumed_protein + + consumed_carb = self.consumed_carb + + consumed_fat = self.consumed_fat + + water_intake_goal = self.water_intake_goal + + goal = self.goal + + start_weight = self.start_weight + + weight_goal = self.weight_goal + + weight = self.weight + + date_of_birth = self.date_of_birth + + favorite_recipes: list[str] | Unset = UNSET + if not isinstance(self.favorite_recipes, Unset): + favorite_recipes = self.favorite_recipes + + exercises: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.exercises, Unset): + exercises = [] + for exercises_item_data in self.exercises: + exercises_item = exercises_item_data.to_dict() + exercises.append(exercises_item) + + sex = self.sex + + weight_change_per_week = self.weight_change_per_week + + consume_activity_calories = self.consume_activity_calories + + streak: dict[str, Any] | Unset = UNSET + if not isinstance(self.streak, Unset): + streak = self.streak.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if user_uuid is not UNSET: + field_dict["user_uuid"] = user_uuid + if name is not UNSET: + field_dict["name"] = name + if energy_goal is not UNSET: + field_dict["energy_goal"] = energy_goal + if protein_goal is not UNSET: + field_dict["protein_goal"] = protein_goal + if carb_goal is not UNSET: + field_dict["carb_goal"] = carb_goal + if fat_goal is not UNSET: + field_dict["fat_goal"] = fat_goal + if consumed_energy is not UNSET: + field_dict["consumed_energy"] = consumed_energy + if consumed_protein is not UNSET: + field_dict["consumed_protein"] = consumed_protein + if consumed_carb is not UNSET: + field_dict["consumed_carb"] = consumed_carb + if consumed_fat is not UNSET: + field_dict["consumed_fat"] = consumed_fat + if water_intake_goal is not UNSET: + field_dict["water_intake_goal"] = water_intake_goal + if goal is not UNSET: + field_dict["goal"] = goal + if start_weight is not UNSET: + field_dict["start_weight"] = start_weight + if weight_goal is not UNSET: + field_dict["weight_goal"] = weight_goal + if weight is not UNSET: + field_dict["weight"] = weight + if date_of_birth is not UNSET: + field_dict["date_of_birth"] = date_of_birth + if favorite_recipes is not UNSET: + field_dict["favorite_recipes"] = favorite_recipes + if exercises is not UNSET: + field_dict["exercises"] = exercises + if sex is not UNSET: + field_dict["sex"] = sex + if weight_change_per_week is not UNSET: + field_dict["weight_change_per_week"] = weight_change_per_week + if consume_activity_calories is not UNSET: + field_dict["consume_activity_calories"] = consume_activity_calories + if streak is not UNSET: + field_dict["streak"] = streak + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.buddy_exercise import BuddyExercise + from ..models.streak_calendar import StreakCalendar + + d = dict(src_dict) + user_uuid = d.pop("user_uuid", UNSET) + + name = d.pop("name", UNSET) + + energy_goal = d.pop("energy_goal", UNSET) + + protein_goal = d.pop("protein_goal", UNSET) + + carb_goal = d.pop("carb_goal", UNSET) + + fat_goal = d.pop("fat_goal", UNSET) + + consumed_energy = d.pop("consumed_energy", UNSET) + + consumed_protein = d.pop("consumed_protein", UNSET) + + consumed_carb = d.pop("consumed_carb", UNSET) + + consumed_fat = d.pop("consumed_fat", UNSET) + + water_intake_goal = d.pop("water_intake_goal", UNSET) + + goal = d.pop("goal", UNSET) + + start_weight = d.pop("start_weight", UNSET) + + weight_goal = d.pop("weight_goal", UNSET) + + weight = d.pop("weight", UNSET) + + date_of_birth = d.pop("date_of_birth", UNSET) + + favorite_recipes = cast(list[str], d.pop("favorite_recipes", UNSET)) + + _exercises = d.pop("exercises", UNSET) + exercises: list[BuddyExercise] | Unset = UNSET + if _exercises is not UNSET: + exercises = [] + for exercises_item_data in _exercises: + exercises_item = BuddyExercise.from_dict(exercises_item_data) + + exercises.append(exercises_item) + + sex = d.pop("sex", UNSET) + + weight_change_per_week = d.pop("weight_change_per_week", UNSET) + + consume_activity_calories = d.pop("consume_activity_calories", UNSET) + + _streak = d.pop("streak", UNSET) + streak: StreakCalendar | Unset + if isinstance(_streak, Unset): + streak = UNSET + else: + streak = StreakCalendar.from_dict(_streak) + + buddy = cls( + user_uuid=user_uuid, + name=name, + energy_goal=energy_goal, + protein_goal=protein_goal, + carb_goal=carb_goal, + fat_goal=fat_goal, + consumed_energy=consumed_energy, + consumed_protein=consumed_protein, + consumed_carb=consumed_carb, + consumed_fat=consumed_fat, + water_intake_goal=water_intake_goal, + goal=goal, + start_weight=start_weight, + weight_goal=weight_goal, + weight=weight, + date_of_birth=date_of_birth, + favorite_recipes=favorite_recipes, + exercises=exercises, + sex=sex, + weight_change_per_week=weight_change_per_week, + consume_activity_calories=consume_activity_calories, + streak=streak, + ) + + buddy.additional_properties = d + return buddy + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/buddy_exercise.py b/src/yazio_sdk/models/buddy_exercise.py new file mode 100644 index 0000000..15c8d72 --- /dev/null +++ b/src/yazio_sdk/models/buddy_exercise.py @@ -0,0 +1,70 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="BuddyExercise") + + +@_attrs_define +class BuddyExercise: + """ + Attributes: + steps (float | Unset): + calories (float | Unset): + """ + + steps: float | Unset = UNSET + calories: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + steps = self.steps + + calories = self.calories + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if steps is not UNSET: + field_dict["steps"] = steps + if calories is not UNSET: + field_dict["calories"] = calories + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + steps = d.pop("steps", UNSET) + + calories = d.pop("calories", UNSET) + + buddy_exercise = cls( + steps=steps, + calories=calories, + ) + + buddy_exercise.additional_properties = d + return buddy_exercise + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/changes_indicator.py b/src/yazio_sdk/models/changes_indicator.py new file mode 100644 index 0000000..8ea388a --- /dev/null +++ b/src/yazio_sdk/models/changes_indicator.py @@ -0,0 +1,79 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ChangesIndicator") + + +@_attrs_define +class ChangesIndicator: + """ + Attributes: + exercises (float | Unset): + body_values (float | Unset): + consumed_items (float | Unset): + """ + + exercises: float | Unset = UNSET + body_values: float | Unset = UNSET + consumed_items: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + exercises = self.exercises + + body_values = self.body_values + + consumed_items = self.consumed_items + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if exercises is not UNSET: + field_dict["exercises"] = exercises + if body_values is not UNSET: + field_dict["body_values"] = body_values + if consumed_items is not UNSET: + field_dict["consumed_items"] = consumed_items + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + exercises = d.pop("exercises", UNSET) + + body_values = d.pop("body_values", UNSET) + + consumed_items = d.pop("consumed_items", UNSET) + + changes_indicator = cls( + exercises=exercises, + body_values=body_values, + consumed_items=consumed_items, + ) + + changes_indicator.additional_properties = d + return changes_indicator + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/claimables.py b/src/yazio_sdk/models/claimables.py new file mode 100644 index 0000000..e452c89 --- /dev/null +++ b/src/yazio_sdk/models/claimables.py @@ -0,0 +1,63 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="Claimables") + + +@_attrs_define +class Claimables: + """ + Attributes: + claimables (list[Any] | Unset): + """ + + claimables: list[Any] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + claimables: list[Any] | Unset = UNSET + if not isinstance(self.claimables, Unset): + claimables = self.claimables + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if claimables is not UNSET: + field_dict["claimables"] = claimables + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + claimables = cast(list[Any], d.pop("claimables", UNSET)) + + claimables = cls( + claimables=claimables, + ) + + claimables.additional_properties = d + return claimables + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/consumed_items.py b/src/yazio_sdk/models/consumed_items.py new file mode 100644 index 0000000..c70cb58 --- /dev/null +++ b/src/yazio_sdk/models/consumed_items.py @@ -0,0 +1,113 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.consumed_items_products_item import ConsumedItemsProductsItem + from ..models.consumed_recipe_portion import ConsumedRecipePortion + + +T = TypeVar("T", bound="ConsumedItems") + + +@_attrs_define +class ConsumedItems: + """ + Attributes: + products (list[ConsumedItemsProductsItem] | Unset): + recipe_portions (list[ConsumedRecipePortion] | Unset): + simple_products (list[Any] | Unset): + """ + + products: list[ConsumedItemsProductsItem] | Unset = UNSET + recipe_portions: list[ConsumedRecipePortion] | Unset = UNSET + simple_products: list[Any] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + products: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.products, Unset): + products = [] + for products_item_data in self.products: + products_item = products_item_data.to_dict() + products.append(products_item) + + recipe_portions: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.recipe_portions, Unset): + recipe_portions = [] + for recipe_portions_item_data in self.recipe_portions: + recipe_portions_item = recipe_portions_item_data.to_dict() + recipe_portions.append(recipe_portions_item) + + simple_products: list[Any] | Unset = UNSET + if not isinstance(self.simple_products, Unset): + simple_products = self.simple_products + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if products is not UNSET: + field_dict["products"] = products + if recipe_portions is not UNSET: + field_dict["recipe_portions"] = recipe_portions + if simple_products is not UNSET: + field_dict["simple_products"] = simple_products + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.consumed_items_products_item import ConsumedItemsProductsItem + from ..models.consumed_recipe_portion import ConsumedRecipePortion + + d = dict(src_dict) + _products = d.pop("products", UNSET) + products: list[ConsumedItemsProductsItem] | Unset = UNSET + if _products is not UNSET: + products = [] + for products_item_data in _products: + products_item = ConsumedItemsProductsItem.from_dict(products_item_data) + + products.append(products_item) + + _recipe_portions = d.pop("recipe_portions", UNSET) + recipe_portions: list[ConsumedRecipePortion] | Unset = UNSET + if _recipe_portions is not UNSET: + recipe_portions = [] + for recipe_portions_item_data in _recipe_portions: + recipe_portions_item = ConsumedRecipePortion.from_dict(recipe_portions_item_data) + + recipe_portions.append(recipe_portions_item) + + simple_products = cast(list[Any], d.pop("simple_products", UNSET)) + + consumed_items = cls( + products=products, + recipe_portions=recipe_portions, + simple_products=simple_products, + ) + + consumed_items.additional_properties = d + return consumed_items + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/consumed_items_deletion.py b/src/yazio_sdk/models/consumed_items_deletion.py new file mode 100644 index 0000000..74593ef --- /dev/null +++ b/src/yazio_sdk/models/consumed_items_deletion.py @@ -0,0 +1,82 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ConsumedItemsDeletion") + + +@_attrs_define +class ConsumedItemsDeletion: + """Body of DELETE /v22/user/consumed-items. Each property names one entry by id, as a single string rather than a list + — passing an array is rejected with "This value should be of type string". Note that the endpoint also accepts an + `?id=` query parameter, answers 204, and does nothing at all. + + Attributes: + products (str | Unset): + recipe_portions (str | Unset): + simple_products (str | Unset): + """ + + products: str | Unset = UNSET + recipe_portions: str | Unset = UNSET + simple_products: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + products = self.products + + recipe_portions = self.recipe_portions + + simple_products = self.simple_products + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if products is not UNSET: + field_dict["products"] = products + if recipe_portions is not UNSET: + field_dict["recipe_portions"] = recipe_portions + if simple_products is not UNSET: + field_dict["simple_products"] = simple_products + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + products = d.pop("products", UNSET) + + recipe_portions = d.pop("recipe_portions", UNSET) + + simple_products = d.pop("simple_products", UNSET) + + consumed_items_deletion = cls( + products=products, + recipe_portions=recipe_portions, + simple_products=simple_products, + ) + + consumed_items_deletion.additional_properties = d + return consumed_items_deletion + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/consumed_items_products_item.py b/src/yazio_sdk/models/consumed_items_products_item.py new file mode 100644 index 0000000..14d5471 --- /dev/null +++ b/src/yazio_sdk/models/consumed_items_products_item.py @@ -0,0 +1,146 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ConsumedItemsProductsItem") + + +@_attrs_define +class ConsumedItemsProductsItem: + """ + Attributes: + id (str | Unset): + serving (None | str | Unset): + amount (float | Unset): + daytime (str | Unset): + date (str | Unset): + type_ (str | Unset): + product_id (str | Unset): + serving_quantity (float | None | Unset): + """ + + id: str | Unset = UNSET + serving: None | str | Unset = UNSET + amount: float | Unset = UNSET + daytime: str | Unset = UNSET + date: str | Unset = UNSET + type_: str | Unset = UNSET + product_id: str | Unset = UNSET + serving_quantity: float | None | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + id = self.id + + serving: None | str | Unset + if isinstance(self.serving, Unset): + serving = UNSET + else: + serving = self.serving + + amount = self.amount + + daytime = self.daytime + + date = self.date + + type_ = self.type_ + + product_id = self.product_id + + serving_quantity: float | None | Unset + if isinstance(self.serving_quantity, Unset): + serving_quantity = UNSET + else: + serving_quantity = self.serving_quantity + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if serving is not UNSET: + field_dict["serving"] = serving + if amount is not UNSET: + field_dict["amount"] = amount + if daytime is not UNSET: + field_dict["daytime"] = daytime + if date is not UNSET: + field_dict["date"] = date + if type_ is not UNSET: + field_dict["type"] = type_ + if product_id is not UNSET: + field_dict["product_id"] = product_id + if serving_quantity is not UNSET: + field_dict["serving_quantity"] = serving_quantity + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + id = d.pop("id", UNSET) + + def _parse_serving(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + serving = _parse_serving(d.pop("serving", UNSET)) + + amount = d.pop("amount", UNSET) + + daytime = d.pop("daytime", UNSET) + + date = d.pop("date", UNSET) + + type_ = d.pop("type", UNSET) + + product_id = d.pop("product_id", UNSET) + + def _parse_serving_quantity(data: object) -> float | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(float | None | Unset, data) + + serving_quantity = _parse_serving_quantity(d.pop("serving_quantity", UNSET)) + + consumed_items_products_item = cls( + id=id, + serving=serving, + amount=amount, + daytime=daytime, + date=date, + type_=type_, + product_id=product_id, + serving_quantity=serving_quantity, + ) + + consumed_items_products_item.additional_properties = d + return consumed_items_products_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/consumed_recipe_portion.py b/src/yazio_sdk/models/consumed_recipe_portion.py new file mode 100644 index 0000000..e4f92c1 --- /dev/null +++ b/src/yazio_sdk/models/consumed_recipe_portion.py @@ -0,0 +1,106 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ConsumedRecipePortion") + + +@_attrs_define +class ConsumedRecipePortion: + """ + Attributes: + id (str | Unset): + date (str | Unset): + daytime (str | Unset): + type_ (str | Unset): + recipe_id (str | Unset): + portion_count (float | Unset): + """ + + id: str | Unset = UNSET + date: str | Unset = UNSET + daytime: str | Unset = UNSET + type_: str | Unset = UNSET + recipe_id: str | Unset = UNSET + portion_count: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + id = self.id + + date = self.date + + daytime = self.daytime + + type_ = self.type_ + + recipe_id = self.recipe_id + + portion_count = self.portion_count + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if date is not UNSET: + field_dict["date"] = date + if daytime is not UNSET: + field_dict["daytime"] = daytime + if type_ is not UNSET: + field_dict["type"] = type_ + if recipe_id is not UNSET: + field_dict["recipe_id"] = recipe_id + if portion_count is not UNSET: + field_dict["portion_count"] = portion_count + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + id = d.pop("id", UNSET) + + date = d.pop("date", UNSET) + + daytime = d.pop("daytime", UNSET) + + type_ = d.pop("type", UNSET) + + recipe_id = d.pop("recipe_id", UNSET) + + portion_count = d.pop("portion_count", UNSET) + + consumed_recipe_portion = cls( + id=id, + date=date, + daytime=daytime, + type_=type_, + recipe_id=recipe_id, + portion_count=portion_count, + ) + + consumed_recipe_portion.additional_properties = d + return consumed_recipe_portion + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/daily_exercise_summary.py b/src/yazio_sdk/models/daily_exercise_summary.py new file mode 100644 index 0000000..f8e5e64 --- /dev/null +++ b/src/yazio_sdk/models/daily_exercise_summary.py @@ -0,0 +1,88 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="DailyExerciseSummary") + + +@_attrs_define +class DailyExerciseSummary: + """ + Attributes: + date (str | Unset): + duration (float | Unset): + steps (float | Unset): + energy (float | Unset): + """ + + date: str | Unset = UNSET + duration: float | Unset = UNSET + steps: float | Unset = UNSET + energy: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + date = self.date + + duration = self.duration + + steps = self.steps + + energy = self.energy + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if date is not UNSET: + field_dict["date"] = date + if duration is not UNSET: + field_dict["duration"] = duration + if steps is not UNSET: + field_dict["steps"] = steps + if energy is not UNSET: + field_dict["energy"] = energy + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + date = d.pop("date", UNSET) + + duration = d.pop("duration", UNSET) + + steps = d.pop("steps", UNSET) + + energy = d.pop("energy", UNSET) + + daily_exercise_summary = cls( + date=date, + duration=duration, + steps=steps, + energy=energy, + ) + + daily_exercise_summary.additional_properties = d + return daily_exercise_summary + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/daily_goals.py b/src/yazio_sdk/models/daily_goals.py new file mode 100644 index 0000000..7d21b04 --- /dev/null +++ b/src/yazio_sdk/models/daily_goals.py @@ -0,0 +1,115 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="DailyGoals") + + +@_attrs_define +class DailyGoals: + """ + Attributes: + energy_energy (float | Unset): + water (float | Unset): + activity_step (float | Unset): + nutrient_protein (float | Unset): + nutrient_fat (float | Unset): + nutrient_carb (float | Unset): + bodyvalue_weight (float | Unset): + """ + + energy_energy: float | Unset = UNSET + water: float | Unset = UNSET + activity_step: float | Unset = UNSET + nutrient_protein: float | Unset = UNSET + nutrient_fat: float | Unset = UNSET + nutrient_carb: float | Unset = UNSET + bodyvalue_weight: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + energy_energy = self.energy_energy + + water = self.water + + activity_step = self.activity_step + + nutrient_protein = self.nutrient_protein + + nutrient_fat = self.nutrient_fat + + nutrient_carb = self.nutrient_carb + + bodyvalue_weight = self.bodyvalue_weight + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if energy_energy is not UNSET: + field_dict["energy.energy"] = energy_energy + if water is not UNSET: + field_dict["water"] = water + if activity_step is not UNSET: + field_dict["activity.step"] = activity_step + if nutrient_protein is not UNSET: + field_dict["nutrient.protein"] = nutrient_protein + if nutrient_fat is not UNSET: + field_dict["nutrient.fat"] = nutrient_fat + if nutrient_carb is not UNSET: + field_dict["nutrient.carb"] = nutrient_carb + if bodyvalue_weight is not UNSET: + field_dict["bodyvalue.weight"] = bodyvalue_weight + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + energy_energy = d.pop("energy.energy", UNSET) + + water = d.pop("water", UNSET) + + activity_step = d.pop("activity.step", UNSET) + + nutrient_protein = d.pop("nutrient.protein", UNSET) + + nutrient_fat = d.pop("nutrient.fat", UNSET) + + nutrient_carb = d.pop("nutrient.carb", UNSET) + + bodyvalue_weight = d.pop("bodyvalue.weight", UNSET) + + daily_goals = cls( + energy_energy=energy_energy, + water=water, + activity_step=activity_step, + nutrient_protein=nutrient_protein, + nutrient_fat=nutrient_fat, + nutrient_carb=nutrient_carb, + bodyvalue_weight=bodyvalue_weight, + ) + + daily_goals.additional_properties = d + return daily_goals + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/daily_nutrients.py b/src/yazio_sdk/models/daily_nutrients.py new file mode 100644 index 0000000..0216942 --- /dev/null +++ b/src/yazio_sdk/models/daily_nutrients.py @@ -0,0 +1,106 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="DailyNutrients") + + +@_attrs_define +class DailyNutrients: + """ + Attributes: + date (str | Unset): + energy (float | Unset): + carb (float | Unset): + protein (float | Unset): + fat (float | Unset): + energy_goal (float | Unset): + """ + + date: str | Unset = UNSET + energy: float | Unset = UNSET + carb: float | Unset = UNSET + protein: float | Unset = UNSET + fat: float | Unset = UNSET + energy_goal: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + date = self.date + + energy = self.energy + + carb = self.carb + + protein = self.protein + + fat = self.fat + + energy_goal = self.energy_goal + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if date is not UNSET: + field_dict["date"] = date + if energy is not UNSET: + field_dict["energy"] = energy + if carb is not UNSET: + field_dict["carb"] = carb + if protein is not UNSET: + field_dict["protein"] = protein + if fat is not UNSET: + field_dict["fat"] = fat + if energy_goal is not UNSET: + field_dict["energy_goal"] = energy_goal + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + date = d.pop("date", UNSET) + + energy = d.pop("energy", UNSET) + + carb = d.pop("carb", UNSET) + + protein = d.pop("protein", UNSET) + + fat = d.pop("fat", UNSET) + + energy_goal = d.pop("energy_goal", UNSET) + + daily_nutrients = cls( + date=date, + energy=energy, + carb=carb, + protein=protein, + fat=fat, + energy_goal=energy_goal, + ) + + daily_nutrients.additional_properties = d + return daily_nutrients + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/daily_summary_widget.py b/src/yazio_sdk/models/daily_summary_widget.py new file mode 100644 index 0000000..9fd2f59 --- /dev/null +++ b/src/yazio_sdk/models/daily_summary_widget.py @@ -0,0 +1,221 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.daily_goals import DailyGoals + from ..models.daily_summary_widget_active_fasting_countdown_template_key_type_0 import ( + DailySummaryWidgetActiveFastingCountdownTemplateKeyType0, + ) + from ..models.daily_summary_widget_meals import DailySummaryWidgetMeals + from ..models.daily_summary_widget_units import DailySummaryWidgetUnits + from ..models.daily_summary_widget_user import DailySummaryWidgetUser + + +T = TypeVar("T", bound="DailySummaryWidget") + + +@_attrs_define +class DailySummaryWidget: + """ + Attributes: + activity_energy (float | Unset): + consume_activity_energy (bool | Unset): + steps (float | Unset): + water_intake (float | Unset): + goals (DailyGoals | Unset): + units (DailySummaryWidgetUnits | Unset): + meals (DailySummaryWidgetMeals | Unset): + user (DailySummaryWidgetUser | Unset): + active_fasting_countdown_template_key (DailySummaryWidgetActiveFastingCountdownTemplateKeyType0 | None | Unset): + """ + + activity_energy: float | Unset = UNSET + consume_activity_energy: bool | Unset = UNSET + steps: float | Unset = UNSET + water_intake: float | Unset = UNSET + goals: DailyGoals | Unset = UNSET + units: DailySummaryWidgetUnits | Unset = UNSET + meals: DailySummaryWidgetMeals | Unset = UNSET + user: DailySummaryWidgetUser | Unset = UNSET + active_fasting_countdown_template_key: ( + DailySummaryWidgetActiveFastingCountdownTemplateKeyType0 | None | Unset + ) = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + from ..models.daily_summary_widget_active_fasting_countdown_template_key_type_0 import ( + DailySummaryWidgetActiveFastingCountdownTemplateKeyType0, + ) + + activity_energy = self.activity_energy + + consume_activity_energy = self.consume_activity_energy + + steps = self.steps + + water_intake = self.water_intake + + goals: dict[str, Any] | Unset = UNSET + if not isinstance(self.goals, Unset): + goals = self.goals.to_dict() + + units: dict[str, Any] | Unset = UNSET + if not isinstance(self.units, Unset): + units = self.units.to_dict() + + meals: dict[str, Any] | Unset = UNSET + if not isinstance(self.meals, Unset): + meals = self.meals.to_dict() + + user: dict[str, Any] | Unset = UNSET + if not isinstance(self.user, Unset): + user = self.user.to_dict() + + active_fasting_countdown_template_key: dict[str, Any] | None | Unset + if isinstance(self.active_fasting_countdown_template_key, Unset): + active_fasting_countdown_template_key = UNSET + elif isinstance( + self.active_fasting_countdown_template_key, + DailySummaryWidgetActiveFastingCountdownTemplateKeyType0, + ): + active_fasting_countdown_template_key = ( + self.active_fasting_countdown_template_key.to_dict() + ) + else: + active_fasting_countdown_template_key = self.active_fasting_countdown_template_key + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if activity_energy is not UNSET: + field_dict["activity_energy"] = activity_energy + if consume_activity_energy is not UNSET: + field_dict["consume_activity_energy"] = consume_activity_energy + if steps is not UNSET: + field_dict["steps"] = steps + if water_intake is not UNSET: + field_dict["water_intake"] = water_intake + if goals is not UNSET: + field_dict["goals"] = goals + if units is not UNSET: + field_dict["units"] = units + if meals is not UNSET: + field_dict["meals"] = meals + if user is not UNSET: + field_dict["user"] = user + if active_fasting_countdown_template_key is not UNSET: + field_dict["active_fasting_countdown_template_key"] = ( + active_fasting_countdown_template_key + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.daily_goals import DailyGoals + from ..models.daily_summary_widget_active_fasting_countdown_template_key_type_0 import ( + DailySummaryWidgetActiveFastingCountdownTemplateKeyType0, + ) + from ..models.daily_summary_widget_meals import DailySummaryWidgetMeals + from ..models.daily_summary_widget_units import DailySummaryWidgetUnits + from ..models.daily_summary_widget_user import DailySummaryWidgetUser + + d = dict(src_dict) + activity_energy = d.pop("activity_energy", UNSET) + + consume_activity_energy = d.pop("consume_activity_energy", UNSET) + + steps = d.pop("steps", UNSET) + + water_intake = d.pop("water_intake", UNSET) + + _goals = d.pop("goals", UNSET) + goals: DailyGoals | Unset + if isinstance(_goals, Unset): + goals = UNSET + else: + goals = DailyGoals.from_dict(_goals) + + _units = d.pop("units", UNSET) + units: DailySummaryWidgetUnits | Unset + if isinstance(_units, Unset): + units = UNSET + else: + units = DailySummaryWidgetUnits.from_dict(_units) + + _meals = d.pop("meals", UNSET) + meals: DailySummaryWidgetMeals | Unset + if isinstance(_meals, Unset): + meals = UNSET + else: + meals = DailySummaryWidgetMeals.from_dict(_meals) + + _user = d.pop("user", UNSET) + user: DailySummaryWidgetUser | Unset + if isinstance(_user, Unset): + user = UNSET + else: + user = DailySummaryWidgetUser.from_dict(_user) + + def _parse_active_fasting_countdown_template_key( + data: object, + ) -> DailySummaryWidgetActiveFastingCountdownTemplateKeyType0 | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + active_fasting_countdown_template_key_type_0 = ( + DailySummaryWidgetActiveFastingCountdownTemplateKeyType0.from_dict(data) + ) + + return active_fasting_countdown_template_key_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast( + DailySummaryWidgetActiveFastingCountdownTemplateKeyType0 | None | Unset, data + ) + + active_fasting_countdown_template_key = _parse_active_fasting_countdown_template_key( + d.pop("active_fasting_countdown_template_key", UNSET) + ) + + daily_summary_widget = cls( + activity_energy=activity_energy, + consume_activity_energy=consume_activity_energy, + steps=steps, + water_intake=water_intake, + goals=goals, + units=units, + meals=meals, + user=user, + active_fasting_countdown_template_key=active_fasting_countdown_template_key, + ) + + daily_summary_widget.additional_properties = d + return daily_summary_widget + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/daily_summary_widget_active_fasting_countdown_template_key_type_0.py b/src/yazio_sdk/models/daily_summary_widget_active_fasting_countdown_template_key_type_0.py new file mode 100644 index 0000000..af1e81d --- /dev/null +++ b/src/yazio_sdk/models/daily_summary_widget_active_fasting_countdown_template_key_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="DailySummaryWidgetActiveFastingCountdownTemplateKeyType0") + + +@_attrs_define +class DailySummaryWidgetActiveFastingCountdownTemplateKeyType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + daily_summary_widget_active_fasting_countdown_template_key_type_0 = cls() + + daily_summary_widget_active_fasting_countdown_template_key_type_0.additional_properties = d + return daily_summary_widget_active_fasting_countdown_template_key_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/daily_summary_widget_meals.py b/src/yazio_sdk/models/daily_summary_widget_meals.py new file mode 100644 index 0000000..9a4443d --- /dev/null +++ b/src/yazio_sdk/models/daily_summary_widget_meals.py @@ -0,0 +1,122 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.meal_summary import MealSummary + + +T = TypeVar("T", bound="DailySummaryWidgetMeals") + + +@_attrs_define +class DailySummaryWidgetMeals: + """ + Attributes: + breakfast (MealSummary | Unset): + lunch (MealSummary | Unset): + dinner (MealSummary | Unset): + snack (MealSummary | Unset): + """ + + breakfast: MealSummary | Unset = UNSET + lunch: MealSummary | Unset = UNSET + dinner: MealSummary | Unset = UNSET + snack: MealSummary | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + breakfast: dict[str, Any] | Unset = UNSET + if not isinstance(self.breakfast, Unset): + breakfast = self.breakfast.to_dict() + + lunch: dict[str, Any] | Unset = UNSET + if not isinstance(self.lunch, Unset): + lunch = self.lunch.to_dict() + + dinner: dict[str, Any] | Unset = UNSET + if not isinstance(self.dinner, Unset): + dinner = self.dinner.to_dict() + + snack: dict[str, Any] | Unset = UNSET + if not isinstance(self.snack, Unset): + snack = self.snack.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if breakfast is not UNSET: + field_dict["breakfast"] = breakfast + if lunch is not UNSET: + field_dict["lunch"] = lunch + if dinner is not UNSET: + field_dict["dinner"] = dinner + if snack is not UNSET: + field_dict["snack"] = snack + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.meal_summary import MealSummary + + d = dict(src_dict) + _breakfast = d.pop("breakfast", UNSET) + breakfast: MealSummary | Unset + if isinstance(_breakfast, Unset): + breakfast = UNSET + else: + breakfast = MealSummary.from_dict(_breakfast) + + _lunch = d.pop("lunch", UNSET) + lunch: MealSummary | Unset + if isinstance(_lunch, Unset): + lunch = UNSET + else: + lunch = MealSummary.from_dict(_lunch) + + _dinner = d.pop("dinner", UNSET) + dinner: MealSummary | Unset + if isinstance(_dinner, Unset): + dinner = UNSET + else: + dinner = MealSummary.from_dict(_dinner) + + _snack = d.pop("snack", UNSET) + snack: MealSummary | Unset + if isinstance(_snack, Unset): + snack = UNSET + else: + snack = MealSummary.from_dict(_snack) + + daily_summary_widget_meals = cls( + breakfast=breakfast, + lunch=lunch, + dinner=dinner, + snack=snack, + ) + + daily_summary_widget_meals.additional_properties = d + return daily_summary_widget_meals + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/daily_summary_widget_units.py b/src/yazio_sdk/models/daily_summary_widget_units.py new file mode 100644 index 0000000..dfb0a22 --- /dev/null +++ b/src/yazio_sdk/models/daily_summary_widget_units.py @@ -0,0 +1,88 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="DailySummaryWidgetUnits") + + +@_attrs_define +class DailySummaryWidgetUnits: + """ + Attributes: + unit_mass (str | Unset): + unit_energy (str | Unset): + unit_serving (str | Unset): + unit_length (str | Unset): + """ + + unit_mass: str | Unset = UNSET + unit_energy: str | Unset = UNSET + unit_serving: str | Unset = UNSET + unit_length: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + unit_mass = self.unit_mass + + unit_energy = self.unit_energy + + unit_serving = self.unit_serving + + unit_length = self.unit_length + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if unit_mass is not UNSET: + field_dict["unit_mass"] = unit_mass + if unit_energy is not UNSET: + field_dict["unit_energy"] = unit_energy + if unit_serving is not UNSET: + field_dict["unit_serving"] = unit_serving + if unit_length is not UNSET: + field_dict["unit_length"] = unit_length + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + unit_mass = d.pop("unit_mass", UNSET) + + unit_energy = d.pop("unit_energy", UNSET) + + unit_serving = d.pop("unit_serving", UNSET) + + unit_length = d.pop("unit_length", UNSET) + + daily_summary_widget_units = cls( + unit_mass=unit_mass, + unit_energy=unit_energy, + unit_serving=unit_serving, + unit_length=unit_length, + ) + + daily_summary_widget_units.additional_properties = d + return daily_summary_widget_units + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/daily_summary_widget_user.py b/src/yazio_sdk/models/daily_summary_widget_user.py new file mode 100644 index 0000000..57eec90 --- /dev/null +++ b/src/yazio_sdk/models/daily_summary_widget_user.py @@ -0,0 +1,88 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="DailySummaryWidgetUser") + + +@_attrs_define +class DailySummaryWidgetUser: + """ + Attributes: + start_weight (float | Unset): + current_weight (float | Unset): + goal (str | Unset): + sex (str | Unset): + """ + + start_weight: float | Unset = UNSET + current_weight: float | Unset = UNSET + goal: str | Unset = UNSET + sex: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + start_weight = self.start_weight + + current_weight = self.current_weight + + goal = self.goal + + sex = self.sex + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if start_weight is not UNSET: + field_dict["start_weight"] = start_weight + if current_weight is not UNSET: + field_dict["current_weight"] = current_weight + if goal is not UNSET: + field_dict["goal"] = goal + if sex is not UNSET: + field_dict["sex"] = sex + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + start_weight = d.pop("start_weight", UNSET) + + current_weight = d.pop("current_weight", UNSET) + + goal = d.pop("goal", UNSET) + + sex = d.pop("sex", UNSET) + + daily_summary_widget_user = cls( + start_weight=start_weight, + current_weight=current_weight, + goal=goal, + sex=sex, + ) + + daily_summary_widget_user.additional_properties = d + return daily_summary_widget_user + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/daily_tips_request.py b/src/yazio_sdk/models/daily_tips_request.py new file mode 100644 index 0000000..788595b --- /dev/null +++ b/src/yazio_sdk/models/daily_tips_request.py @@ -0,0 +1,151 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.daily_tips_request_experiments_item import DailyTipsRequestExperimentsItem + + +T = TypeVar("T", bound="DailyTipsRequest") + + +@_attrs_define +class DailyTipsRequest: + """ + Attributes: + request_uuid (str | Unset): + device_uuid (str | Unset): + app_version (str | Unset): + platform (str | Unset): + session_id (str | Unset): + delivery_mode (str | Unset): + experiments (list[DailyTipsRequestExperimentsItem] | Unset): + requested_at (float | Unset): + language (str | Unset): + """ + + request_uuid: str | Unset = UNSET + device_uuid: str | Unset = UNSET + app_version: str | Unset = UNSET + platform: str | Unset = UNSET + session_id: str | Unset = UNSET + delivery_mode: str | Unset = UNSET + experiments: list[DailyTipsRequestExperimentsItem] | Unset = UNSET + requested_at: float | Unset = UNSET + language: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + request_uuid = self.request_uuid + + device_uuid = self.device_uuid + + app_version = self.app_version + + platform = self.platform + + session_id = self.session_id + + delivery_mode = self.delivery_mode + + experiments: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.experiments, Unset): + experiments = [] + for experiments_item_data in self.experiments: + experiments_item = experiments_item_data.to_dict() + experiments.append(experiments_item) + + requested_at = self.requested_at + + language = self.language + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if request_uuid is not UNSET: + field_dict["request_uuid"] = request_uuid + if device_uuid is not UNSET: + field_dict["device_uuid"] = device_uuid + if app_version is not UNSET: + field_dict["app_version"] = app_version + if platform is not UNSET: + field_dict["platform"] = platform + if session_id is not UNSET: + field_dict["session_id"] = session_id + if delivery_mode is not UNSET: + field_dict["delivery_mode"] = delivery_mode + if experiments is not UNSET: + field_dict["experiments"] = experiments + if requested_at is not UNSET: + field_dict["requested_at"] = requested_at + if language is not UNSET: + field_dict["language"] = language + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.daily_tips_request_experiments_item import DailyTipsRequestExperimentsItem + + d = dict(src_dict) + request_uuid = d.pop("request_uuid", UNSET) + + device_uuid = d.pop("device_uuid", UNSET) + + app_version = d.pop("app_version", UNSET) + + platform = d.pop("platform", UNSET) + + session_id = d.pop("session_id", UNSET) + + delivery_mode = d.pop("delivery_mode", UNSET) + + _experiments = d.pop("experiments", UNSET) + experiments: list[DailyTipsRequestExperimentsItem] | Unset = UNSET + if _experiments is not UNSET: + experiments = [] + for experiments_item_data in _experiments: + experiments_item = DailyTipsRequestExperimentsItem.from_dict(experiments_item_data) + + experiments.append(experiments_item) + + requested_at = d.pop("requested_at", UNSET) + + language = d.pop("language", UNSET) + + daily_tips_request = cls( + request_uuid=request_uuid, + device_uuid=device_uuid, + app_version=app_version, + platform=platform, + session_id=session_id, + delivery_mode=delivery_mode, + experiments=experiments, + requested_at=requested_at, + language=language, + ) + + daily_tips_request.additional_properties = d + return daily_tips_request + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/daily_tips_request_experiments_item.py b/src/yazio_sdk/models/daily_tips_request_experiments_item.py new file mode 100644 index 0000000..1644646 --- /dev/null +++ b/src/yazio_sdk/models/daily_tips_request_experiments_item.py @@ -0,0 +1,70 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="DailyTipsRequestExperimentsItem") + + +@_attrs_define +class DailyTipsRequestExperimentsItem: + """ + Attributes: + variant (str | Unset): + experiment (str | Unset): + """ + + variant: str | Unset = UNSET + experiment: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + variant = self.variant + + experiment = self.experiment + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if variant is not UNSET: + field_dict["variant"] = variant + if experiment is not UNSET: + field_dict["experiment"] = experiment + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + variant = d.pop("variant", UNSET) + + experiment = d.pop("experiment", UNSET) + + daily_tips_request_experiments_item = cls( + variant=variant, + experiment=experiment, + ) + + daily_tips_request_experiments_item.additional_properties = d + return daily_tips_request_experiments_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/dietary_preferences.py b/src/yazio_sdk/models/dietary_preferences.py new file mode 100644 index 0000000..4ee878b --- /dev/null +++ b/src/yazio_sdk/models/dietary_preferences.py @@ -0,0 +1,95 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.dietary_preferences_restriction_type_0 import DietaryPreferencesRestrictionType0 + + +T = TypeVar("T", bound="DietaryPreferences") + + +@_attrs_define +class DietaryPreferences: + """ + Attributes: + restriction (DietaryPreferencesRestrictionType0 | None | Unset): + """ + + restriction: DietaryPreferencesRestrictionType0 | None | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + from ..models.dietary_preferences_restriction_type_0 import ( + DietaryPreferencesRestrictionType0, + ) + + restriction: dict[str, Any] | None | Unset + if isinstance(self.restriction, Unset): + restriction = UNSET + elif isinstance(self.restriction, DietaryPreferencesRestrictionType0): + restriction = self.restriction.to_dict() + else: + restriction = self.restriction + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if restriction is not UNSET: + field_dict["restriction"] = restriction + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.dietary_preferences_restriction_type_0 import ( + DietaryPreferencesRestrictionType0, + ) + + d = dict(src_dict) + + def _parse_restriction(data: object) -> DietaryPreferencesRestrictionType0 | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + restriction_type_0 = DietaryPreferencesRestrictionType0.from_dict(data) + + return restriction_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(DietaryPreferencesRestrictionType0 | None | Unset, data) + + restriction = _parse_restriction(d.pop("restriction", UNSET)) + + dietary_preferences = cls( + restriction=restriction, + ) + + dietary_preferences.additional_properties = d + return dietary_preferences + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/dietary_preferences_restriction_type_0.py b/src/yazio_sdk/models/dietary_preferences_restriction_type_0.py new file mode 100644 index 0000000..3c9a65d --- /dev/null +++ b/src/yazio_sdk/models/dietary_preferences_restriction_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="DietaryPreferencesRestrictionType0") + + +@_attrs_define +class DietaryPreferencesRestrictionType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + dietary_preferences_restriction_type_0 = cls() + + dietary_preferences_restriction_type_0.additional_properties = d + return dietary_preferences_restriction_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/exercise_entry.py b/src/yazio_sdk/models/exercise_entry.py new file mode 100644 index 0000000..aea5a24 --- /dev/null +++ b/src/yazio_sdk/models/exercise_entry.py @@ -0,0 +1,79 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.exercise_entry_activity_item import ExerciseEntryActivityItem + + +T = TypeVar("T", bound="ExerciseEntry") + + +@_attrs_define +class ExerciseEntry: + """ + Attributes: + activity (list[ExerciseEntryActivityItem] | Unset): + """ + + activity: list[ExerciseEntryActivityItem] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + activity: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.activity, Unset): + activity = [] + for activity_item_data in self.activity: + activity_item = activity_item_data.to_dict() + activity.append(activity_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if activity is not UNSET: + field_dict["activity"] = activity + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.exercise_entry_activity_item import ExerciseEntryActivityItem + + d = dict(src_dict) + _activity = d.pop("activity", UNSET) + activity: list[ExerciseEntryActivityItem] | Unset = UNSET + if _activity is not UNSET: + activity = [] + for activity_item_data in _activity: + activity_item = ExerciseEntryActivityItem.from_dict(activity_item_data) + + activity.append(activity_item) + + exercise_entry = cls( + activity=activity, + ) + + exercise_entry.additional_properties = d + return exercise_entry + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/exercise_entry_activity_item.py b/src/yazio_sdk/models/exercise_entry_activity_item.py new file mode 100644 index 0000000..3dfcc7f --- /dev/null +++ b/src/yazio_sdk/models/exercise_entry_activity_item.py @@ -0,0 +1,97 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ExerciseEntryActivityItem") + + +@_attrs_define +class ExerciseEntryActivityItem: + """ + Attributes: + date (str | Unset): + energy (float | Unset): + steps (float | Unset): + distance (float | Unset): + gateway (str | Unset): + """ + + date: str | Unset = UNSET + energy: float | Unset = UNSET + steps: float | Unset = UNSET + distance: float | Unset = UNSET + gateway: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + date = self.date + + energy = self.energy + + steps = self.steps + + distance = self.distance + + gateway = self.gateway + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if date is not UNSET: + field_dict["date"] = date + if energy is not UNSET: + field_dict["energy"] = energy + if steps is not UNSET: + field_dict["steps"] = steps + if distance is not UNSET: + field_dict["distance"] = distance + if gateway is not UNSET: + field_dict["gateway"] = gateway + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + date = d.pop("date", UNSET) + + energy = d.pop("energy", UNSET) + + steps = d.pop("steps", UNSET) + + distance = d.pop("distance", UNSET) + + gateway = d.pop("gateway", UNSET) + + exercise_entry_activity_item = cls( + date=date, + energy=energy, + steps=steps, + distance=distance, + gateway=gateway, + ) + + exercise_entry_activity_item.additional_properties = d + return exercise_entry_activity_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/exercise_log.py b/src/yazio_sdk/models/exercise_log.py new file mode 100644 index 0000000..7ad3d7e --- /dev/null +++ b/src/yazio_sdk/models/exercise_log.py @@ -0,0 +1,96 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.exercise_log_activity import ExerciseLogActivity + + +T = TypeVar("T", bound="ExerciseLog") + + +@_attrs_define +class ExerciseLog: + """ + Attributes: + training (list[Any] | Unset): + custom_training (list[Any] | Unset): + activity (ExerciseLogActivity | Unset): + """ + + training: list[Any] | Unset = UNSET + custom_training: list[Any] | Unset = UNSET + activity: ExerciseLogActivity | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + training: list[Any] | Unset = UNSET + if not isinstance(self.training, Unset): + training = self.training + + custom_training: list[Any] | Unset = UNSET + if not isinstance(self.custom_training, Unset): + custom_training = self.custom_training + + activity: dict[str, Any] | Unset = UNSET + if not isinstance(self.activity, Unset): + activity = self.activity.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if training is not UNSET: + field_dict["training"] = training + if custom_training is not UNSET: + field_dict["custom_training"] = custom_training + if activity is not UNSET: + field_dict["activity"] = activity + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.exercise_log_activity import ExerciseLogActivity + + d = dict(src_dict) + training = cast(list[Any], d.pop("training", UNSET)) + + custom_training = cast(list[Any], d.pop("custom_training", UNSET)) + + _activity = d.pop("activity", UNSET) + activity: ExerciseLogActivity | Unset + if isinstance(_activity, Unset): + activity = UNSET + else: + activity = ExerciseLogActivity.from_dict(_activity) + + exercise_log = cls( + training=training, + custom_training=custom_training, + activity=activity, + ) + + exercise_log.additional_properties = d + return exercise_log + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/exercise_log_activity.py b/src/yazio_sdk/models/exercise_log_activity.py new file mode 100644 index 0000000..a4aef03 --- /dev/null +++ b/src/yazio_sdk/models/exercise_log_activity.py @@ -0,0 +1,135 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.exercise_log_activity_source_type_0 import ExerciseLogActivitySourceType0 + + +T = TypeVar("T", bound="ExerciseLogActivity") + + +@_attrs_define +class ExerciseLogActivity: + """ + Attributes: + energy (float | Unset): + distance (float | Unset): + duration (float | Unset): + source (ExerciseLogActivitySourceType0 | None | Unset): + gateway (str | Unset): + steps (float | Unset): + """ + + energy: float | Unset = UNSET + distance: float | Unset = UNSET + duration: float | Unset = UNSET + source: ExerciseLogActivitySourceType0 | None | Unset = UNSET + gateway: str | Unset = UNSET + steps: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + from ..models.exercise_log_activity_source_type_0 import ExerciseLogActivitySourceType0 + + energy = self.energy + + distance = self.distance + + duration = self.duration + + source: dict[str, Any] | None | Unset + if isinstance(self.source, Unset): + source = UNSET + elif isinstance(self.source, ExerciseLogActivitySourceType0): + source = self.source.to_dict() + else: + source = self.source + + gateway = self.gateway + + steps = self.steps + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if energy is not UNSET: + field_dict["energy"] = energy + if distance is not UNSET: + field_dict["distance"] = distance + if duration is not UNSET: + field_dict["duration"] = duration + if source is not UNSET: + field_dict["source"] = source + if gateway is not UNSET: + field_dict["gateway"] = gateway + if steps is not UNSET: + field_dict["steps"] = steps + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.exercise_log_activity_source_type_0 import ExerciseLogActivitySourceType0 + + d = dict(src_dict) + energy = d.pop("energy", UNSET) + + distance = d.pop("distance", UNSET) + + duration = d.pop("duration", UNSET) + + def _parse_source(data: object) -> ExerciseLogActivitySourceType0 | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + source_type_0 = ExerciseLogActivitySourceType0.from_dict(data) + + return source_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(ExerciseLogActivitySourceType0 | None | Unset, data) + + source = _parse_source(d.pop("source", UNSET)) + + gateway = d.pop("gateway", UNSET) + + steps = d.pop("steps", UNSET) + + exercise_log_activity = cls( + energy=energy, + distance=distance, + duration=duration, + source=source, + gateway=gateway, + steps=steps, + ) + + exercise_log_activity.additional_properties = d + return exercise_log_activity + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/exercise_log_activity_source_type_0.py b/src/yazio_sdk/models/exercise_log_activity_source_type_0.py new file mode 100644 index 0000000..774fb15 --- /dev/null +++ b/src/yazio_sdk/models/exercise_log_activity_source_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ExerciseLogActivitySourceType0") + + +@_attrs_define +class ExerciseLogActivitySourceType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + exercise_log_activity_source_type_0 = cls() + + exercise_log_activity_source_type_0.additional_properties = d + return exercise_log_activity_source_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/fasting_participants.py b/src/yazio_sdk/models/fasting_participants.py new file mode 100644 index 0000000..93d9ff9 --- /dev/null +++ b/src/yazio_sdk/models/fasting_participants.py @@ -0,0 +1,79 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="FastingParticipants") + + +@_attrs_define +class FastingParticipants: + """ + Attributes: + initial_number_of_participants (float | Unset): + growth_per_year (float | Unset): + growth_start (str | Unset): + """ + + initial_number_of_participants: float | Unset = UNSET + growth_per_year: float | Unset = UNSET + growth_start: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + initial_number_of_participants = self.initial_number_of_participants + + growth_per_year = self.growth_per_year + + growth_start = self.growth_start + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if initial_number_of_participants is not UNSET: + field_dict["initial_number_of_participants"] = initial_number_of_participants + if growth_per_year is not UNSET: + field_dict["growth_per_year"] = growth_per_year + if growth_start is not UNSET: + field_dict["growth_start"] = growth_start + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + initial_number_of_participants = d.pop("initial_number_of_participants", UNSET) + + growth_per_year = d.pop("growth_per_year", UNSET) + + growth_start = d.pop("growth_start", UNSET) + + fasting_participants = cls( + initial_number_of_participants=initial_number_of_participants, + growth_per_year=growth_per_year, + growth_start=growth_start, + ) + + fasting_participants.additional_properties = d + return fasting_participants + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/fasting_period_boundary.py b/src/yazio_sdk/models/fasting_period_boundary.py new file mode 100644 index 0000000..fccb54e --- /dev/null +++ b/src/yazio_sdk/models/fasting_period_boundary.py @@ -0,0 +1,70 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="FastingPeriodBoundary") + + +@_attrs_define +class FastingPeriodBoundary: + """ + Attributes: + day (float | Unset): + time (str | Unset): + """ + + day: float | Unset = UNSET + time: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + day = self.day + + time = self.time + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if day is not UNSET: + field_dict["day"] = day + if time is not UNSET: + field_dict["time"] = time + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + day = d.pop("day", UNSET) + + time = d.pop("time", UNSET) + + fasting_period_boundary = cls( + day=day, + time=time, + ) + + fasting_period_boundary.additional_properties = d + return fasting_period_boundary + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/fasting_template.py b/src/yazio_sdk/models/fasting_template.py new file mode 100644 index 0000000..e01dcb6 --- /dev/null +++ b/src/yazio_sdk/models/fasting_template.py @@ -0,0 +1,158 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.fasting_template_fasting_periods_item import FastingTemplateFastingPeriodsItem + from ..models.fasting_template_preset_type_0 import FastingTemplatePresetType0 + from ..models.fasting_tip import FastingTip + + +T = TypeVar("T", bound="FastingTemplate") + + +@_attrs_define +class FastingTemplate: + """ + Attributes: + key (str | Unset): + fasting_periods (list[FastingTemplateFastingPeriodsItem] | Unset): + fasting_days (list[Any] | Unset): + preset (FastingTemplatePresetType0 | None | Unset): + fasting_tips (list[FastingTip] | Unset): + """ + + key: str | Unset = UNSET + fasting_periods: list[FastingTemplateFastingPeriodsItem] | Unset = UNSET + fasting_days: list[Any] | Unset = UNSET + preset: FastingTemplatePresetType0 | None | Unset = UNSET + fasting_tips: list[FastingTip] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + from ..models.fasting_template_preset_type_0 import FastingTemplatePresetType0 + + key = self.key + + fasting_periods: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.fasting_periods, Unset): + fasting_periods = [] + for fasting_periods_item_data in self.fasting_periods: + fasting_periods_item = fasting_periods_item_data.to_dict() + fasting_periods.append(fasting_periods_item) + + fasting_days: list[Any] | Unset = UNSET + if not isinstance(self.fasting_days, Unset): + fasting_days = self.fasting_days + + preset: dict[str, Any] | None | Unset + if isinstance(self.preset, Unset): + preset = UNSET + elif isinstance(self.preset, FastingTemplatePresetType0): + preset = self.preset.to_dict() + else: + preset = self.preset + + fasting_tips: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.fasting_tips, Unset): + fasting_tips = [] + for fasting_tips_item_data in self.fasting_tips: + fasting_tips_item = fasting_tips_item_data.to_dict() + fasting_tips.append(fasting_tips_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if key is not UNSET: + field_dict["key"] = key + if fasting_periods is not UNSET: + field_dict["fasting_periods"] = fasting_periods + if fasting_days is not UNSET: + field_dict["fasting_days"] = fasting_days + if preset is not UNSET: + field_dict["preset"] = preset + if fasting_tips is not UNSET: + field_dict["fasting_tips"] = fasting_tips + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.fasting_template_fasting_periods_item import FastingTemplateFastingPeriodsItem + from ..models.fasting_template_preset_type_0 import FastingTemplatePresetType0 + from ..models.fasting_tip import FastingTip + + d = dict(src_dict) + key = d.pop("key", UNSET) + + _fasting_periods = d.pop("fasting_periods", UNSET) + fasting_periods: list[FastingTemplateFastingPeriodsItem] | Unset = UNSET + if _fasting_periods is not UNSET: + fasting_periods = [] + for fasting_periods_item_data in _fasting_periods: + fasting_periods_item = FastingTemplateFastingPeriodsItem.from_dict( + fasting_periods_item_data + ) + + fasting_periods.append(fasting_periods_item) + + fasting_days = cast(list[Any], d.pop("fasting_days", UNSET)) + + def _parse_preset(data: object) -> FastingTemplatePresetType0 | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + preset_type_0 = FastingTemplatePresetType0.from_dict(data) + + return preset_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(FastingTemplatePresetType0 | None | Unset, data) + + preset = _parse_preset(d.pop("preset", UNSET)) + + _fasting_tips = d.pop("fasting_tips", UNSET) + fasting_tips: list[FastingTip] | Unset = UNSET + if _fasting_tips is not UNSET: + fasting_tips = [] + for fasting_tips_item_data in _fasting_tips: + fasting_tips_item = FastingTip.from_dict(fasting_tips_item_data) + + fasting_tips.append(fasting_tips_item) + + fasting_template = cls( + key=key, + fasting_periods=fasting_periods, + fasting_days=fasting_days, + preset=preset, + fasting_tips=fasting_tips, + ) + + fasting_template.additional_properties = d + return fasting_template + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/fasting_template_category.py b/src/yazio_sdk/models/fasting_template_category.py new file mode 100644 index 0000000..5af86a9 --- /dev/null +++ b/src/yazio_sdk/models/fasting_template_category.py @@ -0,0 +1,88 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.fasting_template_group import FastingTemplateGroup + + +T = TypeVar("T", bound="FastingTemplateCategory") + + +@_attrs_define +class FastingTemplateCategory: + """ + Attributes: + name (str | Unset): + groups (list[FastingTemplateGroup] | Unset): + """ + + name: str | Unset = UNSET + groups: list[FastingTemplateGroup] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + name = self.name + + groups: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.groups, Unset): + groups = [] + for groups_item_data in self.groups: + groups_item = groups_item_data.to_dict() + groups.append(groups_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if name is not UNSET: + field_dict["name"] = name + if groups is not UNSET: + field_dict["groups"] = groups + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.fasting_template_group import FastingTemplateGroup + + d = dict(src_dict) + name = d.pop("name", UNSET) + + _groups = d.pop("groups", UNSET) + groups: list[FastingTemplateGroup] | Unset = UNSET + if _groups is not UNSET: + groups = [] + for groups_item_data in _groups: + groups_item = FastingTemplateGroup.from_dict(groups_item_data) + + groups.append(groups_item) + + fasting_template_category = cls( + name=name, + groups=groups, + ) + + fasting_template_category.additional_properties = d + return fasting_template_category + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/fasting_template_fasting_periods_item.py b/src/yazio_sdk/models/fasting_template_fasting_periods_item.py new file mode 100644 index 0000000..20a4c4b --- /dev/null +++ b/src/yazio_sdk/models/fasting_template_fasting_periods_item.py @@ -0,0 +1,90 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.fasting_period_boundary import FastingPeriodBoundary + + +T = TypeVar("T", bound="FastingTemplateFastingPeriodsItem") + + +@_attrs_define +class FastingTemplateFastingPeriodsItem: + """ + Attributes: + start (FastingPeriodBoundary | Unset): + end (FastingPeriodBoundary | Unset): + """ + + start: FastingPeriodBoundary | Unset = UNSET + end: FastingPeriodBoundary | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + start: dict[str, Any] | Unset = UNSET + if not isinstance(self.start, Unset): + start = self.start.to_dict() + + end: dict[str, Any] | Unset = UNSET + if not isinstance(self.end, Unset): + end = self.end.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if start is not UNSET: + field_dict["start"] = start + if end is not UNSET: + field_dict["end"] = end + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.fasting_period_boundary import FastingPeriodBoundary + + d = dict(src_dict) + _start = d.pop("start", UNSET) + start: FastingPeriodBoundary | Unset + if isinstance(_start, Unset): + start = UNSET + else: + start = FastingPeriodBoundary.from_dict(_start) + + _end = d.pop("end", UNSET) + end: FastingPeriodBoundary | Unset + if isinstance(_end, Unset): + end = UNSET + else: + end = FastingPeriodBoundary.from_dict(_end) + + fasting_template_fasting_periods_item = cls( + start=start, + end=end, + ) + + fasting_template_fasting_periods_item.additional_properties = d + return fasting_template_fasting_periods_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/fasting_template_group.py b/src/yazio_sdk/models/fasting_template_group.py new file mode 100644 index 0000000..ec0153e --- /dev/null +++ b/src/yazio_sdk/models/fasting_template_group.py @@ -0,0 +1,283 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.fasting_participants import FastingParticipants + from ..models.fasting_template import FastingTemplate + from ..models.fasting_template_group_fasting_calorie_goal_type_0 import ( + FastingTemplateGroupFastingCalorieGoalType0, + ) + from ..models.fasting_template_group_teaser_position_type_0 import ( + FastingTemplateGroupTeaserPositionType0, + ) + + +T = TypeVar("T", bound="FastingTemplateGroup") + + +@_attrs_define +class FastingTemplateGroup: + """ + Attributes: + group_name (str | Unset): + participants (FastingParticipants | Unset): + cycle_duration_in_days (float | Unset): + emoji (str | Unset): + title (str | Unset): + subtitle (str | Unset): + teaser (str | Unset): + goals (list[str] | Unset): + flexibility (str | Unset): + difficulty (str | Unset): + fasting_calorie_goal (FastingTemplateGroupFastingCalorieGoalType0 | None | Unset): + free (bool | Unset): + type_ (str | Unset): + teaser_position (FastingTemplateGroupTeaserPositionType0 | None | Unset): + templates (list[FastingTemplate] | Unset): + """ + + group_name: str | Unset = UNSET + participants: FastingParticipants | Unset = UNSET + cycle_duration_in_days: float | Unset = UNSET + emoji: str | Unset = UNSET + title: str | Unset = UNSET + subtitle: str | Unset = UNSET + teaser: str | Unset = UNSET + goals: list[str] | Unset = UNSET + flexibility: str | Unset = UNSET + difficulty: str | Unset = UNSET + fasting_calorie_goal: FastingTemplateGroupFastingCalorieGoalType0 | None | Unset = UNSET + free: bool | Unset = UNSET + type_: str | Unset = UNSET + teaser_position: FastingTemplateGroupTeaserPositionType0 | None | Unset = UNSET + templates: list[FastingTemplate] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + from ..models.fasting_template_group_fasting_calorie_goal_type_0 import ( + FastingTemplateGroupFastingCalorieGoalType0, + ) + from ..models.fasting_template_group_teaser_position_type_0 import ( + FastingTemplateGroupTeaserPositionType0, + ) + + group_name = self.group_name + + participants: dict[str, Any] | Unset = UNSET + if not isinstance(self.participants, Unset): + participants = self.participants.to_dict() + + cycle_duration_in_days = self.cycle_duration_in_days + + emoji = self.emoji + + title = self.title + + subtitle = self.subtitle + + teaser = self.teaser + + goals: list[str] | Unset = UNSET + if not isinstance(self.goals, Unset): + goals = self.goals + + flexibility = self.flexibility + + difficulty = self.difficulty + + fasting_calorie_goal: dict[str, Any] | None | Unset + if isinstance(self.fasting_calorie_goal, Unset): + fasting_calorie_goal = UNSET + elif isinstance(self.fasting_calorie_goal, FastingTemplateGroupFastingCalorieGoalType0): + fasting_calorie_goal = self.fasting_calorie_goal.to_dict() + else: + fasting_calorie_goal = self.fasting_calorie_goal + + free = self.free + + type_ = self.type_ + + teaser_position: dict[str, Any] | None | Unset + if isinstance(self.teaser_position, Unset): + teaser_position = UNSET + elif isinstance(self.teaser_position, FastingTemplateGroupTeaserPositionType0): + teaser_position = self.teaser_position.to_dict() + else: + teaser_position = self.teaser_position + + templates: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.templates, Unset): + templates = [] + for templates_item_data in self.templates: + templates_item = templates_item_data.to_dict() + templates.append(templates_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if group_name is not UNSET: + field_dict["group_name"] = group_name + if participants is not UNSET: + field_dict["participants"] = participants + if cycle_duration_in_days is not UNSET: + field_dict["cycle_duration_in_days"] = cycle_duration_in_days + if emoji is not UNSET: + field_dict["emoji"] = emoji + if title is not UNSET: + field_dict["title"] = title + if subtitle is not UNSET: + field_dict["subtitle"] = subtitle + if teaser is not UNSET: + field_dict["teaser"] = teaser + if goals is not UNSET: + field_dict["goals"] = goals + if flexibility is not UNSET: + field_dict["flexibility"] = flexibility + if difficulty is not UNSET: + field_dict["difficulty"] = difficulty + if fasting_calorie_goal is not UNSET: + field_dict["fasting_calorie_goal"] = fasting_calorie_goal + if free is not UNSET: + field_dict["free"] = free + if type_ is not UNSET: + field_dict["type"] = type_ + if teaser_position is not UNSET: + field_dict["teaser_position"] = teaser_position + if templates is not UNSET: + field_dict["templates"] = templates + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.fasting_participants import FastingParticipants + from ..models.fasting_template import FastingTemplate + from ..models.fasting_template_group_fasting_calorie_goal_type_0 import ( + FastingTemplateGroupFastingCalorieGoalType0, + ) + from ..models.fasting_template_group_teaser_position_type_0 import ( + FastingTemplateGroupTeaserPositionType0, + ) + + d = dict(src_dict) + group_name = d.pop("group_name", UNSET) + + _participants = d.pop("participants", UNSET) + participants: FastingParticipants | Unset + if isinstance(_participants, Unset): + participants = UNSET + else: + participants = FastingParticipants.from_dict(_participants) + + cycle_duration_in_days = d.pop("cycle_duration_in_days", UNSET) + + emoji = d.pop("emoji", UNSET) + + title = d.pop("title", UNSET) + + subtitle = d.pop("subtitle", UNSET) + + teaser = d.pop("teaser", UNSET) + + goals = cast(list[str], d.pop("goals", UNSET)) + + flexibility = d.pop("flexibility", UNSET) + + difficulty = d.pop("difficulty", UNSET) + + def _parse_fasting_calorie_goal( + data: object, + ) -> FastingTemplateGroupFastingCalorieGoalType0 | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + fasting_calorie_goal_type_0 = FastingTemplateGroupFastingCalorieGoalType0.from_dict( + data + ) + + return fasting_calorie_goal_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(FastingTemplateGroupFastingCalorieGoalType0 | None | Unset, data) + + fasting_calorie_goal = _parse_fasting_calorie_goal(d.pop("fasting_calorie_goal", UNSET)) + + free = d.pop("free", UNSET) + + type_ = d.pop("type", UNSET) + + def _parse_teaser_position( + data: object, + ) -> FastingTemplateGroupTeaserPositionType0 | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + teaser_position_type_0 = FastingTemplateGroupTeaserPositionType0.from_dict(data) + + return teaser_position_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(FastingTemplateGroupTeaserPositionType0 | None | Unset, data) + + teaser_position = _parse_teaser_position(d.pop("teaser_position", UNSET)) + + _templates = d.pop("templates", UNSET) + templates: list[FastingTemplate] | Unset = UNSET + if _templates is not UNSET: + templates = [] + for templates_item_data in _templates: + templates_item = FastingTemplate.from_dict(templates_item_data) + + templates.append(templates_item) + + fasting_template_group = cls( + group_name=group_name, + participants=participants, + cycle_duration_in_days=cycle_duration_in_days, + emoji=emoji, + title=title, + subtitle=subtitle, + teaser=teaser, + goals=goals, + flexibility=flexibility, + difficulty=difficulty, + fasting_calorie_goal=fasting_calorie_goal, + free=free, + type_=type_, + teaser_position=teaser_position, + templates=templates, + ) + + fasting_template_group.additional_properties = d + return fasting_template_group + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/fasting_template_group_fasting_calorie_goal_type_0.py b/src/yazio_sdk/models/fasting_template_group_fasting_calorie_goal_type_0.py new file mode 100644 index 0000000..2c6fd7b --- /dev/null +++ b/src/yazio_sdk/models/fasting_template_group_fasting_calorie_goal_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="FastingTemplateGroupFastingCalorieGoalType0") + + +@_attrs_define +class FastingTemplateGroupFastingCalorieGoalType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + fasting_template_group_fasting_calorie_goal_type_0 = cls() + + fasting_template_group_fasting_calorie_goal_type_0.additional_properties = d + return fasting_template_group_fasting_calorie_goal_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/fasting_template_group_teaser_position_type_0.py b/src/yazio_sdk/models/fasting_template_group_teaser_position_type_0.py new file mode 100644 index 0000000..caf3124 --- /dev/null +++ b/src/yazio_sdk/models/fasting_template_group_teaser_position_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="FastingTemplateGroupTeaserPositionType0") + + +@_attrs_define +class FastingTemplateGroupTeaserPositionType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + fasting_template_group_teaser_position_type_0 = cls() + + fasting_template_group_teaser_position_type_0.additional_properties = d + return fasting_template_group_teaser_position_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/fasting_template_preset_type_0.py b/src/yazio_sdk/models/fasting_template_preset_type_0.py new file mode 100644 index 0000000..710be42 --- /dev/null +++ b/src/yazio_sdk/models/fasting_template_preset_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="FastingTemplatePresetType0") + + +@_attrs_define +class FastingTemplatePresetType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + fasting_template_preset_type_0 = cls() + + fasting_template_preset_type_0.additional_properties = d + return fasting_template_preset_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/fasting_tip.py b/src/yazio_sdk/models/fasting_tip.py new file mode 100644 index 0000000..6b48e95 --- /dev/null +++ b/src/yazio_sdk/models/fasting_tip.py @@ -0,0 +1,70 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="FastingTip") + + +@_attrs_define +class FastingTip: + """ + Attributes: + emoji (str | Unset): + text (str | Unset): + """ + + emoji: str | Unset = UNSET + text: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + emoji = self.emoji + + text = self.text + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if emoji is not UNSET: + field_dict["emoji"] = emoji + if text is not UNSET: + field_dict["text"] = text + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + emoji = d.pop("emoji", UNSET) + + text = d.pop("text", UNSET) + + fasting_tip = cls( + emoji=emoji, + text=text, + ) + + fasting_tip.additional_properties = d + return fasting_tip + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/feeling.py b/src/yazio_sdk/models/feeling.py new file mode 100644 index 0000000..2dcc485 --- /dev/null +++ b/src/yazio_sdk/models/feeling.py @@ -0,0 +1,102 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.feeling_note_type_0 import FeelingNoteType0 + + +T = TypeVar("T", bound="Feeling") + + +@_attrs_define +class Feeling: + """ + Attributes: + note (FeelingNoteType0 | None | Unset): + tags (list[Any] | Unset): + """ + + note: FeelingNoteType0 | None | Unset = UNSET + tags: list[Any] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + from ..models.feeling_note_type_0 import FeelingNoteType0 + + note: dict[str, Any] | None | Unset + if isinstance(self.note, Unset): + note = UNSET + elif isinstance(self.note, FeelingNoteType0): + note = self.note.to_dict() + else: + note = self.note + + tags: list[Any] | Unset = UNSET + if not isinstance(self.tags, Unset): + tags = self.tags + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if note is not UNSET: + field_dict["note"] = note + if tags is not UNSET: + field_dict["tags"] = tags + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.feeling_note_type_0 import FeelingNoteType0 + + d = dict(src_dict) + + def _parse_note(data: object) -> FeelingNoteType0 | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + note_type_0 = FeelingNoteType0.from_dict(data) + + return note_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(FeelingNoteType0 | None | Unset, data) + + note = _parse_note(d.pop("note", UNSET)) + + tags = cast(list[Any], d.pop("tags", UNSET)) + + feeling = cls( + note=note, + tags=tags, + ) + + feeling.additional_properties = d + return feeling + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/feeling_note_type_0.py b/src/yazio_sdk/models/feeling_note_type_0.py new file mode 100644 index 0000000..1779c38 --- /dev/null +++ b/src/yazio_sdk/models/feeling_note_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="FeelingNoteType0") + + +@_attrs_define +class FeelingNoteType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + feeling_note_type_0 = cls() + + feeling_note_type_0.additional_properties = d + return feeling_note_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/key_value_store.py b/src/yazio_sdk/models/key_value_store.py new file mode 100644 index 0000000..6ff6d1c --- /dev/null +++ b/src/yazio_sdk/models/key_value_store.py @@ -0,0 +1,61 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="KeyValueStore") + + +@_attrs_define +class KeyValueStore: + """ + Attributes: + streak_repair_remote_key (str | Unset): + """ + + streak_repair_remote_key: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + streak_repair_remote_key = self.streak_repair_remote_key + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if streak_repair_remote_key is not UNSET: + field_dict["StreakRepairRemoteKey"] = streak_repair_remote_key + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + streak_repair_remote_key = d.pop("StreakRepairRemoteKey", UNSET) + + key_value_store = cls( + streak_repair_remote_key=streak_repair_remote_key, + ) + + key_value_store.additional_properties = d + return key_value_store + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/meal_images.py b/src/yazio_sdk/models/meal_images.py new file mode 100644 index 0000000..2219a47 --- /dev/null +++ b/src/yazio_sdk/models/meal_images.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="MealImages") + + +@_attrs_define +class MealImages: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + meal_images = cls() + + meal_images.additional_properties = d + return meal_images + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/meal_summary.py b/src/yazio_sdk/models/meal_summary.py new file mode 100644 index 0000000..5724676 --- /dev/null +++ b/src/yazio_sdk/models/meal_summary.py @@ -0,0 +1,83 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.nutrient_summary import NutrientSummary + + +T = TypeVar("T", bound="MealSummary") + + +@_attrs_define +class MealSummary: + """ + Attributes: + energy_goal (float | Unset): + nutrients (NutrientSummary | Unset): + """ + + energy_goal: float | Unset = UNSET + nutrients: NutrientSummary | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + energy_goal = self.energy_goal + + nutrients: dict[str, Any] | Unset = UNSET + if not isinstance(self.nutrients, Unset): + nutrients = self.nutrients.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if energy_goal is not UNSET: + field_dict["energy_goal"] = energy_goal + if nutrients is not UNSET: + field_dict["nutrients"] = nutrients + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.nutrient_summary import NutrientSummary + + d = dict(src_dict) + energy_goal = d.pop("energy_goal", UNSET) + + _nutrients = d.pop("nutrients", UNSET) + nutrients: NutrientSummary | Unset + if isinstance(_nutrients, Unset): + nutrients = UNSET + else: + nutrients = NutrientSummary.from_dict(_nutrients) + + meal_summary = cls( + energy_goal=energy_goal, + nutrients=nutrients, + ) + + meal_summary.additional_properties = d + return meal_summary + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/meal_summary_tips.py b/src/yazio_sdk/models/meal_summary_tips.py new file mode 100644 index 0000000..3e40ced --- /dev/null +++ b/src/yazio_sdk/models/meal_summary_tips.py @@ -0,0 +1,63 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="MealSummaryTips") + + +@_attrs_define +class MealSummaryTips: + """ + Attributes: + tips (list[str] | Unset): + """ + + tips: list[str] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + tips: list[str] | Unset = UNSET + if not isinstance(self.tips, Unset): + tips = self.tips + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if tips is not UNSET: + field_dict["tips"] = tips + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + tips = cast(list[str], d.pop("tips", UNSET)) + + meal_summary_tips = cls( + tips=tips, + ) + + meal_summary_tips.additional_properties = d + return meal_summary_tips + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/meal_summary_tips_request.py b/src/yazio_sdk/models/meal_summary_tips_request.py new file mode 100644 index 0000000..216b53c --- /dev/null +++ b/src/yazio_sdk/models/meal_summary_tips_request.py @@ -0,0 +1,153 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="MealSummaryTipsRequest") + + +@_attrs_define +class MealSummaryTipsRequest: + """ + Attributes: + request_uuid (str | Unset): + device_uuid (str | Unset): + app_version (str | Unset): + platform (str | Unset): + session_id (str | Unset): + delivery_mode (str | Unset): + experiments (list[Any] | Unset): + requested_at (float | Unset): + date (str | Unset): + mealtime (str | Unset): + language (str | Unset): + """ + + request_uuid: str | Unset = UNSET + device_uuid: str | Unset = UNSET + app_version: str | Unset = UNSET + platform: str | Unset = UNSET + session_id: str | Unset = UNSET + delivery_mode: str | Unset = UNSET + experiments: list[Any] | Unset = UNSET + requested_at: float | Unset = UNSET + date: str | Unset = UNSET + mealtime: str | Unset = UNSET + language: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + request_uuid = self.request_uuid + + device_uuid = self.device_uuid + + app_version = self.app_version + + platform = self.platform + + session_id = self.session_id + + delivery_mode = self.delivery_mode + + experiments: list[Any] | Unset = UNSET + if not isinstance(self.experiments, Unset): + experiments = self.experiments + + requested_at = self.requested_at + + date = self.date + + mealtime = self.mealtime + + language = self.language + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if request_uuid is not UNSET: + field_dict["request_uuid"] = request_uuid + if device_uuid is not UNSET: + field_dict["device_uuid"] = device_uuid + if app_version is not UNSET: + field_dict["app_version"] = app_version + if platform is not UNSET: + field_dict["platform"] = platform + if session_id is not UNSET: + field_dict["session_id"] = session_id + if delivery_mode is not UNSET: + field_dict["delivery_mode"] = delivery_mode + if experiments is not UNSET: + field_dict["experiments"] = experiments + if requested_at is not UNSET: + field_dict["requested_at"] = requested_at + if date is not UNSET: + field_dict["date"] = date + if mealtime is not UNSET: + field_dict["mealtime"] = mealtime + if language is not UNSET: + field_dict["language"] = language + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + request_uuid = d.pop("request_uuid", UNSET) + + device_uuid = d.pop("device_uuid", UNSET) + + app_version = d.pop("app_version", UNSET) + + platform = d.pop("platform", UNSET) + + session_id = d.pop("session_id", UNSET) + + delivery_mode = d.pop("delivery_mode", UNSET) + + experiments = cast(list[Any], d.pop("experiments", UNSET)) + + requested_at = d.pop("requested_at", UNSET) + + date = d.pop("date", UNSET) + + mealtime = d.pop("mealtime", UNSET) + + language = d.pop("language", UNSET) + + meal_summary_tips_request = cls( + request_uuid=request_uuid, + device_uuid=device_uuid, + app_version=app_version, + platform=platform, + session_id=session_id, + delivery_mode=delivery_mode, + experiments=experiments, + requested_at=requested_at, + date=date, + mealtime=mealtime, + language=language, + ) + + meal_summary_tips_request.additional_properties = d + return meal_summary_tips_request + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/nutrient_summary.py b/src/yazio_sdk/models/nutrient_summary.py new file mode 100644 index 0000000..e6b748c --- /dev/null +++ b/src/yazio_sdk/models/nutrient_summary.py @@ -0,0 +1,88 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="NutrientSummary") + + +@_attrs_define +class NutrientSummary: + """ + Attributes: + energy_energy (float | Unset): + nutrient_carb (float | Unset): + nutrient_fat (float | Unset): + nutrient_protein (float | Unset): + """ + + energy_energy: float | Unset = UNSET + nutrient_carb: float | Unset = UNSET + nutrient_fat: float | Unset = UNSET + nutrient_protein: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + energy_energy = self.energy_energy + + nutrient_carb = self.nutrient_carb + + nutrient_fat = self.nutrient_fat + + nutrient_protein = self.nutrient_protein + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if energy_energy is not UNSET: + field_dict["energy.energy"] = energy_energy + if nutrient_carb is not UNSET: + field_dict["nutrient.carb"] = nutrient_carb + if nutrient_fat is not UNSET: + field_dict["nutrient.fat"] = nutrient_fat + if nutrient_protein is not UNSET: + field_dict["nutrient.protein"] = nutrient_protein + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + energy_energy = d.pop("energy.energy", UNSET) + + nutrient_carb = d.pop("nutrient.carb", UNSET) + + nutrient_fat = d.pop("nutrient.fat", UNSET) + + nutrient_protein = d.pop("nutrient.protein", UNSET) + + nutrient_summary = cls( + energy_energy=energy_energy, + nutrient_carb=nutrient_carb, + nutrient_fat=nutrient_fat, + nutrient_protein=nutrient_protein, + ) + + nutrient_summary.additional_properties = d + return nutrient_summary + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/o_auth_token.py b/src/yazio_sdk/models/o_auth_token.py new file mode 100644 index 0000000..010027d --- /dev/null +++ b/src/yazio_sdk/models/o_auth_token.py @@ -0,0 +1,88 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="OAuthToken") + + +@_attrs_define +class OAuthToken: + """ + Attributes: + access_token (str | Unset): + expires_in (float | Unset): + refresh_token (str | Unset): + token_type (str | Unset): + """ + + access_token: str | Unset = UNSET + expires_in: float | Unset = UNSET + refresh_token: str | Unset = UNSET + token_type: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + access_token = self.access_token + + expires_in = self.expires_in + + refresh_token = self.refresh_token + + token_type = self.token_type + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if access_token is not UNSET: + field_dict["access_token"] = access_token + if expires_in is not UNSET: + field_dict["expires_in"] = expires_in + if refresh_token is not UNSET: + field_dict["refresh_token"] = refresh_token + if token_type is not UNSET: + field_dict["token_type"] = token_type + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + access_token = d.pop("access_token", UNSET) + + expires_in = d.pop("expires_in", UNSET) + + refresh_token = d.pop("refresh_token", UNSET) + + token_type = d.pop("token_type", UNSET) + + o_auth_token = cls( + access_token=access_token, + expires_in=expires_in, + refresh_token=refresh_token, + token_type=token_type, + ) + + o_auth_token.additional_properties = d + return o_auth_token + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/o_auth_token_request.py b/src/yazio_sdk/models/o_auth_token_request.py new file mode 100644 index 0000000..590ad46 --- /dev/null +++ b/src/yazio_sdk/models/o_auth_token_request.py @@ -0,0 +1,100 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="OAuthTokenRequest") + + +@_attrs_define +class OAuthTokenRequest: + """ + Attributes: + username (str | Unset): The account's email address. + password (str | Unset): + grant_type (str | Unset): `password` to exchange credentials for a token, `refresh_token` to renew one. Example: + password. + client_id (str | Unset): The client id the mobile app ships with. Identifies the app rather than the user; every + install sends the same value. Example: 3_5rbw4kehpugw8ogsc8ck8oo4ogswgckcskc04gcg8kk8k48ssw. + client_secret (str | Unset): The client secret the mobile app ships with. Not a per-user secret; see + `client_id`. Example: 25gdtt1hvdi8gwowoww4oo88sgsw0oo04o0og0kkgwwks8k0k. + """ + + username: str | Unset = UNSET + password: str | Unset = UNSET + grant_type: str | Unset = UNSET + client_id: str | Unset = UNSET + client_secret: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + username = self.username + + password = self.password + + grant_type = self.grant_type + + client_id = self.client_id + + client_secret = self.client_secret + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if username is not UNSET: + field_dict["username"] = username + if password is not UNSET: + field_dict["password"] = password + if grant_type is not UNSET: + field_dict["grant_type"] = grant_type + if client_id is not UNSET: + field_dict["client_id"] = client_id + if client_secret is not UNSET: + field_dict["client_secret"] = client_secret + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + username = d.pop("username", UNSET) + + password = d.pop("password", UNSET) + + grant_type = d.pop("grant_type", UNSET) + + client_id = d.pop("client_id", UNSET) + + client_secret = d.pop("client_secret", UNSET) + + o_auth_token_request = cls( + username=username, + password=password, + grant_type=grant_type, + client_id=client_id, + client_secret=client_secret, + ) + + o_auth_token_request.additional_properties = d + return o_auth_token_request + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/pending_notifications.py b/src/yazio_sdk/models/pending_notifications.py new file mode 100644 index 0000000..06e30f4 --- /dev/null +++ b/src/yazio_sdk/models/pending_notifications.py @@ -0,0 +1,63 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="PendingNotifications") + + +@_attrs_define +class PendingNotifications: + """ + Attributes: + items (list[Any] | Unset): + """ + + items: list[Any] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + items: list[Any] | Unset = UNSET + if not isinstance(self.items, Unset): + items = self.items + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if items is not UNSET: + field_dict["items"] = items + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + items = cast(list[Any], d.pop("items", UNSET)) + + pending_notifications = cls( + items=items, + ) + + pending_notifications.additional_properties = d + return pending_notifications + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/product.py b/src/yazio_sdk/models/product.py new file mode 100644 index 0000000..8058126 --- /dev/null +++ b/src/yazio_sdk/models/product.py @@ -0,0 +1,222 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.product_nutrients import ProductNutrients + from ..models.product_servings_item import ProductServingsItem + + +T = TypeVar("T", bound="Product") + + +@_attrs_define +class Product: + """Response of GET /v22/products/{id}. Absent from the capture, which only recorded an OPTIONS preflight; filled in + from a live response. Note that the body carries no id of its own. + + Attributes: + name (str | Unset): + producer (None | str | Unset): + category (str | Unset): + base_unit (str | Unset): + is_verified (bool | Unset): + is_private (bool | Unset): + is_deleted (bool | Unset): + has_ean (bool | Unset): + nutrients (ProductNutrients | Unset): + servings (list[ProductServingsItem] | Unset): + eans (list[str] | Unset): + language (str | Unset): + countries (list[str] | Unset): + updated_at (str | Unset): + """ + + name: str | Unset = UNSET + producer: None | str | Unset = UNSET + category: str | Unset = UNSET + base_unit: str | Unset = UNSET + is_verified: bool | Unset = UNSET + is_private: bool | Unset = UNSET + is_deleted: bool | Unset = UNSET + has_ean: bool | Unset = UNSET + nutrients: ProductNutrients | Unset = UNSET + servings: list[ProductServingsItem] | Unset = UNSET + eans: list[str] | Unset = UNSET + language: str | Unset = UNSET + countries: list[str] | Unset = UNSET + updated_at: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + name = self.name + + producer: None | str | Unset + if isinstance(self.producer, Unset): + producer = UNSET + else: + producer = self.producer + + category = self.category + + base_unit = self.base_unit + + is_verified = self.is_verified + + is_private = self.is_private + + is_deleted = self.is_deleted + + has_ean = self.has_ean + + nutrients: dict[str, Any] | Unset = UNSET + if not isinstance(self.nutrients, Unset): + nutrients = self.nutrients.to_dict() + + servings: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.servings, Unset): + servings = [] + for servings_item_data in self.servings: + servings_item = servings_item_data.to_dict() + servings.append(servings_item) + + eans: list[str] | Unset = UNSET + if not isinstance(self.eans, Unset): + eans = self.eans + + language = self.language + + countries: list[str] | Unset = UNSET + if not isinstance(self.countries, Unset): + countries = self.countries + + updated_at = self.updated_at + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if name is not UNSET: + field_dict["name"] = name + if producer is not UNSET: + field_dict["producer"] = producer + if category is not UNSET: + field_dict["category"] = category + if base_unit is not UNSET: + field_dict["base_unit"] = base_unit + if is_verified is not UNSET: + field_dict["is_verified"] = is_verified + if is_private is not UNSET: + field_dict["is_private"] = is_private + if is_deleted is not UNSET: + field_dict["is_deleted"] = is_deleted + if has_ean is not UNSET: + field_dict["has_ean"] = has_ean + if nutrients is not UNSET: + field_dict["nutrients"] = nutrients + if servings is not UNSET: + field_dict["servings"] = servings + if eans is not UNSET: + field_dict["eans"] = eans + if language is not UNSET: + field_dict["language"] = language + if countries is not UNSET: + field_dict["countries"] = countries + if updated_at is not UNSET: + field_dict["updated_at"] = updated_at + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.product_nutrients import ProductNutrients + from ..models.product_servings_item import ProductServingsItem + + d = dict(src_dict) + name = d.pop("name", UNSET) + + def _parse_producer(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + producer = _parse_producer(d.pop("producer", UNSET)) + + category = d.pop("category", UNSET) + + base_unit = d.pop("base_unit", UNSET) + + is_verified = d.pop("is_verified", UNSET) + + is_private = d.pop("is_private", UNSET) + + is_deleted = d.pop("is_deleted", UNSET) + + has_ean = d.pop("has_ean", UNSET) + + _nutrients = d.pop("nutrients", UNSET) + nutrients: ProductNutrients | Unset + if isinstance(_nutrients, Unset): + nutrients = UNSET + else: + nutrients = ProductNutrients.from_dict(_nutrients) + + _servings = d.pop("servings", UNSET) + servings: list[ProductServingsItem] | Unset = UNSET + if _servings is not UNSET: + servings = [] + for servings_item_data in _servings: + servings_item = ProductServingsItem.from_dict(servings_item_data) + + servings.append(servings_item) + + eans = cast(list[str], d.pop("eans", UNSET)) + + language = d.pop("language", UNSET) + + countries = cast(list[str], d.pop("countries", UNSET)) + + updated_at = d.pop("updated_at", UNSET) + + product = cls( + name=name, + producer=producer, + category=category, + base_unit=base_unit, + is_verified=is_verified, + is_private=is_private, + is_deleted=is_deleted, + has_ean=has_ean, + nutrients=nutrients, + servings=servings, + eans=eans, + language=language, + countries=countries, + updated_at=updated_at, + ) + + product.additional_properties = d + return product + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/product_nutrients.py b/src/yazio_sdk/models/product_nutrients.py new file mode 100644 index 0000000..035a2bb --- /dev/null +++ b/src/yazio_sdk/models/product_nutrients.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ProductNutrients") + + +@_attrs_define +class ProductNutrients: + """ """ + + additional_properties: dict[str, float] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + product_nutrients = cls() + + product_nutrients.additional_properties = d + return product_nutrients + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> float: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: float) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/product_search_result.py b/src/yazio_sdk/models/product_search_result.py new file mode 100644 index 0000000..6077bb0 --- /dev/null +++ b/src/yazio_sdk/models/product_search_result.py @@ -0,0 +1,175 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.nutrient_summary import NutrientSummary + + +T = TypeVar("T", bound="ProductSearchResult") + + +@_attrs_define +class ProductSearchResult: + """ + Attributes: + score (float | Unset): + name (str | Unset): + product_id (str | Unset): + serving (str | Unset): + serving_quantity (float | Unset): + amount (float | Unset): + base_unit (str | Unset): + producer (str | Unset): + is_verified (bool | Unset): + nutrients (NutrientSummary | Unset): + countries (list[str] | Unset): + language (str | Unset): + """ + + score: float | Unset = UNSET + name: str | Unset = UNSET + product_id: str | Unset = UNSET + serving: str | Unset = UNSET + serving_quantity: float | Unset = UNSET + amount: float | Unset = UNSET + base_unit: str | Unset = UNSET + producer: str | Unset = UNSET + is_verified: bool | Unset = UNSET + nutrients: NutrientSummary | Unset = UNSET + countries: list[str] | Unset = UNSET + language: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + score = self.score + + name = self.name + + product_id = self.product_id + + serving = self.serving + + serving_quantity = self.serving_quantity + + amount = self.amount + + base_unit = self.base_unit + + producer = self.producer + + is_verified = self.is_verified + + nutrients: dict[str, Any] | Unset = UNSET + if not isinstance(self.nutrients, Unset): + nutrients = self.nutrients.to_dict() + + countries: list[str] | Unset = UNSET + if not isinstance(self.countries, Unset): + countries = self.countries + + language = self.language + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if score is not UNSET: + field_dict["score"] = score + if name is not UNSET: + field_dict["name"] = name + if product_id is not UNSET: + field_dict["product_id"] = product_id + if serving is not UNSET: + field_dict["serving"] = serving + if serving_quantity is not UNSET: + field_dict["serving_quantity"] = serving_quantity + if amount is not UNSET: + field_dict["amount"] = amount + if base_unit is not UNSET: + field_dict["base_unit"] = base_unit + if producer is not UNSET: + field_dict["producer"] = producer + if is_verified is not UNSET: + field_dict["is_verified"] = is_verified + if nutrients is not UNSET: + field_dict["nutrients"] = nutrients + if countries is not UNSET: + field_dict["countries"] = countries + if language is not UNSET: + field_dict["language"] = language + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.nutrient_summary import NutrientSummary + + d = dict(src_dict) + score = d.pop("score", UNSET) + + name = d.pop("name", UNSET) + + product_id = d.pop("product_id", UNSET) + + serving = d.pop("serving", UNSET) + + serving_quantity = d.pop("serving_quantity", UNSET) + + amount = d.pop("amount", UNSET) + + base_unit = d.pop("base_unit", UNSET) + + producer = d.pop("producer", UNSET) + + is_verified = d.pop("is_verified", UNSET) + + _nutrients = d.pop("nutrients", UNSET) + nutrients: NutrientSummary | Unset + if isinstance(_nutrients, Unset): + nutrients = UNSET + else: + nutrients = NutrientSummary.from_dict(_nutrients) + + countries = cast(list[str], d.pop("countries", UNSET)) + + language = d.pop("language", UNSET) + + product_search_result = cls( + score=score, + name=name, + product_id=product_id, + serving=serving, + serving_quantity=serving_quantity, + amount=amount, + base_unit=base_unit, + producer=producer, + is_verified=is_verified, + nutrients=nutrients, + countries=countries, + language=language, + ) + + product_search_result.additional_properties = d + return product_search_result + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/product_servings_item.py b/src/yazio_sdk/models/product_servings_item.py new file mode 100644 index 0000000..9a277b0 --- /dev/null +++ b/src/yazio_sdk/models/product_servings_item.py @@ -0,0 +1,70 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ProductServingsItem") + + +@_attrs_define +class ProductServingsItem: + """ + Attributes: + serving (str | Unset): + amount (float | Unset): + """ + + serving: str | Unset = UNSET + amount: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + serving = self.serving + + amount = self.amount + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if serving is not UNSET: + field_dict["serving"] = serving + if amount is not UNSET: + field_dict["amount"] = amount + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + serving = d.pop("serving", UNSET) + + amount = d.pop("amount", UNSET) + + product_servings_item = cls( + serving=serving, + amount=amount, + ) + + product_servings_item.additional_properties = d + return product_servings_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/recipe.py b/src/yazio_sdk/models/recipe.py new file mode 100644 index 0000000..55376b4 --- /dev/null +++ b/src/yazio_sdk/models/recipe.py @@ -0,0 +1,262 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.recipe_available_since_type_0 import RecipeAvailableSinceType0 + from ..models.recipe_image_type_0 import RecipeImageType0 + from ..models.recipe_nutrients import RecipeNutrients + from ..models.recipe_servings_item import RecipeServingsItem + from ..models.recipe_yazio_id_type_0 import RecipeYazioIdType0 + + +T = TypeVar("T", bound="Recipe") + + +@_attrs_define +class Recipe: + """ + Attributes: + id (str | Unset): + yazio_id (None | RecipeYazioIdType0 | Unset): + locale (str | Unset): + name (str | Unset): + portion_count (float | Unset): + nutrients (RecipeNutrients | Unset): + image (None | RecipeImageType0 | Unset): + servings (list[RecipeServingsItem] | Unset): + instructions (list[Any] | Unset): + is_yazio_recipe (bool | Unset): + available_since (None | RecipeAvailableSinceType0 | Unset): + is_pro_recipe (bool | Unset): + """ + + id: str | Unset = UNSET + yazio_id: None | RecipeYazioIdType0 | Unset = UNSET + locale: str | Unset = UNSET + name: str | Unset = UNSET + portion_count: float | Unset = UNSET + nutrients: RecipeNutrients | Unset = UNSET + image: None | RecipeImageType0 | Unset = UNSET + servings: list[RecipeServingsItem] | Unset = UNSET + instructions: list[Any] | Unset = UNSET + is_yazio_recipe: bool | Unset = UNSET + available_since: None | RecipeAvailableSinceType0 | Unset = UNSET + is_pro_recipe: bool | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + from ..models.recipe_available_since_type_0 import RecipeAvailableSinceType0 + from ..models.recipe_image_type_0 import RecipeImageType0 + from ..models.recipe_yazio_id_type_0 import RecipeYazioIdType0 + + id = self.id + + yazio_id: dict[str, Any] | None | Unset + if isinstance(self.yazio_id, Unset): + yazio_id = UNSET + elif isinstance(self.yazio_id, RecipeYazioIdType0): + yazio_id = self.yazio_id.to_dict() + else: + yazio_id = self.yazio_id + + locale = self.locale + + name = self.name + + portion_count = self.portion_count + + nutrients: dict[str, Any] | Unset = UNSET + if not isinstance(self.nutrients, Unset): + nutrients = self.nutrients.to_dict() + + image: dict[str, Any] | None | Unset + if isinstance(self.image, Unset): + image = UNSET + elif isinstance(self.image, RecipeImageType0): + image = self.image.to_dict() + else: + image = self.image + + servings: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.servings, Unset): + servings = [] + for servings_item_data in self.servings: + servings_item = servings_item_data.to_dict() + servings.append(servings_item) + + instructions: list[Any] | Unset = UNSET + if not isinstance(self.instructions, Unset): + instructions = self.instructions + + is_yazio_recipe = self.is_yazio_recipe + + available_since: dict[str, Any] | None | Unset + if isinstance(self.available_since, Unset): + available_since = UNSET + elif isinstance(self.available_since, RecipeAvailableSinceType0): + available_since = self.available_since.to_dict() + else: + available_since = self.available_since + + is_pro_recipe = self.is_pro_recipe + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if yazio_id is not UNSET: + field_dict["yazio_id"] = yazio_id + if locale is not UNSET: + field_dict["locale"] = locale + if name is not UNSET: + field_dict["name"] = name + if portion_count is not UNSET: + field_dict["portion_count"] = portion_count + if nutrients is not UNSET: + field_dict["nutrients"] = nutrients + if image is not UNSET: + field_dict["image"] = image + if servings is not UNSET: + field_dict["servings"] = servings + if instructions is not UNSET: + field_dict["instructions"] = instructions + if is_yazio_recipe is not UNSET: + field_dict["is_yazio_recipe"] = is_yazio_recipe + if available_since is not UNSET: + field_dict["available_since"] = available_since + if is_pro_recipe is not UNSET: + field_dict["is_pro_recipe"] = is_pro_recipe + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.recipe_available_since_type_0 import RecipeAvailableSinceType0 + from ..models.recipe_image_type_0 import RecipeImageType0 + from ..models.recipe_nutrients import RecipeNutrients + from ..models.recipe_servings_item import RecipeServingsItem + from ..models.recipe_yazio_id_type_0 import RecipeYazioIdType0 + + d = dict(src_dict) + id = d.pop("id", UNSET) + + def _parse_yazio_id(data: object) -> None | RecipeYazioIdType0 | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + yazio_id_type_0 = RecipeYazioIdType0.from_dict(data) + + return yazio_id_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | RecipeYazioIdType0 | Unset, data) + + yazio_id = _parse_yazio_id(d.pop("yazio_id", UNSET)) + + locale = d.pop("locale", UNSET) + + name = d.pop("name", UNSET) + + portion_count = d.pop("portion_count", UNSET) + + _nutrients = d.pop("nutrients", UNSET) + nutrients: RecipeNutrients | Unset + if isinstance(_nutrients, Unset): + nutrients = UNSET + else: + nutrients = RecipeNutrients.from_dict(_nutrients) + + def _parse_image(data: object) -> None | RecipeImageType0 | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + image_type_0 = RecipeImageType0.from_dict(data) + + return image_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | RecipeImageType0 | Unset, data) + + image = _parse_image(d.pop("image", UNSET)) + + _servings = d.pop("servings", UNSET) + servings: list[RecipeServingsItem] | Unset = UNSET + if _servings is not UNSET: + servings = [] + for servings_item_data in _servings: + servings_item = RecipeServingsItem.from_dict(servings_item_data) + + servings.append(servings_item) + + instructions = cast(list[Any], d.pop("instructions", UNSET)) + + is_yazio_recipe = d.pop("is_yazio_recipe", UNSET) + + def _parse_available_since(data: object) -> None | RecipeAvailableSinceType0 | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + available_since_type_0 = RecipeAvailableSinceType0.from_dict(data) + + return available_since_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | RecipeAvailableSinceType0 | Unset, data) + + available_since = _parse_available_since(d.pop("available_since", UNSET)) + + is_pro_recipe = d.pop("is_pro_recipe", UNSET) + + recipe = cls( + id=id, + yazio_id=yazio_id, + locale=locale, + name=name, + portion_count=portion_count, + nutrients=nutrients, + image=image, + servings=servings, + instructions=instructions, + is_yazio_recipe=is_yazio_recipe, + available_since=available_since, + is_pro_recipe=is_pro_recipe, + ) + + recipe.additional_properties = d + return recipe + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/recipe_available_since_type_0.py b/src/yazio_sdk/models/recipe_available_since_type_0.py new file mode 100644 index 0000000..cd899f2 --- /dev/null +++ b/src/yazio_sdk/models/recipe_available_since_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="RecipeAvailableSinceType0") + + +@_attrs_define +class RecipeAvailableSinceType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + recipe_available_since_type_0 = cls() + + recipe_available_since_type_0.additional_properties = d + return recipe_available_since_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/recipe_draft.py b/src/yazio_sdk/models/recipe_draft.py new file mode 100644 index 0000000..f1857c5 --- /dev/null +++ b/src/yazio_sdk/models/recipe_draft.py @@ -0,0 +1,135 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.recipe_draft_nutrients import RecipeDraftNutrients + from ..models.recipe_draft_servings_item import RecipeDraftServingsItem + + +T = TypeVar("T", bound="RecipeDraft") + + +@_attrs_define +class RecipeDraft: + """ + Attributes: + nutrients (RecipeDraftNutrients | Unset): + portion_count (int | Unset): + servings (list[RecipeDraftServingsItem] | Unset): + instructions (list[str] | Unset): + name (str | Unset): + id (str | Unset): + """ + + nutrients: RecipeDraftNutrients | Unset = UNSET + portion_count: int | Unset = UNSET + servings: list[RecipeDraftServingsItem] | Unset = UNSET + instructions: list[str] | Unset = UNSET + name: str | Unset = UNSET + id: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + nutrients: dict[str, Any] | Unset = UNSET + if not isinstance(self.nutrients, Unset): + nutrients = self.nutrients.to_dict() + + portion_count = self.portion_count + + servings: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.servings, Unset): + servings = [] + for servings_item_data in self.servings: + servings_item = servings_item_data.to_dict() + servings.append(servings_item) + + instructions: list[str] | Unset = UNSET + if not isinstance(self.instructions, Unset): + instructions = self.instructions + + name = self.name + + id = self.id + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if nutrients is not UNSET: + field_dict["nutrients"] = nutrients + if portion_count is not UNSET: + field_dict["portion_count"] = portion_count + if servings is not UNSET: + field_dict["servings"] = servings + if instructions is not UNSET: + field_dict["instructions"] = instructions + if name is not UNSET: + field_dict["name"] = name + if id is not UNSET: + field_dict["id"] = id + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.recipe_draft_nutrients import RecipeDraftNutrients + from ..models.recipe_draft_servings_item import RecipeDraftServingsItem + + d = dict(src_dict) + _nutrients = d.pop("nutrients", UNSET) + nutrients: RecipeDraftNutrients | Unset + if isinstance(_nutrients, Unset): + nutrients = UNSET + else: + nutrients = RecipeDraftNutrients.from_dict(_nutrients) + + portion_count = d.pop("portion_count", UNSET) + + _servings = d.pop("servings", UNSET) + servings: list[RecipeDraftServingsItem] | Unset = UNSET + if _servings is not UNSET: + servings = [] + for servings_item_data in _servings: + servings_item = RecipeDraftServingsItem.from_dict(servings_item_data) + + servings.append(servings_item) + + instructions = cast(list[str], d.pop("instructions", UNSET)) + + name = d.pop("name", UNSET) + + id = d.pop("id", UNSET) + + recipe_draft = cls( + nutrients=nutrients, + portion_count=portion_count, + servings=servings, + instructions=instructions, + name=name, + id=id, + ) + + recipe_draft.additional_properties = d + return recipe_draft + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/recipe_draft_nutrients.py b/src/yazio_sdk/models/recipe_draft_nutrients.py new file mode 100644 index 0000000..38c29d7 --- /dev/null +++ b/src/yazio_sdk/models/recipe_draft_nutrients.py @@ -0,0 +1,160 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="RecipeDraftNutrients") + + +@_attrs_define +class RecipeDraftNutrients: + """ + Attributes: + nutrient_salt (float | Unset): + nutrient_monounsaturated (float | Unset): + nutrient_sugar (float | Unset): + mineral_calcium (float | Unset): + nutrient_saturated (float | Unset): + vitamin_b6 (float | Unset): + nutrient_protein (float | Unset): + nutrient_dietaryfiber (float | Unset): + energy_energy (float | Unset): + nutrient_polyunsaturated (float | Unset): + nutrient_fat (float | Unset): + nutrient_carb (float | Unset): + """ + + nutrient_salt: float | Unset = UNSET + nutrient_monounsaturated: float | Unset = UNSET + nutrient_sugar: float | Unset = UNSET + mineral_calcium: float | Unset = UNSET + nutrient_saturated: float | Unset = UNSET + vitamin_b6: float | Unset = UNSET + nutrient_protein: float | Unset = UNSET + nutrient_dietaryfiber: float | Unset = UNSET + energy_energy: float | Unset = UNSET + nutrient_polyunsaturated: float | Unset = UNSET + nutrient_fat: float | Unset = UNSET + nutrient_carb: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + nutrient_salt = self.nutrient_salt + + nutrient_monounsaturated = self.nutrient_monounsaturated + + nutrient_sugar = self.nutrient_sugar + + mineral_calcium = self.mineral_calcium + + nutrient_saturated = self.nutrient_saturated + + vitamin_b6 = self.vitamin_b6 + + nutrient_protein = self.nutrient_protein + + nutrient_dietaryfiber = self.nutrient_dietaryfiber + + energy_energy = self.energy_energy + + nutrient_polyunsaturated = self.nutrient_polyunsaturated + + nutrient_fat = self.nutrient_fat + + nutrient_carb = self.nutrient_carb + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if nutrient_salt is not UNSET: + field_dict["nutrient.salt"] = nutrient_salt + if nutrient_monounsaturated is not UNSET: + field_dict["nutrient.monounsaturated"] = nutrient_monounsaturated + if nutrient_sugar is not UNSET: + field_dict["nutrient.sugar"] = nutrient_sugar + if mineral_calcium is not UNSET: + field_dict["mineral.calcium"] = mineral_calcium + if nutrient_saturated is not UNSET: + field_dict["nutrient.saturated"] = nutrient_saturated + if vitamin_b6 is not UNSET: + field_dict["vitamin.b6"] = vitamin_b6 + if nutrient_protein is not UNSET: + field_dict["nutrient.protein"] = nutrient_protein + if nutrient_dietaryfiber is not UNSET: + field_dict["nutrient.dietaryfiber"] = nutrient_dietaryfiber + if energy_energy is not UNSET: + field_dict["energy.energy"] = energy_energy + if nutrient_polyunsaturated is not UNSET: + field_dict["nutrient.polyunsaturated"] = nutrient_polyunsaturated + if nutrient_fat is not UNSET: + field_dict["nutrient.fat"] = nutrient_fat + if nutrient_carb is not UNSET: + field_dict["nutrient.carb"] = nutrient_carb + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + nutrient_salt = d.pop("nutrient.salt", UNSET) + + nutrient_monounsaturated = d.pop("nutrient.monounsaturated", UNSET) + + nutrient_sugar = d.pop("nutrient.sugar", UNSET) + + mineral_calcium = d.pop("mineral.calcium", UNSET) + + nutrient_saturated = d.pop("nutrient.saturated", UNSET) + + vitamin_b6 = d.pop("vitamin.b6", UNSET) + + nutrient_protein = d.pop("nutrient.protein", UNSET) + + nutrient_dietaryfiber = d.pop("nutrient.dietaryfiber", UNSET) + + energy_energy = d.pop("energy.energy", UNSET) + + nutrient_polyunsaturated = d.pop("nutrient.polyunsaturated", UNSET) + + nutrient_fat = d.pop("nutrient.fat", UNSET) + + nutrient_carb = d.pop("nutrient.carb", UNSET) + + recipe_draft_nutrients = cls( + nutrient_salt=nutrient_salt, + nutrient_monounsaturated=nutrient_monounsaturated, + nutrient_sugar=nutrient_sugar, + mineral_calcium=mineral_calcium, + nutrient_saturated=nutrient_saturated, + vitamin_b6=vitamin_b6, + nutrient_protein=nutrient_protein, + nutrient_dietaryfiber=nutrient_dietaryfiber, + energy_energy=energy_energy, + nutrient_polyunsaturated=nutrient_polyunsaturated, + nutrient_fat=nutrient_fat, + nutrient_carb=nutrient_carb, + ) + + recipe_draft_nutrients.additional_properties = d + return recipe_draft_nutrients + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/recipe_draft_servings_item.py b/src/yazio_sdk/models/recipe_draft_servings_item.py new file mode 100644 index 0000000..3bbec17 --- /dev/null +++ b/src/yazio_sdk/models/recipe_draft_servings_item.py @@ -0,0 +1,115 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="RecipeDraftServingsItem") + + +@_attrs_define +class RecipeDraftServingsItem: + """ + Attributes: + amount (float | Unset): + serving (str | Unset): + producer (str | Unset): + name (str | Unset): + serving_quantity (float | Unset): + base_unit (str | Unset): + product_id (str | Unset): + """ + + amount: float | Unset = UNSET + serving: str | Unset = UNSET + producer: str | Unset = UNSET + name: str | Unset = UNSET + serving_quantity: float | Unset = UNSET + base_unit: str | Unset = UNSET + product_id: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + amount = self.amount + + serving = self.serving + + producer = self.producer + + name = self.name + + serving_quantity = self.serving_quantity + + base_unit = self.base_unit + + product_id = self.product_id + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if amount is not UNSET: + field_dict["amount"] = amount + if serving is not UNSET: + field_dict["serving"] = serving + if producer is not UNSET: + field_dict["producer"] = producer + if name is not UNSET: + field_dict["name"] = name + if serving_quantity is not UNSET: + field_dict["serving_quantity"] = serving_quantity + if base_unit is not UNSET: + field_dict["base_unit"] = base_unit + if product_id is not UNSET: + field_dict["product_id"] = product_id + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + amount = d.pop("amount", UNSET) + + serving = d.pop("serving", UNSET) + + producer = d.pop("producer", UNSET) + + name = d.pop("name", UNSET) + + serving_quantity = d.pop("serving_quantity", UNSET) + + base_unit = d.pop("base_unit", UNSET) + + product_id = d.pop("product_id", UNSET) + + recipe_draft_servings_item = cls( + amount=amount, + serving=serving, + producer=producer, + name=name, + serving_quantity=serving_quantity, + base_unit=base_unit, + product_id=product_id, + ) + + recipe_draft_servings_item.additional_properties = d + return recipe_draft_servings_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/recipe_image_type_0.py b/src/yazio_sdk/models/recipe_image_type_0.py new file mode 100644 index 0000000..cbe03e3 --- /dev/null +++ b/src/yazio_sdk/models/recipe_image_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="RecipeImageType0") + + +@_attrs_define +class RecipeImageType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + recipe_image_type_0 = cls() + + recipe_image_type_0.additional_properties = d + return recipe_image_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/recipe_index_entry.py b/src/yazio_sdk/models/recipe_index_entry.py new file mode 100644 index 0000000..83f9b23 --- /dev/null +++ b/src/yazio_sdk/models/recipe_index_entry.py @@ -0,0 +1,70 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="RecipeIndexEntry") + + +@_attrs_define +class RecipeIndexEntry: + """ + Attributes: + id (str | Unset): + last_changed (float | Unset): + """ + + id: str | Unset = UNSET + last_changed: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + id = self.id + + last_changed = self.last_changed + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if id is not UNSET: + field_dict["id"] = id + if last_changed is not UNSET: + field_dict["lastChanged"] = last_changed + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + id = d.pop("id", UNSET) + + last_changed = d.pop("lastChanged", UNSET) + + recipe_index_entry = cls( + id=id, + last_changed=last_changed, + ) + + recipe_index_entry.additional_properties = d + return recipe_index_entry + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/recipe_nutrients.py b/src/yazio_sdk/models/recipe_nutrients.py new file mode 100644 index 0000000..a119cff --- /dev/null +++ b/src/yazio_sdk/models/recipe_nutrients.py @@ -0,0 +1,448 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="RecipeNutrients") + + +@_attrs_define +class RecipeNutrients: + """ + Attributes: + energy_energy (float | Unset): + mineral_arsenic (float | Unset): + mineral_boron (float | Unset): + mineral_calcium (float | Unset): + mineral_chlorine (float | Unset): + mineral_chrome (float | Unset): + mineral_copper (float | Unset): + mineral_fluoride (float | Unset): + mineral_fluorine (float | Unset): + mineral_iodine (float | Unset): + mineral_iron (float | Unset): + mineral_magnesium (float | Unset): + mineral_manganese (float | Unset): + mineral_phosphorus (float | Unset): + mineral_potassium (float | Unset): + mineral_selenium (float | Unset): + mineral_sulfur (float | Unset): + mineral_zinc (float | Unset): + nutrient_alcohol (float | Unset): + nutrient_carb (float | Unset): + nutrient_cholesterol (float | Unset): + nutrient_dietaryfiber (float | Unset): + nutrient_fat (float | Unset): + nutrient_monounsaturated (float | Unset): + nutrient_polyunsaturated (float | Unset): + nutrient_protein (float | Unset): + nutrient_salt (float | Unset): + nutrient_saturated (float | Unset): + nutrient_sodium (float | Unset): + nutrient_sugar (float | Unset): + nutrient_water (float | Unset): + vitamin_a (float | Unset): + vitamin_b1 (float | Unset): + vitamin_b11 (float | Unset): + vitamin_b12 (float | Unset): + vitamin_b2 (float | Unset): + vitamin_b3 (float | Unset): + vitamin_b5 (float | Unset): + vitamin_b6 (float | Unset): + vitamin_b7 (float | Unset): + vitamin_c (float | Unset): + vitamin_d (float | Unset): + vitamin_e (float | Unset): + vitamin_k (float | Unset): + """ + + energy_energy: float | Unset = UNSET + mineral_arsenic: float | Unset = UNSET + mineral_boron: float | Unset = UNSET + mineral_calcium: float | Unset = UNSET + mineral_chlorine: float | Unset = UNSET + mineral_chrome: float | Unset = UNSET + mineral_copper: float | Unset = UNSET + mineral_fluoride: float | Unset = UNSET + mineral_fluorine: float | Unset = UNSET + mineral_iodine: float | Unset = UNSET + mineral_iron: float | Unset = UNSET + mineral_magnesium: float | Unset = UNSET + mineral_manganese: float | Unset = UNSET + mineral_phosphorus: float | Unset = UNSET + mineral_potassium: float | Unset = UNSET + mineral_selenium: float | Unset = UNSET + mineral_sulfur: float | Unset = UNSET + mineral_zinc: float | Unset = UNSET + nutrient_alcohol: float | Unset = UNSET + nutrient_carb: float | Unset = UNSET + nutrient_cholesterol: float | Unset = UNSET + nutrient_dietaryfiber: float | Unset = UNSET + nutrient_fat: float | Unset = UNSET + nutrient_monounsaturated: float | Unset = UNSET + nutrient_polyunsaturated: float | Unset = UNSET + nutrient_protein: float | Unset = UNSET + nutrient_salt: float | Unset = UNSET + nutrient_saturated: float | Unset = UNSET + nutrient_sodium: float | Unset = UNSET + nutrient_sugar: float | Unset = UNSET + nutrient_water: float | Unset = UNSET + vitamin_a: float | Unset = UNSET + vitamin_b1: float | Unset = UNSET + vitamin_b11: float | Unset = UNSET + vitamin_b12: float | Unset = UNSET + vitamin_b2: float | Unset = UNSET + vitamin_b3: float | Unset = UNSET + vitamin_b5: float | Unset = UNSET + vitamin_b6: float | Unset = UNSET + vitamin_b7: float | Unset = UNSET + vitamin_c: float | Unset = UNSET + vitamin_d: float | Unset = UNSET + vitamin_e: float | Unset = UNSET + vitamin_k: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + energy_energy = self.energy_energy + + mineral_arsenic = self.mineral_arsenic + + mineral_boron = self.mineral_boron + + mineral_calcium = self.mineral_calcium + + mineral_chlorine = self.mineral_chlorine + + mineral_chrome = self.mineral_chrome + + mineral_copper = self.mineral_copper + + mineral_fluoride = self.mineral_fluoride + + mineral_fluorine = self.mineral_fluorine + + mineral_iodine = self.mineral_iodine + + mineral_iron = self.mineral_iron + + mineral_magnesium = self.mineral_magnesium + + mineral_manganese = self.mineral_manganese + + mineral_phosphorus = self.mineral_phosphorus + + mineral_potassium = self.mineral_potassium + + mineral_selenium = self.mineral_selenium + + mineral_sulfur = self.mineral_sulfur + + mineral_zinc = self.mineral_zinc + + nutrient_alcohol = self.nutrient_alcohol + + nutrient_carb = self.nutrient_carb + + nutrient_cholesterol = self.nutrient_cholesterol + + nutrient_dietaryfiber = self.nutrient_dietaryfiber + + nutrient_fat = self.nutrient_fat + + nutrient_monounsaturated = self.nutrient_monounsaturated + + nutrient_polyunsaturated = self.nutrient_polyunsaturated + + nutrient_protein = self.nutrient_protein + + nutrient_salt = self.nutrient_salt + + nutrient_saturated = self.nutrient_saturated + + nutrient_sodium = self.nutrient_sodium + + nutrient_sugar = self.nutrient_sugar + + nutrient_water = self.nutrient_water + + vitamin_a = self.vitamin_a + + vitamin_b1 = self.vitamin_b1 + + vitamin_b11 = self.vitamin_b11 + + vitamin_b12 = self.vitamin_b12 + + vitamin_b2 = self.vitamin_b2 + + vitamin_b3 = self.vitamin_b3 + + vitamin_b5 = self.vitamin_b5 + + vitamin_b6 = self.vitamin_b6 + + vitamin_b7 = self.vitamin_b7 + + vitamin_c = self.vitamin_c + + vitamin_d = self.vitamin_d + + vitamin_e = self.vitamin_e + + vitamin_k = self.vitamin_k + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if energy_energy is not UNSET: + field_dict["energy.energy"] = energy_energy + if mineral_arsenic is not UNSET: + field_dict["mineral.arsenic"] = mineral_arsenic + if mineral_boron is not UNSET: + field_dict["mineral.boron"] = mineral_boron + if mineral_calcium is not UNSET: + field_dict["mineral.calcium"] = mineral_calcium + if mineral_chlorine is not UNSET: + field_dict["mineral.chlorine"] = mineral_chlorine + if mineral_chrome is not UNSET: + field_dict["mineral.chrome"] = mineral_chrome + if mineral_copper is not UNSET: + field_dict["mineral.copper"] = mineral_copper + if mineral_fluoride is not UNSET: + field_dict["mineral.fluoride"] = mineral_fluoride + if mineral_fluorine is not UNSET: + field_dict["mineral.fluorine"] = mineral_fluorine + if mineral_iodine is not UNSET: + field_dict["mineral.iodine"] = mineral_iodine + if mineral_iron is not UNSET: + field_dict["mineral.iron"] = mineral_iron + if mineral_magnesium is not UNSET: + field_dict["mineral.magnesium"] = mineral_magnesium + if mineral_manganese is not UNSET: + field_dict["mineral.manganese"] = mineral_manganese + if mineral_phosphorus is not UNSET: + field_dict["mineral.phosphorus"] = mineral_phosphorus + if mineral_potassium is not UNSET: + field_dict["mineral.potassium"] = mineral_potassium + if mineral_selenium is not UNSET: + field_dict["mineral.selenium"] = mineral_selenium + if mineral_sulfur is not UNSET: + field_dict["mineral.sulfur"] = mineral_sulfur + if mineral_zinc is not UNSET: + field_dict["mineral.zinc"] = mineral_zinc + if nutrient_alcohol is not UNSET: + field_dict["nutrient.alcohol"] = nutrient_alcohol + if nutrient_carb is not UNSET: + field_dict["nutrient.carb"] = nutrient_carb + if nutrient_cholesterol is not UNSET: + field_dict["nutrient.cholesterol"] = nutrient_cholesterol + if nutrient_dietaryfiber is not UNSET: + field_dict["nutrient.dietaryfiber"] = nutrient_dietaryfiber + if nutrient_fat is not UNSET: + field_dict["nutrient.fat"] = nutrient_fat + if nutrient_monounsaturated is not UNSET: + field_dict["nutrient.monounsaturated"] = nutrient_monounsaturated + if nutrient_polyunsaturated is not UNSET: + field_dict["nutrient.polyunsaturated"] = nutrient_polyunsaturated + if nutrient_protein is not UNSET: + field_dict["nutrient.protein"] = nutrient_protein + if nutrient_salt is not UNSET: + field_dict["nutrient.salt"] = nutrient_salt + if nutrient_saturated is not UNSET: + field_dict["nutrient.saturated"] = nutrient_saturated + if nutrient_sodium is not UNSET: + field_dict["nutrient.sodium"] = nutrient_sodium + if nutrient_sugar is not UNSET: + field_dict["nutrient.sugar"] = nutrient_sugar + if nutrient_water is not UNSET: + field_dict["nutrient.water"] = nutrient_water + if vitamin_a is not UNSET: + field_dict["vitamin.a"] = vitamin_a + if vitamin_b1 is not UNSET: + field_dict["vitamin.b1"] = vitamin_b1 + if vitamin_b11 is not UNSET: + field_dict["vitamin.b11"] = vitamin_b11 + if vitamin_b12 is not UNSET: + field_dict["vitamin.b12"] = vitamin_b12 + if vitamin_b2 is not UNSET: + field_dict["vitamin.b2"] = vitamin_b2 + if vitamin_b3 is not UNSET: + field_dict["vitamin.b3"] = vitamin_b3 + if vitamin_b5 is not UNSET: + field_dict["vitamin.b5"] = vitamin_b5 + if vitamin_b6 is not UNSET: + field_dict["vitamin.b6"] = vitamin_b6 + if vitamin_b7 is not UNSET: + field_dict["vitamin.b7"] = vitamin_b7 + if vitamin_c is not UNSET: + field_dict["vitamin.c"] = vitamin_c + if vitamin_d is not UNSET: + field_dict["vitamin.d"] = vitamin_d + if vitamin_e is not UNSET: + field_dict["vitamin.e"] = vitamin_e + if vitamin_k is not UNSET: + field_dict["vitamin.k"] = vitamin_k + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + energy_energy = d.pop("energy.energy", UNSET) + + mineral_arsenic = d.pop("mineral.arsenic", UNSET) + + mineral_boron = d.pop("mineral.boron", UNSET) + + mineral_calcium = d.pop("mineral.calcium", UNSET) + + mineral_chlorine = d.pop("mineral.chlorine", UNSET) + + mineral_chrome = d.pop("mineral.chrome", UNSET) + + mineral_copper = d.pop("mineral.copper", UNSET) + + mineral_fluoride = d.pop("mineral.fluoride", UNSET) + + mineral_fluorine = d.pop("mineral.fluorine", UNSET) + + mineral_iodine = d.pop("mineral.iodine", UNSET) + + mineral_iron = d.pop("mineral.iron", UNSET) + + mineral_magnesium = d.pop("mineral.magnesium", UNSET) + + mineral_manganese = d.pop("mineral.manganese", UNSET) + + mineral_phosphorus = d.pop("mineral.phosphorus", UNSET) + + mineral_potassium = d.pop("mineral.potassium", UNSET) + + mineral_selenium = d.pop("mineral.selenium", UNSET) + + mineral_sulfur = d.pop("mineral.sulfur", UNSET) + + mineral_zinc = d.pop("mineral.zinc", UNSET) + + nutrient_alcohol = d.pop("nutrient.alcohol", UNSET) + + nutrient_carb = d.pop("nutrient.carb", UNSET) + + nutrient_cholesterol = d.pop("nutrient.cholesterol", UNSET) + + nutrient_dietaryfiber = d.pop("nutrient.dietaryfiber", UNSET) + + nutrient_fat = d.pop("nutrient.fat", UNSET) + + nutrient_monounsaturated = d.pop("nutrient.monounsaturated", UNSET) + + nutrient_polyunsaturated = d.pop("nutrient.polyunsaturated", UNSET) + + nutrient_protein = d.pop("nutrient.protein", UNSET) + + nutrient_salt = d.pop("nutrient.salt", UNSET) + + nutrient_saturated = d.pop("nutrient.saturated", UNSET) + + nutrient_sodium = d.pop("nutrient.sodium", UNSET) + + nutrient_sugar = d.pop("nutrient.sugar", UNSET) + + nutrient_water = d.pop("nutrient.water", UNSET) + + vitamin_a = d.pop("vitamin.a", UNSET) + + vitamin_b1 = d.pop("vitamin.b1", UNSET) + + vitamin_b11 = d.pop("vitamin.b11", UNSET) + + vitamin_b12 = d.pop("vitamin.b12", UNSET) + + vitamin_b2 = d.pop("vitamin.b2", UNSET) + + vitamin_b3 = d.pop("vitamin.b3", UNSET) + + vitamin_b5 = d.pop("vitamin.b5", UNSET) + + vitamin_b6 = d.pop("vitamin.b6", UNSET) + + vitamin_b7 = d.pop("vitamin.b7", UNSET) + + vitamin_c = d.pop("vitamin.c", UNSET) + + vitamin_d = d.pop("vitamin.d", UNSET) + + vitamin_e = d.pop("vitamin.e", UNSET) + + vitamin_k = d.pop("vitamin.k", UNSET) + + recipe_nutrients = cls( + energy_energy=energy_energy, + mineral_arsenic=mineral_arsenic, + mineral_boron=mineral_boron, + mineral_calcium=mineral_calcium, + mineral_chlorine=mineral_chlorine, + mineral_chrome=mineral_chrome, + mineral_copper=mineral_copper, + mineral_fluoride=mineral_fluoride, + mineral_fluorine=mineral_fluorine, + mineral_iodine=mineral_iodine, + mineral_iron=mineral_iron, + mineral_magnesium=mineral_magnesium, + mineral_manganese=mineral_manganese, + mineral_phosphorus=mineral_phosphorus, + mineral_potassium=mineral_potassium, + mineral_selenium=mineral_selenium, + mineral_sulfur=mineral_sulfur, + mineral_zinc=mineral_zinc, + nutrient_alcohol=nutrient_alcohol, + nutrient_carb=nutrient_carb, + nutrient_cholesterol=nutrient_cholesterol, + nutrient_dietaryfiber=nutrient_dietaryfiber, + nutrient_fat=nutrient_fat, + nutrient_monounsaturated=nutrient_monounsaturated, + nutrient_polyunsaturated=nutrient_polyunsaturated, + nutrient_protein=nutrient_protein, + nutrient_salt=nutrient_salt, + nutrient_saturated=nutrient_saturated, + nutrient_sodium=nutrient_sodium, + nutrient_sugar=nutrient_sugar, + nutrient_water=nutrient_water, + vitamin_a=vitamin_a, + vitamin_b1=vitamin_b1, + vitamin_b11=vitamin_b11, + vitamin_b12=vitamin_b12, + vitamin_b2=vitamin_b2, + vitamin_b3=vitamin_b3, + vitamin_b5=vitamin_b5, + vitamin_b6=vitamin_b6, + vitamin_b7=vitamin_b7, + vitamin_c=vitamin_c, + vitamin_d=vitamin_d, + vitamin_e=vitamin_e, + vitamin_k=vitamin_k, + ) + + recipe_nutrients.additional_properties = d + return recipe_nutrients + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/recipe_servings_item.py b/src/yazio_sdk/models/recipe_servings_item.py new file mode 100644 index 0000000..0b2a655 --- /dev/null +++ b/src/yazio_sdk/models/recipe_servings_item.py @@ -0,0 +1,209 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.recipe_servings_item_note_type_0 import RecipeServingsItemNoteType0 + from ..models.recipe_servings_item_serving_quantity_type_0 import ( + RecipeServingsItemServingQuantityType0, + ) + from ..models.recipe_servings_item_serving_type_0 import RecipeServingsItemServingType0 + + +T = TypeVar("T", bound="RecipeServingsItem") + + +@_attrs_define +class RecipeServingsItem: + """ + Attributes: + producer (str | Unset): + name (str | Unset): + amount (float | Unset): + serving (None | RecipeServingsItemServingType0 | Unset): + serving_quantity (None | RecipeServingsItemServingQuantityType0 | Unset): + base_unit (str | Unset): + note (None | RecipeServingsItemNoteType0 | Unset): + product_id (str | Unset): + """ + + producer: str | Unset = UNSET + name: str | Unset = UNSET + amount: float | Unset = UNSET + serving: None | RecipeServingsItemServingType0 | Unset = UNSET + serving_quantity: None | RecipeServingsItemServingQuantityType0 | Unset = UNSET + base_unit: str | Unset = UNSET + note: None | RecipeServingsItemNoteType0 | Unset = UNSET + product_id: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + from ..models.recipe_servings_item_note_type_0 import RecipeServingsItemNoteType0 + from ..models.recipe_servings_item_serving_quantity_type_0 import ( + RecipeServingsItemServingQuantityType0, + ) + from ..models.recipe_servings_item_serving_type_0 import RecipeServingsItemServingType0 + + producer = self.producer + + name = self.name + + amount = self.amount + + serving: dict[str, Any] | None | Unset + if isinstance(self.serving, Unset): + serving = UNSET + elif isinstance(self.serving, RecipeServingsItemServingType0): + serving = self.serving.to_dict() + else: + serving = self.serving + + serving_quantity: dict[str, Any] | None | Unset + if isinstance(self.serving_quantity, Unset): + serving_quantity = UNSET + elif isinstance(self.serving_quantity, RecipeServingsItemServingQuantityType0): + serving_quantity = self.serving_quantity.to_dict() + else: + serving_quantity = self.serving_quantity + + base_unit = self.base_unit + + note: dict[str, Any] | None | Unset + if isinstance(self.note, Unset): + note = UNSET + elif isinstance(self.note, RecipeServingsItemNoteType0): + note = self.note.to_dict() + else: + note = self.note + + product_id = self.product_id + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if producer is not UNSET: + field_dict["producer"] = producer + if name is not UNSET: + field_dict["name"] = name + if amount is not UNSET: + field_dict["amount"] = amount + if serving is not UNSET: + field_dict["serving"] = serving + if serving_quantity is not UNSET: + field_dict["serving_quantity"] = serving_quantity + if base_unit is not UNSET: + field_dict["base_unit"] = base_unit + if note is not UNSET: + field_dict["note"] = note + if product_id is not UNSET: + field_dict["product_id"] = product_id + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.recipe_servings_item_note_type_0 import RecipeServingsItemNoteType0 + from ..models.recipe_servings_item_serving_quantity_type_0 import ( + RecipeServingsItemServingQuantityType0, + ) + from ..models.recipe_servings_item_serving_type_0 import RecipeServingsItemServingType0 + + d = dict(src_dict) + producer = d.pop("producer", UNSET) + + name = d.pop("name", UNSET) + + amount = d.pop("amount", UNSET) + + def _parse_serving(data: object) -> None | RecipeServingsItemServingType0 | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + serving_type_0 = RecipeServingsItemServingType0.from_dict(data) + + return serving_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | RecipeServingsItemServingType0 | Unset, data) + + serving = _parse_serving(d.pop("serving", UNSET)) + + def _parse_serving_quantity( + data: object, + ) -> None | RecipeServingsItemServingQuantityType0 | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + serving_quantity_type_0 = RecipeServingsItemServingQuantityType0.from_dict(data) + + return serving_quantity_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | RecipeServingsItemServingQuantityType0 | Unset, data) + + serving_quantity = _parse_serving_quantity(d.pop("serving_quantity", UNSET)) + + base_unit = d.pop("base_unit", UNSET) + + def _parse_note(data: object) -> None | RecipeServingsItemNoteType0 | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + note_type_0 = RecipeServingsItemNoteType0.from_dict(data) + + return note_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | RecipeServingsItemNoteType0 | Unset, data) + + note = _parse_note(d.pop("note", UNSET)) + + product_id = d.pop("product_id", UNSET) + + recipe_servings_item = cls( + producer=producer, + name=name, + amount=amount, + serving=serving, + serving_quantity=serving_quantity, + base_unit=base_unit, + note=note, + product_id=product_id, + ) + + recipe_servings_item.additional_properties = d + return recipe_servings_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/recipe_servings_item_note_type_0.py b/src/yazio_sdk/models/recipe_servings_item_note_type_0.py new file mode 100644 index 0000000..4f87c5e --- /dev/null +++ b/src/yazio_sdk/models/recipe_servings_item_note_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="RecipeServingsItemNoteType0") + + +@_attrs_define +class RecipeServingsItemNoteType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + recipe_servings_item_note_type_0 = cls() + + recipe_servings_item_note_type_0.additional_properties = d + return recipe_servings_item_note_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/recipe_servings_item_serving_quantity_type_0.py b/src/yazio_sdk/models/recipe_servings_item_serving_quantity_type_0.py new file mode 100644 index 0000000..a376d67 --- /dev/null +++ b/src/yazio_sdk/models/recipe_servings_item_serving_quantity_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="RecipeServingsItemServingQuantityType0") + + +@_attrs_define +class RecipeServingsItemServingQuantityType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + recipe_servings_item_serving_quantity_type_0 = cls() + + recipe_servings_item_serving_quantity_type_0.additional_properties = d + return recipe_servings_item_serving_quantity_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/recipe_servings_item_serving_type_0.py b/src/yazio_sdk/models/recipe_servings_item_serving_type_0.py new file mode 100644 index 0000000..6d6c3f3 --- /dev/null +++ b/src/yazio_sdk/models/recipe_servings_item_serving_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="RecipeServingsItemServingType0") + + +@_attrs_define +class RecipeServingsItemServingType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + recipe_servings_item_serving_type_0 = cls() + + recipe_servings_item_serving_type_0.additional_properties = d + return recipe_servings_item_serving_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/recipe_yazio_id_type_0.py b/src/yazio_sdk/models/recipe_yazio_id_type_0.py new file mode 100644 index 0000000..f3ab64f --- /dev/null +++ b/src/yazio_sdk/models/recipe_yazio_id_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="RecipeYazioIdType0") + + +@_attrs_define +class RecipeYazioIdType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + recipe_yazio_id_type_0 = cls() + + recipe_yazio_id_type_0.additional_properties = d + return recipe_yazio_id_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/shop_items.py b/src/yazio_sdk/models/shop_items.py new file mode 100644 index 0000000..dd6e19f --- /dev/null +++ b/src/yazio_sdk/models/shop_items.py @@ -0,0 +1,79 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.shop_items_items_item import ShopItemsItemsItem + + +T = TypeVar("T", bound="ShopItems") + + +@_attrs_define +class ShopItems: + """ + Attributes: + items (list[ShopItemsItemsItem] | Unset): + """ + + items: list[ShopItemsItemsItem] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + items: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.items, Unset): + items = [] + for items_item_data in self.items: + items_item = items_item_data.to_dict() + items.append(items_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if items is not UNSET: + field_dict["items"] = items + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.shop_items_items_item import ShopItemsItemsItem + + d = dict(src_dict) + _items = d.pop("items", UNSET) + items: list[ShopItemsItemsItem] | Unset = UNSET + if _items is not UNSET: + items = [] + for items_item_data in _items: + items_item = ShopItemsItemsItem.from_dict(items_item_data) + + items.append(items_item) + + shop_items = cls( + items=items, + ) + + shop_items.additional_properties = d + return shop_items + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/shop_items_items_item.py b/src/yazio_sdk/models/shop_items_items_item.py new file mode 100644 index 0000000..205987d --- /dev/null +++ b/src/yazio_sdk/models/shop_items_items_item.py @@ -0,0 +1,79 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ShopItemsItemsItem") + + +@_attrs_define +class ShopItemsItemsItem: + """ + Attributes: + shop_item_type (str | Unset): + currency_type (str | Unset): + currency_quantity (float | Unset): + """ + + shop_item_type: str | Unset = UNSET + currency_type: str | Unset = UNSET + currency_quantity: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + shop_item_type = self.shop_item_type + + currency_type = self.currency_type + + currency_quantity = self.currency_quantity + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if shop_item_type is not UNSET: + field_dict["shop_item_type"] = shop_item_type + if currency_type is not UNSET: + field_dict["currency_type"] = currency_type + if currency_quantity is not UNSET: + field_dict["currency_quantity"] = currency_quantity + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + shop_item_type = d.pop("shop_item_type", UNSET) + + currency_type = d.pop("currency_type", UNSET) + + currency_quantity = d.pop("currency_quantity", UNSET) + + shop_items_items_item = cls( + shop_item_type=shop_item_type, + currency_type=currency_type, + currency_quantity=currency_quantity, + ) + + shop_items_items_item.additional_properties = d + return shop_items_items_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/streak_calendar.py b/src/yazio_sdk/models/streak_calendar.py new file mode 100644 index 0000000..167d683 --- /dev/null +++ b/src/yazio_sdk/models/streak_calendar.py @@ -0,0 +1,74 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.streak_day import StreakDay + + +T = TypeVar("T", bound="StreakCalendar") + + +@_attrs_define +class StreakCalendar: + """ + Attributes: + field_1970_01_01 (StreakDay | Unset): + """ + + field_1970_01_01: StreakDay | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + field_1970_01_01: dict[str, Any] | Unset = UNSET + if not isinstance(self.field_1970_01_01, Unset): + field_1970_01_01 = self.field_1970_01_01.to_dict() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if field_1970_01_01 is not UNSET: + field_dict["1970-01-01"] = field_1970_01_01 + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.streak_day import StreakDay + + d = dict(src_dict) + _field_1970_01_01 = d.pop("1970-01-01", UNSET) + field_1970_01_01: StreakDay | Unset + if isinstance(_field_1970_01_01, Unset): + field_1970_01_01 = UNSET + else: + field_1970_01_01 = StreakDay.from_dict(_field_1970_01_01) + + streak_calendar = cls( + field_1970_01_01=field_1970_01_01, + ) + + streak_calendar.additional_properties = d + return streak_calendar + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/streak_day.py b/src/yazio_sdk/models/streak_day.py new file mode 100644 index 0000000..d2bbe9b --- /dev/null +++ b/src/yazio_sdk/models/streak_day.py @@ -0,0 +1,90 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="StreakDay") + + +@_attrs_define +class StreakDay: + """ + Attributes: + daytimes (list[str] | Unset): + streak_count (float | Unset): + freeze_count (float | Unset): + origin_of_recovery (str | Unset): + """ + + daytimes: list[str] | Unset = UNSET + streak_count: float | Unset = UNSET + freeze_count: float | Unset = UNSET + origin_of_recovery: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + daytimes: list[str] | Unset = UNSET + if not isinstance(self.daytimes, Unset): + daytimes = self.daytimes + + streak_count = self.streak_count + + freeze_count = self.freeze_count + + origin_of_recovery = self.origin_of_recovery + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if daytimes is not UNSET: + field_dict["daytimes"] = daytimes + if streak_count is not UNSET: + field_dict["streak_count"] = streak_count + if freeze_count is not UNSET: + field_dict["freeze_count"] = freeze_count + if origin_of_recovery is not UNSET: + field_dict["origin_of_recovery"] = origin_of_recovery + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + daytimes = cast(list[str], d.pop("daytimes", UNSET)) + + streak_count = d.pop("streak_count", UNSET) + + freeze_count = d.pop("freeze_count", UNSET) + + origin_of_recovery = d.pop("origin_of_recovery", UNSET) + + streak_day = cls( + daytimes=daytimes, + streak_count=streak_count, + freeze_count=freeze_count, + origin_of_recovery=origin_of_recovery, + ) + + streak_day.additional_properties = d + return streak_day + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/streak_update.py b/src/yazio_sdk/models/streak_update.py new file mode 100644 index 0000000..5062c08 --- /dev/null +++ b/src/yazio_sdk/models/streak_update.py @@ -0,0 +1,81 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="StreakUpdate") + + +@_attrs_define +class StreakUpdate: + """ + Attributes: + daytimes (list[str] | Unset): + streak_count (float | Unset): + freeze_count (float | Unset): + """ + + daytimes: list[str] | Unset = UNSET + streak_count: float | Unset = UNSET + freeze_count: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + daytimes: list[str] | Unset = UNSET + if not isinstance(self.daytimes, Unset): + daytimes = self.daytimes + + streak_count = self.streak_count + + freeze_count = self.freeze_count + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if daytimes is not UNSET: + field_dict["daytimes"] = daytimes + if streak_count is not UNSET: + field_dict["streak_count"] = streak_count + if freeze_count is not UNSET: + field_dict["freeze_count"] = freeze_count + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + daytimes = cast(list[str], d.pop("daytimes", UNSET)) + + streak_count = d.pop("streak_count", UNSET) + + freeze_count = d.pop("freeze_count", UNSET) + + streak_update = cls( + daytimes=daytimes, + streak_count=streak_count, + freeze_count=freeze_count, + ) + + streak_update.additional_properties = d + return streak_update + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/subscription.py b/src/yazio_sdk/models/subscription.py new file mode 100644 index 0000000..5aaa1ea --- /dev/null +++ b/src/yazio_sdk/models/subscription.py @@ -0,0 +1,153 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.subscription_base_plan_id_type_0 import SubscriptionBasePlanIdType0 + + +T = TypeVar("T", bound="Subscription") + + +@_attrs_define +class Subscription: + """ + Attributes: + start (str | Unset): + end (str | Unset): + gateway (str | Unset): + type_ (str | Unset): + status (str | Unset): + payment_provider_transaction_id (str | Unset): + last_status_change_at (str | Unset): + base_plan_id (None | SubscriptionBasePlanIdType0 | Unset): + """ + + start: str | Unset = UNSET + end: str | Unset = UNSET + gateway: str | Unset = UNSET + type_: str | Unset = UNSET + status: str | Unset = UNSET + payment_provider_transaction_id: str | Unset = UNSET + last_status_change_at: str | Unset = UNSET + base_plan_id: None | SubscriptionBasePlanIdType0 | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + from ..models.subscription_base_plan_id_type_0 import SubscriptionBasePlanIdType0 + + start = self.start + + end = self.end + + gateway = self.gateway + + type_ = self.type_ + + status = self.status + + payment_provider_transaction_id = self.payment_provider_transaction_id + + last_status_change_at = self.last_status_change_at + + base_plan_id: dict[str, Any] | None | Unset + if isinstance(self.base_plan_id, Unset): + base_plan_id = UNSET + elif isinstance(self.base_plan_id, SubscriptionBasePlanIdType0): + base_plan_id = self.base_plan_id.to_dict() + else: + base_plan_id = self.base_plan_id + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if start is not UNSET: + field_dict["start"] = start + if end is not UNSET: + field_dict["end"] = end + if gateway is not UNSET: + field_dict["gateway"] = gateway + if type_ is not UNSET: + field_dict["type"] = type_ + if status is not UNSET: + field_dict["status"] = status + if payment_provider_transaction_id is not UNSET: + field_dict["payment_provider_transaction_id"] = payment_provider_transaction_id + if last_status_change_at is not UNSET: + field_dict["last_status_change_at"] = last_status_change_at + if base_plan_id is not UNSET: + field_dict["base_plan_id"] = base_plan_id + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.subscription_base_plan_id_type_0 import SubscriptionBasePlanIdType0 + + d = dict(src_dict) + start = d.pop("start", UNSET) + + end = d.pop("end", UNSET) + + gateway = d.pop("gateway", UNSET) + + type_ = d.pop("type", UNSET) + + status = d.pop("status", UNSET) + + payment_provider_transaction_id = d.pop("payment_provider_transaction_id", UNSET) + + last_status_change_at = d.pop("last_status_change_at", UNSET) + + def _parse_base_plan_id(data: object) -> None | SubscriptionBasePlanIdType0 | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + base_plan_id_type_0 = SubscriptionBasePlanIdType0.from_dict(data) + + return base_plan_id_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | SubscriptionBasePlanIdType0 | Unset, data) + + base_plan_id = _parse_base_plan_id(d.pop("base_plan_id", UNSET)) + + subscription = cls( + start=start, + end=end, + gateway=gateway, + type_=type_, + status=status, + payment_provider_transaction_id=payment_provider_transaction_id, + last_status_change_at=last_status_change_at, + base_plan_id=base_plan_id, + ) + + subscription.additional_properties = d + return subscription + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/subscription_base_plan_id_type_0.py b/src/yazio_sdk/models/subscription_base_plan_id_type_0.py new file mode 100644 index 0000000..1f46701 --- /dev/null +++ b/src/yazio_sdk/models/subscription_base_plan_id_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="SubscriptionBasePlanIdType0") + + +@_attrs_define +class SubscriptionBasePlanIdType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + subscription_base_plan_id_type_0 = cls() + + subscription_base_plan_id_type_0.additional_properties = d + return subscription_base_plan_id_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/suggested_product.py b/src/yazio_sdk/models/suggested_product.py new file mode 100644 index 0000000..845139c --- /dev/null +++ b/src/yazio_sdk/models/suggested_product.py @@ -0,0 +1,88 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="SuggestedProduct") + + +@_attrs_define +class SuggestedProduct: + """ + Attributes: + product_id (str | Unset): + amount (float | Unset): + serving (str | Unset): + serving_quantity (float | Unset): + """ + + product_id: str | Unset = UNSET + amount: float | Unset = UNSET + serving: str | Unset = UNSET + serving_quantity: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + product_id = self.product_id + + amount = self.amount + + serving = self.serving + + serving_quantity = self.serving_quantity + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if product_id is not UNSET: + field_dict["product_id"] = product_id + if amount is not UNSET: + field_dict["amount"] = amount + if serving is not UNSET: + field_dict["serving"] = serving + if serving_quantity is not UNSET: + field_dict["serving_quantity"] = serving_quantity + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + product_id = d.pop("product_id", UNSET) + + amount = d.pop("amount", UNSET) + + serving = d.pop("serving", UNSET) + + serving_quantity = d.pop("serving_quantity", UNSET) + + suggested_product = cls( + product_id=product_id, + amount=amount, + serving=serving, + serving_quantity=serving_quantity, + ) + + suggested_product.additional_properties = d + return suggested_product + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/third_party_integration.py b/src/yazio_sdk/models/third_party_integration.py new file mode 100644 index 0000000..e563004 --- /dev/null +++ b/src/yazio_sdk/models/third_party_integration.py @@ -0,0 +1,72 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="ThirdPartyIntegration") + + +@_attrs_define +class ThirdPartyIntegration: + """ + Attributes: + required_actions (list[Any] | Unset): + active_gateway (str | Unset): + """ + + required_actions: list[Any] | Unset = UNSET + active_gateway: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + required_actions: list[Any] | Unset = UNSET + if not isinstance(self.required_actions, Unset): + required_actions = self.required_actions + + active_gateway = self.active_gateway + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if required_actions is not UNSET: + field_dict["required_actions"] = required_actions + if active_gateway is not UNSET: + field_dict["active_gateway"] = active_gateway + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + required_actions = cast(list[Any], d.pop("required_actions", UNSET)) + + active_gateway = d.pop("active_gateway", UNSET) + + third_party_integration = cls( + required_actions=required_actions, + active_gateway=active_gateway, + ) + + third_party_integration.additional_properties = d + return third_party_integration + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/unlocked_features.py b/src/yazio_sdk/models/unlocked_features.py new file mode 100644 index 0000000..9b927f3 --- /dev/null +++ b/src/yazio_sdk/models/unlocked_features.py @@ -0,0 +1,85 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.unlocked_features_unlocked_features_item import ( + UnlockedFeaturesUnlockedFeaturesItem, + ) + + +T = TypeVar("T", bound="UnlockedFeatures") + + +@_attrs_define +class UnlockedFeatures: + """ + Attributes: + unlocked_features (list[UnlockedFeaturesUnlockedFeaturesItem] | Unset): + """ + + unlocked_features: list[UnlockedFeaturesUnlockedFeaturesItem] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + unlocked_features: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.unlocked_features, Unset): + unlocked_features = [] + for unlocked_features_item_data in self.unlocked_features: + unlocked_features_item = unlocked_features_item_data.to_dict() + unlocked_features.append(unlocked_features_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if unlocked_features is not UNSET: + field_dict["unlocked_features"] = unlocked_features + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.unlocked_features_unlocked_features_item import ( + UnlockedFeaturesUnlockedFeaturesItem, + ) + + d = dict(src_dict) + _unlocked_features = d.pop("unlocked_features", UNSET) + unlocked_features: list[UnlockedFeaturesUnlockedFeaturesItem] | Unset = UNSET + if _unlocked_features is not UNSET: + unlocked_features = [] + for unlocked_features_item_data in _unlocked_features: + unlocked_features_item = UnlockedFeaturesUnlockedFeaturesItem.from_dict( + unlocked_features_item_data + ) + + unlocked_features.append(unlocked_features_item) + + unlocked_features = cls( + unlocked_features=unlocked_features, + ) + + unlocked_features.additional_properties = d + return unlocked_features + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/unlocked_features_unlocked_features_item.py b/src/yazio_sdk/models/unlocked_features_unlocked_features_item.py new file mode 100644 index 0000000..3ca7906 --- /dev/null +++ b/src/yazio_sdk/models/unlocked_features_unlocked_features_item.py @@ -0,0 +1,79 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="UnlockedFeaturesUnlockedFeaturesItem") + + +@_attrs_define +class UnlockedFeaturesUnlockedFeaturesItem: + """ + Attributes: + feature (str | Unset): + origin (str | Unset): + expire_date_time_utc (str | Unset): + """ + + feature: str | Unset = UNSET + origin: str | Unset = UNSET + expire_date_time_utc: str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + feature = self.feature + + origin = self.origin + + expire_date_time_utc = self.expire_date_time_utc + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if feature is not UNSET: + field_dict["feature"] = feature + if origin is not UNSET: + field_dict["origin"] = origin + if expire_date_time_utc is not UNSET: + field_dict["expire_date_time_utc"] = expire_date_time_utc + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + feature = d.pop("feature", UNSET) + + origin = d.pop("origin", UNSET) + + expire_date_time_utc = d.pop("expire_date_time_utc", UNSET) + + unlocked_features_unlocked_features_item = cls( + feature=feature, + origin=origin, + expire_date_time_utc=expire_date_time_utc, + ) + + unlocked_features_unlocked_features_item.additional_properties = d + return unlocked_features_unlocked_features_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/user_profile.py b/src/yazio_sdk/models/user_profile.py new file mode 100644 index 0000000..e32a416 --- /dev/null +++ b/src/yazio_sdk/models/user_profile.py @@ -0,0 +1,461 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.user_profile_city_type_0 import UserProfileCityType0 + from ..models.user_profile_diet import UserProfileDiet + from ..models.user_profile_last_name_type_0 import UserProfileLastNameType0 + from ..models.user_profile_profile_image_type_0 import UserProfileProfileImageType0 + from ..models.user_profile_siwa_user_id_type_0 import UserProfileSiwaUserIdType0 + + +T = TypeVar("T", bound="UserProfile") + + +@_attrs_define +class UserProfile: + """ + Attributes: + first_name (str | Unset): + last_name (None | Unset | UserProfileLastNameType0): + sex (str | Unset): + city (None | Unset | UserProfileCityType0): + country (str | Unset): + language (str | Unset): + timezone_offset (float | Unset): + food_database_country (str | Unset): + goal (str | Unset): + activity_degree (str | Unset): + weight_change_per_week (float | Unset): + unit_length (str | Unset): + unit_mass (str | Unset): + unit_energy (str | Unset): + unit_glucose (str | Unset): + unit_serving (str | Unset): + stripe_customer_id (str | Unset): + diet (UserProfileDiet | Unset): + registration_date (str | Unset): + reset_date (str | Unset): + profile_image (None | Unset | UserProfileProfileImageType0): + user_token (str | Unset): + email_confirmation_status (str | Unset): + newsletter_opt_in (bool | Unset): + login_type (str | Unset): + siwa_user_id (None | Unset | UserProfileSiwaUserIdType0): + premium_type (str | Unset): + start_weight (float | Unset): + uuid (str | Unset): + body_height (float | Unset): + date_of_birth (str | Unset): + email (str | Unset): + tags (list[Any] | Unset): + """ + + first_name: str | Unset = UNSET + last_name: None | Unset | UserProfileLastNameType0 = UNSET + sex: str | Unset = UNSET + city: None | Unset | UserProfileCityType0 = UNSET + country: str | Unset = UNSET + language: str | Unset = UNSET + timezone_offset: float | Unset = UNSET + food_database_country: str | Unset = UNSET + goal: str | Unset = UNSET + activity_degree: str | Unset = UNSET + weight_change_per_week: float | Unset = UNSET + unit_length: str | Unset = UNSET + unit_mass: str | Unset = UNSET + unit_energy: str | Unset = UNSET + unit_glucose: str | Unset = UNSET + unit_serving: str | Unset = UNSET + stripe_customer_id: str | Unset = UNSET + diet: UserProfileDiet | Unset = UNSET + registration_date: str | Unset = UNSET + reset_date: str | Unset = UNSET + profile_image: None | Unset | UserProfileProfileImageType0 = UNSET + user_token: str | Unset = UNSET + email_confirmation_status: str | Unset = UNSET + newsletter_opt_in: bool | Unset = UNSET + login_type: str | Unset = UNSET + siwa_user_id: None | Unset | UserProfileSiwaUserIdType0 = UNSET + premium_type: str | Unset = UNSET + start_weight: float | Unset = UNSET + uuid: str | Unset = UNSET + body_height: float | Unset = UNSET + date_of_birth: str | Unset = UNSET + email: str | Unset = UNSET + tags: list[Any] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + from ..models.user_profile_city_type_0 import UserProfileCityType0 + from ..models.user_profile_last_name_type_0 import UserProfileLastNameType0 + from ..models.user_profile_profile_image_type_0 import UserProfileProfileImageType0 + from ..models.user_profile_siwa_user_id_type_0 import UserProfileSiwaUserIdType0 + + first_name = self.first_name + + last_name: dict[str, Any] | None | Unset + if isinstance(self.last_name, Unset): + last_name = UNSET + elif isinstance(self.last_name, UserProfileLastNameType0): + last_name = self.last_name.to_dict() + else: + last_name = self.last_name + + sex = self.sex + + city: dict[str, Any] | None | Unset + if isinstance(self.city, Unset): + city = UNSET + elif isinstance(self.city, UserProfileCityType0): + city = self.city.to_dict() + else: + city = self.city + + country = self.country + + language = self.language + + timezone_offset = self.timezone_offset + + food_database_country = self.food_database_country + + goal = self.goal + + activity_degree = self.activity_degree + + weight_change_per_week = self.weight_change_per_week + + unit_length = self.unit_length + + unit_mass = self.unit_mass + + unit_energy = self.unit_energy + + unit_glucose = self.unit_glucose + + unit_serving = self.unit_serving + + stripe_customer_id = self.stripe_customer_id + + diet: dict[str, Any] | Unset = UNSET + if not isinstance(self.diet, Unset): + diet = self.diet.to_dict() + + registration_date = self.registration_date + + reset_date = self.reset_date + + profile_image: dict[str, Any] | None | Unset + if isinstance(self.profile_image, Unset): + profile_image = UNSET + elif isinstance(self.profile_image, UserProfileProfileImageType0): + profile_image = self.profile_image.to_dict() + else: + profile_image = self.profile_image + + user_token = self.user_token + + email_confirmation_status = self.email_confirmation_status + + newsletter_opt_in = self.newsletter_opt_in + + login_type = self.login_type + + siwa_user_id: dict[str, Any] | None | Unset + if isinstance(self.siwa_user_id, Unset): + siwa_user_id = UNSET + elif isinstance(self.siwa_user_id, UserProfileSiwaUserIdType0): + siwa_user_id = self.siwa_user_id.to_dict() + else: + siwa_user_id = self.siwa_user_id + + premium_type = self.premium_type + + start_weight = self.start_weight + + uuid = self.uuid + + body_height = self.body_height + + date_of_birth = self.date_of_birth + + email = self.email + + tags: list[Any] | Unset = UNSET + if not isinstance(self.tags, Unset): + tags = self.tags + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if first_name is not UNSET: + field_dict["first_name"] = first_name + if last_name is not UNSET: + field_dict["last_name"] = last_name + if sex is not UNSET: + field_dict["sex"] = sex + if city is not UNSET: + field_dict["city"] = city + if country is not UNSET: + field_dict["country"] = country + if language is not UNSET: + field_dict["language"] = language + if timezone_offset is not UNSET: + field_dict["timezone_offset"] = timezone_offset + if food_database_country is not UNSET: + field_dict["food_database_country"] = food_database_country + if goal is not UNSET: + field_dict["goal"] = goal + if activity_degree is not UNSET: + field_dict["activity_degree"] = activity_degree + if weight_change_per_week is not UNSET: + field_dict["weight_change_per_week"] = weight_change_per_week + if unit_length is not UNSET: + field_dict["unit_length"] = unit_length + if unit_mass is not UNSET: + field_dict["unit_mass"] = unit_mass + if unit_energy is not UNSET: + field_dict["unit_energy"] = unit_energy + if unit_glucose is not UNSET: + field_dict["unit_glucose"] = unit_glucose + if unit_serving is not UNSET: + field_dict["unit_serving"] = unit_serving + if stripe_customer_id is not UNSET: + field_dict["stripe_customer_id"] = stripe_customer_id + if diet is not UNSET: + field_dict["diet"] = diet + if registration_date is not UNSET: + field_dict["registration_date"] = registration_date + if reset_date is not UNSET: + field_dict["reset_date"] = reset_date + if profile_image is not UNSET: + field_dict["profile_image"] = profile_image + if user_token is not UNSET: + field_dict["user_token"] = user_token + if email_confirmation_status is not UNSET: + field_dict["email_confirmation_status"] = email_confirmation_status + if newsletter_opt_in is not UNSET: + field_dict["newsletter_opt_in"] = newsletter_opt_in + if login_type is not UNSET: + field_dict["login_type"] = login_type + if siwa_user_id is not UNSET: + field_dict["siwa_user_id"] = siwa_user_id + if premium_type is not UNSET: + field_dict["premium_type"] = premium_type + if start_weight is not UNSET: + field_dict["start_weight"] = start_weight + if uuid is not UNSET: + field_dict["uuid"] = uuid + if body_height is not UNSET: + field_dict["body_height"] = body_height + if date_of_birth is not UNSET: + field_dict["date_of_birth"] = date_of_birth + if email is not UNSET: + field_dict["email"] = email + if tags is not UNSET: + field_dict["tags"] = tags + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.user_profile_city_type_0 import UserProfileCityType0 + from ..models.user_profile_diet import UserProfileDiet + from ..models.user_profile_last_name_type_0 import UserProfileLastNameType0 + from ..models.user_profile_profile_image_type_0 import UserProfileProfileImageType0 + from ..models.user_profile_siwa_user_id_type_0 import UserProfileSiwaUserIdType0 + + d = dict(src_dict) + first_name = d.pop("first_name", UNSET) + + def _parse_last_name(data: object) -> None | Unset | UserProfileLastNameType0: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + last_name_type_0 = UserProfileLastNameType0.from_dict(data) + + return last_name_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | Unset | UserProfileLastNameType0, data) + + last_name = _parse_last_name(d.pop("last_name", UNSET)) + + sex = d.pop("sex", UNSET) + + def _parse_city(data: object) -> None | Unset | UserProfileCityType0: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + city_type_0 = UserProfileCityType0.from_dict(data) + + return city_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | Unset | UserProfileCityType0, data) + + city = _parse_city(d.pop("city", UNSET)) + + country = d.pop("country", UNSET) + + language = d.pop("language", UNSET) + + timezone_offset = d.pop("timezone_offset", UNSET) + + food_database_country = d.pop("food_database_country", UNSET) + + goal = d.pop("goal", UNSET) + + activity_degree = d.pop("activity_degree", UNSET) + + weight_change_per_week = d.pop("weight_change_per_week", UNSET) + + unit_length = d.pop("unit_length", UNSET) + + unit_mass = d.pop("unit_mass", UNSET) + + unit_energy = d.pop("unit_energy", UNSET) + + unit_glucose = d.pop("unit_glucose", UNSET) + + unit_serving = d.pop("unit_serving", UNSET) + + stripe_customer_id = d.pop("stripe_customer_id", UNSET) + + _diet = d.pop("diet", UNSET) + diet: UserProfileDiet | Unset + if isinstance(_diet, Unset): + diet = UNSET + else: + diet = UserProfileDiet.from_dict(_diet) + + registration_date = d.pop("registration_date", UNSET) + + reset_date = d.pop("reset_date", UNSET) + + def _parse_profile_image(data: object) -> None | Unset | UserProfileProfileImageType0: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + profile_image_type_0 = UserProfileProfileImageType0.from_dict(data) + + return profile_image_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | Unset | UserProfileProfileImageType0, data) + + profile_image = _parse_profile_image(d.pop("profile_image", UNSET)) + + user_token = d.pop("user_token", UNSET) + + email_confirmation_status = d.pop("email_confirmation_status", UNSET) + + newsletter_opt_in = d.pop("newsletter_opt_in", UNSET) + + login_type = d.pop("login_type", UNSET) + + def _parse_siwa_user_id(data: object) -> None | Unset | UserProfileSiwaUserIdType0: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + siwa_user_id_type_0 = UserProfileSiwaUserIdType0.from_dict(data) + + return siwa_user_id_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | Unset | UserProfileSiwaUserIdType0, data) + + siwa_user_id = _parse_siwa_user_id(d.pop("siwa_user_id", UNSET)) + + premium_type = d.pop("premium_type", UNSET) + + start_weight = d.pop("start_weight", UNSET) + + uuid = d.pop("uuid", UNSET) + + body_height = d.pop("body_height", UNSET) + + date_of_birth = d.pop("date_of_birth", UNSET) + + email = d.pop("email", UNSET) + + tags = cast(list[Any], d.pop("tags", UNSET)) + + user_profile = cls( + first_name=first_name, + last_name=last_name, + sex=sex, + city=city, + country=country, + language=language, + timezone_offset=timezone_offset, + food_database_country=food_database_country, + goal=goal, + activity_degree=activity_degree, + weight_change_per_week=weight_change_per_week, + unit_length=unit_length, + unit_mass=unit_mass, + unit_energy=unit_energy, + unit_glucose=unit_glucose, + unit_serving=unit_serving, + stripe_customer_id=stripe_customer_id, + diet=diet, + registration_date=registration_date, + reset_date=reset_date, + profile_image=profile_image, + user_token=user_token, + email_confirmation_status=email_confirmation_status, + newsletter_opt_in=newsletter_opt_in, + login_type=login_type, + siwa_user_id=siwa_user_id, + premium_type=premium_type, + start_weight=start_weight, + uuid=uuid, + body_height=body_height, + date_of_birth=date_of_birth, + email=email, + tags=tags, + ) + + user_profile.additional_properties = d + return user_profile + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/user_profile_city_type_0.py b/src/yazio_sdk/models/user_profile_city_type_0.py new file mode 100644 index 0000000..e1a148a --- /dev/null +++ b/src/yazio_sdk/models/user_profile_city_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="UserProfileCityType0") + + +@_attrs_define +class UserProfileCityType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + user_profile_city_type_0 = cls() + + user_profile_city_type_0.additional_properties = d + return user_profile_city_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/user_profile_diet.py b/src/yazio_sdk/models/user_profile_diet.py new file mode 100644 index 0000000..b2396f7 --- /dev/null +++ b/src/yazio_sdk/models/user_profile_diet.py @@ -0,0 +1,88 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="UserProfileDiet") + + +@_attrs_define +class UserProfileDiet: + """ + Attributes: + name (str | Unset): + carb_percentage (float | Unset): + fat_percentage (float | Unset): + protein_percentage (float | Unset): + """ + + name: str | Unset = UNSET + carb_percentage: float | Unset = UNSET + fat_percentage: float | Unset = UNSET + protein_percentage: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + name = self.name + + carb_percentage = self.carb_percentage + + fat_percentage = self.fat_percentage + + protein_percentage = self.protein_percentage + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if name is not UNSET: + field_dict["name"] = name + if carb_percentage is not UNSET: + field_dict["carb_percentage"] = carb_percentage + if fat_percentage is not UNSET: + field_dict["fat_percentage"] = fat_percentage + if protein_percentage is not UNSET: + field_dict["protein_percentage"] = protein_percentage + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + name = d.pop("name", UNSET) + + carb_percentage = d.pop("carb_percentage", UNSET) + + fat_percentage = d.pop("fat_percentage", UNSET) + + protein_percentage = d.pop("protein_percentage", UNSET) + + user_profile_diet = cls( + name=name, + carb_percentage=carb_percentage, + fat_percentage=fat_percentage, + protein_percentage=protein_percentage, + ) + + user_profile_diet.additional_properties = d + return user_profile_diet + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/user_profile_last_name_type_0.py b/src/yazio_sdk/models/user_profile_last_name_type_0.py new file mode 100644 index 0000000..72482a6 --- /dev/null +++ b/src/yazio_sdk/models/user_profile_last_name_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="UserProfileLastNameType0") + + +@_attrs_define +class UserProfileLastNameType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + user_profile_last_name_type_0 = cls() + + user_profile_last_name_type_0.additional_properties = d + return user_profile_last_name_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/user_profile_profile_image_type_0.py b/src/yazio_sdk/models/user_profile_profile_image_type_0.py new file mode 100644 index 0000000..33be29f --- /dev/null +++ b/src/yazio_sdk/models/user_profile_profile_image_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="UserProfileProfileImageType0") + + +@_attrs_define +class UserProfileProfileImageType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + user_profile_profile_image_type_0 = cls() + + user_profile_profile_image_type_0.additional_properties = d + return user_profile_profile_image_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/user_profile_siwa_user_id_type_0.py b/src/yazio_sdk/models/user_profile_siwa_user_id_type_0.py new file mode 100644 index 0000000..c24651c --- /dev/null +++ b/src/yazio_sdk/models/user_profile_siwa_user_id_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="UserProfileSiwaUserIdType0") + + +@_attrs_define +class UserProfileSiwaUserIdType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + user_profile_siwa_user_id_type_0 = cls() + + user_profile_siwa_user_id_type_0.additional_properties = d + return user_profile_siwa_user_id_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/user_settings.py b/src/yazio_sdk/models/user_settings.py new file mode 100644 index 0000000..0655345 --- /dev/null +++ b/src/yazio_sdk/models/user_settings.py @@ -0,0 +1,142 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="UserSettings") + + +@_attrs_define +class UserSettings: + """ + Attributes: + has_water_tracker (bool | Unset): + has_diary_tipps (bool | Unset): + has_meal_reminders (bool | Unset): + has_usage_reminders (bool | Unset): + has_weight_reminders (bool | Unset): + has_water_reminders (bool | Unset): + consume_activity_calories (bool | Unset): + has_feelings (bool | Unset): + has_fasting_tracker_reminders (bool | Unset): + has_fasting_stage_reminders (bool | Unset): + """ + + has_water_tracker: bool | Unset = UNSET + has_diary_tipps: bool | Unset = UNSET + has_meal_reminders: bool | Unset = UNSET + has_usage_reminders: bool | Unset = UNSET + has_weight_reminders: bool | Unset = UNSET + has_water_reminders: bool | Unset = UNSET + consume_activity_calories: bool | Unset = UNSET + has_feelings: bool | Unset = UNSET + has_fasting_tracker_reminders: bool | Unset = UNSET + has_fasting_stage_reminders: bool | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + has_water_tracker = self.has_water_tracker + + has_diary_tipps = self.has_diary_tipps + + has_meal_reminders = self.has_meal_reminders + + has_usage_reminders = self.has_usage_reminders + + has_weight_reminders = self.has_weight_reminders + + has_water_reminders = self.has_water_reminders + + consume_activity_calories = self.consume_activity_calories + + has_feelings = self.has_feelings + + has_fasting_tracker_reminders = self.has_fasting_tracker_reminders + + has_fasting_stage_reminders = self.has_fasting_stage_reminders + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if has_water_tracker is not UNSET: + field_dict["has_water_tracker"] = has_water_tracker + if has_diary_tipps is not UNSET: + field_dict["has_diary_tipps"] = has_diary_tipps + if has_meal_reminders is not UNSET: + field_dict["has_meal_reminders"] = has_meal_reminders + if has_usage_reminders is not UNSET: + field_dict["has_usage_reminders"] = has_usage_reminders + if has_weight_reminders is not UNSET: + field_dict["has_weight_reminders"] = has_weight_reminders + if has_water_reminders is not UNSET: + field_dict["has_water_reminders"] = has_water_reminders + if consume_activity_calories is not UNSET: + field_dict["consume_activity_calories"] = consume_activity_calories + if has_feelings is not UNSET: + field_dict["has_feelings"] = has_feelings + if has_fasting_tracker_reminders is not UNSET: + field_dict["has_fasting_tracker_reminders"] = has_fasting_tracker_reminders + if has_fasting_stage_reminders is not UNSET: + field_dict["has_fasting_stage_reminders"] = has_fasting_stage_reminders + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + has_water_tracker = d.pop("has_water_tracker", UNSET) + + has_diary_tipps = d.pop("has_diary_tipps", UNSET) + + has_meal_reminders = d.pop("has_meal_reminders", UNSET) + + has_usage_reminders = d.pop("has_usage_reminders", UNSET) + + has_weight_reminders = d.pop("has_weight_reminders", UNSET) + + has_water_reminders = d.pop("has_water_reminders", UNSET) + + consume_activity_calories = d.pop("consume_activity_calories", UNSET) + + has_feelings = d.pop("has_feelings", UNSET) + + has_fasting_tracker_reminders = d.pop("has_fasting_tracker_reminders", UNSET) + + has_fasting_stage_reminders = d.pop("has_fasting_stage_reminders", UNSET) + + user_settings = cls( + has_water_tracker=has_water_tracker, + has_diary_tipps=has_diary_tipps, + has_meal_reminders=has_meal_reminders, + has_usage_reminders=has_usage_reminders, + has_weight_reminders=has_weight_reminders, + has_water_reminders=has_water_reminders, + consume_activity_calories=consume_activity_calories, + has_feelings=has_feelings, + has_fasting_tracker_reminders=has_fasting_tracker_reminders, + has_fasting_stage_reminders=has_fasting_stage_reminders, + ) + + user_settings.additional_properties = d + return user_settings + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/wallet.py b/src/yazio_sdk/models/wallet.py new file mode 100644 index 0000000..e2efae0 --- /dev/null +++ b/src/yazio_sdk/models/wallet.py @@ -0,0 +1,79 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.wallet_currencies_item import WalletCurrenciesItem + + +T = TypeVar("T", bound="Wallet") + + +@_attrs_define +class Wallet: + """ + Attributes: + currencies (list[WalletCurrenciesItem] | Unset): + """ + + currencies: list[WalletCurrenciesItem] | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + currencies: list[dict[str, Any]] | Unset = UNSET + if not isinstance(self.currencies, Unset): + currencies = [] + for currencies_item_data in self.currencies: + currencies_item = currencies_item_data.to_dict() + currencies.append(currencies_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if currencies is not UNSET: + field_dict["currencies"] = currencies + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.wallet_currencies_item import WalletCurrenciesItem + + d = dict(src_dict) + _currencies = d.pop("currencies", UNSET) + currencies: list[WalletCurrenciesItem] | Unset = UNSET + if _currencies is not UNSET: + currencies = [] + for currencies_item_data in _currencies: + currencies_item = WalletCurrenciesItem.from_dict(currencies_item_data) + + currencies.append(currencies_item) + + wallet = cls( + currencies=currencies, + ) + + wallet.additional_properties = d + return wallet + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/wallet_currencies_item.py b/src/yazio_sdk/models/wallet_currencies_item.py new file mode 100644 index 0000000..56b0194 --- /dev/null +++ b/src/yazio_sdk/models/wallet_currencies_item.py @@ -0,0 +1,70 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="WalletCurrenciesItem") + + +@_attrs_define +class WalletCurrenciesItem: + """ + Attributes: + currency (str | Unset): + quantity (float | Unset): + """ + + currency: str | Unset = UNSET + quantity: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + currency = self.currency + + quantity = self.quantity + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if currency is not UNSET: + field_dict["currency"] = currency + if quantity is not UNSET: + field_dict["quantity"] = quantity + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + currency = d.pop("currency", UNSET) + + quantity = d.pop("quantity", UNSET) + + wallet_currencies_item = cls( + currency=currency, + quantity=quantity, + ) + + wallet_currencies_item.additional_properties = d + return wallet_currencies_item + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/water_intake.py b/src/yazio_sdk/models/water_intake.py new file mode 100644 index 0000000..d8e955f --- /dev/null +++ b/src/yazio_sdk/models/water_intake.py @@ -0,0 +1,132 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.water_intake_gateway_type_0 import WaterIntakeGatewayType0 + from ..models.water_intake_source_type_0 import WaterIntakeSourceType0 + + +T = TypeVar("T", bound="WaterIntake") + + +@_attrs_define +class WaterIntake: + """ + Attributes: + water_intake (float | Unset): + gateway (None | Unset | WaterIntakeGatewayType0): + source (None | Unset | WaterIntakeSourceType0): + """ + + water_intake: float | Unset = UNSET + gateway: None | Unset | WaterIntakeGatewayType0 = UNSET + source: None | Unset | WaterIntakeSourceType0 = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + from ..models.water_intake_gateway_type_0 import WaterIntakeGatewayType0 + from ..models.water_intake_source_type_0 import WaterIntakeSourceType0 + + water_intake = self.water_intake + + gateway: dict[str, Any] | None | Unset + if isinstance(self.gateway, Unset): + gateway = UNSET + elif isinstance(self.gateway, WaterIntakeGatewayType0): + gateway = self.gateway.to_dict() + else: + gateway = self.gateway + + source: dict[str, Any] | None | Unset + if isinstance(self.source, Unset): + source = UNSET + elif isinstance(self.source, WaterIntakeSourceType0): + source = self.source.to_dict() + else: + source = self.source + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if water_intake is not UNSET: + field_dict["water_intake"] = water_intake + if gateway is not UNSET: + field_dict["gateway"] = gateway + if source is not UNSET: + field_dict["source"] = source + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.water_intake_gateway_type_0 import WaterIntakeGatewayType0 + from ..models.water_intake_source_type_0 import WaterIntakeSourceType0 + + d = dict(src_dict) + water_intake = d.pop("water_intake", UNSET) + + def _parse_gateway(data: object) -> None | Unset | WaterIntakeGatewayType0: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + gateway_type_0 = WaterIntakeGatewayType0.from_dict(data) + + return gateway_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | Unset | WaterIntakeGatewayType0, data) + + gateway = _parse_gateway(d.pop("gateway", UNSET)) + + def _parse_source(data: object) -> None | Unset | WaterIntakeSourceType0: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + source_type_0 = WaterIntakeSourceType0.from_dict(data) + + return source_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | Unset | WaterIntakeSourceType0, data) + + source = _parse_source(d.pop("source", UNSET)) + + water_intake = cls( + water_intake=water_intake, + gateway=gateway, + source=source, + ) + + water_intake.additional_properties = d + return water_intake + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/water_intake_entry.py b/src/yazio_sdk/models/water_intake_entry.py new file mode 100644 index 0000000..300facb --- /dev/null +++ b/src/yazio_sdk/models/water_intake_entry.py @@ -0,0 +1,70 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +T = TypeVar("T", bound="WaterIntakeEntry") + + +@_attrs_define +class WaterIntakeEntry: + """ + Attributes: + date (str | Unset): + water_intake (float | Unset): + """ + + date: str | Unset = UNSET + water_intake: float | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + date = self.date + + water_intake = self.water_intake + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if date is not UNSET: + field_dict["date"] = date + if water_intake is not UNSET: + field_dict["water_intake"] = water_intake + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + date = d.pop("date", UNSET) + + water_intake = d.pop("water_intake", UNSET) + + water_intake_entry = cls( + date=date, + water_intake=water_intake, + ) + + water_intake_entry.additional_properties = d + return water_intake_entry + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/water_intake_gateway_type_0.py b/src/yazio_sdk/models/water_intake_gateway_type_0.py new file mode 100644 index 0000000..1608f4b --- /dev/null +++ b/src/yazio_sdk/models/water_intake_gateway_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="WaterIntakeGatewayType0") + + +@_attrs_define +class WaterIntakeGatewayType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + water_intake_gateway_type_0 = cls() + + water_intake_gateway_type_0.additional_properties = d + return water_intake_gateway_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/water_intake_source_type_0.py b/src/yazio_sdk/models/water_intake_source_type_0.py new file mode 100644 index 0000000..46df02e --- /dev/null +++ b/src/yazio_sdk/models/water_intake_source_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="WaterIntakeSourceType0") + + +@_attrs_define +class WaterIntakeSourceType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + water_intake_source_type_0 = cls() + + water_intake_source_type_0.additional_properties = d + return water_intake_source_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/weight_entry.py b/src/yazio_sdk/models/weight_entry.py new file mode 100644 index 0000000..6c49f2f --- /dev/null +++ b/src/yazio_sdk/models/weight_entry.py @@ -0,0 +1,159 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +from ..types import UNSET, Unset + +if TYPE_CHECKING: + from ..models.weight_entry_external_id_type_0 import WeightEntryExternalIdType0 + from ..models.weight_entry_source_type_0 import WeightEntrySourceType0 + + +T = TypeVar("T", bound="WeightEntry") + + +@_attrs_define +class WeightEntry: + """ + Attributes: + date (str | Unset): + id (str | Unset): + value (float | Unset): + external_id (None | Unset | WeightEntryExternalIdType0): + gateway (str | Unset): + source (None | Unset | WeightEntrySourceType0): + """ + + date: str | Unset = UNSET + id: str | Unset = UNSET + value: float | Unset = UNSET + external_id: None | Unset | WeightEntryExternalIdType0 = UNSET + gateway: str | Unset = UNSET + source: None | Unset | WeightEntrySourceType0 = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + from ..models.weight_entry_external_id_type_0 import WeightEntryExternalIdType0 + from ..models.weight_entry_source_type_0 import WeightEntrySourceType0 + + date = self.date + + id = self.id + + value = self.value + + external_id: dict[str, Any] | None | Unset + if isinstance(self.external_id, Unset): + external_id = UNSET + elif isinstance(self.external_id, WeightEntryExternalIdType0): + external_id = self.external_id.to_dict() + else: + external_id = self.external_id + + gateway = self.gateway + + source: dict[str, Any] | None | Unset + if isinstance(self.source, Unset): + source = UNSET + elif isinstance(self.source, WeightEntrySourceType0): + source = self.source.to_dict() + else: + source = self.source + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update({}) + if date is not UNSET: + field_dict["date"] = date + if id is not UNSET: + field_dict["id"] = id + if value is not UNSET: + field_dict["value"] = value + if external_id is not UNSET: + field_dict["external_id"] = external_id + if gateway is not UNSET: + field_dict["gateway"] = gateway + if source is not UNSET: + field_dict["source"] = source + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + from ..models.weight_entry_external_id_type_0 import WeightEntryExternalIdType0 + from ..models.weight_entry_source_type_0 import WeightEntrySourceType0 + + d = dict(src_dict) + date = d.pop("date", UNSET) + + id = d.pop("id", UNSET) + + value = d.pop("value", UNSET) + + def _parse_external_id(data: object) -> None | Unset | WeightEntryExternalIdType0: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + external_id_type_0 = WeightEntryExternalIdType0.from_dict(data) + + return external_id_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | Unset | WeightEntryExternalIdType0, data) + + external_id = _parse_external_id(d.pop("external_id", UNSET)) + + gateway = d.pop("gateway", UNSET) + + def _parse_source(data: object) -> None | Unset | WeightEntrySourceType0: + if data is None: + return data + if isinstance(data, Unset): + return data + try: + if not isinstance(data, dict): + raise TypeError() + source_type_0 = WeightEntrySourceType0.from_dict(data) + + return source_type_0 + except (TypeError, ValueError, AttributeError, KeyError): + pass + return cast(None | Unset | WeightEntrySourceType0, data) + + source = _parse_source(d.pop("source", UNSET)) + + weight_entry = cls( + date=date, + id=id, + value=value, + external_id=external_id, + gateway=gateway, + source=source, + ) + + weight_entry.additional_properties = d + return weight_entry + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/weight_entry_external_id_type_0.py b/src/yazio_sdk/models/weight_entry_external_id_type_0.py new file mode 100644 index 0000000..2f8b150 --- /dev/null +++ b/src/yazio_sdk/models/weight_entry_external_id_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="WeightEntryExternalIdType0") + + +@_attrs_define +class WeightEntryExternalIdType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + weight_entry_external_id_type_0 = cls() + + weight_entry_external_id_type_0.additional_properties = d + return weight_entry_external_id_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/models/weight_entry_source_type_0.py b/src/yazio_sdk/models/weight_entry_source_type_0.py new file mode 100644 index 0000000..92e7019 --- /dev/null +++ b/src/yazio_sdk/models/weight_entry_source_type_0.py @@ -0,0 +1,47 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="WeightEntrySourceType0") + + +@_attrs_define +class WeightEntrySourceType0: + """ """ + + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + weight_entry_source_type_0 = cls() + + weight_entry_source_type_0.additional_properties = d + return weight_entry_source_type_0 + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/src/yazio_sdk/types.py b/src/yazio_sdk/types.py new file mode 100644 index 0000000..b64af09 --- /dev/null +++ b/src/yazio_sdk/types.py @@ -0,0 +1,54 @@ +"""Contains some shared types for properties""" + +from collections.abc import Mapping, MutableMapping +from http import HTTPStatus +from typing import IO, BinaryIO, Generic, Literal, TypeVar + +from attrs import define + + +class Unset: + def __bool__(self) -> Literal[False]: + return False + + +UNSET: Unset = Unset() + +# The types that `httpx.Client(files=)` can accept, copied from that library. +FileContent = IO[bytes] | bytes | str +FileTypes = ( + # (filename, file (or bytes), content_type) + tuple[str | None, FileContent, str | None] + # (filename, file (or bytes), content_type, headers) + | tuple[str | None, FileContent, str | None, Mapping[str, str]] +) +RequestFiles = list[tuple[str, FileTypes]] + + +@define +class File: + """Contains information for file uploads""" + + payload: BinaryIO + file_name: str | None = None + mime_type: str | None = None + + def to_tuple(self) -> FileTypes: + """Return a tuple representation that httpx will accept for multipart/form-data""" + return self.file_name, self.payload, self.mime_type + + +T = TypeVar("T") + + +@define +class Response(Generic[T]): + """A response from an endpoint""" + + status_code: HTTPStatus + content: bytes + headers: MutableMapping[str, str] + parsed: T | None + + +__all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"]