channel3-sdk 0.2.1__py3-none-any.whl → 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of channel3-sdk might be problematic. Click here for more details.
- channel3_sdk/__init__.py +23 -17
- channel3_sdk/_gen/.gitignore +23 -0
- channel3_sdk/_gen/README.md +124 -0
- channel3_sdk/_gen/fast_api_client/__init__.py +8 -0
- channel3_sdk/_gen/fast_api_client/api/__init__.py +1 -0
- channel3_sdk/_gen/fast_api_client/api/channel3_api/__init__.py +1 -0
- channel3_sdk/_gen/fast_api_client/api/channel3_api/get_brand_detail_v0_brands_brand_id_get.py +179 -0
- channel3_sdk/_gen/fast_api_client/api/channel3_api/get_brands_v0_brands_get.py +218 -0
- channel3_sdk/_gen/fast_api_client/api/channel3_api/get_product_detail_v0_products_product_id_get.py +179 -0
- channel3_sdk/_gen/fast_api_client/api/channel3_api/search_v0_search_post.py +193 -0
- channel3_sdk/_gen/fast_api_client/api/default/__init__.py +1 -0
- channel3_sdk/_gen/fast_api_client/api/default/root_get.py +79 -0
- channel3_sdk/_gen/fast_api_client/client.py +268 -0
- channel3_sdk/_gen/fast_api_client/errors.py +16 -0
- channel3_sdk/_gen/fast_api_client/models/__init__.py +35 -0
- channel3_sdk/_gen/fast_api_client/models/availability_status.py +15 -0
- channel3_sdk/_gen/fast_api_client/models/brand.py +109 -0
- channel3_sdk/_gen/fast_api_client/models/error_response.py +59 -0
- channel3_sdk/_gen/fast_api_client/models/paginated_response_brand.py +83 -0
- channel3_sdk/_gen/fast_api_client/models/pagination_meta.py +84 -0
- channel3_sdk/_gen/fast_api_client/models/price.py +89 -0
- channel3_sdk/_gen/fast_api_client/models/product.py +166 -0
- channel3_sdk/_gen/fast_api_client/models/product_detail.py +306 -0
- channel3_sdk/_gen/fast_api_client/models/product_detail_gender_type_0.py +10 -0
- channel3_sdk/_gen/fast_api_client/models/search_config.py +69 -0
- channel3_sdk/_gen/fast_api_client/models/search_filter_price.py +92 -0
- channel3_sdk/_gen/fast_api_client/models/search_filters.py +191 -0
- channel3_sdk/_gen/fast_api_client/models/search_filters_gender_type_0.py +10 -0
- channel3_sdk/_gen/fast_api_client/models/search_request.py +191 -0
- channel3_sdk/_gen/fast_api_client/models/variant.py +75 -0
- channel3_sdk/_gen/fast_api_client/py.typed +1 -0
- channel3_sdk/_gen/fast_api_client/types.py +54 -0
- channel3_sdk/_gen/pyproject.toml +26 -0
- channel3_sdk/client.py +266 -479
- {channel3_sdk-0.2.1.dist-info → channel3_sdk-1.0.0.dist-info}/METADATA +83 -26
- channel3_sdk-1.0.0.dist-info/RECORD +38 -0
- {channel3_sdk-0.2.1.dist-info → channel3_sdk-1.0.0.dist-info}/WHEEL +1 -1
- channel3_sdk/models.py +0 -135
- channel3_sdk-0.2.1.dist-info/RECORD +0 -7
channel3_sdk/__init__.py
CHANGED
|
@@ -1,41 +1,47 @@
|
|
|
1
1
|
"""Channel3 SDK for Python - Official SDK for the Channel3 AI Shopping API."""
|
|
2
2
|
|
|
3
|
-
from .
|
|
4
|
-
from .models import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
SearchFilters,
|
|
8
|
-
SearchRequest,
|
|
9
|
-
SearchFilterPrice,
|
|
10
|
-
Brand,
|
|
11
|
-
Variant,
|
|
12
|
-
Price,
|
|
13
|
-
AvailabilityStatus,
|
|
3
|
+
from ._gen.fast_api_client.models.availability_status import AvailabilityStatus
|
|
4
|
+
from ._gen.fast_api_client.models.brand import Brand
|
|
5
|
+
from ._gen.fast_api_client.models.paginated_response_brand import (
|
|
6
|
+
PaginatedResponseBrand,
|
|
14
7
|
)
|
|
8
|
+
|
|
9
|
+
# Re-export generated models so the public API returns exactly what the OpenAPI returns
|
|
10
|
+
from ._gen.fast_api_client.models.pagination_meta import PaginationMeta
|
|
11
|
+
from ._gen.fast_api_client.models.price import Price
|
|
12
|
+
from ._gen.fast_api_client.models.product import Product
|
|
13
|
+
from ._gen.fast_api_client.models.product_detail import ProductDetail
|
|
14
|
+
from ._gen.fast_api_client.models.search_config import SearchConfig
|
|
15
|
+
from ._gen.fast_api_client.models.search_filters import SearchFilters
|
|
16
|
+
from ._gen.fast_api_client.models.search_request import SearchRequest
|
|
17
|
+
from ._gen.fast_api_client.models.variant import Variant
|
|
18
|
+
from .client import AsyncChannel3Client, Channel3Client
|
|
15
19
|
from .exceptions import (
|
|
16
|
-
Channel3Error,
|
|
17
20
|
Channel3AuthenticationError,
|
|
18
|
-
|
|
21
|
+
Channel3ConnectionError,
|
|
22
|
+
Channel3Error,
|
|
19
23
|
Channel3NotFoundError,
|
|
20
24
|
Channel3ServerError,
|
|
21
|
-
|
|
25
|
+
Channel3ValidationError,
|
|
22
26
|
)
|
|
23
27
|
|
|
24
|
-
__version__ = "0.
|
|
28
|
+
__version__ = "1.0.0"
|
|
25
29
|
__all__ = [
|
|
26
30
|
# Clients
|
|
27
31
|
"Channel3Client",
|
|
28
32
|
"AsyncChannel3Client",
|
|
29
|
-
# Models
|
|
33
|
+
# Models (generated)
|
|
30
34
|
"Product",
|
|
31
35
|
"ProductDetail",
|
|
32
36
|
"SearchFilters",
|
|
37
|
+
"SearchConfig",
|
|
33
38
|
"SearchRequest",
|
|
34
|
-
"SearchFilterPrice",
|
|
35
39
|
"Brand",
|
|
36
40
|
"Variant",
|
|
37
41
|
"Price",
|
|
38
42
|
"AvailabilityStatus",
|
|
43
|
+
"PaginatedResponseBrand",
|
|
44
|
+
"PaginationMeta",
|
|
39
45
|
# Exceptions
|
|
40
46
|
"Channel3Error",
|
|
41
47
|
"Channel3AuthenticationError",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
build/
|
|
3
|
+
dist/
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.pytest_cache/
|
|
6
|
+
|
|
7
|
+
# pyenv
|
|
8
|
+
.python-version
|
|
9
|
+
|
|
10
|
+
# Environments
|
|
11
|
+
.env
|
|
12
|
+
.venv
|
|
13
|
+
|
|
14
|
+
# mypy
|
|
15
|
+
.mypy_cache/
|
|
16
|
+
.dmypy.json
|
|
17
|
+
dmypy.json
|
|
18
|
+
|
|
19
|
+
# JetBrains
|
|
20
|
+
.idea/
|
|
21
|
+
|
|
22
|
+
/coverage.xml
|
|
23
|
+
/.coverage
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# fast-api-client
|
|
2
|
+
A client library for accessing FastAPI
|
|
3
|
+
|
|
4
|
+
## Usage
|
|
5
|
+
First, create a client:
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from fast_api_client import Client
|
|
9
|
+
|
|
10
|
+
client = Client(base_url="https://api.example.com")
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead:
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from fast_api_client import AuthenticatedClient
|
|
17
|
+
|
|
18
|
+
client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Now call your endpoint and use your models:
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from fast_api_client.models import MyDataModel
|
|
25
|
+
from fast_api_client.api.my_tag import get_my_data_model
|
|
26
|
+
from fast_api_client.types import Response
|
|
27
|
+
|
|
28
|
+
with client as client:
|
|
29
|
+
my_data: MyDataModel = get_my_data_model.sync(client=client)
|
|
30
|
+
# or if you need more info (e.g. status_code)
|
|
31
|
+
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Or do the same thing with an async version:
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from fast_api_client.models import MyDataModel
|
|
38
|
+
from fast_api_client.api.my_tag import get_my_data_model
|
|
39
|
+
from fast_api_client.types import Response
|
|
40
|
+
|
|
41
|
+
async with client as client:
|
|
42
|
+
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
|
|
43
|
+
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
client = AuthenticatedClient(
|
|
50
|
+
base_url="https://internal_api.example.com",
|
|
51
|
+
token="SuperSecretToken",
|
|
52
|
+
verify_ssl="/path/to/certificate_bundle.pem",
|
|
53
|
+
)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
You can also disable certificate validation altogether, but beware that **this is a security risk**.
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
client = AuthenticatedClient(
|
|
60
|
+
base_url="https://internal_api.example.com",
|
|
61
|
+
token="SuperSecretToken",
|
|
62
|
+
verify_ssl=False
|
|
63
|
+
)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Things to know:
|
|
67
|
+
1. Every path/method combo becomes a Python module with four functions:
|
|
68
|
+
1. `sync`: Blocking request that returns parsed data (if successful) or `None`
|
|
69
|
+
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
|
|
70
|
+
1. `asyncio`: Like `sync` but async instead of blocking
|
|
71
|
+
1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking
|
|
72
|
+
|
|
73
|
+
1. All path/query params, and bodies become method arguments.
|
|
74
|
+
1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
|
|
75
|
+
1. Any endpoint which did not have a tag will be in `fast_api_client.api.default`
|
|
76
|
+
|
|
77
|
+
## Advanced customizations
|
|
78
|
+
|
|
79
|
+
There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case):
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from fast_api_client import Client
|
|
83
|
+
|
|
84
|
+
def log_request(request):
|
|
85
|
+
print(f"Request event hook: {request.method} {request.url} - Waiting for response")
|
|
86
|
+
|
|
87
|
+
def log_response(response):
|
|
88
|
+
request = response.request
|
|
89
|
+
print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
|
|
90
|
+
|
|
91
|
+
client = Client(
|
|
92
|
+
base_url="https://api.example.com",
|
|
93
|
+
httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
import httpx
|
|
103
|
+
from fast_api_client import Client
|
|
104
|
+
|
|
105
|
+
client = Client(
|
|
106
|
+
base_url="https://api.example.com",
|
|
107
|
+
)
|
|
108
|
+
# Note that base_url needs to be re-set, as would any shared cookies, headers, etc.
|
|
109
|
+
client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030"))
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Building / publishing this package
|
|
113
|
+
This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:
|
|
114
|
+
1. Update the metadata in pyproject.toml (e.g. authors, version)
|
|
115
|
+
1. If you're using a private repository, configure it with Poetry
|
|
116
|
+
1. `poetry config repositories.<your-repository-name> <url-to-your-repository>`
|
|
117
|
+
1. `poetry config http-basic.<your-repository-name> <username> <password>`
|
|
118
|
+
1. Publish the client with `poetry publish --build -r <your-repository-name>` or, if for public PyPI, just `poetry publish --build`
|
|
119
|
+
|
|
120
|
+
If you want to install this client into another project without publishing it (e.g. for development) then:
|
|
121
|
+
1. If that project **is using Poetry**, you can simply do `poetry add <path-to-this-client>` from that project
|
|
122
|
+
1. If that project is not using Poetry:
|
|
123
|
+
1. Build a wheel with `poetry build -f wheel`
|
|
124
|
+
1. Install that wheel from the other project `pip install <path-to-wheel>`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Contains methods for accessing the API"""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Contains endpoint functions for accessing the API"""
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from typing import Any, Optional, Union
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
|
|
6
|
+
from ... import errors
|
|
7
|
+
from ...client import AuthenticatedClient, Client
|
|
8
|
+
from ...models.brand import Brand
|
|
9
|
+
from ...models.error_response import ErrorResponse
|
|
10
|
+
from ...types import Response
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _get_kwargs(
|
|
14
|
+
brand_id: str,
|
|
15
|
+
) -> dict[str, Any]:
|
|
16
|
+
_kwargs: dict[str, Any] = {
|
|
17
|
+
"method": "get",
|
|
18
|
+
"url": f"/v0/brands/{brand_id}",
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return _kwargs
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _parse_response(
|
|
25
|
+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
|
26
|
+
) -> Optional[Union[Brand, ErrorResponse]]:
|
|
27
|
+
if response.status_code == 200:
|
|
28
|
+
response_200 = Brand.from_dict(response.json())
|
|
29
|
+
|
|
30
|
+
return response_200
|
|
31
|
+
if response.status_code == 401:
|
|
32
|
+
response_401 = ErrorResponse.from_dict(response.json())
|
|
33
|
+
|
|
34
|
+
return response_401
|
|
35
|
+
if response.status_code == 402:
|
|
36
|
+
response_402 = ErrorResponse.from_dict(response.json())
|
|
37
|
+
|
|
38
|
+
return response_402
|
|
39
|
+
if response.status_code == 422:
|
|
40
|
+
response_422 = ErrorResponse.from_dict(response.json())
|
|
41
|
+
|
|
42
|
+
return response_422
|
|
43
|
+
if response.status_code == 500:
|
|
44
|
+
response_500 = ErrorResponse.from_dict(response.json())
|
|
45
|
+
|
|
46
|
+
return response_500
|
|
47
|
+
if response.status_code == 404:
|
|
48
|
+
response_404 = ErrorResponse.from_dict(response.json())
|
|
49
|
+
|
|
50
|
+
return response_404
|
|
51
|
+
if client.raise_on_unexpected_status:
|
|
52
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
53
|
+
else:
|
|
54
|
+
return None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _build_response(
|
|
58
|
+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
|
59
|
+
) -> Response[Union[Brand, ErrorResponse]]:
|
|
60
|
+
return Response(
|
|
61
|
+
status_code=HTTPStatus(response.status_code),
|
|
62
|
+
content=response.content,
|
|
63
|
+
headers=response.headers,
|
|
64
|
+
parsed=_parse_response(client=client, response=response),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def sync_detailed(
|
|
69
|
+
brand_id: str,
|
|
70
|
+
*,
|
|
71
|
+
client: AuthenticatedClient,
|
|
72
|
+
) -> Response[Union[Brand, ErrorResponse]]:
|
|
73
|
+
"""Get Brand Detail
|
|
74
|
+
|
|
75
|
+
Get detailed information for a specific brand by its ID.
|
|
76
|
+
|
|
77
|
+
Args:
|
|
78
|
+
brand_id (str):
|
|
79
|
+
|
|
80
|
+
Raises:
|
|
81
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
82
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
Response[Union[Brand, ErrorResponse]]
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
kwargs = _get_kwargs(
|
|
89
|
+
brand_id=brand_id,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
response = client.get_httpx_client().request(
|
|
93
|
+
**kwargs,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
return _build_response(client=client, response=response)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def sync(
|
|
100
|
+
brand_id: str,
|
|
101
|
+
*,
|
|
102
|
+
client: AuthenticatedClient,
|
|
103
|
+
) -> Optional[Union[Brand, ErrorResponse]]:
|
|
104
|
+
"""Get Brand Detail
|
|
105
|
+
|
|
106
|
+
Get detailed information for a specific brand by its ID.
|
|
107
|
+
|
|
108
|
+
Args:
|
|
109
|
+
brand_id (str):
|
|
110
|
+
|
|
111
|
+
Raises:
|
|
112
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
113
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
114
|
+
|
|
115
|
+
Returns:
|
|
116
|
+
Union[Brand, ErrorResponse]
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
return sync_detailed(
|
|
120
|
+
brand_id=brand_id,
|
|
121
|
+
client=client,
|
|
122
|
+
).parsed
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
async def asyncio_detailed(
|
|
126
|
+
brand_id: str,
|
|
127
|
+
*,
|
|
128
|
+
client: AuthenticatedClient,
|
|
129
|
+
) -> Response[Union[Brand, ErrorResponse]]:
|
|
130
|
+
"""Get Brand Detail
|
|
131
|
+
|
|
132
|
+
Get detailed information for a specific brand by its ID.
|
|
133
|
+
|
|
134
|
+
Args:
|
|
135
|
+
brand_id (str):
|
|
136
|
+
|
|
137
|
+
Raises:
|
|
138
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
139
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
140
|
+
|
|
141
|
+
Returns:
|
|
142
|
+
Response[Union[Brand, ErrorResponse]]
|
|
143
|
+
"""
|
|
144
|
+
|
|
145
|
+
kwargs = _get_kwargs(
|
|
146
|
+
brand_id=brand_id,
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
150
|
+
|
|
151
|
+
return _build_response(client=client, response=response)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
async def asyncio(
|
|
155
|
+
brand_id: str,
|
|
156
|
+
*,
|
|
157
|
+
client: AuthenticatedClient,
|
|
158
|
+
) -> Optional[Union[Brand, ErrorResponse]]:
|
|
159
|
+
"""Get Brand Detail
|
|
160
|
+
|
|
161
|
+
Get detailed information for a specific brand by its ID.
|
|
162
|
+
|
|
163
|
+
Args:
|
|
164
|
+
brand_id (str):
|
|
165
|
+
|
|
166
|
+
Raises:
|
|
167
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
168
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
169
|
+
|
|
170
|
+
Returns:
|
|
171
|
+
Union[Brand, ErrorResponse]
|
|
172
|
+
"""
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
await asyncio_detailed(
|
|
176
|
+
brand_id=brand_id,
|
|
177
|
+
client=client,
|
|
178
|
+
)
|
|
179
|
+
).parsed
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
from http import HTTPStatus
|
|
2
|
+
from typing import Any, Optional, Union
|
|
3
|
+
|
|
4
|
+
import httpx
|
|
5
|
+
|
|
6
|
+
from ... import errors
|
|
7
|
+
from ...client import AuthenticatedClient, Client
|
|
8
|
+
from ...models.error_response import ErrorResponse
|
|
9
|
+
from ...models.paginated_response_brand import PaginatedResponseBrand
|
|
10
|
+
from ...types import UNSET, Response, Unset
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _get_kwargs(
|
|
14
|
+
*,
|
|
15
|
+
query: Union[None, Unset, str] = UNSET,
|
|
16
|
+
page: Union[Unset, int] = 1,
|
|
17
|
+
size: Union[Unset, int] = 100,
|
|
18
|
+
) -> dict[str, Any]:
|
|
19
|
+
params: dict[str, Any] = {}
|
|
20
|
+
|
|
21
|
+
json_query: Union[None, Unset, str]
|
|
22
|
+
if isinstance(query, Unset):
|
|
23
|
+
json_query = UNSET
|
|
24
|
+
else:
|
|
25
|
+
json_query = query
|
|
26
|
+
params["query"] = json_query
|
|
27
|
+
|
|
28
|
+
params["page"] = page
|
|
29
|
+
|
|
30
|
+
params["size"] = size
|
|
31
|
+
|
|
32
|
+
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
|
|
33
|
+
|
|
34
|
+
_kwargs: dict[str, Any] = {
|
|
35
|
+
"method": "get",
|
|
36
|
+
"url": "/v0/brands",
|
|
37
|
+
"params": params,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return _kwargs
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _parse_response(
|
|
44
|
+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
|
45
|
+
) -> Optional[Union[ErrorResponse, PaginatedResponseBrand]]:
|
|
46
|
+
if response.status_code == 200:
|
|
47
|
+
response_200 = PaginatedResponseBrand.from_dict(response.json())
|
|
48
|
+
|
|
49
|
+
return response_200
|
|
50
|
+
if response.status_code == 401:
|
|
51
|
+
response_401 = ErrorResponse.from_dict(response.json())
|
|
52
|
+
|
|
53
|
+
return response_401
|
|
54
|
+
if response.status_code == 402:
|
|
55
|
+
response_402 = ErrorResponse.from_dict(response.json())
|
|
56
|
+
|
|
57
|
+
return response_402
|
|
58
|
+
if response.status_code == 422:
|
|
59
|
+
response_422 = ErrorResponse.from_dict(response.json())
|
|
60
|
+
|
|
61
|
+
return response_422
|
|
62
|
+
if response.status_code == 500:
|
|
63
|
+
response_500 = ErrorResponse.from_dict(response.json())
|
|
64
|
+
|
|
65
|
+
return response_500
|
|
66
|
+
if client.raise_on_unexpected_status:
|
|
67
|
+
raise errors.UnexpectedStatus(response.status_code, response.content)
|
|
68
|
+
else:
|
|
69
|
+
return None
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _build_response(
|
|
73
|
+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
|
|
74
|
+
) -> Response[Union[ErrorResponse, PaginatedResponseBrand]]:
|
|
75
|
+
return Response(
|
|
76
|
+
status_code=HTTPStatus(response.status_code),
|
|
77
|
+
content=response.content,
|
|
78
|
+
headers=response.headers,
|
|
79
|
+
parsed=_parse_response(client=client, response=response),
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def sync_detailed(
|
|
84
|
+
*,
|
|
85
|
+
client: AuthenticatedClient,
|
|
86
|
+
query: Union[None, Unset, str] = UNSET,
|
|
87
|
+
page: Union[Unset, int] = 1,
|
|
88
|
+
size: Union[Unset, int] = 100,
|
|
89
|
+
) -> Response[Union[ErrorResponse, PaginatedResponseBrand]]:
|
|
90
|
+
"""Get Brands
|
|
91
|
+
|
|
92
|
+
Get all brands that the vendor currently sells.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
query (Union[None, Unset, str]):
|
|
96
|
+
page (Union[Unset, int]): Default: 1.
|
|
97
|
+
size (Union[Unset, int]): Default: 100.
|
|
98
|
+
|
|
99
|
+
Raises:
|
|
100
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
101
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
102
|
+
|
|
103
|
+
Returns:
|
|
104
|
+
Response[Union[ErrorResponse, PaginatedResponseBrand]]
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
kwargs = _get_kwargs(
|
|
108
|
+
query=query,
|
|
109
|
+
page=page,
|
|
110
|
+
size=size,
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
response = client.get_httpx_client().request(
|
|
114
|
+
**kwargs,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
return _build_response(client=client, response=response)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def sync(
|
|
121
|
+
*,
|
|
122
|
+
client: AuthenticatedClient,
|
|
123
|
+
query: Union[None, Unset, str] = UNSET,
|
|
124
|
+
page: Union[Unset, int] = 1,
|
|
125
|
+
size: Union[Unset, int] = 100,
|
|
126
|
+
) -> Optional[Union[ErrorResponse, PaginatedResponseBrand]]:
|
|
127
|
+
"""Get Brands
|
|
128
|
+
|
|
129
|
+
Get all brands that the vendor currently sells.
|
|
130
|
+
|
|
131
|
+
Args:
|
|
132
|
+
query (Union[None, Unset, str]):
|
|
133
|
+
page (Union[Unset, int]): Default: 1.
|
|
134
|
+
size (Union[Unset, int]): Default: 100.
|
|
135
|
+
|
|
136
|
+
Raises:
|
|
137
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
138
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
Union[ErrorResponse, PaginatedResponseBrand]
|
|
142
|
+
"""
|
|
143
|
+
|
|
144
|
+
return sync_detailed(
|
|
145
|
+
client=client,
|
|
146
|
+
query=query,
|
|
147
|
+
page=page,
|
|
148
|
+
size=size,
|
|
149
|
+
).parsed
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
async def asyncio_detailed(
|
|
153
|
+
*,
|
|
154
|
+
client: AuthenticatedClient,
|
|
155
|
+
query: Union[None, Unset, str] = UNSET,
|
|
156
|
+
page: Union[Unset, int] = 1,
|
|
157
|
+
size: Union[Unset, int] = 100,
|
|
158
|
+
) -> Response[Union[ErrorResponse, PaginatedResponseBrand]]:
|
|
159
|
+
"""Get Brands
|
|
160
|
+
|
|
161
|
+
Get all brands that the vendor currently sells.
|
|
162
|
+
|
|
163
|
+
Args:
|
|
164
|
+
query (Union[None, Unset, str]):
|
|
165
|
+
page (Union[Unset, int]): Default: 1.
|
|
166
|
+
size (Union[Unset, int]): Default: 100.
|
|
167
|
+
|
|
168
|
+
Raises:
|
|
169
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
170
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
171
|
+
|
|
172
|
+
Returns:
|
|
173
|
+
Response[Union[ErrorResponse, PaginatedResponseBrand]]
|
|
174
|
+
"""
|
|
175
|
+
|
|
176
|
+
kwargs = _get_kwargs(
|
|
177
|
+
query=query,
|
|
178
|
+
page=page,
|
|
179
|
+
size=size,
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
response = await client.get_async_httpx_client().request(**kwargs)
|
|
183
|
+
|
|
184
|
+
return _build_response(client=client, response=response)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
async def asyncio(
|
|
188
|
+
*,
|
|
189
|
+
client: AuthenticatedClient,
|
|
190
|
+
query: Union[None, Unset, str] = UNSET,
|
|
191
|
+
page: Union[Unset, int] = 1,
|
|
192
|
+
size: Union[Unset, int] = 100,
|
|
193
|
+
) -> Optional[Union[ErrorResponse, PaginatedResponseBrand]]:
|
|
194
|
+
"""Get Brands
|
|
195
|
+
|
|
196
|
+
Get all brands that the vendor currently sells.
|
|
197
|
+
|
|
198
|
+
Args:
|
|
199
|
+
query (Union[None, Unset, str]):
|
|
200
|
+
page (Union[Unset, int]): Default: 1.
|
|
201
|
+
size (Union[Unset, int]): Default: 100.
|
|
202
|
+
|
|
203
|
+
Raises:
|
|
204
|
+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
|
205
|
+
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
|
206
|
+
|
|
207
|
+
Returns:
|
|
208
|
+
Union[ErrorResponse, PaginatedResponseBrand]
|
|
209
|
+
"""
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
await asyncio_detailed(
|
|
213
|
+
client=client,
|
|
214
|
+
query=query,
|
|
215
|
+
page=page,
|
|
216
|
+
size=size,
|
|
217
|
+
)
|
|
218
|
+
).parsed
|