From 561ed28a0412fa1cf0edb5b6d8553f727fea0bc5 Mon Sep 17 00:00:00 2001 From: NathanFallet Date: Fri, 23 Oct 2026 19:40:11 +0100 Subject: [PATCH] feat: regenerate with the catalog routes and expose them The generated client is regenerated from the production OpenAPI document (API 2.116.0, backend#1473) without the webhook routes, which stay out of scope. The catalog routes are exposed like the other resources. Co-Authored-By: Claude Sonnet 5.5 --- .spec-sha256 | 2 +- README.md | 2 + src/controlresell/client.py | 128 +++++++++ .../generated/api/catalogs/__init__.py | 1 + .../api/catalogs/get_catalog_category.py | 197 +++++++++++++ .../catalogs/get_catalog_category_fields.py | 217 +++++++++++++++ .../api/catalogs/list_catalog_brands.py | 235 ++++++++++++++++ .../api/catalogs/list_catalog_categories.py | 259 ++++++++++++++++++ .../api/catalogs/list_catalog_colors.py | 236 ++++++++++++++++ .../api/catalogs/list_catalog_conditions.py | 236 ++++++++++++++++ .../api/catalogs/list_catalog_materials.py | 236 ++++++++++++++++ .../catalogs/list_catalog_package_sizes.py | 236 ++++++++++++++++ .../api/catalogs/list_catalog_sizes.py | 236 ++++++++++++++++ .../generated/models/__init__.py | 24 ++ .../generated/models/catalog_brand.py | 77 ++++++ .../generated/models/catalog_brand_page.py | 97 +++++++ .../generated/models/catalog_category.py | 115 ++++++++ .../models/catalog_category_fields.py | 127 +++++++++ .../generated/models/catalog_category_page.py | 97 +++++++ .../generated/models/catalog_enum_field.py | 153 +++++++++++ .../generated/models/catalog_measurement.py | 77 ++++++ .../generated/models/catalog_size.py | 85 ++++++ .../generated/models/catalog_size_page.py | 97 +++++++ .../generated/models/catalog_text_field.py | 139 ++++++++++ .../generated/models/catalog_value.py | 77 ++++++ .../generated/models/catalog_value_page.py | 97 +++++++ tests/test_client.py | 28 ++ 27 files changed, 3510 insertions(+), 1 deletion(-) create mode 100644 src/controlresell/generated/api/catalogs/__init__.py create mode 100644 src/controlresell/generated/api/catalogs/get_catalog_category.py create mode 100644 src/controlresell/generated/api/catalogs/get_catalog_category_fields.py create mode 100644 src/controlresell/generated/api/catalogs/list_catalog_brands.py create mode 100644 src/controlresell/generated/api/catalogs/list_catalog_categories.py create mode 100644 src/controlresell/generated/api/catalogs/list_catalog_colors.py create mode 100644 src/controlresell/generated/api/catalogs/list_catalog_conditions.py create mode 100644 src/controlresell/generated/api/catalogs/list_catalog_materials.py create mode 100644 src/controlresell/generated/api/catalogs/list_catalog_package_sizes.py create mode 100644 src/controlresell/generated/api/catalogs/list_catalog_sizes.py create mode 100644 src/controlresell/generated/models/catalog_brand.py create mode 100644 src/controlresell/generated/models/catalog_brand_page.py create mode 100644 src/controlresell/generated/models/catalog_category.py create mode 100644 src/controlresell/generated/models/catalog_category_fields.py create mode 100644 src/controlresell/generated/models/catalog_category_page.py create mode 100644 src/controlresell/generated/models/catalog_enum_field.py create mode 100644 src/controlresell/generated/models/catalog_measurement.py create mode 100644 src/controlresell/generated/models/catalog_size.py create mode 100644 src/controlresell/generated/models/catalog_size_page.py create mode 100644 src/controlresell/generated/models/catalog_text_field.py create mode 100644 src/controlresell/generated/models/catalog_value.py create mode 100644 src/controlresell/generated/models/catalog_value_page.py diff --git a/.spec-sha256 b/.spec-sha256 index fa982ec..aa855c8 100644 --- a/.spec-sha256 +++ b/.spec-sha256 @@ -1 +1 @@ -41311cb64247613fcc1634a63a1804e344c71873d665fc58af33e053a5f919f1 +15321a7caa009c61dd09fb6412b8f44544953a2a90355f1afc081dc79d784900 diff --git a/README.md b/README.md index 6f4d88e..36132b1 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ for item in client.items.iter(sold=False): print(item.name) for order in client.orders.iter(bucket="to_send"): # needs the orders:read scope; also orders.get(id), orders.labels(id) print(order.id) +for brand in client.catalogs.iter_brands(q="nik"): # the identifiers an item is written with (items:read): categories, category, category_fields, brands, sizes, colors, conditions, package_sizes, materials + print(brand.id, brand.name) # Writes (API key with `items:write` / `conversations:write`); `idempotency_key=` chooses the key. from controlresell.generated.models import ItemCreateRequest, ItemUpdateRequest, PublishRequest, SendMessageRequest diff --git a/src/controlresell/client.py b/src/controlresell/client.py index 7aeff5d..2192873 100644 --- a/src/controlresell/client.py +++ b/src/controlresell/client.py @@ -33,6 +33,17 @@ republish_item, update_item, ) +from .generated.api.catalogs import ( + get_catalog_category, + get_catalog_category_fields, + list_catalog_brands, + list_catalog_categories, + list_catalog_colors, + list_catalog_conditions, + list_catalog_materials, + list_catalog_package_sizes, + list_catalog_sizes, +) from .generated.api.customers import get_customer, list_customers from .generated.api.me import get_me from .generated.api.orders import get_order, list_labels_to_ship, list_order_labels, list_orders @@ -40,6 +51,15 @@ from .generated.models import ( Account, AccountPage, + CatalogBrand, + CatalogBrandPage, + CatalogCategory, + CatalogCategoryFields, + CatalogCategoryPage, + CatalogSize, + CatalogSizePage, + CatalogValue, + CatalogValuePage, Conversation, ConversationPage, Customer, @@ -113,6 +133,7 @@ def __init__( self.conversations = _Conversations(self) self.orders = _Orders(self) self.customers = _Customers(self) + self.catalogs = _Catalogs(self) @property def http(self) -> httpx.Client: @@ -430,3 +451,110 @@ def iter( ) -> Iterator[Customer]: """Every customer, page after page, with the same filters.""" return paginate(lambda cursor: self.list(limit=limit, cursor=cursor, account_id=account_id, from_=from_, to=to)) + + +class _Catalogs: + """The catalog an item is written with: categories, brands, sizes, colors... (needs the ``items:read`` scope). + + Every ``category_id`` keeps what applies to one category. + """ + + def __init__(self, sdk: ControlResell) -> None: + self._sdk = sdk + + def categories( + self, + *, + limit: int | None = None, + cursor: str | None = None, + parent_id: int | None = None, + platform: str | None = None, + ) -> CatalogCategoryPage: + """One page of categories, flat, by identifier; ``parent_id`` keeps the children of one, ``platform`` one marketplace.""" + return self._sdk._call( # noqa: SLF001 + list_catalog_categories, **_query(limit=limit, cursor=cursor, parent_id=parent_id, platform=platform) + ) + + def iter_categories( + self, *, limit: int | None = None, parent_id: int | None = None, platform: str | None = None + ) -> Iterator[CatalogCategory]: + """Every category, page after page, with the same filters.""" + return paginate( + lambda cursor: self.categories(limit=limit, cursor=cursor, parent_id=parent_id, platform=platform) + ) + + def category(self, id: int) -> CatalogCategory: + """One category by its identifier.""" + return self._sdk._call(get_catalog_category, id=id) # noqa: SLF001 + + def category_fields(self, id: int) -> CatalogCategoryFields: + """What an item of a category is filled with: its size groups, enumerated and text fields, measurements.""" + return self._sdk._call(get_catalog_category_fields, id=id) # noqa: SLF001 + + def brands(self, *, limit: int | None = None, cursor: str | None = None, q: str | None = None) -> CatalogBrandPage: + """One page of brands, by identifier or, with ``q``, those whose name starts with it.""" + return self._sdk._call(list_catalog_brands, **_query(limit=limit, cursor=cursor, q=q)) # noqa: SLF001 + + def iter_brands(self, *, limit: int | None = None, q: str | None = None) -> Iterator[CatalogBrand]: + """Every brand, page after page, with the same filters.""" + return paginate(lambda cursor: self.brands(limit=limit, cursor=cursor, q=q)) + + def sizes( + self, *, limit: int | None = None, cursor: str | None = None, category_id: int | None = None + ) -> CatalogSizePage: + """One page of sizes, each with its size group.""" + return self._sdk._call( # noqa: SLF001 + list_catalog_sizes, **_query(limit=limit, cursor=cursor, category_id=category_id) + ) + + def iter_sizes(self, *, limit: int | None = None, category_id: int | None = None) -> Iterator[CatalogSize]: + """Every size, page after page, with the same filters.""" + return paginate(lambda cursor: self.sizes(limit=limit, cursor=cursor, category_id=category_id)) + + def colors( + self, *, limit: int | None = None, cursor: str | None = None, category_id: int | None = None + ) -> CatalogValuePage: + """One page of colors.""" + return self._sdk._call( # noqa: SLF001 + list_catalog_colors, **_query(limit=limit, cursor=cursor, category_id=category_id) + ) + + def iter_colors(self, *, limit: int | None = None, category_id: int | None = None) -> Iterator[CatalogValue]: + """Every one of the colors, page after page, with the same filters.""" + return paginate(lambda cursor: self.colors(limit=limit, cursor=cursor, category_id=category_id)) + + def conditions( + self, *, limit: int | None = None, cursor: str | None = None, category_id: int | None = None + ) -> CatalogValuePage: + """One page of conditions.""" + return self._sdk._call( # noqa: SLF001 + list_catalog_conditions, **_query(limit=limit, cursor=cursor, category_id=category_id) + ) + + def iter_conditions(self, *, limit: int | None = None, category_id: int | None = None) -> Iterator[CatalogValue]: + """Every one of the conditions, page after page, with the same filters.""" + return paginate(lambda cursor: self.conditions(limit=limit, cursor=cursor, category_id=category_id)) + + def package_sizes( + self, *, limit: int | None = None, cursor: str | None = None, category_id: int | None = None + ) -> CatalogValuePage: + """One page of package sizes.""" + return self._sdk._call( # noqa: SLF001 + list_catalog_package_sizes, **_query(limit=limit, cursor=cursor, category_id=category_id) + ) + + def iter_package_sizes(self, *, limit: int | None = None, category_id: int | None = None) -> Iterator[CatalogValue]: + """Every one of the package sizes, page after page, with the same filters.""" + return paginate(lambda cursor: self.package_sizes(limit=limit, cursor=cursor, category_id=category_id)) + + def materials( + self, *, limit: int | None = None, cursor: str | None = None, category_id: int | None = None + ) -> CatalogValuePage: + """One page of materials.""" + return self._sdk._call( # noqa: SLF001 + list_catalog_materials, **_query(limit=limit, cursor=cursor, category_id=category_id) + ) + + def iter_materials(self, *, limit: int | None = None, category_id: int | None = None) -> Iterator[CatalogValue]: + """Every one of the materials, page after page, with the same filters.""" + return paginate(lambda cursor: self.materials(limit=limit, cursor=cursor, category_id=category_id)) diff --git a/src/controlresell/generated/api/catalogs/__init__.py b/src/controlresell/generated/api/catalogs/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/src/controlresell/generated/api/catalogs/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/src/controlresell/generated/api/catalogs/get_catalog_category.py b/src/controlresell/generated/api/catalogs/get_catalog_category.py new file mode 100644 index 0000000..af787f4 --- /dev/null +++ b/src/controlresell/generated/api/catalogs/get_catalog_category.py @@ -0,0 +1,197 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ...client import AuthenticatedClient, Client +from ...models.catalog_category import CatalogCategory +from ...models.error_response import ErrorResponse +from ...types import Response + + +def _get_kwargs( + id: int, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/api/public/v1/catalogs/categories/{id}".format( + id=quote(str(id), safe=""), + ), + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> CatalogCategory | ErrorResponse: + if response.status_code == 200: + response_200 = CatalogCategory.from_dict(response.json()) + + return response_200 + + if response.status_code == 400: + response_400 = ErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 402: + response_402 = ErrorResponse.from_dict(response.json()) + + return response_402 + + if response.status_code == 403: + response_403 = ErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 429: + response_429 = ErrorResponse.from_dict(response.json()) + + return response_429 + + if response.status_code == 500: + response_500 = ErrorResponse.from_dict(response.json()) + + return response_500 + + response_default = ErrorResponse.from_dict(response.json()) + + return response_default + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CatalogCategory | ErrorResponse]: + 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: int, + *, + client: AuthenticatedClient | Client, +) -> Response[CatalogCategory | ErrorResponse]: + """Read one category + + One category of the catalog, by its identifier. Requires `items:read`. + + Args: + id (int): + + 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[CatalogCategory | ErrorResponse] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: int, + *, + client: AuthenticatedClient | Client, +) -> CatalogCategory | ErrorResponse | None: + """Read one category + + One category of the catalog, by its identifier. Requires `items:read`. + + Args: + id (int): + + 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: + CatalogCategory | ErrorResponse + """ + + return sync_detailed( + id=id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: int, + *, + client: AuthenticatedClient | Client, +) -> Response[CatalogCategory | ErrorResponse]: + """Read one category + + One category of the catalog, by its identifier. Requires `items:read`. + + Args: + id (int): + + 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[CatalogCategory | ErrorResponse] + """ + + 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: int, + *, + client: AuthenticatedClient | Client, +) -> CatalogCategory | ErrorResponse | None: + """Read one category + + One category of the catalog, by its identifier. Requires `items:read`. + + Args: + id (int): + + 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: + CatalogCategory | ErrorResponse + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed diff --git a/src/controlresell/generated/api/catalogs/get_catalog_category_fields.py b/src/controlresell/generated/api/catalogs/get_catalog_category_fields.py new file mode 100644 index 0000000..03cc19f --- /dev/null +++ b/src/controlresell/generated/api/catalogs/get_catalog_category_fields.py @@ -0,0 +1,217 @@ +from http import HTTPStatus +from typing import Any +from urllib.parse import quote + +import httpx + +from ...client import AuthenticatedClient, Client +from ...models.catalog_category_fields import CatalogCategoryFields +from ...models.error_response import ErrorResponse +from ...types import Response + + +def _get_kwargs( + id: int, +) -> dict[str, Any]: + + _kwargs: dict[str, Any] = { + "method": "get", + "url": "/api/public/v1/catalogs/categories/{id}/fields".format( + id=quote(str(id), safe=""), + ), + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> CatalogCategoryFields | ErrorResponse: + if response.status_code == 200: + response_200 = CatalogCategoryFields.from_dict(response.json()) + + return response_200 + + if response.status_code == 400: + response_400 = ErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 402: + response_402 = ErrorResponse.from_dict(response.json()) + + return response_402 + + if response.status_code == 403: + response_403 = ErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 429: + response_429 = ErrorResponse.from_dict(response.json()) + + return response_429 + + if response.status_code == 500: + response_500 = ErrorResponse.from_dict(response.json()) + + return response_500 + + response_default = ErrorResponse.from_dict(response.json()) + + return response_default + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CatalogCategoryFields | ErrorResponse]: + 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: int, + *, + client: AuthenticatedClient | Client, +) -> Response[CatalogCategoryFields | ErrorResponse]: + """Read what an item of a category is filled with + + Everything an item of this category takes beyond its common fields: its size groups (`sizeId`), its + enumerated fields with their values, each naming the item field it is written in (`colorIds`, + `materialIds`, `state`, `packageSizeId`, or an `enumValues` entry `{"enumKey": field.key, + "enumValue": value.key}`), its free-text fields (`attributes`, with whether a marketplace requires + them) and the measurements. A field used on one marketplace only names it in `platform`. Requires + `items:read`. + + Args: + id (int): + + 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[CatalogCategoryFields | ErrorResponse] + """ + + kwargs = _get_kwargs( + id=id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + id: int, + *, + client: AuthenticatedClient | Client, +) -> CatalogCategoryFields | ErrorResponse | None: + """Read what an item of a category is filled with + + Everything an item of this category takes beyond its common fields: its size groups (`sizeId`), its + enumerated fields with their values, each naming the item field it is written in (`colorIds`, + `materialIds`, `state`, `packageSizeId`, or an `enumValues` entry `{"enumKey": field.key, + "enumValue": value.key}`), its free-text fields (`attributes`, with whether a marketplace requires + them) and the measurements. A field used on one marketplace only names it in `platform`. Requires + `items:read`. + + Args: + id (int): + + 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: + CatalogCategoryFields | ErrorResponse + """ + + return sync_detailed( + id=id, + client=client, + ).parsed + + +async def asyncio_detailed( + id: int, + *, + client: AuthenticatedClient | Client, +) -> Response[CatalogCategoryFields | ErrorResponse]: + """Read what an item of a category is filled with + + Everything an item of this category takes beyond its common fields: its size groups (`sizeId`), its + enumerated fields with their values, each naming the item field it is written in (`colorIds`, + `materialIds`, `state`, `packageSizeId`, or an `enumValues` entry `{"enumKey": field.key, + "enumValue": value.key}`), its free-text fields (`attributes`, with whether a marketplace requires + them) and the measurements. A field used on one marketplace only names it in `platform`. Requires + `items:read`. + + Args: + id (int): + + 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[CatalogCategoryFields | ErrorResponse] + """ + + 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: int, + *, + client: AuthenticatedClient | Client, +) -> CatalogCategoryFields | ErrorResponse | None: + """Read what an item of a category is filled with + + Everything an item of this category takes beyond its common fields: its size groups (`sizeId`), its + enumerated fields with their values, each naming the item field it is written in (`colorIds`, + `materialIds`, `state`, `packageSizeId`, or an `enumValues` entry `{"enumKey": field.key, + "enumValue": value.key}`), its free-text fields (`attributes`, with whether a marketplace requires + them) and the measurements. A field used on one marketplace only names it in `platform`. Requires + `items:read`. + + Args: + id (int): + + 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: + CatalogCategoryFields | ErrorResponse + """ + + return ( + await asyncio_detailed( + id=id, + client=client, + ) + ).parsed diff --git a/src/controlresell/generated/api/catalogs/list_catalog_brands.py b/src/controlresell/generated/api/catalogs/list_catalog_brands.py new file mode 100644 index 0000000..c4166e7 --- /dev/null +++ b/src/controlresell/generated/api/catalogs/list_catalog_brands.py @@ -0,0 +1,235 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ...client import AuthenticatedClient, Client +from ...models.catalog_brand_page import CatalogBrandPage +from ...models.error_response import ErrorResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + q: str | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["limit"] = limit + + params["cursor"] = cursor + + params["q"] = q + + 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": "/api/public/v1/catalogs/brands", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> CatalogBrandPage | ErrorResponse: + if response.status_code == 200: + response_200 = CatalogBrandPage.from_dict(response.json()) + + return response_200 + + if response.status_code == 400: + response_400 = ErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 402: + response_402 = ErrorResponse.from_dict(response.json()) + + return response_402 + + if response.status_code == 403: + response_403 = ErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 429: + response_429 = ErrorResponse.from_dict(response.json()) + + return response_429 + + if response.status_code == 500: + response_500 = ErrorResponse.from_dict(response.json()) + + return response_500 + + response_default = ErrorResponse.from_dict(response.json()) + + return response_default + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CatalogBrandPage | ErrorResponse]: + 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, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + q: str | Unset = UNSET, +) -> Response[CatalogBrandPage | ErrorResponse]: + """List the brands + + The brands an item's `brandId` takes: the global ones and the seller's own (`custom`), by + identifier, or with `q` the brands whose name starts with it, by name (case and accents ignored). + Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + q (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[CatalogBrandPage | ErrorResponse] + """ + + kwargs = _get_kwargs( + limit=limit, + cursor=cursor, + q=q, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + q: str | Unset = UNSET, +) -> CatalogBrandPage | ErrorResponse | None: + """List the brands + + The brands an item's `brandId` takes: the global ones and the seller's own (`custom`), by + identifier, or with `q` the brands whose name starts with it, by name (case and accents ignored). + Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + q (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: + CatalogBrandPage | ErrorResponse + """ + + return sync_detailed( + client=client, + limit=limit, + cursor=cursor, + q=q, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + q: str | Unset = UNSET, +) -> Response[CatalogBrandPage | ErrorResponse]: + """List the brands + + The brands an item's `brandId` takes: the global ones and the seller's own (`custom`), by + identifier, or with `q` the brands whose name starts with it, by name (case and accents ignored). + Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + q (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[CatalogBrandPage | ErrorResponse] + """ + + kwargs = _get_kwargs( + limit=limit, + cursor=cursor, + q=q, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + q: str | Unset = UNSET, +) -> CatalogBrandPage | ErrorResponse | None: + """List the brands + + The brands an item's `brandId` takes: the global ones and the seller's own (`custom`), by + identifier, or with `q` the brands whose name starts with it, by name (case and accents ignored). + Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + q (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: + CatalogBrandPage | ErrorResponse + """ + + return ( + await asyncio_detailed( + client=client, + limit=limit, + cursor=cursor, + q=q, + ) + ).parsed diff --git a/src/controlresell/generated/api/catalogs/list_catalog_categories.py b/src/controlresell/generated/api/catalogs/list_catalog_categories.py new file mode 100644 index 0000000..497bbbb --- /dev/null +++ b/src/controlresell/generated/api/catalogs/list_catalog_categories.py @@ -0,0 +1,259 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ...client import AuthenticatedClient, Client +from ...models.catalog_category_page import CatalogCategoryPage +from ...models.error_response import ErrorResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + parent_id: int | Unset = UNSET, + platform: str | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["limit"] = limit + + params["cursor"] = cursor + + params["parentId"] = parent_id + + params["platform"] = platform + + 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": "/api/public/v1/catalogs/categories", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> CatalogCategoryPage | ErrorResponse: + if response.status_code == 200: + response_200 = CatalogCategoryPage.from_dict(response.json()) + + return response_200 + + if response.status_code == 400: + response_400 = ErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 402: + response_402 = ErrorResponse.from_dict(response.json()) + + return response_402 + + if response.status_code == 403: + response_403 = ErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 429: + response_429 = ErrorResponse.from_dict(response.json()) + + return response_429 + + if response.status_code == 500: + response_500 = ErrorResponse.from_dict(response.json()) + + return response_500 + + response_default = ErrorResponse.from_dict(response.json()) + + return response_default + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CatalogCategoryPage | ErrorResponse]: + 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, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + parent_id: int | Unset = UNSET, + platform: str | Unset = UNSET, +) -> Response[CatalogCategoryPage | ErrorResponse]: + """List the catalog's categories + + The categories an item's `categoryId` takes, flat, by identifier; each names its parent, so the tree + is rebuilt from the pages (or read level by level with `parentId`). One catalog for every + marketplace: `platforms` names where the category already has a mapping. Titles in the seller's + language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + parent_id (int | Unset): + platform (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[CatalogCategoryPage | ErrorResponse] + """ + + kwargs = _get_kwargs( + limit=limit, + cursor=cursor, + parent_id=parent_id, + platform=platform, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + parent_id: int | Unset = UNSET, + platform: str | Unset = UNSET, +) -> CatalogCategoryPage | ErrorResponse | None: + """List the catalog's categories + + The categories an item's `categoryId` takes, flat, by identifier; each names its parent, so the tree + is rebuilt from the pages (or read level by level with `parentId`). One catalog for every + marketplace: `platforms` names where the category already has a mapping. Titles in the seller's + language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + parent_id (int | Unset): + platform (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: + CatalogCategoryPage | ErrorResponse + """ + + return sync_detailed( + client=client, + limit=limit, + cursor=cursor, + parent_id=parent_id, + platform=platform, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + parent_id: int | Unset = UNSET, + platform: str | Unset = UNSET, +) -> Response[CatalogCategoryPage | ErrorResponse]: + """List the catalog's categories + + The categories an item's `categoryId` takes, flat, by identifier; each names its parent, so the tree + is rebuilt from the pages (or read level by level with `parentId`). One catalog for every + marketplace: `platforms` names where the category already has a mapping. Titles in the seller's + language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + parent_id (int | Unset): + platform (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[CatalogCategoryPage | ErrorResponse] + """ + + kwargs = _get_kwargs( + limit=limit, + cursor=cursor, + parent_id=parent_id, + platform=platform, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + parent_id: int | Unset = UNSET, + platform: str | Unset = UNSET, +) -> CatalogCategoryPage | ErrorResponse | None: + """List the catalog's categories + + The categories an item's `categoryId` takes, flat, by identifier; each names its parent, so the tree + is rebuilt from the pages (or read level by level with `parentId`). One catalog for every + marketplace: `platforms` names where the category already has a mapping. Titles in the seller's + language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + parent_id (int | Unset): + platform (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: + CatalogCategoryPage | ErrorResponse + """ + + return ( + await asyncio_detailed( + client=client, + limit=limit, + cursor=cursor, + parent_id=parent_id, + platform=platform, + ) + ).parsed diff --git a/src/controlresell/generated/api/catalogs/list_catalog_colors.py b/src/controlresell/generated/api/catalogs/list_catalog_colors.py new file mode 100644 index 0000000..0408047 --- /dev/null +++ b/src/controlresell/generated/api/catalogs/list_catalog_colors.py @@ -0,0 +1,236 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ...client import AuthenticatedClient, Client +from ...models.catalog_value_page import CatalogValuePage +from ...models.error_response import ErrorResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["limit"] = limit + + params["cursor"] = cursor + + params["categoryId"] = category_id + + 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": "/api/public/v1/catalogs/colors", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> CatalogValuePage | ErrorResponse: + if response.status_code == 200: + response_200 = CatalogValuePage.from_dict(response.json()) + + return response_200 + + if response.status_code == 400: + response_400 = ErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 402: + response_402 = ErrorResponse.from_dict(response.json()) + + return response_402 + + if response.status_code == 403: + response_403 = ErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 429: + response_429 = ErrorResponse.from_dict(response.json()) + + return response_429 + + if response.status_code == 500: + response_500 = ErrorResponse.from_dict(response.json()) + + return response_500 + + response_default = ErrorResponse.from_dict(response.json()) + + return response_default + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CatalogValuePage | ErrorResponse]: + 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, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> Response[CatalogValuePage | ErrorResponse]: + """List the colors + + The colors an item's `colorIds` takes (their `id`), by identifier; with `categoryId`, only those + that apply to that category. Titles in the seller's language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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[CatalogValuePage | ErrorResponse] + """ + + kwargs = _get_kwargs( + limit=limit, + cursor=cursor, + category_id=category_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> CatalogValuePage | ErrorResponse | None: + """List the colors + + The colors an item's `colorIds` takes (their `id`), by identifier; with `categoryId`, only those + that apply to that category. Titles in the seller's language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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: + CatalogValuePage | ErrorResponse + """ + + return sync_detailed( + client=client, + limit=limit, + cursor=cursor, + category_id=category_id, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> Response[CatalogValuePage | ErrorResponse]: + """List the colors + + The colors an item's `colorIds` takes (their `id`), by identifier; with `categoryId`, only those + that apply to that category. Titles in the seller's language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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[CatalogValuePage | ErrorResponse] + """ + + kwargs = _get_kwargs( + limit=limit, + cursor=cursor, + category_id=category_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> CatalogValuePage | ErrorResponse | None: + """List the colors + + The colors an item's `colorIds` takes (their `id`), by identifier; with `categoryId`, only those + that apply to that category. Titles in the seller's language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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: + CatalogValuePage | ErrorResponse + """ + + return ( + await asyncio_detailed( + client=client, + limit=limit, + cursor=cursor, + category_id=category_id, + ) + ).parsed diff --git a/src/controlresell/generated/api/catalogs/list_catalog_conditions.py b/src/controlresell/generated/api/catalogs/list_catalog_conditions.py new file mode 100644 index 0000000..8d11688 --- /dev/null +++ b/src/controlresell/generated/api/catalogs/list_catalog_conditions.py @@ -0,0 +1,236 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ...client import AuthenticatedClient, Client +from ...models.catalog_value_page import CatalogValuePage +from ...models.error_response import ErrorResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["limit"] = limit + + params["cursor"] = cursor + + params["categoryId"] = category_id + + 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": "/api/public/v1/catalogs/conditions", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> CatalogValuePage | ErrorResponse: + if response.status_code == 200: + response_200 = CatalogValuePage.from_dict(response.json()) + + return response_200 + + if response.status_code == 400: + response_400 = ErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 402: + response_402 = ErrorResponse.from_dict(response.json()) + + return response_402 + + if response.status_code == 403: + response_403 = ErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 429: + response_429 = ErrorResponse.from_dict(response.json()) + + return response_429 + + if response.status_code == 500: + response_500 = ErrorResponse.from_dict(response.json()) + + return response_500 + + response_default = ErrorResponse.from_dict(response.json()) + + return response_default + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CatalogValuePage | ErrorResponse]: + 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, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> Response[CatalogValuePage | ErrorResponse]: + """List the conditions + + The conditions an item's `state` takes (their `id`), by identifier; with `categoryId`, only those + that apply to that category. Titles in the seller's language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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[CatalogValuePage | ErrorResponse] + """ + + kwargs = _get_kwargs( + limit=limit, + cursor=cursor, + category_id=category_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> CatalogValuePage | ErrorResponse | None: + """List the conditions + + The conditions an item's `state` takes (their `id`), by identifier; with `categoryId`, only those + that apply to that category. Titles in the seller's language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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: + CatalogValuePage | ErrorResponse + """ + + return sync_detailed( + client=client, + limit=limit, + cursor=cursor, + category_id=category_id, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> Response[CatalogValuePage | ErrorResponse]: + """List the conditions + + The conditions an item's `state` takes (their `id`), by identifier; with `categoryId`, only those + that apply to that category. Titles in the seller's language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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[CatalogValuePage | ErrorResponse] + """ + + kwargs = _get_kwargs( + limit=limit, + cursor=cursor, + category_id=category_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> CatalogValuePage | ErrorResponse | None: + """List the conditions + + The conditions an item's `state` takes (their `id`), by identifier; with `categoryId`, only those + that apply to that category. Titles in the seller's language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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: + CatalogValuePage | ErrorResponse + """ + + return ( + await asyncio_detailed( + client=client, + limit=limit, + cursor=cursor, + category_id=category_id, + ) + ).parsed diff --git a/src/controlresell/generated/api/catalogs/list_catalog_materials.py b/src/controlresell/generated/api/catalogs/list_catalog_materials.py new file mode 100644 index 0000000..365d90b --- /dev/null +++ b/src/controlresell/generated/api/catalogs/list_catalog_materials.py @@ -0,0 +1,236 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ...client import AuthenticatedClient, Client +from ...models.catalog_value_page import CatalogValuePage +from ...models.error_response import ErrorResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["limit"] = limit + + params["cursor"] = cursor + + params["categoryId"] = category_id + + 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": "/api/public/v1/catalogs/materials", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> CatalogValuePage | ErrorResponse: + if response.status_code == 200: + response_200 = CatalogValuePage.from_dict(response.json()) + + return response_200 + + if response.status_code == 400: + response_400 = ErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 402: + response_402 = ErrorResponse.from_dict(response.json()) + + return response_402 + + if response.status_code == 403: + response_403 = ErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 429: + response_429 = ErrorResponse.from_dict(response.json()) + + return response_429 + + if response.status_code == 500: + response_500 = ErrorResponse.from_dict(response.json()) + + return response_500 + + response_default = ErrorResponse.from_dict(response.json()) + + return response_default + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CatalogValuePage | ErrorResponse]: + 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, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> Response[CatalogValuePage | ErrorResponse]: + """List the materials + + The materials an item's `materialIds` takes (their `id`), by identifier; with `categoryId`, only + those that apply to that category. Titles in the seller's language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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[CatalogValuePage | ErrorResponse] + """ + + kwargs = _get_kwargs( + limit=limit, + cursor=cursor, + category_id=category_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> CatalogValuePage | ErrorResponse | None: + """List the materials + + The materials an item's `materialIds` takes (their `id`), by identifier; with `categoryId`, only + those that apply to that category. Titles in the seller's language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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: + CatalogValuePage | ErrorResponse + """ + + return sync_detailed( + client=client, + limit=limit, + cursor=cursor, + category_id=category_id, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> Response[CatalogValuePage | ErrorResponse]: + """List the materials + + The materials an item's `materialIds` takes (their `id`), by identifier; with `categoryId`, only + those that apply to that category. Titles in the seller's language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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[CatalogValuePage | ErrorResponse] + """ + + kwargs = _get_kwargs( + limit=limit, + cursor=cursor, + category_id=category_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> CatalogValuePage | ErrorResponse | None: + """List the materials + + The materials an item's `materialIds` takes (their `id`), by identifier; with `categoryId`, only + those that apply to that category. Titles in the seller's language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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: + CatalogValuePage | ErrorResponse + """ + + return ( + await asyncio_detailed( + client=client, + limit=limit, + cursor=cursor, + category_id=category_id, + ) + ).parsed diff --git a/src/controlresell/generated/api/catalogs/list_catalog_package_sizes.py b/src/controlresell/generated/api/catalogs/list_catalog_package_sizes.py new file mode 100644 index 0000000..930e353 --- /dev/null +++ b/src/controlresell/generated/api/catalogs/list_catalog_package_sizes.py @@ -0,0 +1,236 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ...client import AuthenticatedClient, Client +from ...models.catalog_value_page import CatalogValuePage +from ...models.error_response import ErrorResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["limit"] = limit + + params["cursor"] = cursor + + params["categoryId"] = category_id + + 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": "/api/public/v1/catalogs/package-sizes", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> CatalogValuePage | ErrorResponse: + if response.status_code == 200: + response_200 = CatalogValuePage.from_dict(response.json()) + + return response_200 + + if response.status_code == 400: + response_400 = ErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 402: + response_402 = ErrorResponse.from_dict(response.json()) + + return response_402 + + if response.status_code == 403: + response_403 = ErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 429: + response_429 = ErrorResponse.from_dict(response.json()) + + return response_429 + + if response.status_code == 500: + response_500 = ErrorResponse.from_dict(response.json()) + + return response_500 + + response_default = ErrorResponse.from_dict(response.json()) + + return response_default + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CatalogValuePage | ErrorResponse]: + 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, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> Response[CatalogValuePage | ErrorResponse]: + """List the package sizes + + The package sizes an item's `packageSizeId` takes (their `id`), by identifier; with `categoryId`, + only those that apply to that category. Titles in the seller's language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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[CatalogValuePage | ErrorResponse] + """ + + kwargs = _get_kwargs( + limit=limit, + cursor=cursor, + category_id=category_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> CatalogValuePage | ErrorResponse | None: + """List the package sizes + + The package sizes an item's `packageSizeId` takes (their `id`), by identifier; with `categoryId`, + only those that apply to that category. Titles in the seller's language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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: + CatalogValuePage | ErrorResponse + """ + + return sync_detailed( + client=client, + limit=limit, + cursor=cursor, + category_id=category_id, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> Response[CatalogValuePage | ErrorResponse]: + """List the package sizes + + The package sizes an item's `packageSizeId` takes (their `id`), by identifier; with `categoryId`, + only those that apply to that category. Titles in the seller's language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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[CatalogValuePage | ErrorResponse] + """ + + kwargs = _get_kwargs( + limit=limit, + cursor=cursor, + category_id=category_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> CatalogValuePage | ErrorResponse | None: + """List the package sizes + + The package sizes an item's `packageSizeId` takes (their `id`), by identifier; with `categoryId`, + only those that apply to that category. Titles in the seller's language. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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: + CatalogValuePage | ErrorResponse + """ + + return ( + await asyncio_detailed( + client=client, + limit=limit, + cursor=cursor, + category_id=category_id, + ) + ).parsed diff --git a/src/controlresell/generated/api/catalogs/list_catalog_sizes.py b/src/controlresell/generated/api/catalogs/list_catalog_sizes.py new file mode 100644 index 0000000..fe3f48a --- /dev/null +++ b/src/controlresell/generated/api/catalogs/list_catalog_sizes.py @@ -0,0 +1,236 @@ +from http import HTTPStatus +from typing import Any + +import httpx + +from ...client import AuthenticatedClient, Client +from ...models.catalog_size_page import CatalogSizePage +from ...models.error_response import ErrorResponse +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + *, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> dict[str, Any]: + + params: dict[str, Any] = {} + + params["limit"] = limit + + params["cursor"] = cursor + + params["categoryId"] = category_id + + 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": "/api/public/v1/catalogs/sizes", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> CatalogSizePage | ErrorResponse: + if response.status_code == 200: + response_200 = CatalogSizePage.from_dict(response.json()) + + return response_200 + + if response.status_code == 400: + response_400 = ErrorResponse.from_dict(response.json()) + + return response_400 + + if response.status_code == 401: + response_401 = ErrorResponse.from_dict(response.json()) + + return response_401 + + if response.status_code == 402: + response_402 = ErrorResponse.from_dict(response.json()) + + return response_402 + + if response.status_code == 403: + response_403 = ErrorResponse.from_dict(response.json()) + + return response_403 + + if response.status_code == 404: + response_404 = ErrorResponse.from_dict(response.json()) + + return response_404 + + if response.status_code == 429: + response_429 = ErrorResponse.from_dict(response.json()) + + return response_429 + + if response.status_code == 500: + response_500 = ErrorResponse.from_dict(response.json()) + + return response_500 + + response_default = ErrorResponse.from_dict(response.json()) + + return response_default + + +def _build_response( + *, client: AuthenticatedClient | Client, response: httpx.Response +) -> Response[CatalogSizePage | ErrorResponse]: + 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, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> Response[CatalogSizePage | ErrorResponse]: + """List the sizes + + The sizes an item's `sizeId` takes, by identifier, each with its size group; with `categoryId`, only + the sizes of that category's size groups. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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[CatalogSizePage | ErrorResponse] + """ + + kwargs = _get_kwargs( + limit=limit, + cursor=cursor, + category_id=category_id, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> CatalogSizePage | ErrorResponse | None: + """List the sizes + + The sizes an item's `sizeId` takes, by identifier, each with its size group; with `categoryId`, only + the sizes of that category's size groups. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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: + CatalogSizePage | ErrorResponse + """ + + return sync_detailed( + client=client, + limit=limit, + cursor=cursor, + category_id=category_id, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> Response[CatalogSizePage | ErrorResponse]: + """List the sizes + + The sizes an item's `sizeId` takes, by identifier, each with its size group; with `categoryId`, only + the sizes of that category's size groups. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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[CatalogSizePage | ErrorResponse] + """ + + kwargs = _get_kwargs( + limit=limit, + cursor=cursor, + category_id=category_id, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient | Client, + limit: int | Unset = 50, + cursor: str | Unset = UNSET, + category_id: int | Unset = UNSET, +) -> CatalogSizePage | ErrorResponse | None: + """List the sizes + + The sizes an item's `sizeId` takes, by identifier, each with its size group; with `categoryId`, only + the sizes of that category's size groups. Requires `items:read`. + + Args: + limit (int | Unset): Default: 50. + cursor (str | Unset): + category_id (int | 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: + CatalogSizePage | ErrorResponse + """ + + return ( + await asyncio_detailed( + client=client, + limit=limit, + cursor=cursor, + category_id=category_id, + ) + ).parsed diff --git a/src/controlresell/generated/models/__init__.py b/src/controlresell/generated/models/__init__.py index 065e166..602335b 100644 --- a/src/controlresell/generated/models/__init__.py +++ b/src/controlresell/generated/models/__init__.py @@ -4,6 +4,18 @@ from .account_page import AccountPage from .api_error import ApiError from .api_error_params import ApiErrorParams +from .catalog_brand import CatalogBrand +from .catalog_brand_page import CatalogBrandPage +from .catalog_category import CatalogCategory +from .catalog_category_fields import CatalogCategoryFields +from .catalog_category_page import CatalogCategoryPage +from .catalog_enum_field import CatalogEnumField +from .catalog_measurement import CatalogMeasurement +from .catalog_size import CatalogSize +from .catalog_size_page import CatalogSizePage +from .catalog_text_field import CatalogTextField +from .catalog_value import CatalogValue +from .catalog_value_page import CatalogValuePage from .conversation import Conversation from .conversation_page import ConversationPage from .customer import Customer @@ -42,6 +54,18 @@ "AccountPage", "ApiError", "ApiErrorParams", + "CatalogBrand", + "CatalogBrandPage", + "CatalogCategory", + "CatalogCategoryFields", + "CatalogCategoryPage", + "CatalogEnumField", + "CatalogMeasurement", + "CatalogSize", + "CatalogSizePage", + "CatalogTextField", + "CatalogValue", + "CatalogValuePage", "Conversation", "ConversationPage", "Customer", diff --git a/src/controlresell/generated/models/catalog_brand.py b/src/controlresell/generated/models/catalog_brand.py new file mode 100644 index 0000000..92ab501 --- /dev/null +++ b/src/controlresell/generated/models/catalog_brand.py @@ -0,0 +1,77 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, Self, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="CatalogBrand") + + +@_attrs_define +class CatalogBrand: + """ + Attributes: + id (int): + name (str): + custom (bool): + """ + + id: int + name: str + custom: bool + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + id = self.id + + name = self.name + + custom = self.custom + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "name": name, + "custom": custom, + } + ) + + return field_dict + + @classmethod + def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: + d = dict(src_dict) + id = d.pop("id") + + name = d.pop("name") + + custom = d.pop("custom") + + catalog_brand = cls( + id=id, + name=name, + custom=custom, + ) + + catalog_brand.additional_properties = d + return catalog_brand + + @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/controlresell/generated/models/catalog_brand_page.py b/src/controlresell/generated/models/catalog_brand_page.py new file mode 100644 index 0000000..44aec44 --- /dev/null +++ b/src/controlresell/generated/models/catalog_brand_page.py @@ -0,0 +1,97 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, Self, 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.catalog_brand import CatalogBrand + + +T = TypeVar("T", bound="CatalogBrandPage") + + +@_attrs_define +class CatalogBrandPage: + """ + Attributes: + data (list[CatalogBrand]): + next_cursor (None | str | Unset): + """ + + data: list[CatalogBrand] + next_cursor: None | str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + data = [] + for data_item_data in self.data: + data_item = data_item_data.to_dict() + data.append(data_item) + + next_cursor: None | str | Unset + if isinstance(self.next_cursor, Unset): + next_cursor = UNSET + else: + next_cursor = self.next_cursor + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "data": data, + } + ) + if next_cursor is not UNSET: + field_dict["nextCursor"] = next_cursor + + return field_dict + + @classmethod + def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: + from ..models.catalog_brand import CatalogBrand + + d = dict(src_dict) + data = [] + _data = d.pop("data") + for data_item_data in _data: + data_item = CatalogBrand.from_dict(data_item_data) + + data.append(data_item) + + def _parse_next_cursor(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + next_cursor = _parse_next_cursor(d.pop("nextCursor", UNSET)) + + catalog_brand_page = cls( + data=data, + next_cursor=next_cursor, + ) + + catalog_brand_page.additional_properties = d + return catalog_brand_page + + @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/controlresell/generated/models/catalog_category.py b/src/controlresell/generated/models/catalog_category.py new file mode 100644 index 0000000..409fe70 --- /dev/null +++ b/src/controlresell/generated/models/catalog_category.py @@ -0,0 +1,115 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, Self, 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="CatalogCategory") + + +@_attrs_define +class CatalogCategory: + """ + Attributes: + id (int): + title (str): + has_children (bool): + size_group_ids (list[int]): + platforms (list[str]): + parent_id (int | None | Unset): + """ + + id: int + title: str + has_children: bool + size_group_ids: list[int] + platforms: list[str] + parent_id: int | None | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + id = self.id + + title = self.title + + has_children = self.has_children + + size_group_ids = self.size_group_ids + + platforms = self.platforms + + parent_id: int | None | Unset + if isinstance(self.parent_id, Unset): + parent_id = UNSET + else: + parent_id = self.parent_id + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "title": title, + "hasChildren": has_children, + "sizeGroupIds": size_group_ids, + "platforms": platforms, + } + ) + if parent_id is not UNSET: + field_dict["parentId"] = parent_id + + return field_dict + + @classmethod + def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: + d = dict(src_dict) + id = d.pop("id") + + title = d.pop("title") + + has_children = d.pop("hasChildren") + + size_group_ids = cast(list[int], d.pop("sizeGroupIds")) + + platforms = cast(list[str], d.pop("platforms")) + + def _parse_parent_id(data: object) -> int | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(int | None | Unset, data) + + parent_id = _parse_parent_id(d.pop("parentId", UNSET)) + + catalog_category = cls( + id=id, + title=title, + has_children=has_children, + size_group_ids=size_group_ids, + platforms=platforms, + parent_id=parent_id, + ) + + catalog_category.additional_properties = d + return catalog_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/controlresell/generated/models/catalog_category_fields.py b/src/controlresell/generated/models/catalog_category_fields.py new file mode 100644 index 0000000..eb0913e --- /dev/null +++ b/src/controlresell/generated/models/catalog_category_fields.py @@ -0,0 +1,127 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, Self, TypeVar, cast + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +if TYPE_CHECKING: + from ..models.catalog_enum_field import CatalogEnumField + from ..models.catalog_measurement import CatalogMeasurement + from ..models.catalog_text_field import CatalogTextField + + +T = TypeVar("T", bound="CatalogCategoryFields") + + +@_attrs_define +class CatalogCategoryFields: + """ + Attributes: + category_id (int): + size_group_ids (list[int]): + enum_fields (list[CatalogEnumField]): + text_fields (list[CatalogTextField]): + measurements (list[CatalogMeasurement]): + """ + + category_id: int + size_group_ids: list[int] + enum_fields: list[CatalogEnumField] + text_fields: list[CatalogTextField] + measurements: list[CatalogMeasurement] + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + category_id = self.category_id + + size_group_ids = self.size_group_ids + + enum_fields = [] + for enum_fields_item_data in self.enum_fields: + enum_fields_item = enum_fields_item_data.to_dict() + enum_fields.append(enum_fields_item) + + text_fields = [] + for text_fields_item_data in self.text_fields: + text_fields_item = text_fields_item_data.to_dict() + text_fields.append(text_fields_item) + + measurements = [] + for measurements_item_data in self.measurements: + measurements_item = measurements_item_data.to_dict() + measurements.append(measurements_item) + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "categoryId": category_id, + "sizeGroupIds": size_group_ids, + "enumFields": enum_fields, + "textFields": text_fields, + "measurements": measurements, + } + ) + + return field_dict + + @classmethod + def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: + from ..models.catalog_enum_field import CatalogEnumField + from ..models.catalog_measurement import CatalogMeasurement + from ..models.catalog_text_field import CatalogTextField + + d = dict(src_dict) + category_id = d.pop("categoryId") + + size_group_ids = cast(list[int], d.pop("sizeGroupIds")) + + enum_fields = [] + _enum_fields = d.pop("enumFields") + for enum_fields_item_data in _enum_fields: + enum_fields_item = CatalogEnumField.from_dict(enum_fields_item_data) + + enum_fields.append(enum_fields_item) + + text_fields = [] + _text_fields = d.pop("textFields") + for text_fields_item_data in _text_fields: + text_fields_item = CatalogTextField.from_dict(text_fields_item_data) + + text_fields.append(text_fields_item) + + measurements = [] + _measurements = d.pop("measurements") + for measurements_item_data in _measurements: + measurements_item = CatalogMeasurement.from_dict(measurements_item_data) + + measurements.append(measurements_item) + + catalog_category_fields = cls( + category_id=category_id, + size_group_ids=size_group_ids, + enum_fields=enum_fields, + text_fields=text_fields, + measurements=measurements, + ) + + catalog_category_fields.additional_properties = d + return catalog_category_fields + + @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/controlresell/generated/models/catalog_category_page.py b/src/controlresell/generated/models/catalog_category_page.py new file mode 100644 index 0000000..9040cb0 --- /dev/null +++ b/src/controlresell/generated/models/catalog_category_page.py @@ -0,0 +1,97 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, Self, 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.catalog_category import CatalogCategory + + +T = TypeVar("T", bound="CatalogCategoryPage") + + +@_attrs_define +class CatalogCategoryPage: + """ + Attributes: + data (list[CatalogCategory]): + next_cursor (None | str | Unset): + """ + + data: list[CatalogCategory] + next_cursor: None | str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + data = [] + for data_item_data in self.data: + data_item = data_item_data.to_dict() + data.append(data_item) + + next_cursor: None | str | Unset + if isinstance(self.next_cursor, Unset): + next_cursor = UNSET + else: + next_cursor = self.next_cursor + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "data": data, + } + ) + if next_cursor is not UNSET: + field_dict["nextCursor"] = next_cursor + + return field_dict + + @classmethod + def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: + from ..models.catalog_category import CatalogCategory + + d = dict(src_dict) + data = [] + _data = d.pop("data") + for data_item_data in _data: + data_item = CatalogCategory.from_dict(data_item_data) + + data.append(data_item) + + def _parse_next_cursor(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + next_cursor = _parse_next_cursor(d.pop("nextCursor", UNSET)) + + catalog_category_page = cls( + data=data, + next_cursor=next_cursor, + ) + + catalog_category_page.additional_properties = d + return catalog_category_page + + @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/controlresell/generated/models/catalog_enum_field.py b/src/controlresell/generated/models/catalog_enum_field.py new file mode 100644 index 0000000..e608de8 --- /dev/null +++ b/src/controlresell/generated/models/catalog_enum_field.py @@ -0,0 +1,153 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, Self, 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.catalog_value import CatalogValue + + +T = TypeVar("T", bound="CatalogEnumField") + + +@_attrs_define +class CatalogEnumField: + """ + Attributes: + key (str): + target (str): + values (list[CatalogValue]): + title (None | str | Unset): + multiple (bool | None | Unset): + platform (None | str | Unset): + """ + + key: str + target: str + values: list[CatalogValue] + title: None | str | Unset = UNSET + multiple: bool | None | Unset = UNSET + platform: None | str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + key = self.key + + target = self.target + + values = [] + for values_item_data in self.values: + values_item = values_item_data.to_dict() + values.append(values_item) + + title: None | str | Unset + if isinstance(self.title, Unset): + title = UNSET + else: + title = self.title + + multiple: bool | None | Unset + if isinstance(self.multiple, Unset): + multiple = UNSET + else: + multiple = self.multiple + + platform: None | str | Unset + if isinstance(self.platform, Unset): + platform = UNSET + else: + platform = self.platform + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "key": key, + "target": target, + "values": values, + } + ) + if title is not UNSET: + field_dict["title"] = title + if multiple is not UNSET: + field_dict["multiple"] = multiple + if platform is not UNSET: + field_dict["platform"] = platform + + return field_dict + + @classmethod + def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: + from ..models.catalog_value import CatalogValue + + d = dict(src_dict) + key = d.pop("key") + + target = d.pop("target") + + values = [] + _values = d.pop("values") + for values_item_data in _values: + values_item = CatalogValue.from_dict(values_item_data) + + values.append(values_item) + + def _parse_title(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + title = _parse_title(d.pop("title", UNSET)) + + def _parse_multiple(data: object) -> bool | None | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(bool | None | Unset, data) + + multiple = _parse_multiple(d.pop("multiple", UNSET)) + + def _parse_platform(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + platform = _parse_platform(d.pop("platform", UNSET)) + + catalog_enum_field = cls( + key=key, + target=target, + values=values, + title=title, + multiple=multiple, + platform=platform, + ) + + catalog_enum_field.additional_properties = d + return catalog_enum_field + + @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/controlresell/generated/models/catalog_measurement.py b/src/controlresell/generated/models/catalog_measurement.py new file mode 100644 index 0000000..5ba44f7 --- /dev/null +++ b/src/controlresell/generated/models/catalog_measurement.py @@ -0,0 +1,77 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, Self, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="CatalogMeasurement") + + +@_attrs_define +class CatalogMeasurement: + """ + Attributes: + target (str): + unit (str): + required (bool): + """ + + target: str + unit: str + required: bool + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + target = self.target + + unit = self.unit + + required = self.required + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "target": target, + "unit": unit, + "required": required, + } + ) + + return field_dict + + @classmethod + def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: + d = dict(src_dict) + target = d.pop("target") + + unit = d.pop("unit") + + required = d.pop("required") + + catalog_measurement = cls( + target=target, + unit=unit, + required=required, + ) + + catalog_measurement.additional_properties = d + return catalog_measurement + + @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/controlresell/generated/models/catalog_size.py b/src/controlresell/generated/models/catalog_size.py new file mode 100644 index 0000000..322f302 --- /dev/null +++ b/src/controlresell/generated/models/catalog_size.py @@ -0,0 +1,85 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, Self, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="CatalogSize") + + +@_attrs_define +class CatalogSize: + """ + Attributes: + id (int): + title (str): + size_group_id (int): + size_group_title (str): + """ + + id: int + title: str + size_group_id: int + size_group_title: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + id = self.id + + title = self.title + + size_group_id = self.size_group_id + + size_group_title = self.size_group_title + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "title": title, + "sizeGroupId": size_group_id, + "sizeGroupTitle": size_group_title, + } + ) + + return field_dict + + @classmethod + def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: + d = dict(src_dict) + id = d.pop("id") + + title = d.pop("title") + + size_group_id = d.pop("sizeGroupId") + + size_group_title = d.pop("sizeGroupTitle") + + catalog_size = cls( + id=id, + title=title, + size_group_id=size_group_id, + size_group_title=size_group_title, + ) + + catalog_size.additional_properties = d + return catalog_size + + @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/controlresell/generated/models/catalog_size_page.py b/src/controlresell/generated/models/catalog_size_page.py new file mode 100644 index 0000000..0bf6757 --- /dev/null +++ b/src/controlresell/generated/models/catalog_size_page.py @@ -0,0 +1,97 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, Self, 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.catalog_size import CatalogSize + + +T = TypeVar("T", bound="CatalogSizePage") + + +@_attrs_define +class CatalogSizePage: + """ + Attributes: + data (list[CatalogSize]): + next_cursor (None | str | Unset): + """ + + data: list[CatalogSize] + next_cursor: None | str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + data = [] + for data_item_data in self.data: + data_item = data_item_data.to_dict() + data.append(data_item) + + next_cursor: None | str | Unset + if isinstance(self.next_cursor, Unset): + next_cursor = UNSET + else: + next_cursor = self.next_cursor + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "data": data, + } + ) + if next_cursor is not UNSET: + field_dict["nextCursor"] = next_cursor + + return field_dict + + @classmethod + def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: + from ..models.catalog_size import CatalogSize + + d = dict(src_dict) + data = [] + _data = d.pop("data") + for data_item_data in _data: + data_item = CatalogSize.from_dict(data_item_data) + + data.append(data_item) + + def _parse_next_cursor(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + next_cursor = _parse_next_cursor(d.pop("nextCursor", UNSET)) + + catalog_size_page = cls( + data=data, + next_cursor=next_cursor, + ) + + catalog_size_page.additional_properties = d + return catalog_size_page + + @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/controlresell/generated/models/catalog_text_field.py b/src/controlresell/generated/models/catalog_text_field.py new file mode 100644 index 0000000..489853e --- /dev/null +++ b/src/controlresell/generated/models/catalog_text_field.py @@ -0,0 +1,139 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, Self, 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="CatalogTextField") + + +@_attrs_define +class CatalogTextField: + """ + Attributes: + key (str): + type_ (str): + required (bool): + title (None | str | Unset): + validation (None | str | Unset): + platform (None | str | Unset): + """ + + key: str + type_: str + required: bool + title: None | str | Unset = UNSET + validation: None | str | Unset = UNSET + platform: None | str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + key = self.key + + type_ = self.type_ + + required = self.required + + title: None | str | Unset + if isinstance(self.title, Unset): + title = UNSET + else: + title = self.title + + validation: None | str | Unset + if isinstance(self.validation, Unset): + validation = UNSET + else: + validation = self.validation + + platform: None | str | Unset + if isinstance(self.platform, Unset): + platform = UNSET + else: + platform = self.platform + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "key": key, + "type": type_, + "required": required, + } + ) + if title is not UNSET: + field_dict["title"] = title + if validation is not UNSET: + field_dict["validation"] = validation + if platform is not UNSET: + field_dict["platform"] = platform + + return field_dict + + @classmethod + def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: + d = dict(src_dict) + key = d.pop("key") + + type_ = d.pop("type") + + required = d.pop("required") + + def _parse_title(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + title = _parse_title(d.pop("title", UNSET)) + + def _parse_validation(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + validation = _parse_validation(d.pop("validation", UNSET)) + + def _parse_platform(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + platform = _parse_platform(d.pop("platform", UNSET)) + + catalog_text_field = cls( + key=key, + type_=type_, + required=required, + title=title, + validation=validation, + platform=platform, + ) + + catalog_text_field.additional_properties = d + return catalog_text_field + + @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/controlresell/generated/models/catalog_value.py b/src/controlresell/generated/models/catalog_value.py new file mode 100644 index 0000000..c1714d9 --- /dev/null +++ b/src/controlresell/generated/models/catalog_value.py @@ -0,0 +1,77 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, Self, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="CatalogValue") + + +@_attrs_define +class CatalogValue: + """ + Attributes: + id (int): + key (str): + title (str): + """ + + id: int + key: str + title: str + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + id = self.id + + key = self.key + + title = self.title + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "id": id, + "key": key, + "title": title, + } + ) + + return field_dict + + @classmethod + def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: + d = dict(src_dict) + id = d.pop("id") + + key = d.pop("key") + + title = d.pop("title") + + catalog_value = cls( + id=id, + key=key, + title=title, + ) + + catalog_value.additional_properties = d + return catalog_value + + @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/controlresell/generated/models/catalog_value_page.py b/src/controlresell/generated/models/catalog_value_page.py new file mode 100644 index 0000000..be6f1bd --- /dev/null +++ b/src/controlresell/generated/models/catalog_value_page.py @@ -0,0 +1,97 @@ +from __future__ import annotations + +from collections.abc import Mapping +from typing import TYPE_CHECKING, Any, Self, 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.catalog_value import CatalogValue + + +T = TypeVar("T", bound="CatalogValuePage") + + +@_attrs_define +class CatalogValuePage: + """ + Attributes: + data (list[CatalogValue]): + next_cursor (None | str | Unset): + """ + + data: list[CatalogValue] + next_cursor: None | str | Unset = UNSET + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + data = [] + for data_item_data in self.data: + data_item = data_item_data.to_dict() + data.append(data_item) + + next_cursor: None | str | Unset + if isinstance(self.next_cursor, Unset): + next_cursor = UNSET + else: + next_cursor = self.next_cursor + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "data": data, + } + ) + if next_cursor is not UNSET: + field_dict["nextCursor"] = next_cursor + + return field_dict + + @classmethod + def from_dict(cls, src_dict: Mapping[str, Any]) -> Self: + from ..models.catalog_value import CatalogValue + + d = dict(src_dict) + data = [] + _data = d.pop("data") + for data_item_data in _data: + data_item = CatalogValue.from_dict(data_item_data) + + data.append(data_item) + + def _parse_next_cursor(data: object) -> None | str | Unset: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(None | str | Unset, data) + + next_cursor = _parse_next_cursor(d.pop("nextCursor", UNSET)) + + catalog_value_page = cls( + data=data, + next_cursor=next_cursor, + ) + + catalog_value_page.additional_properties = d + return catalog_value_page + + @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/tests/test_client.py b/tests/test_client.py index 1ca691f..3b38c76 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -368,6 +368,34 @@ def test_customers_get_reads_one_customer(): assert requests[0].url.path == f"/api/public/v1/customers/{ACCOUNT}" +def test_catalogs_iter_brands_follows_the_cursor_with_the_same_query(): + seen = [] + + def handler(request): + seen.append(request.url) + if request.url.params.get("cursor"): + return reply({"data": [{"id": 2, "name": "Nikon", "custom": True}], "nextCursor": None}) + return reply({"data": [{"id": 1, "name": "Nike", "custom": False}], "nextCursor": "c2"}) + + _, sdk = client(handler) + assert [b.name for b in sdk.catalogs.iter_brands(q="nik")] == ["Nike", "Nikon"] + assert [u.path for u in seen] == ["/api/public/v1/catalogs/brands"] * 2 + assert [u.params["q"] for u in seen] == ["nik", "nik"] and seen[1].params["cursor"] == "c2" + + +def test_catalogs_colors_send_the_category_and_read_the_values(): + requests, sdk = client(lambda r: reply({"data": [{"id": 3, "key": "red", "title": "Red"}], "nextCursor": None})) + assert sdk.catalogs.colors(category_id=12).data[0].title == "Red" + assert requests[0].url.path == "/api/public/v1/catalogs/colors" and requests[0].url.params["categoryId"] == "12" + + +def test_catalogs_category_fields_reads_the_fields_of_one_category(): + body = {"categoryId": 12, "sizeGroupIds": [1], "enumFields": [], "textFields": [], "measurements": []} + requests, sdk = client(lambda r: reply(body)) + assert sdk.catalogs.category_fields(12).category_id == 12 + assert requests[0].url.path == "/api/public/v1/catalogs/categories/12/fields" + + def test_conversations_messages_and_list_send_the_from_and_to_window(): import datetime