dub 0.23.1__py3-none-any.whl → 0.24.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.
- dub/_version.py +3 -3
- dub/commissions.py +600 -0
- dub/httpclient.py +7 -37
- dub/models/components/partnerenrolledevent.py +78 -0
- dub/models/operations/__init__.py +44 -14
- dub/models/operations/createcustomer.py +8 -0
- dub/models/operations/createpartner.py +81 -3
- dub/models/operations/getcustomer.py +8 -0
- dub/models/operations/getcustomers.py +8 -0
- dub/models/operations/listcommissions.py +252 -0
- dub/models/operations/updatecommission.py +150 -0
- dub/models/operations/updatecustomer.py +8 -0
- dub/partners.py +0 -310
- dub/sdk.py +3 -0
- {dub-0.23.1.dist-info → dub-0.24.1.dist-info}/METADATA +7 -4
- {dub-0.23.1.dist-info → dub-0.24.1.dist-info}/RECORD +18 -16
- dub/models/operations/updatepartnersale.py +0 -121
- {dub-0.23.1.dist-info → dub-0.24.1.dist-info}/LICENSE +0 -0
- {dub-0.23.1.dist-info → dub-0.24.1.dist-info}/WHEEL +0 -0
dub/_version.py
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import importlib.metadata
|
|
4
4
|
|
|
5
5
|
__title__: str = "dub"
|
|
6
|
-
__version__: str = "0.
|
|
6
|
+
__version__: str = "0.24.1"
|
|
7
7
|
__openapi_doc_version__: str = "0.0.1"
|
|
8
|
-
__gen_version__: str = "2.
|
|
9
|
-
__user_agent__: str = "speakeasy-sdk/python 0.
|
|
8
|
+
__gen_version__: str = "2.605.6"
|
|
9
|
+
__user_agent__: str = "speakeasy-sdk/python 0.24.1 2.605.6 0.0.1 dub"
|
|
10
10
|
|
|
11
11
|
try:
|
|
12
12
|
if __package__ is not None:
|
dub/commissions.py
ADDED
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from .basesdk import BaseSDK
|
|
4
|
+
from dub import utils
|
|
5
|
+
from dub._hooks import HookContext
|
|
6
|
+
from dub.models import errors, operations
|
|
7
|
+
from dub.types import BaseModel, OptionalNullable, UNSET
|
|
8
|
+
from typing import Any, List, Mapping, Optional, Union, cast
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Commissions(BaseSDK):
|
|
12
|
+
def list(
|
|
13
|
+
self,
|
|
14
|
+
*,
|
|
15
|
+
request: Union[
|
|
16
|
+
operations.ListCommissionsRequest,
|
|
17
|
+
operations.ListCommissionsRequestTypedDict,
|
|
18
|
+
],
|
|
19
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
20
|
+
server_url: Optional[str] = None,
|
|
21
|
+
timeout_ms: Optional[int] = None,
|
|
22
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
23
|
+
) -> Optional[List[operations.ListCommissionsResponseBody]]:
|
|
24
|
+
r"""Get commissions for a program.
|
|
25
|
+
|
|
26
|
+
Retrieve a list of commissions for a program.
|
|
27
|
+
|
|
28
|
+
:param request: The request object to send.
|
|
29
|
+
:param retries: Override the default retry configuration for this method
|
|
30
|
+
:param server_url: Override the default server URL for this method
|
|
31
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
32
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
33
|
+
"""
|
|
34
|
+
base_url = None
|
|
35
|
+
url_variables = None
|
|
36
|
+
if timeout_ms is None:
|
|
37
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
38
|
+
|
|
39
|
+
if server_url is not None:
|
|
40
|
+
base_url = server_url
|
|
41
|
+
else:
|
|
42
|
+
base_url = self._get_url(base_url, url_variables)
|
|
43
|
+
|
|
44
|
+
if not isinstance(request, BaseModel):
|
|
45
|
+
request = utils.unmarshal(request, operations.ListCommissionsRequest)
|
|
46
|
+
request = cast(operations.ListCommissionsRequest, request)
|
|
47
|
+
|
|
48
|
+
req = self._build_request(
|
|
49
|
+
method="GET",
|
|
50
|
+
path="/commissions",
|
|
51
|
+
base_url=base_url,
|
|
52
|
+
url_variables=url_variables,
|
|
53
|
+
request=request,
|
|
54
|
+
request_body_required=False,
|
|
55
|
+
request_has_path_params=False,
|
|
56
|
+
request_has_query_params=True,
|
|
57
|
+
user_agent_header="user-agent",
|
|
58
|
+
accept_header_value="application/json",
|
|
59
|
+
http_headers=http_headers,
|
|
60
|
+
security=self.sdk_configuration.security,
|
|
61
|
+
timeout_ms=timeout_ms,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
if retries == UNSET:
|
|
65
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
66
|
+
retries = self.sdk_configuration.retry_config
|
|
67
|
+
|
|
68
|
+
retry_config = None
|
|
69
|
+
if isinstance(retries, utils.RetryConfig):
|
|
70
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
71
|
+
|
|
72
|
+
http_res = self.do_request(
|
|
73
|
+
hook_ctx=HookContext(
|
|
74
|
+
base_url=base_url or "",
|
|
75
|
+
operation_id="listCommissions",
|
|
76
|
+
oauth2_scopes=[],
|
|
77
|
+
security_source=self.sdk_configuration.security,
|
|
78
|
+
),
|
|
79
|
+
request=req,
|
|
80
|
+
error_status_codes=[
|
|
81
|
+
"400",
|
|
82
|
+
"401",
|
|
83
|
+
"403",
|
|
84
|
+
"404",
|
|
85
|
+
"409",
|
|
86
|
+
"410",
|
|
87
|
+
"422",
|
|
88
|
+
"429",
|
|
89
|
+
"4XX",
|
|
90
|
+
"500",
|
|
91
|
+
"5XX",
|
|
92
|
+
],
|
|
93
|
+
retry_config=retry_config,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
response_data: Any = None
|
|
97
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
98
|
+
return utils.unmarshal_json(
|
|
99
|
+
http_res.text, Optional[List[operations.ListCommissionsResponseBody]]
|
|
100
|
+
)
|
|
101
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
102
|
+
response_data = utils.unmarshal_json(http_res.text, errors.BadRequestData)
|
|
103
|
+
raise errors.BadRequest(data=response_data)
|
|
104
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
105
|
+
response_data = utils.unmarshal_json(http_res.text, errors.UnauthorizedData)
|
|
106
|
+
raise errors.Unauthorized(data=response_data)
|
|
107
|
+
if utils.match_response(http_res, "403", "application/json"):
|
|
108
|
+
response_data = utils.unmarshal_json(http_res.text, errors.ForbiddenData)
|
|
109
|
+
raise errors.Forbidden(data=response_data)
|
|
110
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
111
|
+
response_data = utils.unmarshal_json(http_res.text, errors.NotFoundData)
|
|
112
|
+
raise errors.NotFound(data=response_data)
|
|
113
|
+
if utils.match_response(http_res, "409", "application/json"):
|
|
114
|
+
response_data = utils.unmarshal_json(http_res.text, errors.ConflictData)
|
|
115
|
+
raise errors.Conflict(data=response_data)
|
|
116
|
+
if utils.match_response(http_res, "410", "application/json"):
|
|
117
|
+
response_data = utils.unmarshal_json(
|
|
118
|
+
http_res.text, errors.InviteExpiredData
|
|
119
|
+
)
|
|
120
|
+
raise errors.InviteExpired(data=response_data)
|
|
121
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
122
|
+
response_data = utils.unmarshal_json(
|
|
123
|
+
http_res.text, errors.UnprocessableEntityData
|
|
124
|
+
)
|
|
125
|
+
raise errors.UnprocessableEntity(data=response_data)
|
|
126
|
+
if utils.match_response(http_res, "429", "application/json"):
|
|
127
|
+
response_data = utils.unmarshal_json(
|
|
128
|
+
http_res.text, errors.RateLimitExceededData
|
|
129
|
+
)
|
|
130
|
+
raise errors.RateLimitExceeded(data=response_data)
|
|
131
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
132
|
+
response_data = utils.unmarshal_json(
|
|
133
|
+
http_res.text, errors.InternalServerErrorData
|
|
134
|
+
)
|
|
135
|
+
raise errors.InternalServerError(data=response_data)
|
|
136
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
137
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
138
|
+
raise errors.SDKError(
|
|
139
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
140
|
+
)
|
|
141
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
142
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
143
|
+
raise errors.SDKError(
|
|
144
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
content_type = http_res.headers.get("Content-Type")
|
|
148
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
149
|
+
raise errors.SDKError(
|
|
150
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
151
|
+
http_res.status_code,
|
|
152
|
+
http_res_text,
|
|
153
|
+
http_res,
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
async def list_async(
|
|
157
|
+
self,
|
|
158
|
+
*,
|
|
159
|
+
request: Union[
|
|
160
|
+
operations.ListCommissionsRequest,
|
|
161
|
+
operations.ListCommissionsRequestTypedDict,
|
|
162
|
+
],
|
|
163
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
164
|
+
server_url: Optional[str] = None,
|
|
165
|
+
timeout_ms: Optional[int] = None,
|
|
166
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
167
|
+
) -> Optional[List[operations.ListCommissionsResponseBody]]:
|
|
168
|
+
r"""Get commissions for a program.
|
|
169
|
+
|
|
170
|
+
Retrieve a list of commissions for a program.
|
|
171
|
+
|
|
172
|
+
:param request: The request object to send.
|
|
173
|
+
:param retries: Override the default retry configuration for this method
|
|
174
|
+
:param server_url: Override the default server URL for this method
|
|
175
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
176
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
177
|
+
"""
|
|
178
|
+
base_url = None
|
|
179
|
+
url_variables = None
|
|
180
|
+
if timeout_ms is None:
|
|
181
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
182
|
+
|
|
183
|
+
if server_url is not None:
|
|
184
|
+
base_url = server_url
|
|
185
|
+
else:
|
|
186
|
+
base_url = self._get_url(base_url, url_variables)
|
|
187
|
+
|
|
188
|
+
if not isinstance(request, BaseModel):
|
|
189
|
+
request = utils.unmarshal(request, operations.ListCommissionsRequest)
|
|
190
|
+
request = cast(operations.ListCommissionsRequest, request)
|
|
191
|
+
|
|
192
|
+
req = self._build_request_async(
|
|
193
|
+
method="GET",
|
|
194
|
+
path="/commissions",
|
|
195
|
+
base_url=base_url,
|
|
196
|
+
url_variables=url_variables,
|
|
197
|
+
request=request,
|
|
198
|
+
request_body_required=False,
|
|
199
|
+
request_has_path_params=False,
|
|
200
|
+
request_has_query_params=True,
|
|
201
|
+
user_agent_header="user-agent",
|
|
202
|
+
accept_header_value="application/json",
|
|
203
|
+
http_headers=http_headers,
|
|
204
|
+
security=self.sdk_configuration.security,
|
|
205
|
+
timeout_ms=timeout_ms,
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
if retries == UNSET:
|
|
209
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
210
|
+
retries = self.sdk_configuration.retry_config
|
|
211
|
+
|
|
212
|
+
retry_config = None
|
|
213
|
+
if isinstance(retries, utils.RetryConfig):
|
|
214
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
215
|
+
|
|
216
|
+
http_res = await self.do_request_async(
|
|
217
|
+
hook_ctx=HookContext(
|
|
218
|
+
base_url=base_url or "",
|
|
219
|
+
operation_id="listCommissions",
|
|
220
|
+
oauth2_scopes=[],
|
|
221
|
+
security_source=self.sdk_configuration.security,
|
|
222
|
+
),
|
|
223
|
+
request=req,
|
|
224
|
+
error_status_codes=[
|
|
225
|
+
"400",
|
|
226
|
+
"401",
|
|
227
|
+
"403",
|
|
228
|
+
"404",
|
|
229
|
+
"409",
|
|
230
|
+
"410",
|
|
231
|
+
"422",
|
|
232
|
+
"429",
|
|
233
|
+
"4XX",
|
|
234
|
+
"500",
|
|
235
|
+
"5XX",
|
|
236
|
+
],
|
|
237
|
+
retry_config=retry_config,
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
response_data: Any = None
|
|
241
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
242
|
+
return utils.unmarshal_json(
|
|
243
|
+
http_res.text, Optional[List[operations.ListCommissionsResponseBody]]
|
|
244
|
+
)
|
|
245
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
246
|
+
response_data = utils.unmarshal_json(http_res.text, errors.BadRequestData)
|
|
247
|
+
raise errors.BadRequest(data=response_data)
|
|
248
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
249
|
+
response_data = utils.unmarshal_json(http_res.text, errors.UnauthorizedData)
|
|
250
|
+
raise errors.Unauthorized(data=response_data)
|
|
251
|
+
if utils.match_response(http_res, "403", "application/json"):
|
|
252
|
+
response_data = utils.unmarshal_json(http_res.text, errors.ForbiddenData)
|
|
253
|
+
raise errors.Forbidden(data=response_data)
|
|
254
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
255
|
+
response_data = utils.unmarshal_json(http_res.text, errors.NotFoundData)
|
|
256
|
+
raise errors.NotFound(data=response_data)
|
|
257
|
+
if utils.match_response(http_res, "409", "application/json"):
|
|
258
|
+
response_data = utils.unmarshal_json(http_res.text, errors.ConflictData)
|
|
259
|
+
raise errors.Conflict(data=response_data)
|
|
260
|
+
if utils.match_response(http_res, "410", "application/json"):
|
|
261
|
+
response_data = utils.unmarshal_json(
|
|
262
|
+
http_res.text, errors.InviteExpiredData
|
|
263
|
+
)
|
|
264
|
+
raise errors.InviteExpired(data=response_data)
|
|
265
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
266
|
+
response_data = utils.unmarshal_json(
|
|
267
|
+
http_res.text, errors.UnprocessableEntityData
|
|
268
|
+
)
|
|
269
|
+
raise errors.UnprocessableEntity(data=response_data)
|
|
270
|
+
if utils.match_response(http_res, "429", "application/json"):
|
|
271
|
+
response_data = utils.unmarshal_json(
|
|
272
|
+
http_res.text, errors.RateLimitExceededData
|
|
273
|
+
)
|
|
274
|
+
raise errors.RateLimitExceeded(data=response_data)
|
|
275
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
276
|
+
response_data = utils.unmarshal_json(
|
|
277
|
+
http_res.text, errors.InternalServerErrorData
|
|
278
|
+
)
|
|
279
|
+
raise errors.InternalServerError(data=response_data)
|
|
280
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
281
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
282
|
+
raise errors.SDKError(
|
|
283
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
284
|
+
)
|
|
285
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
286
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
287
|
+
raise errors.SDKError(
|
|
288
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
content_type = http_res.headers.get("Content-Type")
|
|
292
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
293
|
+
raise errors.SDKError(
|
|
294
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
295
|
+
http_res.status_code,
|
|
296
|
+
http_res_text,
|
|
297
|
+
http_res,
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
def update(
|
|
301
|
+
self,
|
|
302
|
+
*,
|
|
303
|
+
request: Union[
|
|
304
|
+
operations.UpdateCommissionRequest,
|
|
305
|
+
operations.UpdateCommissionRequestTypedDict,
|
|
306
|
+
],
|
|
307
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
308
|
+
server_url: Optional[str] = None,
|
|
309
|
+
timeout_ms: Optional[int] = None,
|
|
310
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
311
|
+
) -> Optional[operations.UpdateCommissionResponseBody]:
|
|
312
|
+
r"""Update a commission.
|
|
313
|
+
|
|
314
|
+
Update an existing commission amount. This is useful for handling refunds (partial or full) or fraudulent sales.
|
|
315
|
+
|
|
316
|
+
:param request: The request object to send.
|
|
317
|
+
:param retries: Override the default retry configuration for this method
|
|
318
|
+
:param server_url: Override the default server URL for this method
|
|
319
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
320
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
321
|
+
"""
|
|
322
|
+
base_url = None
|
|
323
|
+
url_variables = None
|
|
324
|
+
if timeout_ms is None:
|
|
325
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
326
|
+
|
|
327
|
+
if server_url is not None:
|
|
328
|
+
base_url = server_url
|
|
329
|
+
else:
|
|
330
|
+
base_url = self._get_url(base_url, url_variables)
|
|
331
|
+
|
|
332
|
+
if not isinstance(request, BaseModel):
|
|
333
|
+
request = utils.unmarshal(request, operations.UpdateCommissionRequest)
|
|
334
|
+
request = cast(operations.UpdateCommissionRequest, request)
|
|
335
|
+
|
|
336
|
+
req = self._build_request(
|
|
337
|
+
method="PATCH",
|
|
338
|
+
path="/commissions/{id}",
|
|
339
|
+
base_url=base_url,
|
|
340
|
+
url_variables=url_variables,
|
|
341
|
+
request=request,
|
|
342
|
+
request_body_required=False,
|
|
343
|
+
request_has_path_params=True,
|
|
344
|
+
request_has_query_params=True,
|
|
345
|
+
user_agent_header="user-agent",
|
|
346
|
+
accept_header_value="application/json",
|
|
347
|
+
http_headers=http_headers,
|
|
348
|
+
security=self.sdk_configuration.security,
|
|
349
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
350
|
+
request.request_body,
|
|
351
|
+
False,
|
|
352
|
+
True,
|
|
353
|
+
"json",
|
|
354
|
+
Optional[operations.UpdateCommissionRequestBody],
|
|
355
|
+
),
|
|
356
|
+
timeout_ms=timeout_ms,
|
|
357
|
+
)
|
|
358
|
+
|
|
359
|
+
if retries == UNSET:
|
|
360
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
361
|
+
retries = self.sdk_configuration.retry_config
|
|
362
|
+
|
|
363
|
+
retry_config = None
|
|
364
|
+
if isinstance(retries, utils.RetryConfig):
|
|
365
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
366
|
+
|
|
367
|
+
http_res = self.do_request(
|
|
368
|
+
hook_ctx=HookContext(
|
|
369
|
+
base_url=base_url or "",
|
|
370
|
+
operation_id="updateCommission",
|
|
371
|
+
oauth2_scopes=[],
|
|
372
|
+
security_source=self.sdk_configuration.security,
|
|
373
|
+
),
|
|
374
|
+
request=req,
|
|
375
|
+
error_status_codes=[
|
|
376
|
+
"400",
|
|
377
|
+
"401",
|
|
378
|
+
"403",
|
|
379
|
+
"404",
|
|
380
|
+
"409",
|
|
381
|
+
"410",
|
|
382
|
+
"422",
|
|
383
|
+
"429",
|
|
384
|
+
"4XX",
|
|
385
|
+
"500",
|
|
386
|
+
"5XX",
|
|
387
|
+
],
|
|
388
|
+
retry_config=retry_config,
|
|
389
|
+
)
|
|
390
|
+
|
|
391
|
+
response_data: Any = None
|
|
392
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
393
|
+
return utils.unmarshal_json(
|
|
394
|
+
http_res.text, Optional[operations.UpdateCommissionResponseBody]
|
|
395
|
+
)
|
|
396
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
397
|
+
response_data = utils.unmarshal_json(http_res.text, errors.BadRequestData)
|
|
398
|
+
raise errors.BadRequest(data=response_data)
|
|
399
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
400
|
+
response_data = utils.unmarshal_json(http_res.text, errors.UnauthorizedData)
|
|
401
|
+
raise errors.Unauthorized(data=response_data)
|
|
402
|
+
if utils.match_response(http_res, "403", "application/json"):
|
|
403
|
+
response_data = utils.unmarshal_json(http_res.text, errors.ForbiddenData)
|
|
404
|
+
raise errors.Forbidden(data=response_data)
|
|
405
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
406
|
+
response_data = utils.unmarshal_json(http_res.text, errors.NotFoundData)
|
|
407
|
+
raise errors.NotFound(data=response_data)
|
|
408
|
+
if utils.match_response(http_res, "409", "application/json"):
|
|
409
|
+
response_data = utils.unmarshal_json(http_res.text, errors.ConflictData)
|
|
410
|
+
raise errors.Conflict(data=response_data)
|
|
411
|
+
if utils.match_response(http_res, "410", "application/json"):
|
|
412
|
+
response_data = utils.unmarshal_json(
|
|
413
|
+
http_res.text, errors.InviteExpiredData
|
|
414
|
+
)
|
|
415
|
+
raise errors.InviteExpired(data=response_data)
|
|
416
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
417
|
+
response_data = utils.unmarshal_json(
|
|
418
|
+
http_res.text, errors.UnprocessableEntityData
|
|
419
|
+
)
|
|
420
|
+
raise errors.UnprocessableEntity(data=response_data)
|
|
421
|
+
if utils.match_response(http_res, "429", "application/json"):
|
|
422
|
+
response_data = utils.unmarshal_json(
|
|
423
|
+
http_res.text, errors.RateLimitExceededData
|
|
424
|
+
)
|
|
425
|
+
raise errors.RateLimitExceeded(data=response_data)
|
|
426
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
427
|
+
response_data = utils.unmarshal_json(
|
|
428
|
+
http_res.text, errors.InternalServerErrorData
|
|
429
|
+
)
|
|
430
|
+
raise errors.InternalServerError(data=response_data)
|
|
431
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
432
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
433
|
+
raise errors.SDKError(
|
|
434
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
435
|
+
)
|
|
436
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
437
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
438
|
+
raise errors.SDKError(
|
|
439
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
440
|
+
)
|
|
441
|
+
|
|
442
|
+
content_type = http_res.headers.get("Content-Type")
|
|
443
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
444
|
+
raise errors.SDKError(
|
|
445
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
446
|
+
http_res.status_code,
|
|
447
|
+
http_res_text,
|
|
448
|
+
http_res,
|
|
449
|
+
)
|
|
450
|
+
|
|
451
|
+
async def update_async(
|
|
452
|
+
self,
|
|
453
|
+
*,
|
|
454
|
+
request: Union[
|
|
455
|
+
operations.UpdateCommissionRequest,
|
|
456
|
+
operations.UpdateCommissionRequestTypedDict,
|
|
457
|
+
],
|
|
458
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
459
|
+
server_url: Optional[str] = None,
|
|
460
|
+
timeout_ms: Optional[int] = None,
|
|
461
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
462
|
+
) -> Optional[operations.UpdateCommissionResponseBody]:
|
|
463
|
+
r"""Update a commission.
|
|
464
|
+
|
|
465
|
+
Update an existing commission amount. This is useful for handling refunds (partial or full) or fraudulent sales.
|
|
466
|
+
|
|
467
|
+
:param request: The request object to send.
|
|
468
|
+
:param retries: Override the default retry configuration for this method
|
|
469
|
+
:param server_url: Override the default server URL for this method
|
|
470
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
471
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
472
|
+
"""
|
|
473
|
+
base_url = None
|
|
474
|
+
url_variables = None
|
|
475
|
+
if timeout_ms is None:
|
|
476
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
477
|
+
|
|
478
|
+
if server_url is not None:
|
|
479
|
+
base_url = server_url
|
|
480
|
+
else:
|
|
481
|
+
base_url = self._get_url(base_url, url_variables)
|
|
482
|
+
|
|
483
|
+
if not isinstance(request, BaseModel):
|
|
484
|
+
request = utils.unmarshal(request, operations.UpdateCommissionRequest)
|
|
485
|
+
request = cast(operations.UpdateCommissionRequest, request)
|
|
486
|
+
|
|
487
|
+
req = self._build_request_async(
|
|
488
|
+
method="PATCH",
|
|
489
|
+
path="/commissions/{id}",
|
|
490
|
+
base_url=base_url,
|
|
491
|
+
url_variables=url_variables,
|
|
492
|
+
request=request,
|
|
493
|
+
request_body_required=False,
|
|
494
|
+
request_has_path_params=True,
|
|
495
|
+
request_has_query_params=True,
|
|
496
|
+
user_agent_header="user-agent",
|
|
497
|
+
accept_header_value="application/json",
|
|
498
|
+
http_headers=http_headers,
|
|
499
|
+
security=self.sdk_configuration.security,
|
|
500
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
501
|
+
request.request_body,
|
|
502
|
+
False,
|
|
503
|
+
True,
|
|
504
|
+
"json",
|
|
505
|
+
Optional[operations.UpdateCommissionRequestBody],
|
|
506
|
+
),
|
|
507
|
+
timeout_ms=timeout_ms,
|
|
508
|
+
)
|
|
509
|
+
|
|
510
|
+
if retries == UNSET:
|
|
511
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
512
|
+
retries = self.sdk_configuration.retry_config
|
|
513
|
+
|
|
514
|
+
retry_config = None
|
|
515
|
+
if isinstance(retries, utils.RetryConfig):
|
|
516
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
517
|
+
|
|
518
|
+
http_res = await self.do_request_async(
|
|
519
|
+
hook_ctx=HookContext(
|
|
520
|
+
base_url=base_url or "",
|
|
521
|
+
operation_id="updateCommission",
|
|
522
|
+
oauth2_scopes=[],
|
|
523
|
+
security_source=self.sdk_configuration.security,
|
|
524
|
+
),
|
|
525
|
+
request=req,
|
|
526
|
+
error_status_codes=[
|
|
527
|
+
"400",
|
|
528
|
+
"401",
|
|
529
|
+
"403",
|
|
530
|
+
"404",
|
|
531
|
+
"409",
|
|
532
|
+
"410",
|
|
533
|
+
"422",
|
|
534
|
+
"429",
|
|
535
|
+
"4XX",
|
|
536
|
+
"500",
|
|
537
|
+
"5XX",
|
|
538
|
+
],
|
|
539
|
+
retry_config=retry_config,
|
|
540
|
+
)
|
|
541
|
+
|
|
542
|
+
response_data: Any = None
|
|
543
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
544
|
+
return utils.unmarshal_json(
|
|
545
|
+
http_res.text, Optional[operations.UpdateCommissionResponseBody]
|
|
546
|
+
)
|
|
547
|
+
if utils.match_response(http_res, "400", "application/json"):
|
|
548
|
+
response_data = utils.unmarshal_json(http_res.text, errors.BadRequestData)
|
|
549
|
+
raise errors.BadRequest(data=response_data)
|
|
550
|
+
if utils.match_response(http_res, "401", "application/json"):
|
|
551
|
+
response_data = utils.unmarshal_json(http_res.text, errors.UnauthorizedData)
|
|
552
|
+
raise errors.Unauthorized(data=response_data)
|
|
553
|
+
if utils.match_response(http_res, "403", "application/json"):
|
|
554
|
+
response_data = utils.unmarshal_json(http_res.text, errors.ForbiddenData)
|
|
555
|
+
raise errors.Forbidden(data=response_data)
|
|
556
|
+
if utils.match_response(http_res, "404", "application/json"):
|
|
557
|
+
response_data = utils.unmarshal_json(http_res.text, errors.NotFoundData)
|
|
558
|
+
raise errors.NotFound(data=response_data)
|
|
559
|
+
if utils.match_response(http_res, "409", "application/json"):
|
|
560
|
+
response_data = utils.unmarshal_json(http_res.text, errors.ConflictData)
|
|
561
|
+
raise errors.Conflict(data=response_data)
|
|
562
|
+
if utils.match_response(http_res, "410", "application/json"):
|
|
563
|
+
response_data = utils.unmarshal_json(
|
|
564
|
+
http_res.text, errors.InviteExpiredData
|
|
565
|
+
)
|
|
566
|
+
raise errors.InviteExpired(data=response_data)
|
|
567
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
568
|
+
response_data = utils.unmarshal_json(
|
|
569
|
+
http_res.text, errors.UnprocessableEntityData
|
|
570
|
+
)
|
|
571
|
+
raise errors.UnprocessableEntity(data=response_data)
|
|
572
|
+
if utils.match_response(http_res, "429", "application/json"):
|
|
573
|
+
response_data = utils.unmarshal_json(
|
|
574
|
+
http_res.text, errors.RateLimitExceededData
|
|
575
|
+
)
|
|
576
|
+
raise errors.RateLimitExceeded(data=response_data)
|
|
577
|
+
if utils.match_response(http_res, "500", "application/json"):
|
|
578
|
+
response_data = utils.unmarshal_json(
|
|
579
|
+
http_res.text, errors.InternalServerErrorData
|
|
580
|
+
)
|
|
581
|
+
raise errors.InternalServerError(data=response_data)
|
|
582
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
583
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
584
|
+
raise errors.SDKError(
|
|
585
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
586
|
+
)
|
|
587
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
588
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
589
|
+
raise errors.SDKError(
|
|
590
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
591
|
+
)
|
|
592
|
+
|
|
593
|
+
content_type = http_res.headers.get("Content-Type")
|
|
594
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
595
|
+
raise errors.SDKError(
|
|
596
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
597
|
+
http_res.status_code,
|
|
598
|
+
http_res_text,
|
|
599
|
+
http_res,
|
|
600
|
+
)
|
dub/httpclient.py
CHANGED
|
@@ -115,42 +115,12 @@ def close_clients(
|
|
|
115
115
|
pass
|
|
116
116
|
|
|
117
117
|
if async_client is not None and not async_client_supplied:
|
|
118
|
-
# First, try the simplest approach - use asyncio.run()
|
|
119
|
-
# This works when we're not in an async context
|
|
120
118
|
try:
|
|
121
|
-
asyncio.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
loop = asyncio.get_running_loop()
|
|
129
|
-
# Create a task but don't wait for it
|
|
130
|
-
loop.create_task(async_client.aclose())
|
|
131
|
-
except Exception:
|
|
132
|
-
# If we can't get the loop or create a task, just ignore
|
|
133
|
-
# The GC will eventually clean up the resources
|
|
134
|
-
pass
|
|
135
|
-
# If we get "RuntimeError: There is no current event loop in thread",
|
|
136
|
-
# we're not in an async context, but asyncio.run() failed for some reason
|
|
137
|
-
# In this case, we can try to create a new event loop explicitly
|
|
138
|
-
elif "no current event loop" in str(e):
|
|
139
|
-
try:
|
|
140
|
-
# Create a new event loop and run the coroutine
|
|
141
|
-
loop = asyncio.new_event_loop()
|
|
142
|
-
asyncio.set_event_loop(loop)
|
|
143
|
-
try:
|
|
144
|
-
loop.run_until_complete(async_client.aclose())
|
|
145
|
-
finally:
|
|
146
|
-
loop.close()
|
|
147
|
-
asyncio.set_event_loop(None)
|
|
148
|
-
except Exception:
|
|
149
|
-
# If this also fails, just ignore
|
|
150
|
-
pass
|
|
151
|
-
# For any other RuntimeError, just ignore
|
|
152
|
-
else:
|
|
119
|
+
loop = asyncio.get_running_loop()
|
|
120
|
+
asyncio.run_coroutine_threadsafe(async_client.aclose(), loop)
|
|
121
|
+
except RuntimeError:
|
|
122
|
+
try:
|
|
123
|
+
asyncio.run(async_client.aclose())
|
|
124
|
+
except RuntimeError:
|
|
125
|
+
# best effort
|
|
153
126
|
pass
|
|
154
|
-
except Exception:
|
|
155
|
-
# For any other exception, just ignore
|
|
156
|
-
pass
|