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,227 @@
|
|
|
1
|
+
# GENERATED by tools/codegen — DO NOT EDIT
|
|
2
|
+
# Source: ordercloud-openapi-v3.json
|
|
3
|
+
"""OrderCloud SpendingAccounts API resource."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
from typing import Any, Optional, Union
|
|
7
|
+
|
|
8
|
+
from ..models.assignments import SpendingAccountAssignment
|
|
9
|
+
from ..models.misc import PartyType
|
|
10
|
+
from ..models.spending_account import SpendingAccount
|
|
11
|
+
from ..models.shared import ListPage
|
|
12
|
+
from .base import BaseResource
|
|
13
|
+
|
|
14
|
+
__all__ = ["SpendingAccountsResource"]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class SpendingAccountsResource(BaseResource):
|
|
18
|
+
"""Operations on OrderCloud SpendingAccounts."""
|
|
19
|
+
|
|
20
|
+
async def list(
|
|
21
|
+
self,
|
|
22
|
+
buyer_id: str,
|
|
23
|
+
*,
|
|
24
|
+
search: Optional[str] = None,
|
|
25
|
+
search_on: Optional[str] = None,
|
|
26
|
+
sort_by: Optional[str] = None,
|
|
27
|
+
page: Optional[int] = None,
|
|
28
|
+
page_size: Optional[int] = None,
|
|
29
|
+
filters: Optional[dict[str, Any]] = None,
|
|
30
|
+
) -> ListPage[SpendingAccount]:
|
|
31
|
+
"""List spending accounts
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
buyer_id: ID of the buyer.
|
|
35
|
+
search: Word or phrase to search for.
|
|
36
|
+
search_on: Comma-delimited list of fields to search on.
|
|
37
|
+
sort_by: Comma-delimited list of fields to sort by.
|
|
38
|
+
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.
|
|
39
|
+
page_size: Number of results to return per page.
|
|
40
|
+
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.???'
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
A paginated list of SpendingAccount objects.
|
|
44
|
+
"""
|
|
45
|
+
params = self._build_list_params(
|
|
46
|
+
search=search,
|
|
47
|
+
search_on=search_on,
|
|
48
|
+
sort_by=sort_by,
|
|
49
|
+
page=page,
|
|
50
|
+
page_size=page_size,
|
|
51
|
+
filters=filters,
|
|
52
|
+
)
|
|
53
|
+
resp = await self._http.get(f"/buyers/{buyer_id}/spendingaccounts", **params)
|
|
54
|
+
return self._parse_list(resp.json(), SpendingAccount)
|
|
55
|
+
|
|
56
|
+
async def create(
|
|
57
|
+
self,
|
|
58
|
+
buyer_id: str,
|
|
59
|
+
spending_account: Union[SpendingAccount, dict[str, Any]],
|
|
60
|
+
) -> SpendingAccount:
|
|
61
|
+
"""Create a spending account
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
buyer_id: ID of the buyer.
|
|
65
|
+
spending_account: A ``SpendingAccount`` model or dict. Required fields: Name, Balance.
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
The SpendingAccount object.
|
|
69
|
+
"""
|
|
70
|
+
resp = await self._http.post(
|
|
71
|
+
f"/buyers/{buyer_id}/spendingaccounts", json=self._serialize(spending_account)
|
|
72
|
+
)
|
|
73
|
+
return SpendingAccount(**resp.json())
|
|
74
|
+
|
|
75
|
+
async def get(
|
|
76
|
+
self,
|
|
77
|
+
buyer_id: str,
|
|
78
|
+
spending_account_id: str,
|
|
79
|
+
) -> SpendingAccount:
|
|
80
|
+
"""Retrieve a spending account
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
buyer_id: ID of the buyer.
|
|
84
|
+
spending_account_id: ID of the spending account.
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
The SpendingAccount object.
|
|
88
|
+
"""
|
|
89
|
+
resp = await self._http.get(f"/buyers/{buyer_id}/spendingaccounts/{spending_account_id}")
|
|
90
|
+
return SpendingAccount(**resp.json())
|
|
91
|
+
|
|
92
|
+
async def save(
|
|
93
|
+
self,
|
|
94
|
+
buyer_id: str,
|
|
95
|
+
spending_account_id: str,
|
|
96
|
+
spending_account: Union[SpendingAccount, dict[str, Any]],
|
|
97
|
+
) -> SpendingAccount:
|
|
98
|
+
"""Create or update a spending account
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
buyer_id: ID of the buyer.
|
|
102
|
+
spending_account_id: ID of the spending account.
|
|
103
|
+
spending_account: A ``SpendingAccount`` model or dict. Required fields: Name, Balance.
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
The SpendingAccount object.
|
|
107
|
+
"""
|
|
108
|
+
resp = await self._http.put(
|
|
109
|
+
f"/buyers/{buyer_id}/spendingaccounts/{spending_account_id}",
|
|
110
|
+
json=self._serialize(spending_account),
|
|
111
|
+
)
|
|
112
|
+
return SpendingAccount(**resp.json())
|
|
113
|
+
|
|
114
|
+
async def delete(
|
|
115
|
+
self,
|
|
116
|
+
buyer_id: str,
|
|
117
|
+
spending_account_id: str,
|
|
118
|
+
) -> None:
|
|
119
|
+
"""Delete a spending account
|
|
120
|
+
|
|
121
|
+
Args:
|
|
122
|
+
buyer_id: ID of the buyer.
|
|
123
|
+
spending_account_id: ID of the spending account.
|
|
124
|
+
"""
|
|
125
|
+
await self._http.delete(f"/buyers/{buyer_id}/spendingaccounts/{spending_account_id}")
|
|
126
|
+
|
|
127
|
+
async def patch(
|
|
128
|
+
self,
|
|
129
|
+
buyer_id: str,
|
|
130
|
+
spending_account_id: str,
|
|
131
|
+
partial: dict[str, Any],
|
|
132
|
+
) -> SpendingAccount:
|
|
133
|
+
"""Partially update a spending account
|
|
134
|
+
|
|
135
|
+
Args:
|
|
136
|
+
buyer_id: ID of the buyer.
|
|
137
|
+
spending_account_id: ID of the spending account.
|
|
138
|
+
partial: A dict of fields to update.
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
The SpendingAccount object.
|
|
142
|
+
"""
|
|
143
|
+
resp = await self._http.patch(
|
|
144
|
+
f"/buyers/{buyer_id}/spendingaccounts/{spending_account_id}", json=partial
|
|
145
|
+
)
|
|
146
|
+
return SpendingAccount(**resp.json())
|
|
147
|
+
|
|
148
|
+
async def delete_assignment(
|
|
149
|
+
self,
|
|
150
|
+
buyer_id: str,
|
|
151
|
+
spending_account_id: str,
|
|
152
|
+
*,
|
|
153
|
+
user_id: Optional[str] = None,
|
|
154
|
+
user_group_id: Optional[str] = None,
|
|
155
|
+
) -> None:
|
|
156
|
+
"""Delete a spending account assignment
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
buyer_id: ID of the buyer.
|
|
160
|
+
spending_account_id: ID of the spending account.
|
|
161
|
+
user_id: ID of the user.
|
|
162
|
+
user_group_id: ID of the user group.
|
|
163
|
+
"""
|
|
164
|
+
_params: dict[str, Any] = {}
|
|
165
|
+
if user_id is not None:
|
|
166
|
+
_params["userID"] = user_id
|
|
167
|
+
if user_group_id is not None:
|
|
168
|
+
_params["userGroupID"] = user_group_id
|
|
169
|
+
await self._http.delete(
|
|
170
|
+
f"/buyers/{buyer_id}/spendingaccounts/{spending_account_id}/assignments", **_params
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
async def list_assignments(
|
|
174
|
+
self,
|
|
175
|
+
buyer_id: str,
|
|
176
|
+
*,
|
|
177
|
+
spending_account_id: Optional[str] = None,
|
|
178
|
+
user_id: Optional[str] = None,
|
|
179
|
+
user_group_id: Optional[str] = None,
|
|
180
|
+
level: Optional[PartyType] = None,
|
|
181
|
+
page: Optional[int] = None,
|
|
182
|
+
page_size: Optional[int] = None,
|
|
183
|
+
) -> ListPage[SpendingAccountAssignment]:
|
|
184
|
+
"""List spending account assignments
|
|
185
|
+
|
|
186
|
+
Args:
|
|
187
|
+
buyer_id: ID of the buyer.
|
|
188
|
+
spending_account_id: ID of the spending account.
|
|
189
|
+
user_id: ID of the user.
|
|
190
|
+
user_group_id: ID of the user group.
|
|
191
|
+
level: Level of the spending account assignment. Possible values: User, Group, Company, BuyerGroup.
|
|
192
|
+
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.
|
|
193
|
+
page_size: Number of results to return per page.
|
|
194
|
+
|
|
195
|
+
Returns:
|
|
196
|
+
A paginated list of SpendingAccountAssignment objects.
|
|
197
|
+
"""
|
|
198
|
+
params = self._build_list_params(
|
|
199
|
+
page=page,
|
|
200
|
+
page_size=page_size,
|
|
201
|
+
)
|
|
202
|
+
if spending_account_id is not None:
|
|
203
|
+
params["spendingAccountID"] = spending_account_id
|
|
204
|
+
if user_id is not None:
|
|
205
|
+
params["userID"] = user_id
|
|
206
|
+
if user_group_id is not None:
|
|
207
|
+
params["userGroupID"] = user_group_id
|
|
208
|
+
if level is not None:
|
|
209
|
+
params["level"] = level
|
|
210
|
+
resp = await self._http.get(f"/buyers/{buyer_id}/spendingaccounts/assignments", **params)
|
|
211
|
+
return self._parse_list(resp.json(), SpendingAccountAssignment)
|
|
212
|
+
|
|
213
|
+
async def save_assignment(
|
|
214
|
+
self,
|
|
215
|
+
buyer_id: str,
|
|
216
|
+
spending_account_assignment: Union[SpendingAccountAssignment, dict[str, Any]],
|
|
217
|
+
) -> None:
|
|
218
|
+
"""Create or update a spending account assignment
|
|
219
|
+
|
|
220
|
+
Args:
|
|
221
|
+
buyer_id: ID of the buyer.
|
|
222
|
+
spending_account_assignment: A ``SpendingAccountAssignment`` model or dict. Required fields: SpendingAccountID.
|
|
223
|
+
"""
|
|
224
|
+
await self._http.post(
|
|
225
|
+
f"/buyers/{buyer_id}/spendingaccounts/assignments",
|
|
226
|
+
json=self._serialize(spending_account_assignment),
|
|
227
|
+
)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# GENERATED by tools/codegen — DO NOT EDIT
|
|
2
|
+
# Source: ordercloud-openapi-v3.json
|
|
3
|
+
"""OrderCloud SubscriptionIntegrations API resource."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
from typing import Any, Union
|
|
7
|
+
|
|
8
|
+
from ..models.subscription import SubscriptionIntegration
|
|
9
|
+
from .base import BaseResource
|
|
10
|
+
|
|
11
|
+
__all__ = ["SubscriptionIntegrationsResource"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class SubscriptionIntegrationsResource(BaseResource):
|
|
15
|
+
"""Operations on OrderCloud SubscriptionIntegrations."""
|
|
16
|
+
|
|
17
|
+
async def get(
|
|
18
|
+
self,
|
|
19
|
+
) -> SubscriptionIntegration:
|
|
20
|
+
"""Retrieve a subscription integration
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
The SubscriptionIntegration object.
|
|
24
|
+
"""
|
|
25
|
+
resp = await self._http.get("/integrations/subscription")
|
|
26
|
+
return SubscriptionIntegration(**resp.json())
|
|
27
|
+
|
|
28
|
+
async def save(
|
|
29
|
+
self,
|
|
30
|
+
subscription_integration: Union[SubscriptionIntegration, dict[str, Any]],
|
|
31
|
+
) -> SubscriptionIntegration:
|
|
32
|
+
"""Create or update a subscription integration
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
subscription_integration: A ``SubscriptionIntegration`` model or dict. Required fields: ApiClientID, HashKey.
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
The SubscriptionIntegration object.
|
|
39
|
+
"""
|
|
40
|
+
resp = await self._http.put(
|
|
41
|
+
"/integrations/subscription",
|
|
42
|
+
json=self._serialize(subscription_integration),
|
|
43
|
+
)
|
|
44
|
+
return SubscriptionIntegration(**resp.json())
|
|
45
|
+
|
|
46
|
+
async def delete(
|
|
47
|
+
self,
|
|
48
|
+
) -> None:
|
|
49
|
+
"""Delete a subscription integration"""
|
|
50
|
+
await self._http.delete("/integrations/subscription")
|
|
51
|
+
|
|
52
|
+
async def patch(
|
|
53
|
+
self,
|
|
54
|
+
partial: dict[str, Any],
|
|
55
|
+
) -> SubscriptionIntegration:
|
|
56
|
+
"""Partially update a subscription integration
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
partial: A dict of fields to update.
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
The SubscriptionIntegration object.
|
|
63
|
+
"""
|
|
64
|
+
resp = await self._http.patch("/integrations/subscription", json=partial)
|
|
65
|
+
return SubscriptionIntegration(**resp.json())
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# GENERATED by tools/codegen — DO NOT EDIT
|
|
2
|
+
# Source: ordercloud-openapi-v3.json
|
|
3
|
+
"""OrderCloud SubscriptionItems API resource."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
from typing import Any, Optional, Union
|
|
7
|
+
|
|
8
|
+
from ..models.line_item import LineItem
|
|
9
|
+
from ..models.shared import ListPage
|
|
10
|
+
from .base import BaseResource
|
|
11
|
+
|
|
12
|
+
__all__ = ["SubscriptionItemsResource"]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class SubscriptionItemsResource(BaseResource):
|
|
16
|
+
"""Operations on OrderCloud SubscriptionItems."""
|
|
17
|
+
|
|
18
|
+
async def list(
|
|
19
|
+
self,
|
|
20
|
+
subscription_id: str,
|
|
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[LineItem]:
|
|
29
|
+
"""List subscription items
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
subscription_id: ID of the subscription.
|
|
33
|
+
search: Word or phrase to search for.
|
|
34
|
+
search_on: Comma-delimited list of fields to search on.
|
|
35
|
+
sort_by: Comma-delimited list of fields to sort by.
|
|
36
|
+
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.
|
|
37
|
+
page_size: Number of results to return per page.
|
|
38
|
+
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.???'
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
A paginated list of LineItem objects.
|
|
42
|
+
"""
|
|
43
|
+
params = self._build_list_params(
|
|
44
|
+
search=search,
|
|
45
|
+
search_on=search_on,
|
|
46
|
+
sort_by=sort_by,
|
|
47
|
+
page=page,
|
|
48
|
+
page_size=page_size,
|
|
49
|
+
filters=filters,
|
|
50
|
+
)
|
|
51
|
+
resp = await self._http.get(f"/subscriptions/{subscription_id}/items", **params)
|
|
52
|
+
return self._parse_list(resp.json(), LineItem)
|
|
53
|
+
|
|
54
|
+
async def create(
|
|
55
|
+
self,
|
|
56
|
+
subscription_id: str,
|
|
57
|
+
line_item: Union[LineItem, dict[str, Any]],
|
|
58
|
+
) -> LineItem:
|
|
59
|
+
"""Create a subscription item
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
subscription_id: ID of the subscription.
|
|
63
|
+
line_item: A ``LineItem`` model or dict. Required fields: ProductID.
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
The LineItem object.
|
|
67
|
+
"""
|
|
68
|
+
resp = await self._http.post(
|
|
69
|
+
f"/subscriptions/{subscription_id}/items", json=self._serialize(line_item)
|
|
70
|
+
)
|
|
71
|
+
return LineItem(**resp.json())
|
|
72
|
+
|
|
73
|
+
async def get(
|
|
74
|
+
self,
|
|
75
|
+
subscription_id: str,
|
|
76
|
+
subscription_item_id: str,
|
|
77
|
+
) -> LineItem:
|
|
78
|
+
"""Retrieve a subscription item
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
subscription_id: ID of the subscription.
|
|
82
|
+
subscription_item_id: ID of the subscription item.
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
The LineItem object.
|
|
86
|
+
"""
|
|
87
|
+
resp = await self._http.get(
|
|
88
|
+
f"/subscriptions/{subscription_id}/items/{subscription_item_id}"
|
|
89
|
+
)
|
|
90
|
+
return LineItem(**resp.json())
|
|
91
|
+
|
|
92
|
+
async def save(
|
|
93
|
+
self,
|
|
94
|
+
subscription_id: str,
|
|
95
|
+
subscription_item_id: str,
|
|
96
|
+
line_item: Union[LineItem, dict[str, Any]],
|
|
97
|
+
) -> LineItem:
|
|
98
|
+
"""Create or update a subscription item
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
subscription_id: ID of the subscription.
|
|
102
|
+
subscription_item_id: ID of the subscription item.
|
|
103
|
+
line_item: A ``LineItem`` model or dict. Required fields: ProductID.
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
The LineItem object.
|
|
107
|
+
"""
|
|
108
|
+
resp = await self._http.put(
|
|
109
|
+
f"/subscriptions/{subscription_id}/items/{subscription_item_id}",
|
|
110
|
+
json=self._serialize(line_item),
|
|
111
|
+
)
|
|
112
|
+
return LineItem(**resp.json())
|
|
113
|
+
|
|
114
|
+
async def delete(
|
|
115
|
+
self,
|
|
116
|
+
subscription_id: str,
|
|
117
|
+
subscription_item_id: str,
|
|
118
|
+
) -> None:
|
|
119
|
+
"""Delete a subscription item
|
|
120
|
+
|
|
121
|
+
Args:
|
|
122
|
+
subscription_id: ID of the subscription.
|
|
123
|
+
subscription_item_id: ID of the subscription item.
|
|
124
|
+
"""
|
|
125
|
+
await self._http.delete(f"/subscriptions/{subscription_id}/items/{subscription_item_id}")
|
|
126
|
+
|
|
127
|
+
async def patch(
|
|
128
|
+
self,
|
|
129
|
+
subscription_id: str,
|
|
130
|
+
subscription_item_id: str,
|
|
131
|
+
partial: dict[str, Any],
|
|
132
|
+
) -> LineItem:
|
|
133
|
+
"""Partially update a subscription item
|
|
134
|
+
|
|
135
|
+
Args:
|
|
136
|
+
subscription_id: ID of the subscription.
|
|
137
|
+
subscription_item_id: ID of the subscription item.
|
|
138
|
+
partial: A dict of fields to update.
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
The LineItem object.
|
|
142
|
+
"""
|
|
143
|
+
resp = await self._http.patch(
|
|
144
|
+
f"/subscriptions/{subscription_id}/items/{subscription_item_id}", json=partial
|
|
145
|
+
)
|
|
146
|
+
return LineItem(**resp.json())
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# GENERATED by tools/codegen — DO NOT EDIT
|
|
2
|
+
# Source: ordercloud-openapi-v3.json
|
|
3
|
+
"""OrderCloud Subscriptions API resource."""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
from typing import Any, Optional, Union
|
|
7
|
+
|
|
8
|
+
from ..models.subscription import Subscription
|
|
9
|
+
from ..models.shared import ListPage
|
|
10
|
+
from .base import BaseResource
|
|
11
|
+
|
|
12
|
+
__all__ = ["SubscriptionsResource"]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class SubscriptionsResource(BaseResource):
|
|
16
|
+
"""Operations on OrderCloud Subscriptions."""
|
|
17
|
+
|
|
18
|
+
async def list(
|
|
19
|
+
self,
|
|
20
|
+
*,
|
|
21
|
+
search: Optional[str] = None,
|
|
22
|
+
search_on: Optional[str] = None,
|
|
23
|
+
sort_by: Optional[str] = None,
|
|
24
|
+
page: Optional[int] = None,
|
|
25
|
+
page_size: Optional[int] = None,
|
|
26
|
+
filters: Optional[dict[str, Any]] = None,
|
|
27
|
+
) -> ListPage[Subscription]:
|
|
28
|
+
"""List subscriptions
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
search: Word or phrase to search for.
|
|
32
|
+
search_on: Comma-delimited list of fields to search on.
|
|
33
|
+
sort_by: Comma-delimited list of fields to sort by.
|
|
34
|
+
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.
|
|
35
|
+
page_size: Number of results to return per page.
|
|
36
|
+
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.???'
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
A paginated list of Subscription objects.
|
|
40
|
+
"""
|
|
41
|
+
params = self._build_list_params(
|
|
42
|
+
search=search,
|
|
43
|
+
search_on=search_on,
|
|
44
|
+
sort_by=sort_by,
|
|
45
|
+
page=page,
|
|
46
|
+
page_size=page_size,
|
|
47
|
+
filters=filters,
|
|
48
|
+
)
|
|
49
|
+
resp = await self._http.get("/subscriptions", **params)
|
|
50
|
+
return self._parse_list(resp.json(), Subscription)
|
|
51
|
+
|
|
52
|
+
async def create(
|
|
53
|
+
self,
|
|
54
|
+
subscription: Union[Subscription, dict[str, Any]],
|
|
55
|
+
) -> Subscription:
|
|
56
|
+
"""Create a subscription
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
subscription: A ``Subscription`` model or dict. Required fields: Frequency, Interval, NextOrderDate.
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
The Subscription object.
|
|
63
|
+
"""
|
|
64
|
+
resp = await self._http.post("/subscriptions", json=self._serialize(subscription))
|
|
65
|
+
return Subscription(**resp.json())
|
|
66
|
+
|
|
67
|
+
async def get(
|
|
68
|
+
self,
|
|
69
|
+
subscription_id: str,
|
|
70
|
+
) -> Subscription:
|
|
71
|
+
"""Retrieve a subscription
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
subscription_id: ID of the subscription.
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
The Subscription object.
|
|
78
|
+
"""
|
|
79
|
+
resp = await self._http.get(f"/subscriptions/{subscription_id}")
|
|
80
|
+
return Subscription(**resp.json())
|
|
81
|
+
|
|
82
|
+
async def save(
|
|
83
|
+
self,
|
|
84
|
+
subscription_id: str,
|
|
85
|
+
subscription: Union[Subscription, dict[str, Any]],
|
|
86
|
+
) -> Subscription:
|
|
87
|
+
"""Create or update a subscription
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
subscription_id: ID of the subscription.
|
|
91
|
+
subscription: A ``Subscription`` model or dict. Required fields: Frequency, Interval, NextOrderDate.
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
The Subscription object.
|
|
95
|
+
"""
|
|
96
|
+
resp = await self._http.put(
|
|
97
|
+
f"/subscriptions/{subscription_id}",
|
|
98
|
+
json=self._serialize(subscription),
|
|
99
|
+
)
|
|
100
|
+
return Subscription(**resp.json())
|
|
101
|
+
|
|
102
|
+
async def delete(
|
|
103
|
+
self,
|
|
104
|
+
subscription_id: str,
|
|
105
|
+
) -> None:
|
|
106
|
+
"""Delete a subscription
|
|
107
|
+
|
|
108
|
+
Args:
|
|
109
|
+
subscription_id: ID of the subscription.
|
|
110
|
+
"""
|
|
111
|
+
await self._http.delete(f"/subscriptions/{subscription_id}")
|
|
112
|
+
|
|
113
|
+
async def patch(
|
|
114
|
+
self,
|
|
115
|
+
subscription_id: str,
|
|
116
|
+
partial: dict[str, Any],
|
|
117
|
+
) -> Subscription:
|
|
118
|
+
"""Partially update a subscription
|
|
119
|
+
|
|
120
|
+
Args:
|
|
121
|
+
subscription_id: ID of the subscription.
|
|
122
|
+
partial: A dict of fields to update.
|
|
123
|
+
|
|
124
|
+
Returns:
|
|
125
|
+
The Subscription object.
|
|
126
|
+
"""
|
|
127
|
+
resp = await self._http.patch(f"/subscriptions/{subscription_id}", json=partial)
|
|
128
|
+
return Subscription(**resp.json())
|