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,201 @@
|
|
|
1
|
+
# GENERATED by tools/codegen — DO NOT EDIT
|
|
2
|
+
# Source: ordercloud-openapi-v3.json
|
|
3
|
+
"""OrderCloud Discounts API resource."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
from typing import Any, Optional, Union
|
|
7
|
+
|
|
8
|
+
from ..models.assignments import DiscountAssignment
|
|
9
|
+
from ..models.discount import Discount
|
|
10
|
+
from ..models.shared import ListPage
|
|
11
|
+
from .base import BaseResource
|
|
12
|
+
|
|
13
|
+
__all__ = ["DiscountsResource"]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class DiscountsResource(BaseResource):
|
|
17
|
+
"""Operations on OrderCloud Discounts."""
|
|
18
|
+
|
|
19
|
+
async def list(
|
|
20
|
+
self,
|
|
21
|
+
*,
|
|
22
|
+
sort_by: Optional[str] = None,
|
|
23
|
+
page: Optional[int] = None,
|
|
24
|
+
page_size: Optional[int] = None,
|
|
25
|
+
filters: Optional[dict[str, Any]] = None,
|
|
26
|
+
) -> ListPage[Discount]:
|
|
27
|
+
"""List discounts
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
sort_by: Comma-delimited list of fields to sort by.
|
|
31
|
+
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.
|
|
32
|
+
page_size: Number of results to return per page.
|
|
33
|
+
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.???'
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
A paginated list of Discount objects.
|
|
37
|
+
"""
|
|
38
|
+
params = self._build_list_params(
|
|
39
|
+
sort_by=sort_by,
|
|
40
|
+
page=page,
|
|
41
|
+
page_size=page_size,
|
|
42
|
+
filters=filters,
|
|
43
|
+
)
|
|
44
|
+
resp = await self._http.get("/discounts", **params)
|
|
45
|
+
return self._parse_list(resp.json(), Discount)
|
|
46
|
+
|
|
47
|
+
async def create(
|
|
48
|
+
self,
|
|
49
|
+
discount: Union[Discount, dict[str, Any]],
|
|
50
|
+
) -> Discount:
|
|
51
|
+
"""Create a discount
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
discount: A ``Discount`` model or dict. Required fields: DiscountBreaks.
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
The Discount object.
|
|
58
|
+
"""
|
|
59
|
+
resp = await self._http.post("/discounts", json=self._serialize(discount))
|
|
60
|
+
return Discount(**resp.json())
|
|
61
|
+
|
|
62
|
+
async def get(
|
|
63
|
+
self,
|
|
64
|
+
discount_id: str,
|
|
65
|
+
) -> Discount:
|
|
66
|
+
"""Retrieve a discount
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
discount_id: ID of the discount.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
The Discount object.
|
|
73
|
+
"""
|
|
74
|
+
resp = await self._http.get(f"/discounts/{discount_id}")
|
|
75
|
+
return Discount(**resp.json())
|
|
76
|
+
|
|
77
|
+
async def save(
|
|
78
|
+
self,
|
|
79
|
+
discount_id: str,
|
|
80
|
+
discount: Union[Discount, dict[str, Any]],
|
|
81
|
+
) -> Discount:
|
|
82
|
+
"""Create or update a discount
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
discount_id: ID of the discount.
|
|
86
|
+
discount: A ``Discount`` model or dict. Required fields: DiscountBreaks.
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
The Discount object.
|
|
90
|
+
"""
|
|
91
|
+
resp = await self._http.put(
|
|
92
|
+
f"/discounts/{discount_id}",
|
|
93
|
+
json=self._serialize(discount),
|
|
94
|
+
)
|
|
95
|
+
return Discount(**resp.json())
|
|
96
|
+
|
|
97
|
+
async def delete(
|
|
98
|
+
self,
|
|
99
|
+
discount_id: str,
|
|
100
|
+
) -> None:
|
|
101
|
+
"""Delete a discount
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
discount_id: ID of the discount.
|
|
105
|
+
"""
|
|
106
|
+
await self._http.delete(f"/discounts/{discount_id}")
|
|
107
|
+
|
|
108
|
+
async def patch(
|
|
109
|
+
self,
|
|
110
|
+
discount_id: str,
|
|
111
|
+
partial: dict[str, Any],
|
|
112
|
+
) -> Discount:
|
|
113
|
+
"""Partially update a discount
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
discount_id: ID of the discount.
|
|
117
|
+
partial: A dict of fields to update.
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
The Discount object.
|
|
121
|
+
"""
|
|
122
|
+
resp = await self._http.patch(f"/discounts/{discount_id}", json=partial)
|
|
123
|
+
return Discount(**resp.json())
|
|
124
|
+
|
|
125
|
+
async def delete_assignment(
|
|
126
|
+
self,
|
|
127
|
+
discount_id: str,
|
|
128
|
+
*,
|
|
129
|
+
buyer_id: Optional[str] = None,
|
|
130
|
+
user_group_id: Optional[str] = None,
|
|
131
|
+
buyer_group_id: Optional[str] = None,
|
|
132
|
+
) -> None:
|
|
133
|
+
"""Delete a discount assignment
|
|
134
|
+
|
|
135
|
+
Args:
|
|
136
|
+
discount_id: ID of the discount.
|
|
137
|
+
buyer_id: ID of the buyer.
|
|
138
|
+
user_group_id: ID of the user group.
|
|
139
|
+
buyer_group_id: ID of the buyer group.
|
|
140
|
+
"""
|
|
141
|
+
_params: dict[str, Any] = {}
|
|
142
|
+
if buyer_id is not None:
|
|
143
|
+
_params["buyerID"] = buyer_id
|
|
144
|
+
if user_group_id is not None:
|
|
145
|
+
_params["userGroupID"] = user_group_id
|
|
146
|
+
if buyer_group_id is not None:
|
|
147
|
+
_params["buyerGroupID"] = buyer_group_id
|
|
148
|
+
await self._http.delete(f"/discounts/{discount_id}/assignments", **_params)
|
|
149
|
+
|
|
150
|
+
async def list_assignments(
|
|
151
|
+
self,
|
|
152
|
+
*,
|
|
153
|
+
discount_id: Optional[str] = None,
|
|
154
|
+
buyer_id: Optional[str] = None,
|
|
155
|
+
user_group_id: Optional[str] = None,
|
|
156
|
+
buyer_group_id: Optional[str] = None,
|
|
157
|
+
level: Optional[str] = None,
|
|
158
|
+
page: Optional[int] = None,
|
|
159
|
+
page_size: Optional[int] = None,
|
|
160
|
+
) -> ListPage[DiscountAssignment]:
|
|
161
|
+
"""List discount assignments
|
|
162
|
+
|
|
163
|
+
Args:
|
|
164
|
+
discount_id: ID of the discount.
|
|
165
|
+
buyer_id: ID of the buyer.
|
|
166
|
+
user_group_id: ID of the user group.
|
|
167
|
+
buyer_group_id: ID of the buyer group.
|
|
168
|
+
level: Level of the discount assignment. Possible values: Group, Company, BuyerGroup.
|
|
169
|
+
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.
|
|
170
|
+
page_size: Number of results to return per page.
|
|
171
|
+
|
|
172
|
+
Returns:
|
|
173
|
+
A paginated list of DiscountAssignment objects.
|
|
174
|
+
"""
|
|
175
|
+
params = self._build_list_params(
|
|
176
|
+
page=page,
|
|
177
|
+
page_size=page_size,
|
|
178
|
+
)
|
|
179
|
+
if discount_id is not None:
|
|
180
|
+
params["discountID"] = discount_id
|
|
181
|
+
if buyer_id is not None:
|
|
182
|
+
params["buyerID"] = buyer_id
|
|
183
|
+
if user_group_id is not None:
|
|
184
|
+
params["userGroupID"] = user_group_id
|
|
185
|
+
if buyer_group_id is not None:
|
|
186
|
+
params["buyerGroupID"] = buyer_group_id
|
|
187
|
+
if level is not None:
|
|
188
|
+
params["level"] = level
|
|
189
|
+
resp = await self._http.get("/discounts/assignments", **params)
|
|
190
|
+
return self._parse_list(resp.json(), DiscountAssignment)
|
|
191
|
+
|
|
192
|
+
async def save_assignment(
|
|
193
|
+
self,
|
|
194
|
+
discount_assignment: Union[DiscountAssignment, dict[str, Any]],
|
|
195
|
+
) -> None:
|
|
196
|
+
"""Create or update a discount assignment
|
|
197
|
+
|
|
198
|
+
Args:
|
|
199
|
+
discount_assignment: A ``DiscountAssignment`` model or dict. Required fields: DiscountID.
|
|
200
|
+
"""
|
|
201
|
+
await self._http.post("/discounts/assignments", json=self._serialize(discount_assignment))
|