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,262 @@
|
|
|
1
|
+
# GENERATED by tools/codegen — DO NOT EDIT
|
|
2
|
+
# Source: ordercloud-openapi-v3.json
|
|
3
|
+
"""OrderCloud LineItems API resource."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
from typing import Any, Optional, Union
|
|
7
|
+
|
|
8
|
+
from ..models.address import Address
|
|
9
|
+
from ..models.line_item import LineItem
|
|
10
|
+
from ..models.misc import OrderDirection, SearchType
|
|
11
|
+
from ..models.order import ExtendedLineItem
|
|
12
|
+
from ..models.shared import ListPage
|
|
13
|
+
from .base import BaseResource
|
|
14
|
+
|
|
15
|
+
__all__ = ["LineItemsResource"]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class LineItemsResource(BaseResource):
|
|
19
|
+
"""Operations on OrderCloud LineItems."""
|
|
20
|
+
|
|
21
|
+
async def list_across_orders(
|
|
22
|
+
self,
|
|
23
|
+
direction: OrderDirection,
|
|
24
|
+
*,
|
|
25
|
+
buyer_id: Optional[str] = None,
|
|
26
|
+
supplier_id: Optional[str] = None,
|
|
27
|
+
from_: Optional[str] = None,
|
|
28
|
+
to: Optional[str] = None,
|
|
29
|
+
search: Optional[str] = None,
|
|
30
|
+
search_on: Optional[str] = None,
|
|
31
|
+
search_type: Optional[SearchType] = None,
|
|
32
|
+
sort_by: Optional[str] = None,
|
|
33
|
+
page: Optional[int] = None,
|
|
34
|
+
page_size: Optional[int] = None,
|
|
35
|
+
filters: Optional[dict[str, Any]] = None,
|
|
36
|
+
) -> ListPage[ExtendedLineItem]:
|
|
37
|
+
"""List line item across orders
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
direction: Direction of the order, from the current user's perspective.
|
|
41
|
+
buyer_id: ID of the buyer.
|
|
42
|
+
supplier_id: ID of the supplier.
|
|
43
|
+
from_: Lower bound of date range that the order was created.
|
|
44
|
+
to: Upper bound of date range that the order was created.
|
|
45
|
+
search: Word or phrase to search for.
|
|
46
|
+
search_on: Comma-delimited list of fields to search on.
|
|
47
|
+
search_type: Type of search to perform.
|
|
48
|
+
sort_by: Comma-delimited list of fields to sort by.
|
|
49
|
+
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.
|
|
50
|
+
page_size: Number of results to return per page.
|
|
51
|
+
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.???'
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
A paginated list of ExtendedLineItem objects.
|
|
55
|
+
"""
|
|
56
|
+
params = self._build_list_params(
|
|
57
|
+
search=search,
|
|
58
|
+
search_on=search_on,
|
|
59
|
+
sort_by=sort_by,
|
|
60
|
+
page=page,
|
|
61
|
+
page_size=page_size,
|
|
62
|
+
filters=filters,
|
|
63
|
+
)
|
|
64
|
+
if buyer_id is not None:
|
|
65
|
+
params["buyerID"] = buyer_id
|
|
66
|
+
if supplier_id is not None:
|
|
67
|
+
params["supplierID"] = supplier_id
|
|
68
|
+
if from_ is not None:
|
|
69
|
+
params["from"] = from_
|
|
70
|
+
if to is not None:
|
|
71
|
+
params["to"] = to
|
|
72
|
+
if search_type is not None:
|
|
73
|
+
params["searchType"] = search_type
|
|
74
|
+
resp = await self._http.get(f"/lineitems/{direction}", **params)
|
|
75
|
+
return self._parse_list(resp.json(), ExtendedLineItem)
|
|
76
|
+
|
|
77
|
+
async def list(
|
|
78
|
+
self,
|
|
79
|
+
direction: OrderDirection,
|
|
80
|
+
order_id: str,
|
|
81
|
+
*,
|
|
82
|
+
search: Optional[str] = None,
|
|
83
|
+
search_on: Optional[str] = None,
|
|
84
|
+
sort_by: Optional[str] = None,
|
|
85
|
+
page: Optional[int] = None,
|
|
86
|
+
page_size: Optional[int] = None,
|
|
87
|
+
filters: Optional[dict[str, Any]] = None,
|
|
88
|
+
) -> ListPage[LineItem]:
|
|
89
|
+
"""List line items
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
direction: Direction of the order, from the current user's perspective.
|
|
93
|
+
order_id: ID of the order.
|
|
94
|
+
search: Word or phrase to search for.
|
|
95
|
+
search_on: Comma-delimited list of fields to search on.
|
|
96
|
+
sort_by: Comma-delimited list of fields to sort by.
|
|
97
|
+
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.
|
|
98
|
+
page_size: Number of results to return per page.
|
|
99
|
+
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.???'
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
A paginated list of LineItem objects.
|
|
103
|
+
"""
|
|
104
|
+
params = self._build_list_params(
|
|
105
|
+
search=search,
|
|
106
|
+
search_on=search_on,
|
|
107
|
+
sort_by=sort_by,
|
|
108
|
+
page=page,
|
|
109
|
+
page_size=page_size,
|
|
110
|
+
filters=filters,
|
|
111
|
+
)
|
|
112
|
+
resp = await self._http.get(f"/orders/{direction}/{order_id}/lineitems", **params)
|
|
113
|
+
return self._parse_list(resp.json(), LineItem)
|
|
114
|
+
|
|
115
|
+
async def create(
|
|
116
|
+
self,
|
|
117
|
+
direction: OrderDirection,
|
|
118
|
+
order_id: str,
|
|
119
|
+
line_item: Union[LineItem, dict[str, Any]],
|
|
120
|
+
) -> LineItem:
|
|
121
|
+
"""Create a line item
|
|
122
|
+
|
|
123
|
+
Args:
|
|
124
|
+
direction: Direction of the order, from the current user's perspective.
|
|
125
|
+
order_id: ID of the order.
|
|
126
|
+
line_item: A ``LineItem`` model or dict. Required fields: ProductID.
|
|
127
|
+
|
|
128
|
+
Returns:
|
|
129
|
+
The LineItem object.
|
|
130
|
+
"""
|
|
131
|
+
resp = await self._http.post(
|
|
132
|
+
f"/orders/{direction}/{order_id}/lineitems", json=self._serialize(line_item)
|
|
133
|
+
)
|
|
134
|
+
return LineItem(**resp.json())
|
|
135
|
+
|
|
136
|
+
async def get(
|
|
137
|
+
self,
|
|
138
|
+
direction: OrderDirection,
|
|
139
|
+
order_id: str,
|
|
140
|
+
line_item_id: str,
|
|
141
|
+
) -> LineItem:
|
|
142
|
+
"""Retrieve a line item
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
direction: Direction of the order, from the current user's perspective.
|
|
146
|
+
order_id: ID of the order.
|
|
147
|
+
line_item_id: ID of the line item.
|
|
148
|
+
|
|
149
|
+
Returns:
|
|
150
|
+
The LineItem object.
|
|
151
|
+
"""
|
|
152
|
+
resp = await self._http.get(f"/orders/{direction}/{order_id}/lineitems/{line_item_id}")
|
|
153
|
+
return LineItem(**resp.json())
|
|
154
|
+
|
|
155
|
+
async def save(
|
|
156
|
+
self,
|
|
157
|
+
direction: OrderDirection,
|
|
158
|
+
order_id: str,
|
|
159
|
+
line_item_id: str,
|
|
160
|
+
line_item: Union[LineItem, dict[str, Any]],
|
|
161
|
+
) -> LineItem:
|
|
162
|
+
"""Create or update a line item
|
|
163
|
+
|
|
164
|
+
Args:
|
|
165
|
+
direction: Direction of the order, from the current user's perspective.
|
|
166
|
+
order_id: ID of the order.
|
|
167
|
+
line_item_id: ID of the line item.
|
|
168
|
+
line_item: A ``LineItem`` model or dict. Required fields: ProductID.
|
|
169
|
+
|
|
170
|
+
Returns:
|
|
171
|
+
The LineItem object.
|
|
172
|
+
"""
|
|
173
|
+
resp = await self._http.put(
|
|
174
|
+
f"/orders/{direction}/{order_id}/lineitems/{line_item_id}",
|
|
175
|
+
json=self._serialize(line_item),
|
|
176
|
+
)
|
|
177
|
+
return LineItem(**resp.json())
|
|
178
|
+
|
|
179
|
+
async def delete(
|
|
180
|
+
self,
|
|
181
|
+
direction: OrderDirection,
|
|
182
|
+
order_id: str,
|
|
183
|
+
line_item_id: str,
|
|
184
|
+
) -> None:
|
|
185
|
+
"""Delete a line item
|
|
186
|
+
|
|
187
|
+
Args:
|
|
188
|
+
direction: Direction of the order, from the current user's perspective.
|
|
189
|
+
order_id: ID of the order.
|
|
190
|
+
line_item_id: ID of the line item.
|
|
191
|
+
"""
|
|
192
|
+
await self._http.delete(f"/orders/{direction}/{order_id}/lineitems/{line_item_id}")
|
|
193
|
+
|
|
194
|
+
async def patch(
|
|
195
|
+
self,
|
|
196
|
+
direction: OrderDirection,
|
|
197
|
+
order_id: str,
|
|
198
|
+
line_item_id: str,
|
|
199
|
+
partial: dict[str, Any],
|
|
200
|
+
) -> LineItem:
|
|
201
|
+
"""Partially update a line item
|
|
202
|
+
|
|
203
|
+
Args:
|
|
204
|
+
direction: Direction of the order, from the current user's perspective.
|
|
205
|
+
order_id: ID of the order.
|
|
206
|
+
line_item_id: ID of the line item.
|
|
207
|
+
partial: A dict of fields to update.
|
|
208
|
+
|
|
209
|
+
Returns:
|
|
210
|
+
The LineItem object.
|
|
211
|
+
"""
|
|
212
|
+
resp = await self._http.patch(
|
|
213
|
+
f"/orders/{direction}/{order_id}/lineitems/{line_item_id}", json=partial
|
|
214
|
+
)
|
|
215
|
+
return LineItem(**resp.json())
|
|
216
|
+
|
|
217
|
+
async def set_shipping_address(
|
|
218
|
+
self,
|
|
219
|
+
direction: OrderDirection,
|
|
220
|
+
order_id: str,
|
|
221
|
+
line_item_id: str,
|
|
222
|
+
address: Union[Address, dict[str, Any]],
|
|
223
|
+
) -> LineItem:
|
|
224
|
+
"""Set a shipping address
|
|
225
|
+
|
|
226
|
+
Args:
|
|
227
|
+
direction: Direction of the order, from the current user's perspective.
|
|
228
|
+
order_id: ID of the order.
|
|
229
|
+
line_item_id: ID of the line item.
|
|
230
|
+
address: A ``Address`` model or dict. Required fields: Street1, City, Country.
|
|
231
|
+
|
|
232
|
+
Returns:
|
|
233
|
+
The LineItem object.
|
|
234
|
+
"""
|
|
235
|
+
resp = await self._http.put(
|
|
236
|
+
f"/orders/{direction}/{order_id}/lineitems/{line_item_id}/shipto",
|
|
237
|
+
json=self._serialize(address),
|
|
238
|
+
)
|
|
239
|
+
return LineItem(**resp.json())
|
|
240
|
+
|
|
241
|
+
async def patch_shipping_address(
|
|
242
|
+
self,
|
|
243
|
+
direction: OrderDirection,
|
|
244
|
+
order_id: str,
|
|
245
|
+
line_item_id: str,
|
|
246
|
+
partial: dict[str, Any],
|
|
247
|
+
) -> LineItem:
|
|
248
|
+
"""Partially update a line item shipping address
|
|
249
|
+
|
|
250
|
+
Args:
|
|
251
|
+
direction: Direction of the order, from the current user's perspective.
|
|
252
|
+
order_id: ID of the order.
|
|
253
|
+
line_item_id: ID of the line item.
|
|
254
|
+
partial: A dict of fields to update.
|
|
255
|
+
|
|
256
|
+
Returns:
|
|
257
|
+
The LineItem object.
|
|
258
|
+
"""
|
|
259
|
+
resp = await self._http.patch(
|
|
260
|
+
f"/orders/{direction}/{order_id}/lineitems/{line_item_id}/shipto", json=partial
|
|
261
|
+
)
|
|
262
|
+
return LineItem(**resp.json())
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# GENERATED by tools/codegen — DO NOT EDIT
|
|
2
|
+
# Source: ordercloud-openapi-v3.json
|
|
3
|
+
"""OrderCloud Locales API resource."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
from typing import Any, Optional, Union
|
|
7
|
+
|
|
8
|
+
from ..models.assignments import LocaleAssignment
|
|
9
|
+
from ..models.user import Locale
|
|
10
|
+
from ..models.shared import ListPage
|
|
11
|
+
from .base import BaseResource
|
|
12
|
+
|
|
13
|
+
__all__ = ["LocalesResource"]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class LocalesResource(BaseResource):
|
|
17
|
+
"""Operations on OrderCloud Locales."""
|
|
18
|
+
|
|
19
|
+
async def list(
|
|
20
|
+
self,
|
|
21
|
+
*,
|
|
22
|
+
search: Optional[str] = None,
|
|
23
|
+
search_on: Optional[str] = None,
|
|
24
|
+
sort_by: Optional[str] = None,
|
|
25
|
+
page: Optional[int] = None,
|
|
26
|
+
page_size: Optional[int] = None,
|
|
27
|
+
filters: Optional[dict[str, Any]] = None,
|
|
28
|
+
) -> ListPage[Locale]:
|
|
29
|
+
"""List locales
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
search: Word or phrase to search for.
|
|
33
|
+
search_on: Comma-delimited list of fields to search on.
|
|
34
|
+
sort_by: Comma-delimited list of fields to sort by.
|
|
35
|
+
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.
|
|
36
|
+
page_size: Number of results to return per page.
|
|
37
|
+
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.???'
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
A paginated list of Locale objects.
|
|
41
|
+
"""
|
|
42
|
+
params = self._build_list_params(
|
|
43
|
+
search=search,
|
|
44
|
+
search_on=search_on,
|
|
45
|
+
sort_by=sort_by,
|
|
46
|
+
page=page,
|
|
47
|
+
page_size=page_size,
|
|
48
|
+
filters=filters,
|
|
49
|
+
)
|
|
50
|
+
resp = await self._http.get("/locales", **params)
|
|
51
|
+
return self._parse_list(resp.json(), Locale)
|
|
52
|
+
|
|
53
|
+
async def create(
|
|
54
|
+
self,
|
|
55
|
+
locale: Union[Locale, dict[str, Any]],
|
|
56
|
+
) -> Locale:
|
|
57
|
+
"""Create a locale
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
locale: A ``Locale`` model or dict. Required fields: Currency.
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
The Locale object.
|
|
64
|
+
"""
|
|
65
|
+
resp = await self._http.post("/locales", json=self._serialize(locale))
|
|
66
|
+
return Locale(**resp.json())
|
|
67
|
+
|
|
68
|
+
async def get(
|
|
69
|
+
self,
|
|
70
|
+
locale_id: str,
|
|
71
|
+
) -> Locale:
|
|
72
|
+
"""Retrieve a locale
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
locale_id: ID of the locale.
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
The Locale object.
|
|
79
|
+
"""
|
|
80
|
+
resp = await self._http.get(f"/locales/{locale_id}")
|
|
81
|
+
return Locale(**resp.json())
|
|
82
|
+
|
|
83
|
+
async def save(
|
|
84
|
+
self,
|
|
85
|
+
locale_id: str,
|
|
86
|
+
locale: Union[Locale, dict[str, Any]],
|
|
87
|
+
) -> Locale:
|
|
88
|
+
"""Create or update a locale
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
locale_id: ID of the locale.
|
|
92
|
+
locale: A ``Locale`` model or dict. Required fields: Currency.
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
The Locale object.
|
|
96
|
+
"""
|
|
97
|
+
resp = await self._http.put(
|
|
98
|
+
f"/locales/{locale_id}",
|
|
99
|
+
json=self._serialize(locale),
|
|
100
|
+
)
|
|
101
|
+
return Locale(**resp.json())
|
|
102
|
+
|
|
103
|
+
async def delete(
|
|
104
|
+
self,
|
|
105
|
+
locale_id: str,
|
|
106
|
+
) -> None:
|
|
107
|
+
"""Delete a locale
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
locale_id: ID of the locale.
|
|
111
|
+
"""
|
|
112
|
+
await self._http.delete(f"/locales/{locale_id}")
|
|
113
|
+
|
|
114
|
+
async def patch(
|
|
115
|
+
self,
|
|
116
|
+
locale_id: str,
|
|
117
|
+
partial: dict[str, Any],
|
|
118
|
+
) -> Locale:
|
|
119
|
+
"""Partially update a locale
|
|
120
|
+
|
|
121
|
+
Args:
|
|
122
|
+
locale_id: ID of the locale.
|
|
123
|
+
partial: A dict of fields to update.
|
|
124
|
+
|
|
125
|
+
Returns:
|
|
126
|
+
The Locale object.
|
|
127
|
+
"""
|
|
128
|
+
resp = await self._http.patch(f"/locales/{locale_id}", json=partial)
|
|
129
|
+
return Locale(**resp.json())
|
|
130
|
+
|
|
131
|
+
async def delete_assignment(
|
|
132
|
+
self,
|
|
133
|
+
locale_id: str,
|
|
134
|
+
*,
|
|
135
|
+
buyer_id: Optional[str],
|
|
136
|
+
user_id: Optional[str] = None,
|
|
137
|
+
user_group_id: Optional[str] = None,
|
|
138
|
+
) -> None:
|
|
139
|
+
"""Delete a locale assignment
|
|
140
|
+
|
|
141
|
+
Args:
|
|
142
|
+
locale_id: ID of the locale.
|
|
143
|
+
buyer_id: ID of the buyer.
|
|
144
|
+
user_id: ID of the user.
|
|
145
|
+
user_group_id: ID of the user group.
|
|
146
|
+
"""
|
|
147
|
+
_params: dict[str, Any] = {}
|
|
148
|
+
if buyer_id is not None:
|
|
149
|
+
_params["buyerID"] = buyer_id
|
|
150
|
+
if user_id is not None:
|
|
151
|
+
_params["userID"] = user_id
|
|
152
|
+
if user_group_id is not None:
|
|
153
|
+
_params["userGroupID"] = user_group_id
|
|
154
|
+
await self._http.delete(f"/locales/{locale_id}/assignments", **_params)
|
|
155
|
+
|
|
156
|
+
async def list_assignments(
|
|
157
|
+
self,
|
|
158
|
+
*,
|
|
159
|
+
buyer_id: Optional[str] = None,
|
|
160
|
+
locale_id: Optional[str] = None,
|
|
161
|
+
user_group_id: Optional[str] = None,
|
|
162
|
+
level: Optional[str] = None,
|
|
163
|
+
page: Optional[int] = None,
|
|
164
|
+
page_size: Optional[int] = None,
|
|
165
|
+
) -> ListPage[LocaleAssignment]:
|
|
166
|
+
"""List locale assignments
|
|
167
|
+
|
|
168
|
+
Args:
|
|
169
|
+
buyer_id: ID of the buyer.
|
|
170
|
+
locale_id: ID of the locale.
|
|
171
|
+
user_group_id: ID of the user group.
|
|
172
|
+
level: Level of the locale assignment. Possible values: Group, Company, BuyerGroup.
|
|
173
|
+
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.
|
|
174
|
+
page_size: Number of results to return per page.
|
|
175
|
+
|
|
176
|
+
Returns:
|
|
177
|
+
A paginated list of LocaleAssignment objects.
|
|
178
|
+
"""
|
|
179
|
+
params = self._build_list_params(
|
|
180
|
+
page=page,
|
|
181
|
+
page_size=page_size,
|
|
182
|
+
)
|
|
183
|
+
if buyer_id is not None:
|
|
184
|
+
params["buyerID"] = buyer_id
|
|
185
|
+
if locale_id is not None:
|
|
186
|
+
params["localeID"] = locale_id
|
|
187
|
+
if user_group_id is not None:
|
|
188
|
+
params["userGroupID"] = user_group_id
|
|
189
|
+
if level is not None:
|
|
190
|
+
params["level"] = level
|
|
191
|
+
resp = await self._http.get("/locales/assignments", **params)
|
|
192
|
+
return self._parse_list(resp.json(), LocaleAssignment)
|
|
193
|
+
|
|
194
|
+
async def save_assignment(
|
|
195
|
+
self,
|
|
196
|
+
locale_assignment: Union[LocaleAssignment, dict[str, Any]],
|
|
197
|
+
) -> None:
|
|
198
|
+
"""Create or update a locale assignment
|
|
199
|
+
|
|
200
|
+
Args:
|
|
201
|
+
locale_assignment: A ``LocaleAssignment`` model or dict. Required fields: LocaleID, BuyerID.
|
|
202
|
+
"""
|
|
203
|
+
await self._http.post("/locales/assignments", json=self._serialize(locale_assignment))
|