ordercloud-python 2026.4.1__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.
- ordercloud/__init__.py +37 -0
- ordercloud/auth.py +136 -0
- ordercloud/client.py +211 -0
- ordercloud/config.py +42 -0
- ordercloud/errors.py +47 -0
- ordercloud/http.py +218 -0
- ordercloud/middleware.py +66 -0
- ordercloud/models/__init__.py +271 -0
- ordercloud/models/address.py +47 -0
- ordercloud/models/api_client.py +116 -0
- ordercloud/models/approval.py +73 -0
- ordercloud/models/assignments.py +402 -0
- ordercloud/models/auth_models.py +114 -0
- ordercloud/models/bundle.py +31 -0
- ordercloud/models/buyer.py +271 -0
- ordercloud/models/catalog.py +33 -0
- ordercloud/models/category.py +35 -0
- ordercloud/models/cost_center.py +27 -0
- ordercloud/models/credit_card.py +35 -0
- ordercloud/models/delivery.py +277 -0
- ordercloud/models/discount.py +63 -0
- ordercloud/models/integration.py +76 -0
- ordercloud/models/inventory_record.py +53 -0
- ordercloud/models/line_item.py +95 -0
- ordercloud/models/line_item_types.py +89 -0
- ordercloud/models/message_sender.py +80 -0
- ordercloud/models/misc.py +280 -0
- ordercloud/models/open_id_connect.py +47 -0
- ordercloud/models/order.py +477 -0
- ordercloud/models/order_return.py +92 -0
- ordercloud/models/payment.py +77 -0
- ordercloud/models/price_schedule.py +76 -0
- ordercloud/models/product.py +227 -0
- ordercloud/models/product_collection.py +186 -0
- ordercloud/models/promotion.py +297 -0
- ordercloud/models/security.py +89 -0
- ordercloud/models/shared.py +131 -0
- ordercloud/models/shipment.py +150 -0
- ordercloud/models/spec.py +67 -0
- ordercloud/models/spending_account.py +33 -0
- ordercloud/models/subscription.py +125 -0
- ordercloud/models/supplier.py +43 -0
- ordercloud/models/sync.py +172 -0
- ordercloud/models/user.py +207 -0
- ordercloud/models/user_group.py +27 -0
- ordercloud/models/webhook.py +58 -0
- ordercloud/py.typed +0 -0
- ordercloud/resources/__init__.py +65 -0
- ordercloud/resources/addresses.py +228 -0
- ordercloud/resources/admin_addresses.py +128 -0
- ordercloud/resources/admin_user_groups.py +185 -0
- ordercloud/resources/admin_users.py +150 -0
- ordercloud/resources/api_clients.py +308 -0
- ordercloud/resources/approval_rules.py +144 -0
- ordercloud/resources/base.py +145 -0
- ordercloud/resources/bundle_line_items.py +59 -0
- ordercloud/resources/bundle_subscription_items.py +54 -0
- ordercloud/resources/bundles.py +278 -0
- ordercloud/resources/buyer_groups.py +128 -0
- ordercloud/resources/buyers.py +164 -0
- ordercloud/resources/cart.py +613 -0
- ordercloud/resources/catalogs.py +311 -0
- ordercloud/resources/categories.py +392 -0
- ordercloud/resources/cost_centers.py +222 -0
- ordercloud/resources/credit_cards.py +227 -0
- ordercloud/resources/delivery_configurations.py +132 -0
- ordercloud/resources/discounts.py +201 -0
- ordercloud/resources/entity_syncs.py +534 -0
- ordercloud/resources/error_configs.py +71 -0
- ordercloud/resources/forgotten_credentials.py +74 -0
- ordercloud/resources/group_orders.py +28 -0
- ordercloud/resources/impersonation_configs.py +132 -0
- ordercloud/resources/incrementors.py +128 -0
- ordercloud/resources/integration_events.py +203 -0
- ordercloud/resources/inventory_integrations.py +65 -0
- ordercloud/resources/inventory_records.py +484 -0
- ordercloud/resources/line_items.py +262 -0
- ordercloud/resources/locales.py +203 -0
- ordercloud/resources/me.py +1882 -0
- ordercloud/resources/message_senders.py +261 -0
- ordercloud/resources/open_id_connects.py +128 -0
- ordercloud/resources/order_returns.py +306 -0
- ordercloud/resources/order_syncs.py +65 -0
- ordercloud/resources/orders.py +689 -0
- ordercloud/resources/payments.py +176 -0
- ordercloud/resources/price_schedules.py +164 -0
- ordercloud/resources/product_collections.py +116 -0
- ordercloud/resources/product_facets.py +128 -0
- ordercloud/resources/product_syncs.py +76 -0
- ordercloud/resources/products.py +454 -0
- ordercloud/resources/promotion_integrations.py +65 -0
- ordercloud/resources/promotions.py +203 -0
- ordercloud/resources/security_profiles.py +222 -0
- ordercloud/resources/seller_approval_rules.py +128 -0
- ordercloud/resources/shipments.py +256 -0
- ordercloud/resources/specs.py +313 -0
- ordercloud/resources/spending_accounts.py +227 -0
- ordercloud/resources/subscription_integrations.py +65 -0
- ordercloud/resources/subscription_items.py +146 -0
- ordercloud/resources/subscriptions.py +128 -0
- ordercloud/resources/supplier_addresses.py +144 -0
- ordercloud/resources/supplier_user_groups.py +210 -0
- ordercloud/resources/supplier_users.py +170 -0
- ordercloud/resources/suppliers.py +190 -0
- ordercloud/resources/tracking_events.py +130 -0
- ordercloud/resources/user_groups.py +210 -0
- ordercloud/resources/users.py +254 -0
- ordercloud/resources/webhooks.py +128 -0
- ordercloud/resources/xp_indices.py +77 -0
- ordercloud/sync_client.py +170 -0
- ordercloud_python-2026.4.1.dist-info/METADATA +552 -0
- ordercloud_python-2026.4.1.dist-info/RECORD +114 -0
- ordercloud_python-2026.4.1.dist-info/WHEEL +4 -0
- ordercloud_python-2026.4.1.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# GENERATED by tools/codegen — DO NOT EDIT
|
|
2
|
+
# Source: ordercloud-openapi-v3.json
|
|
3
|
+
"""OrderCloud Catalogs API resource."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
from typing import Any, Optional, Union
|
|
7
|
+
|
|
8
|
+
from ..models.assignments import (
|
|
9
|
+
BundleCatalogAssignment,
|
|
10
|
+
CatalogAssignment,
|
|
11
|
+
ProductCatalogAssignment,
|
|
12
|
+
)
|
|
13
|
+
from ..models.catalog import Catalog
|
|
14
|
+
from ..models.shared import ListPage
|
|
15
|
+
from .base import BaseResource
|
|
16
|
+
|
|
17
|
+
__all__ = ["CatalogsResource"]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class CatalogsResource(BaseResource):
|
|
21
|
+
"""Operations on OrderCloud Catalogs."""
|
|
22
|
+
|
|
23
|
+
async def list(
|
|
24
|
+
self,
|
|
25
|
+
*,
|
|
26
|
+
search: Optional[str] = None,
|
|
27
|
+
search_on: Optional[str] = None,
|
|
28
|
+
sort_by: Optional[str] = None,
|
|
29
|
+
page: Optional[int] = None,
|
|
30
|
+
page_size: Optional[int] = None,
|
|
31
|
+
filters: Optional[dict[str, Any]] = None,
|
|
32
|
+
) -> ListPage[Catalog]:
|
|
33
|
+
"""List catalogs
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
search: Word or phrase to search for.
|
|
37
|
+
search_on: Comma-delimited list of fields to search on.
|
|
38
|
+
sort_by: Comma-delimited list of fields to sort by.
|
|
39
|
+
page: Page of results to return. When paginating through many items (> page 30), we recommend the "Last ID" method, as outlined in the Advanced Querying documentation.
|
|
40
|
+
page_size: Number of results to return per page.
|
|
41
|
+
filters: An object or dictionary representing key/value pairs to apply as filters. Valid keys are top-level properties of the returned model or 'xp.???'
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
A paginated list of Catalog objects.
|
|
45
|
+
"""
|
|
46
|
+
params = self._build_list_params(
|
|
47
|
+
search=search,
|
|
48
|
+
search_on=search_on,
|
|
49
|
+
sort_by=sort_by,
|
|
50
|
+
page=page,
|
|
51
|
+
page_size=page_size,
|
|
52
|
+
filters=filters,
|
|
53
|
+
)
|
|
54
|
+
resp = await self._http.get("/catalogs", **params)
|
|
55
|
+
return self._parse_list(resp.json(), Catalog)
|
|
56
|
+
|
|
57
|
+
async def create(
|
|
58
|
+
self,
|
|
59
|
+
catalog: Union[Catalog, dict[str, Any]],
|
|
60
|
+
) -> Catalog:
|
|
61
|
+
"""Create a catalog
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
catalog: A ``Catalog`` model or dict. Required fields: Name.
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
The Catalog object.
|
|
68
|
+
"""
|
|
69
|
+
resp = await self._http.post("/catalogs", json=self._serialize(catalog))
|
|
70
|
+
return Catalog(**resp.json())
|
|
71
|
+
|
|
72
|
+
async def get(
|
|
73
|
+
self,
|
|
74
|
+
catalog_id: str,
|
|
75
|
+
) -> Catalog:
|
|
76
|
+
"""Retrieve a catalog
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
catalog_id: ID of the catalog.
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
The Catalog object.
|
|
83
|
+
"""
|
|
84
|
+
resp = await self._http.get(f"/catalogs/{catalog_id}")
|
|
85
|
+
return Catalog(**resp.json())
|
|
86
|
+
|
|
87
|
+
async def save(
|
|
88
|
+
self,
|
|
89
|
+
catalog_id: str,
|
|
90
|
+
catalog: Union[Catalog, dict[str, Any]],
|
|
91
|
+
) -> Catalog:
|
|
92
|
+
"""Create or update a catalog
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
catalog_id: ID of the catalog.
|
|
96
|
+
catalog: A ``Catalog`` model or dict. Required fields: Name.
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
The Catalog object.
|
|
100
|
+
"""
|
|
101
|
+
resp = await self._http.put(
|
|
102
|
+
f"/catalogs/{catalog_id}",
|
|
103
|
+
json=self._serialize(catalog),
|
|
104
|
+
)
|
|
105
|
+
return Catalog(**resp.json())
|
|
106
|
+
|
|
107
|
+
async def delete(
|
|
108
|
+
self,
|
|
109
|
+
catalog_id: str,
|
|
110
|
+
) -> None:
|
|
111
|
+
"""Delete a catalog
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
catalog_id: ID of the catalog.
|
|
115
|
+
"""
|
|
116
|
+
await self._http.delete(f"/catalogs/{catalog_id}")
|
|
117
|
+
|
|
118
|
+
async def patch(
|
|
119
|
+
self,
|
|
120
|
+
catalog_id: str,
|
|
121
|
+
partial: dict[str, Any],
|
|
122
|
+
) -> Catalog:
|
|
123
|
+
"""Partially update a catalog
|
|
124
|
+
|
|
125
|
+
Args:
|
|
126
|
+
catalog_id: ID of the catalog.
|
|
127
|
+
partial: A dict of fields to update.
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
The Catalog object.
|
|
131
|
+
"""
|
|
132
|
+
resp = await self._http.patch(f"/catalogs/{catalog_id}", json=partial)
|
|
133
|
+
return Catalog(**resp.json())
|
|
134
|
+
|
|
135
|
+
async def delete_assignment(
|
|
136
|
+
self,
|
|
137
|
+
catalog_id: str,
|
|
138
|
+
*,
|
|
139
|
+
buyer_id: Optional[str] = None,
|
|
140
|
+
buyer_group_id: Optional[str] = None,
|
|
141
|
+
) -> None:
|
|
142
|
+
"""Delete a catalog assignment
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
catalog_id: ID of the catalog.
|
|
146
|
+
buyer_id: ID of the buyer.
|
|
147
|
+
buyer_group_id: ID of the buyer group.
|
|
148
|
+
"""
|
|
149
|
+
_params: dict[str, Any] = {}
|
|
150
|
+
if buyer_id is not None:
|
|
151
|
+
_params["buyerID"] = buyer_id
|
|
152
|
+
if buyer_group_id is not None:
|
|
153
|
+
_params["buyerGroupID"] = buyer_group_id
|
|
154
|
+
await self._http.delete(f"/catalogs/{catalog_id}/assignments", **_params)
|
|
155
|
+
|
|
156
|
+
async def delete_bundle_assignment(
|
|
157
|
+
self,
|
|
158
|
+
catalog_id: str,
|
|
159
|
+
bundle_id: str,
|
|
160
|
+
) -> None:
|
|
161
|
+
"""Delete a catalog bundle assignment
|
|
162
|
+
|
|
163
|
+
Args:
|
|
164
|
+
catalog_id: ID of the catalog.
|
|
165
|
+
bundle_id: ID of the bundle.
|
|
166
|
+
"""
|
|
167
|
+
await self._http.delete(f"/catalogs/{catalog_id}/bundleassignments/{bundle_id}")
|
|
168
|
+
|
|
169
|
+
async def delete_product_assignment(
|
|
170
|
+
self,
|
|
171
|
+
catalog_id: str,
|
|
172
|
+
product_id: str,
|
|
173
|
+
) -> None:
|
|
174
|
+
"""Delete a catalog product assignment
|
|
175
|
+
|
|
176
|
+
Args:
|
|
177
|
+
catalog_id: ID of the catalog.
|
|
178
|
+
product_id: ID of the product.
|
|
179
|
+
"""
|
|
180
|
+
await self._http.delete(f"/catalogs/{catalog_id}/productassignments/{product_id}")
|
|
181
|
+
|
|
182
|
+
async def list_assignments(
|
|
183
|
+
self,
|
|
184
|
+
*,
|
|
185
|
+
catalog_id: Optional[str] = None,
|
|
186
|
+
buyer_id: Optional[str] = None,
|
|
187
|
+
buyer_group_id: Optional[str] = None,
|
|
188
|
+
page: Optional[int] = None,
|
|
189
|
+
page_size: Optional[int] = None,
|
|
190
|
+
) -> ListPage[CatalogAssignment]:
|
|
191
|
+
"""List catalog assignments
|
|
192
|
+
|
|
193
|
+
Args:
|
|
194
|
+
catalog_id: ID of the catalog.
|
|
195
|
+
buyer_id: ID of the buyer.
|
|
196
|
+
buyer_group_id: ID of the buyer group.
|
|
197
|
+
page: Page of results to return. When paginating through many items (> page 30), we recommend the "Last ID" method, as outlined in the Advanced Querying documentation.
|
|
198
|
+
page_size: Number of results to return per page.
|
|
199
|
+
|
|
200
|
+
Returns:
|
|
201
|
+
A paginated list of CatalogAssignment objects.
|
|
202
|
+
"""
|
|
203
|
+
params = self._build_list_params(
|
|
204
|
+
page=page,
|
|
205
|
+
page_size=page_size,
|
|
206
|
+
)
|
|
207
|
+
if catalog_id is not None:
|
|
208
|
+
params["catalogID"] = catalog_id
|
|
209
|
+
if buyer_id is not None:
|
|
210
|
+
params["buyerID"] = buyer_id
|
|
211
|
+
if buyer_group_id is not None:
|
|
212
|
+
params["buyerGroupID"] = buyer_group_id
|
|
213
|
+
resp = await self._http.get("/catalogs/assignments", **params)
|
|
214
|
+
return self._parse_list(resp.json(), CatalogAssignment)
|
|
215
|
+
|
|
216
|
+
async def save_assignment(
|
|
217
|
+
self,
|
|
218
|
+
catalog_assignment: Union[CatalogAssignment, dict[str, Any]],
|
|
219
|
+
) -> None:
|
|
220
|
+
"""Create or update a catalog assignment
|
|
221
|
+
|
|
222
|
+
Args:
|
|
223
|
+
catalog_assignment: A ``CatalogAssignment`` model or dict. Required fields: CatalogID.
|
|
224
|
+
"""
|
|
225
|
+
await self._http.post("/catalogs/assignments", json=self._serialize(catalog_assignment))
|
|
226
|
+
|
|
227
|
+
async def list_bundle_assignments(
|
|
228
|
+
self,
|
|
229
|
+
*,
|
|
230
|
+
catalog_id: Optional[str] = None,
|
|
231
|
+
bundle_id: Optional[str] = None,
|
|
232
|
+
page: Optional[int] = None,
|
|
233
|
+
page_size: Optional[int] = None,
|
|
234
|
+
) -> ListPage[BundleCatalogAssignment]:
|
|
235
|
+
"""List catalog bundle assignments
|
|
236
|
+
|
|
237
|
+
Args:
|
|
238
|
+
catalog_id: ID of the catalog.
|
|
239
|
+
bundle_id: ID of the bundle.
|
|
240
|
+
page: Page of results to return. When paginating through many items (> page 30), we recommend the "Last ID" method, as outlined in the Advanced Querying documentation.
|
|
241
|
+
page_size: Number of results to return per page.
|
|
242
|
+
|
|
243
|
+
Returns:
|
|
244
|
+
A paginated list of BundleCatalogAssignment objects.
|
|
245
|
+
"""
|
|
246
|
+
params = self._build_list_params(
|
|
247
|
+
page=page,
|
|
248
|
+
page_size=page_size,
|
|
249
|
+
)
|
|
250
|
+
if catalog_id is not None:
|
|
251
|
+
params["catalogID"] = catalog_id
|
|
252
|
+
if bundle_id is not None:
|
|
253
|
+
params["bundleID"] = bundle_id
|
|
254
|
+
resp = await self._http.get("/catalogs/bundleassignments", **params)
|
|
255
|
+
return self._parse_list(resp.json(), BundleCatalogAssignment)
|
|
256
|
+
|
|
257
|
+
async def save_bundle_assignment(
|
|
258
|
+
self,
|
|
259
|
+
bundle_catalog_assignment: Union[BundleCatalogAssignment, dict[str, Any]],
|
|
260
|
+
) -> None:
|
|
261
|
+
"""Create or update a catalog bundle assignment
|
|
262
|
+
|
|
263
|
+
Args:
|
|
264
|
+
bundle_catalog_assignment: A ``BundleCatalogAssignment`` model or dict. Required fields: CatalogID, BundleID.
|
|
265
|
+
"""
|
|
266
|
+
await self._http.post(
|
|
267
|
+
"/catalogs/bundleassignments", json=self._serialize(bundle_catalog_assignment)
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
async def list_product_assignments(
|
|
271
|
+
self,
|
|
272
|
+
*,
|
|
273
|
+
catalog_id: Optional[str] = None,
|
|
274
|
+
product_id: Optional[str] = None,
|
|
275
|
+
page: Optional[int] = None,
|
|
276
|
+
page_size: Optional[int] = None,
|
|
277
|
+
) -> ListPage[ProductCatalogAssignment]:
|
|
278
|
+
"""List catalog product assignments
|
|
279
|
+
|
|
280
|
+
Args:
|
|
281
|
+
catalog_id: ID of the catalog.
|
|
282
|
+
product_id: ID of the product.
|
|
283
|
+
page: Page of results to return. When paginating through many items (> page 30), we recommend the "Last ID" method, as outlined in the Advanced Querying documentation.
|
|
284
|
+
page_size: Number of results to return per page.
|
|
285
|
+
|
|
286
|
+
Returns:
|
|
287
|
+
A paginated list of ProductCatalogAssignment objects.
|
|
288
|
+
"""
|
|
289
|
+
params = self._build_list_params(
|
|
290
|
+
page=page,
|
|
291
|
+
page_size=page_size,
|
|
292
|
+
)
|
|
293
|
+
if catalog_id is not None:
|
|
294
|
+
params["catalogID"] = catalog_id
|
|
295
|
+
if product_id is not None:
|
|
296
|
+
params["productID"] = product_id
|
|
297
|
+
resp = await self._http.get("/catalogs/productassignments", **params)
|
|
298
|
+
return self._parse_list(resp.json(), ProductCatalogAssignment)
|
|
299
|
+
|
|
300
|
+
async def save_product_assignment(
|
|
301
|
+
self,
|
|
302
|
+
product_catalog_assignment: Union[ProductCatalogAssignment, dict[str, Any]],
|
|
303
|
+
) -> None:
|
|
304
|
+
"""Create or update a catalog product assignment
|
|
305
|
+
|
|
306
|
+
Args:
|
|
307
|
+
product_catalog_assignment: A ``ProductCatalogAssignment`` model or dict. Required fields: CatalogID, ProductID.
|
|
308
|
+
"""
|
|
309
|
+
await self._http.post(
|
|
310
|
+
"/catalogs/productassignments", json=self._serialize(product_catalog_assignment)
|
|
311
|
+
)
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
# GENERATED by tools/codegen — DO NOT EDIT
|
|
2
|
+
# Source: ordercloud-openapi-v3.json
|
|
3
|
+
"""OrderCloud Categories API resource."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
from typing import Any, Optional, Union
|
|
7
|
+
|
|
8
|
+
from ..models.assignments import (
|
|
9
|
+
CategoryAssignment,
|
|
10
|
+
CategoryBundleAssignment,
|
|
11
|
+
CategoryProductAssignment,
|
|
12
|
+
)
|
|
13
|
+
from ..models.category import Category
|
|
14
|
+
from ..models.shared import ListPage
|
|
15
|
+
from .base import BaseResource
|
|
16
|
+
|
|
17
|
+
__all__ = ["CategoriesResource"]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class CategoriesResource(BaseResource):
|
|
21
|
+
"""Operations on OrderCloud Categories."""
|
|
22
|
+
|
|
23
|
+
async def list(
|
|
24
|
+
self,
|
|
25
|
+
catalog_id: str,
|
|
26
|
+
*,
|
|
27
|
+
depth: Optional[str] = None,
|
|
28
|
+
search: Optional[str] = None,
|
|
29
|
+
search_on: Optional[str] = None,
|
|
30
|
+
sort_by: Optional[str] = None,
|
|
31
|
+
page: Optional[int] = None,
|
|
32
|
+
page_size: Optional[int] = None,
|
|
33
|
+
filters: Optional[dict[str, Any]] = None,
|
|
34
|
+
) -> ListPage[Category]:
|
|
35
|
+
"""List categories
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
catalog_id: ID of the catalog.
|
|
39
|
+
depth: Depth of the category.
|
|
40
|
+
search: Word or phrase to search for.
|
|
41
|
+
search_on: Comma-delimited list of fields to search on.
|
|
42
|
+
sort_by: Comma-delimited list of fields to sort by.
|
|
43
|
+
page: Page of results to return. When paginating through many items (> page 30), we recommend the "Last ID" method, as outlined in the Advanced Querying documentation.
|
|
44
|
+
page_size: Number of results to return per page.
|
|
45
|
+
filters: An object or dictionary representing key/value pairs to apply as filters. Valid keys are top-level properties of the returned model or 'xp.???'
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
A paginated list of Category objects.
|
|
49
|
+
"""
|
|
50
|
+
params = self._build_list_params(
|
|
51
|
+
depth=depth,
|
|
52
|
+
search=search,
|
|
53
|
+
search_on=search_on,
|
|
54
|
+
sort_by=sort_by,
|
|
55
|
+
page=page,
|
|
56
|
+
page_size=page_size,
|
|
57
|
+
filters=filters,
|
|
58
|
+
)
|
|
59
|
+
resp = await self._http.get(f"/catalogs/{catalog_id}/categories", **params)
|
|
60
|
+
return self._parse_list(resp.json(), Category)
|
|
61
|
+
|
|
62
|
+
async def create(
|
|
63
|
+
self,
|
|
64
|
+
catalog_id: str,
|
|
65
|
+
category: Union[Category, dict[str, Any]],
|
|
66
|
+
*,
|
|
67
|
+
adjust_list_orders: Optional[bool] = None,
|
|
68
|
+
) -> Category:
|
|
69
|
+
"""Create a category
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
catalog_id: ID of the catalog.
|
|
73
|
+
category: A ``Category`` model or dict. Required fields: Name.
|
|
74
|
+
adjust_list_orders: Adjust list orders of the category.
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
The Category object.
|
|
78
|
+
"""
|
|
79
|
+
_params: dict[str, Any] = {}
|
|
80
|
+
if adjust_list_orders is not None:
|
|
81
|
+
_params["adjustListOrders"] = adjust_list_orders
|
|
82
|
+
resp = await self._http.post(
|
|
83
|
+
f"/catalogs/{catalog_id}/categories",
|
|
84
|
+
json=self._serialize(category),
|
|
85
|
+
params=_params or None,
|
|
86
|
+
)
|
|
87
|
+
return Category(**resp.json())
|
|
88
|
+
|
|
89
|
+
async def get(
|
|
90
|
+
self,
|
|
91
|
+
catalog_id: str,
|
|
92
|
+
category_id: str,
|
|
93
|
+
) -> Category:
|
|
94
|
+
"""Retrieve a category
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
catalog_id: ID of the catalog.
|
|
98
|
+
category_id: ID of the category.
|
|
99
|
+
|
|
100
|
+
Returns:
|
|
101
|
+
The Category object.
|
|
102
|
+
"""
|
|
103
|
+
resp = await self._http.get(f"/catalogs/{catalog_id}/categories/{category_id}")
|
|
104
|
+
return Category(**resp.json())
|
|
105
|
+
|
|
106
|
+
async def save(
|
|
107
|
+
self,
|
|
108
|
+
catalog_id: str,
|
|
109
|
+
category_id: str,
|
|
110
|
+
category: Union[Category, dict[str, Any]],
|
|
111
|
+
*,
|
|
112
|
+
adjust_list_orders: Optional[bool] = None,
|
|
113
|
+
) -> Category:
|
|
114
|
+
"""Create or update a category
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
catalog_id: ID of the catalog.
|
|
118
|
+
category_id: ID of the category.
|
|
119
|
+
category: A ``Category`` model or dict. Required fields: Name.
|
|
120
|
+
adjust_list_orders: Adjust list orders of the category.
|
|
121
|
+
|
|
122
|
+
Returns:
|
|
123
|
+
The Category object.
|
|
124
|
+
"""
|
|
125
|
+
_params: dict[str, Any] = {}
|
|
126
|
+
if adjust_list_orders is not None:
|
|
127
|
+
_params["adjustListOrders"] = adjust_list_orders
|
|
128
|
+
resp = await self._http.put(
|
|
129
|
+
f"/catalogs/{catalog_id}/categories/{category_id}",
|
|
130
|
+
json=self._serialize(category),
|
|
131
|
+
params=_params or None,
|
|
132
|
+
)
|
|
133
|
+
return Category(**resp.json())
|
|
134
|
+
|
|
135
|
+
async def delete(
|
|
136
|
+
self,
|
|
137
|
+
catalog_id: str,
|
|
138
|
+
category_id: str,
|
|
139
|
+
) -> None:
|
|
140
|
+
"""Delete a category
|
|
141
|
+
|
|
142
|
+
Args:
|
|
143
|
+
catalog_id: ID of the catalog.
|
|
144
|
+
category_id: ID of the category.
|
|
145
|
+
"""
|
|
146
|
+
await self._http.delete(f"/catalogs/{catalog_id}/categories/{category_id}")
|
|
147
|
+
|
|
148
|
+
async def patch(
|
|
149
|
+
self,
|
|
150
|
+
catalog_id: str,
|
|
151
|
+
category_id: str,
|
|
152
|
+
partial: dict[str, Any],
|
|
153
|
+
*,
|
|
154
|
+
adjust_list_orders: Optional[bool] = None,
|
|
155
|
+
) -> Category:
|
|
156
|
+
"""Partially update a category
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
catalog_id: ID of the catalog.
|
|
160
|
+
category_id: ID of the category.
|
|
161
|
+
partial: A dict of fields to update.
|
|
162
|
+
adjust_list_orders: Adjust list orders of the partial 1.
|
|
163
|
+
|
|
164
|
+
Returns:
|
|
165
|
+
The Category object.
|
|
166
|
+
"""
|
|
167
|
+
_params: dict[str, Any] = {}
|
|
168
|
+
if adjust_list_orders is not None:
|
|
169
|
+
_params["adjustListOrders"] = adjust_list_orders
|
|
170
|
+
resp = await self._http.patch(
|
|
171
|
+
f"/catalogs/{catalog_id}/categories/{category_id}", json=partial, params=_params or None
|
|
172
|
+
)
|
|
173
|
+
return Category(**resp.json())
|
|
174
|
+
|
|
175
|
+
async def delete_assignment(
|
|
176
|
+
self,
|
|
177
|
+
catalog_id: str,
|
|
178
|
+
category_id: str,
|
|
179
|
+
*,
|
|
180
|
+
buyer_id: Optional[str],
|
|
181
|
+
user_id: Optional[str] = None,
|
|
182
|
+
user_group_id: Optional[str] = None,
|
|
183
|
+
) -> None:
|
|
184
|
+
"""Delete a category assignment
|
|
185
|
+
|
|
186
|
+
Args:
|
|
187
|
+
catalog_id: ID of the catalog.
|
|
188
|
+
category_id: ID of the category.
|
|
189
|
+
buyer_id: ID of the buyer.
|
|
190
|
+
user_id: ID of the user.
|
|
191
|
+
user_group_id: ID of the user group.
|
|
192
|
+
"""
|
|
193
|
+
_params: dict[str, Any] = {}
|
|
194
|
+
if buyer_id is not None:
|
|
195
|
+
_params["buyerID"] = buyer_id
|
|
196
|
+
if user_id is not None:
|
|
197
|
+
_params["userID"] = user_id
|
|
198
|
+
if user_group_id is not None:
|
|
199
|
+
_params["userGroupID"] = user_group_id
|
|
200
|
+
await self._http.delete(
|
|
201
|
+
f"/catalogs/{catalog_id}/categories/{category_id}/assignments", **_params
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
async def delete_bundle_assignment(
|
|
205
|
+
self,
|
|
206
|
+
catalog_id: str,
|
|
207
|
+
category_id: str,
|
|
208
|
+
bundle_id: str,
|
|
209
|
+
) -> None:
|
|
210
|
+
"""Delete a category bundle assignment
|
|
211
|
+
|
|
212
|
+
Args:
|
|
213
|
+
catalog_id: ID of the catalog.
|
|
214
|
+
category_id: ID of the category.
|
|
215
|
+
bundle_id: ID of the bundle.
|
|
216
|
+
"""
|
|
217
|
+
await self._http.delete(
|
|
218
|
+
f"/catalogs/{catalog_id}/categories/{category_id}/bundleassignments/{bundle_id}"
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
async def delete_product_assignment(
|
|
222
|
+
self,
|
|
223
|
+
catalog_id: str,
|
|
224
|
+
category_id: str,
|
|
225
|
+
product_id: str,
|
|
226
|
+
) -> None:
|
|
227
|
+
"""Delete a category product assignment
|
|
228
|
+
|
|
229
|
+
Args:
|
|
230
|
+
catalog_id: ID of the catalog.
|
|
231
|
+
category_id: ID of the category.
|
|
232
|
+
product_id: ID of the product.
|
|
233
|
+
"""
|
|
234
|
+
await self._http.delete(
|
|
235
|
+
f"/catalogs/{catalog_id}/categories/{category_id}/productassignments/{product_id}"
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
async def list_assignments(
|
|
239
|
+
self,
|
|
240
|
+
catalog_id: str,
|
|
241
|
+
*,
|
|
242
|
+
category_id: Optional[str] = None,
|
|
243
|
+
buyer_id: Optional[str] = None,
|
|
244
|
+
user_group_id: Optional[str] = None,
|
|
245
|
+
level: Optional[str] = None,
|
|
246
|
+
page: Optional[int] = None,
|
|
247
|
+
page_size: Optional[int] = None,
|
|
248
|
+
) -> ListPage[CategoryAssignment]:
|
|
249
|
+
"""List category assignments
|
|
250
|
+
|
|
251
|
+
Args:
|
|
252
|
+
catalog_id: ID of the catalog.
|
|
253
|
+
category_id: ID of the category.
|
|
254
|
+
buyer_id: ID of the buyer.
|
|
255
|
+
user_group_id: ID of the user group.
|
|
256
|
+
level: Level of the category assignment. Possible values: Group, Company, BuyerGroup.
|
|
257
|
+
page: Page of results to return. When paginating through many items (> page 30), we recommend the "Last ID" method, as outlined in the Advanced Querying documentation.
|
|
258
|
+
page_size: Number of results to return per page.
|
|
259
|
+
|
|
260
|
+
Returns:
|
|
261
|
+
A paginated list of CategoryAssignment objects.
|
|
262
|
+
"""
|
|
263
|
+
params = self._build_list_params(
|
|
264
|
+
page=page,
|
|
265
|
+
page_size=page_size,
|
|
266
|
+
)
|
|
267
|
+
if category_id is not None:
|
|
268
|
+
params["categoryID"] = category_id
|
|
269
|
+
if buyer_id is not None:
|
|
270
|
+
params["buyerID"] = buyer_id
|
|
271
|
+
if user_group_id is not None:
|
|
272
|
+
params["userGroupID"] = user_group_id
|
|
273
|
+
if level is not None:
|
|
274
|
+
params["level"] = level
|
|
275
|
+
resp = await self._http.get(f"/catalogs/{catalog_id}/categories/assignments", **params)
|
|
276
|
+
return self._parse_list(resp.json(), CategoryAssignment)
|
|
277
|
+
|
|
278
|
+
async def save_assignment(
|
|
279
|
+
self,
|
|
280
|
+
catalog_id: str,
|
|
281
|
+
category_assignment: Union[CategoryAssignment, dict[str, Any]],
|
|
282
|
+
) -> None:
|
|
283
|
+
"""Create or update a category assignment
|
|
284
|
+
|
|
285
|
+
Args:
|
|
286
|
+
catalog_id: ID of the catalog.
|
|
287
|
+
category_assignment: A ``CategoryAssignment`` model or dict. Required fields: CategoryID, BuyerID.
|
|
288
|
+
"""
|
|
289
|
+
await self._http.post(
|
|
290
|
+
f"/catalogs/{catalog_id}/categories/assignments",
|
|
291
|
+
json=self._serialize(category_assignment),
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
async def list_bundle_assignments(
|
|
295
|
+
self,
|
|
296
|
+
catalog_id: str,
|
|
297
|
+
*,
|
|
298
|
+
category_id: Optional[str] = None,
|
|
299
|
+
bundle_id: Optional[str] = None,
|
|
300
|
+
page: Optional[int] = None,
|
|
301
|
+
page_size: Optional[int] = None,
|
|
302
|
+
) -> ListPage[CategoryBundleAssignment]:
|
|
303
|
+
"""List category bundle assignments
|
|
304
|
+
|
|
305
|
+
Args:
|
|
306
|
+
catalog_id: ID of the catalog.
|
|
307
|
+
category_id: ID of the category.
|
|
308
|
+
bundle_id: ID of the bundle.
|
|
309
|
+
page: Page of results to return. When paginating through many items (> page 30), we recommend the "Last ID" method, as outlined in the Advanced Querying documentation.
|
|
310
|
+
page_size: Number of results to return per page.
|
|
311
|
+
|
|
312
|
+
Returns:
|
|
313
|
+
A paginated list of CategoryBundleAssignment objects.
|
|
314
|
+
"""
|
|
315
|
+
params = self._build_list_params(
|
|
316
|
+
page=page,
|
|
317
|
+
page_size=page_size,
|
|
318
|
+
)
|
|
319
|
+
if category_id is not None:
|
|
320
|
+
params["categoryID"] = category_id
|
|
321
|
+
if bundle_id is not None:
|
|
322
|
+
params["bundleID"] = bundle_id
|
|
323
|
+
resp = await self._http.get(
|
|
324
|
+
f"/catalogs/{catalog_id}/categories/bundleassignments", **params
|
|
325
|
+
)
|
|
326
|
+
return self._parse_list(resp.json(), CategoryBundleAssignment)
|
|
327
|
+
|
|
328
|
+
async def save_bundle_assignment(
|
|
329
|
+
self,
|
|
330
|
+
catalog_id: str,
|
|
331
|
+
category_bundle_assignment: Union[CategoryBundleAssignment, dict[str, Any]],
|
|
332
|
+
) -> None:
|
|
333
|
+
"""Create or update a category bundle assignment
|
|
334
|
+
|
|
335
|
+
Args:
|
|
336
|
+
catalog_id: ID of the catalog.
|
|
337
|
+
category_bundle_assignment: A ``CategoryBundleAssignment`` model or dict. Required fields: CategoryID, BundleID.
|
|
338
|
+
"""
|
|
339
|
+
await self._http.post(
|
|
340
|
+
f"/catalogs/{catalog_id}/categories/bundleassignments",
|
|
341
|
+
json=self._serialize(category_bundle_assignment),
|
|
342
|
+
)
|
|
343
|
+
|
|
344
|
+
async def list_product_assignments(
|
|
345
|
+
self,
|
|
346
|
+
catalog_id: str,
|
|
347
|
+
*,
|
|
348
|
+
category_id: Optional[str] = None,
|
|
349
|
+
product_id: Optional[str] = None,
|
|
350
|
+
page: Optional[int] = None,
|
|
351
|
+
page_size: Optional[int] = None,
|
|
352
|
+
) -> ListPage[CategoryProductAssignment]:
|
|
353
|
+
"""List category product assignments
|
|
354
|
+
|
|
355
|
+
Args:
|
|
356
|
+
catalog_id: ID of the catalog.
|
|
357
|
+
category_id: ID of the category.
|
|
358
|
+
product_id: ID of the product.
|
|
359
|
+
page: Page of results to return. When paginating through many items (> page 30), we recommend the "Last ID" method, as outlined in the Advanced Querying documentation.
|
|
360
|
+
page_size: Number of results to return per page.
|
|
361
|
+
|
|
362
|
+
Returns:
|
|
363
|
+
A paginated list of CategoryProductAssignment objects.
|
|
364
|
+
"""
|
|
365
|
+
params = self._build_list_params(
|
|
366
|
+
page=page,
|
|
367
|
+
page_size=page_size,
|
|
368
|
+
)
|
|
369
|
+
if category_id is not None:
|
|
370
|
+
params["categoryID"] = category_id
|
|
371
|
+
if product_id is not None:
|
|
372
|
+
params["productID"] = product_id
|
|
373
|
+
resp = await self._http.get(
|
|
374
|
+
f"/catalogs/{catalog_id}/categories/productassignments", **params
|
|
375
|
+
)
|
|
376
|
+
return self._parse_list(resp.json(), CategoryProductAssignment)
|
|
377
|
+
|
|
378
|
+
async def save_product_assignment(
|
|
379
|
+
self,
|
|
380
|
+
catalog_id: str,
|
|
381
|
+
category_product_assignment: Union[CategoryProductAssignment, dict[str, Any]],
|
|
382
|
+
) -> None:
|
|
383
|
+
"""Create or update a category product assignment
|
|
384
|
+
|
|
385
|
+
Args:
|
|
386
|
+
catalog_id: ID of the catalog.
|
|
387
|
+
category_product_assignment: A ``CategoryProductAssignment`` model or dict. Required fields: CategoryID, ProductID.
|
|
388
|
+
"""
|
|
389
|
+
await self._http.post(
|
|
390
|
+
f"/catalogs/{catalog_id}/categories/productassignments",
|
|
391
|
+
json=self._serialize(category_product_assignment),
|
|
392
|
+
)
|