moovio_sdk 0.11.6__py3-none-any.whl → 0.13.0__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.
Files changed (144) hide show
  1. moovio_sdk/_version.py +3 -3
  2. moovio_sdk/account_terminal_applications.py +70 -186
  3. moovio_sdk/accounts.py +168 -408
  4. moovio_sdk/adjustments.py +28 -84
  5. moovio_sdk/apple_pay.py +102 -236
  6. moovio_sdk/authentication.py +50 -102
  7. moovio_sdk/avatars.py +10 -38
  8. moovio_sdk/bank_accounts.py +174 -420
  9. moovio_sdk/basesdk.py +4 -4
  10. moovio_sdk/branding.py +106 -198
  11. moovio_sdk/capabilities.py +76 -180
  12. moovio_sdk/card_issuing.py +94 -228
  13. moovio_sdk/cards.py +94 -232
  14. moovio_sdk/disputes.py +204 -500
  15. moovio_sdk/end_to_end_encryption.py +28 -80
  16. moovio_sdk/enriched_address.py +14 -44
  17. moovio_sdk/enriched_profile.py +14 -44
  18. moovio_sdk/fee_plans.py +116 -314
  19. moovio_sdk/files.py +52 -138
  20. moovio_sdk/industries.py +14 -44
  21. moovio_sdk/institutions.py +36 -92
  22. moovio_sdk/issuing_transactions.py +70 -220
  23. moovio_sdk/models/components/__init__.py +244 -0
  24. moovio_sdk/models/components/businesspresence.py +13 -0
  25. moovio_sdk/models/components/cardacceptancemethods.py +37 -0
  26. moovio_sdk/models/components/cardacceptancemethodserror.py +27 -0
  27. moovio_sdk/models/components/collectfunds.py +25 -0
  28. moovio_sdk/models/components/collectfundsach.py +18 -0
  29. moovio_sdk/models/components/collectfundsacherror.py +21 -0
  30. moovio_sdk/models/components/collectfundscardpayments.py +41 -0
  31. moovio_sdk/models/components/collectfundscardpaymentserror.py +43 -0
  32. moovio_sdk/models/components/collectfundserror.py +25 -0
  33. moovio_sdk/models/components/createdtransfer.py +5 -0
  34. moovio_sdk/models/components/createticket.py +24 -0
  35. moovio_sdk/models/components/createticketcontacterror.py +17 -0
  36. moovio_sdk/models/components/createtransfer.py +5 -0
  37. moovio_sdk/models/components/estimatedactivity.py +30 -0
  38. moovio_sdk/models/components/estimatedactivityerror.py +27 -0
  39. moovio_sdk/models/components/fulfillment.py +19 -0
  40. moovio_sdk/models/components/fulfillmenterror.py +17 -0
  41. moovio_sdk/models/components/fulfillmentmethod.py +16 -0
  42. moovio_sdk/models/components/fulfillmenttimeframe.py +15 -0
  43. moovio_sdk/models/components/geographicreach.py +10 -0
  44. moovio_sdk/models/components/moneytransfer.py +30 -0
  45. moovio_sdk/models/components/moneytransfererror.py +30 -0
  46. moovio_sdk/models/components/moneytransferpullfromcard.py +18 -0
  47. moovio_sdk/models/components/moneytransferpullfromcarderror.py +21 -0
  48. moovio_sdk/models/components/moneytransferpushtocard.py +18 -0
  49. moovio_sdk/models/components/moneytransferpushtocarderror.py +21 -0
  50. moovio_sdk/models/components/monthlyvolumerange.py +17 -0
  51. moovio_sdk/models/components/pendinglitigation.py +17 -0
  52. moovio_sdk/models/components/refundpolicy.py +16 -0
  53. moovio_sdk/models/components/sendfunds.py +26 -0
  54. moovio_sdk/models/components/sendfundsach.py +18 -0
  55. moovio_sdk/models/components/sendfundsacherror.py +21 -0
  56. moovio_sdk/models/components/sendfundserror.py +29 -0
  57. moovio_sdk/models/components/sendfundspushtocard.py +18 -0
  58. moovio_sdk/models/components/sendfundspushtocarderror.py +21 -0
  59. moovio_sdk/models/components/sendfundsrtp.py +18 -0
  60. moovio_sdk/models/components/sendfundsrtperror.py +21 -0
  61. moovio_sdk/models/components/ticket.py +44 -0
  62. moovio_sdk/models/components/ticketcontact.py +17 -0
  63. moovio_sdk/models/components/ticketmessage.py +21 -0
  64. moovio_sdk/models/components/ticketstatus.py +11 -0
  65. moovio_sdk/models/components/transfer.py +5 -0
  66. moovio_sdk/models/components/underwriting.py +67 -20
  67. moovio_sdk/models/components/updateticket.py +19 -0
  68. moovio_sdk/models/components/updateticketstatus.py +8 -0
  69. moovio_sdk/models/components/upsertunderwriting.py +56 -0
  70. moovio_sdk/models/components/volumesharebycustomertype.py +20 -0
  71. moovio_sdk/models/components/volumesharebycustomertypeerror.py +20 -0
  72. moovio_sdk/models/components/webhookdata.py +10 -10
  73. moovio_sdk/models/components/webhookdatatransfercreated.py +5 -1
  74. moovio_sdk/models/components/webhookdatatransferupdated.py +5 -1
  75. moovio_sdk/models/errors/__init__.py +27 -0
  76. moovio_sdk/models/errors/accountterminalapplicationerror.py +11 -6
  77. moovio_sdk/models/errors/addcapabilitieserror.py +11 -6
  78. moovio_sdk/models/errors/apierror.py +30 -14
  79. moovio_sdk/models/errors/assigncountrieserror.py +12 -6
  80. moovio_sdk/models/errors/authtokenrequesterror.py +11 -6
  81. moovio_sdk/models/errors/bankaccountvalidationerror.py +11 -6
  82. moovio_sdk/models/errors/brandvalidationerror.py +11 -6
  83. moovio_sdk/models/errors/cardacquiringrefund.py +11 -6
  84. moovio_sdk/models/errors/createaccount.py +12 -6
  85. moovio_sdk/models/errors/createpaymentlinkerror.py +11 -6
  86. moovio_sdk/models/errors/createsweepconfigerror.py +11 -6
  87. moovio_sdk/models/errors/createticketerror.py +34 -0
  88. moovio_sdk/models/errors/feeplanagreementerror.py +11 -6
  89. moovio_sdk/models/errors/fileuploadvalidationerror.py +11 -6
  90. moovio_sdk/models/errors/filevalidationerror.py +11 -6
  91. moovio_sdk/models/errors/genericerror.py +12 -6
  92. moovio_sdk/models/errors/linkapplepayerror.py +11 -6
  93. moovio_sdk/models/errors/linkcarderror.py +11 -6
  94. moovio_sdk/models/errors/microdepositvalidationerror.py +11 -6
  95. moovio_sdk/models/errors/mooverror.py +26 -0
  96. moovio_sdk/models/errors/no_response_error.py +13 -0
  97. moovio_sdk/models/errors/onboardinginviteerror.py +11 -6
  98. moovio_sdk/models/errors/patchsweepconfigerror.py +11 -6
  99. moovio_sdk/models/errors/refundvalidationerror.py +11 -6
  100. moovio_sdk/models/errors/representativevalidationerror.py +11 -6
  101. moovio_sdk/models/errors/requestcarderror.py +11 -6
  102. moovio_sdk/models/errors/responsevalidationerror.py +25 -0
  103. moovio_sdk/models/errors/reversalvalidationerror.py +11 -6
  104. moovio_sdk/models/errors/revoketokenrequesterror.py +11 -6
  105. moovio_sdk/models/errors/schedulevalidationerror.py +11 -6
  106. moovio_sdk/models/errors/terminalapplicationerror.py +11 -6
  107. moovio_sdk/models/errors/transfer.py +14 -6
  108. moovio_sdk/models/errors/transferoptionsvalidationerror.py +11 -6
  109. moovio_sdk/models/errors/transfervalidationerror.py +11 -6
  110. moovio_sdk/models/errors/updateaccount.py +12 -6
  111. moovio_sdk/models/errors/updatecarderror.py +11 -6
  112. moovio_sdk/models/errors/updateissuedcarderror.py +11 -6
  113. moovio_sdk/models/errors/updatepaymentlinkerror.py +11 -6
  114. moovio_sdk/models/errors/updateticketerror.py +25 -0
  115. moovio_sdk/models/errors/updateunderwritingerror.py +11 -6
  116. moovio_sdk/models/errors/upsertunderwritingerror.py +94 -0
  117. moovio_sdk/models/operations/__init__.py +120 -0
  118. moovio_sdk/models/operations/createticket.py +78 -0
  119. moovio_sdk/models/operations/getticket.py +71 -0
  120. moovio_sdk/models/operations/listticketmessages.py +88 -0
  121. moovio_sdk/models/operations/listtickets.py +81 -0
  122. moovio_sdk/models/operations/listtransfers.py +9 -0
  123. moovio_sdk/models/operations/saveunderwriting.py +78 -0
  124. moovio_sdk/models/operations/updateticket.py +85 -0
  125. moovio_sdk/onboarding.py +66 -166
  126. moovio_sdk/payment_links.py +106 -272
  127. moovio_sdk/payment_methods.py +30 -86
  128. moovio_sdk/ping.py +10 -40
  129. moovio_sdk/receipts.py +36 -92
  130. moovio_sdk/representatives.py +102 -228
  131. moovio_sdk/scheduling.py +122 -278
  132. moovio_sdk/sdk.py +3 -0
  133. moovio_sdk/support.py +1153 -0
  134. moovio_sdk/sweeps.py +102 -274
  135. moovio_sdk/terminal_applications.py +74 -186
  136. moovio_sdk/transfers.py +278 -582
  137. moovio_sdk/underwriting.py +378 -92
  138. moovio_sdk/utils/__init__.py +3 -0
  139. moovio_sdk/utils/serializers.py +21 -3
  140. moovio_sdk/wallet_transactions.py +28 -88
  141. moovio_sdk/wallets.py +24 -84
  142. {moovio_sdk-0.11.6.dist-info → moovio_sdk-0.13.0.dist-info}/METADATA +109 -28
  143. {moovio_sdk-0.11.6.dist-info → moovio_sdk-0.13.0.dist-info}/RECORD +144 -87
  144. {moovio_sdk-0.11.6.dist-info → moovio_sdk-0.13.0.dist-info}/WHEEL +0 -0
@@ -90,38 +90,23 @@ class Underwriting(BaseSDK):
90
90
 
91
91
  if utils.match_response(http_res, "200", "application/json"):
92
92
  return operations.GetUnderwritingResponse(
93
- result=utils.unmarshal_json(http_res.text, components.Underwriting),
93
+ result=utils.unmarshal_json_response(components.Underwriting, http_res),
94
94
  headers=utils.get_response_headers(http_res.headers),
95
95
  )
96
96
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
97
97
  http_res_text = utils.stream_to_text(http_res)
98
- raise errors.APIError(
99
- "API error occurred", http_res.status_code, http_res_text, http_res
100
- )
98
+ raise errors.APIError("API error occurred", http_res, http_res_text)
101
99
  if utils.match_response(http_res, ["500", "504"], "*"):
102
100
  http_res_text = utils.stream_to_text(http_res)
103
- raise errors.APIError(
104
- "API error occurred", http_res.status_code, http_res_text, http_res
105
- )
101
+ raise errors.APIError("API error occurred", http_res, http_res_text)
106
102
  if utils.match_response(http_res, "4XX", "*"):
107
103
  http_res_text = utils.stream_to_text(http_res)
108
- raise errors.APIError(
109
- "API error occurred", http_res.status_code, http_res_text, http_res
110
- )
104
+ raise errors.APIError("API error occurred", http_res, http_res_text)
111
105
  if utils.match_response(http_res, "5XX", "*"):
112
106
  http_res_text = utils.stream_to_text(http_res)
113
- raise errors.APIError(
114
- "API error occurred", http_res.status_code, http_res_text, http_res
115
- )
107
+ raise errors.APIError("API error occurred", http_res, http_res_text)
116
108
 
117
- content_type = http_res.headers.get("Content-Type")
118
- http_res_text = utils.stream_to_text(http_res)
119
- raise errors.APIError(
120
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
121
- http_res.status_code,
122
- http_res_text,
123
- http_res,
124
- )
109
+ raise errors.APIError("Unexpected response received", http_res)
125
110
 
126
111
  async def get_async(
127
112
  self,
@@ -203,39 +188,366 @@ class Underwriting(BaseSDK):
203
188
 
204
189
  if utils.match_response(http_res, "200", "application/json"):
205
190
  return operations.GetUnderwritingResponse(
206
- result=utils.unmarshal_json(http_res.text, components.Underwriting),
191
+ result=utils.unmarshal_json_response(components.Underwriting, http_res),
207
192
  headers=utils.get_response_headers(http_res.headers),
208
193
  )
209
194
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
210
195
  http_res_text = await utils.stream_to_text_async(http_res)
211
- raise errors.APIError(
212
- "API error occurred", http_res.status_code, http_res_text, http_res
213
- )
196
+ raise errors.APIError("API error occurred", http_res, http_res_text)
214
197
  if utils.match_response(http_res, ["500", "504"], "*"):
215
198
  http_res_text = await utils.stream_to_text_async(http_res)
216
- raise errors.APIError(
217
- "API error occurred", http_res.status_code, http_res_text, http_res
218
- )
199
+ raise errors.APIError("API error occurred", http_res, http_res_text)
219
200
  if utils.match_response(http_res, "4XX", "*"):
220
201
  http_res_text = await utils.stream_to_text_async(http_res)
221
- raise errors.APIError(
222
- "API error occurred", http_res.status_code, http_res_text, http_res
223
- )
202
+ raise errors.APIError("API error occurred", http_res, http_res_text)
224
203
  if utils.match_response(http_res, "5XX", "*"):
225
204
  http_res_text = await utils.stream_to_text_async(http_res)
226
- raise errors.APIError(
227
- "API error occurred", http_res.status_code, http_res_text, http_res
205
+ raise errors.APIError("API error occurred", http_res, http_res_text)
206
+
207
+ raise errors.APIError("Unexpected response received", http_res)
208
+
209
+ def save(
210
+ self,
211
+ *,
212
+ account_id: str,
213
+ geographic_reach: Optional[components.GeographicReach] = None,
214
+ business_presence: Optional[components.BusinessPresence] = None,
215
+ pending_litigation: Optional[components.PendingLitigation] = None,
216
+ volume_share_by_customer_type: Optional[
217
+ Union[
218
+ components.VolumeShareByCustomerType,
219
+ components.VolumeShareByCustomerTypeTypedDict,
220
+ ]
221
+ ] = None,
222
+ collect_funds: Optional[
223
+ Union[components.CollectFunds, components.CollectFundsTypedDict]
224
+ ] = None,
225
+ money_transfer: Optional[
226
+ Union[components.MoneyTransfer, components.MoneyTransferTypedDict]
227
+ ] = None,
228
+ send_funds: Optional[
229
+ Union[components.SendFunds, components.SendFundsTypedDict]
230
+ ] = None,
231
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
232
+ server_url: Optional[str] = None,
233
+ timeout_ms: Optional[int] = None,
234
+ http_headers: Optional[Mapping[str, str]] = None,
235
+ ) -> operations.SaveUnderwritingResponse:
236
+ r"""Create or update the account's underwriting.
237
+
238
+ Read our [underwriting guide](https://docs.moov.io/guides/accounts/requirements/underwriting/) to learn more.
239
+
240
+ To access this endpoint using an [access token](https://docs.moov.io/api/authentication/access-tokens/)
241
+ you'll need to specify the `/accounts/{accountID}/profile.write` scope.
242
+
243
+ :param account_id:
244
+ :param geographic_reach:
245
+ :param business_presence:
246
+ :param pending_litigation:
247
+ :param volume_share_by_customer_type:
248
+ :param collect_funds:
249
+ :param money_transfer:
250
+ :param send_funds:
251
+ :param retries: Override the default retry configuration for this method
252
+ :param server_url: Override the default server URL for this method
253
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
254
+ :param http_headers: Additional headers to set or replace on requests.
255
+ """
256
+ base_url = None
257
+ url_variables = None
258
+ if timeout_ms is None:
259
+ timeout_ms = self.sdk_configuration.timeout_ms
260
+
261
+ if server_url is not None:
262
+ base_url = server_url
263
+ else:
264
+ base_url = self._get_url(base_url, url_variables)
265
+
266
+ request = operations.SaveUnderwritingRequest(
267
+ account_id=account_id,
268
+ upsert_underwriting=components.UpsertUnderwriting(
269
+ geographic_reach=geographic_reach,
270
+ business_presence=business_presence,
271
+ pending_litigation=pending_litigation,
272
+ volume_share_by_customer_type=utils.get_pydantic_model(
273
+ volume_share_by_customer_type,
274
+ Optional[components.VolumeShareByCustomerType],
275
+ ),
276
+ collect_funds=utils.get_pydantic_model(
277
+ collect_funds, Optional[components.CollectFunds]
278
+ ),
279
+ money_transfer=utils.get_pydantic_model(
280
+ money_transfer, Optional[components.MoneyTransfer]
281
+ ),
282
+ send_funds=utils.get_pydantic_model(
283
+ send_funds, Optional[components.SendFunds]
284
+ ),
285
+ ),
286
+ )
287
+
288
+ req = self._build_request(
289
+ method="POST",
290
+ path="/accounts/{accountID}/underwriting",
291
+ base_url=base_url,
292
+ url_variables=url_variables,
293
+ request=request,
294
+ request_body_required=True,
295
+ request_has_path_params=True,
296
+ request_has_query_params=True,
297
+ user_agent_header="user-agent",
298
+ accept_header_value="application/json",
299
+ http_headers=http_headers,
300
+ _globals=operations.SaveUnderwritingGlobals(
301
+ x_moov_version=self.sdk_configuration.globals.x_moov_version,
302
+ ),
303
+ security=self.sdk_configuration.security,
304
+ get_serialized_body=lambda: utils.serialize_request_body(
305
+ request.upsert_underwriting,
306
+ False,
307
+ False,
308
+ "json",
309
+ components.UpsertUnderwriting,
310
+ ),
311
+ timeout_ms=timeout_ms,
312
+ )
313
+
314
+ if retries == UNSET:
315
+ if self.sdk_configuration.retry_config is not UNSET:
316
+ retries = self.sdk_configuration.retry_config
317
+
318
+ retry_config = None
319
+ if isinstance(retries, utils.RetryConfig):
320
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
321
+
322
+ http_res = self.do_request(
323
+ hook_ctx=HookContext(
324
+ config=self.sdk_configuration,
325
+ base_url=base_url or "",
326
+ operation_id="saveUnderwriting",
327
+ oauth2_scopes=[],
328
+ security_source=get_security_from_env(
329
+ self.sdk_configuration.security, components.Security
330
+ ),
331
+ ),
332
+ request=req,
333
+ error_status_codes=[
334
+ "400",
335
+ "401",
336
+ "403",
337
+ "404",
338
+ "409",
339
+ "422",
340
+ "429",
341
+ "4XX",
342
+ "500",
343
+ "504",
344
+ "5XX",
345
+ ],
346
+ retry_config=retry_config,
347
+ )
348
+
349
+ response_data: Any = None
350
+ if utils.match_response(http_res, "200", "application/json"):
351
+ return operations.SaveUnderwritingResponse(
352
+ result=utils.unmarshal_json_response(components.Underwriting, http_res),
353
+ headers=utils.get_response_headers(http_res.headers),
354
+ )
355
+ if utils.match_response(http_res, ["400", "409"], "application/json"):
356
+ response_data = utils.unmarshal_json_response(
357
+ errors.GenericErrorData, http_res
358
+ )
359
+ raise errors.GenericError(response_data, http_res)
360
+ if utils.match_response(http_res, "422", "application/json"):
361
+ response_data = utils.unmarshal_json_response(
362
+ errors.UpsertUnderwritingErrorData, http_res
228
363
  )
364
+ raise errors.UpsertUnderwritingError(response_data, http_res)
365
+ if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
366
+ http_res_text = utils.stream_to_text(http_res)
367
+ raise errors.APIError("API error occurred", http_res, http_res_text)
368
+ if utils.match_response(http_res, ["500", "504"], "*"):
369
+ http_res_text = utils.stream_to_text(http_res)
370
+ raise errors.APIError("API error occurred", http_res, http_res_text)
371
+ if utils.match_response(http_res, "4XX", "*"):
372
+ http_res_text = utils.stream_to_text(http_res)
373
+ raise errors.APIError("API error occurred", http_res, http_res_text)
374
+ if utils.match_response(http_res, "5XX", "*"):
375
+ http_res_text = utils.stream_to_text(http_res)
376
+ raise errors.APIError("API error occurred", http_res, http_res_text)
377
+
378
+ raise errors.APIError("Unexpected response received", http_res)
379
+
380
+ async def save_async(
381
+ self,
382
+ *,
383
+ account_id: str,
384
+ geographic_reach: Optional[components.GeographicReach] = None,
385
+ business_presence: Optional[components.BusinessPresence] = None,
386
+ pending_litigation: Optional[components.PendingLitigation] = None,
387
+ volume_share_by_customer_type: Optional[
388
+ Union[
389
+ components.VolumeShareByCustomerType,
390
+ components.VolumeShareByCustomerTypeTypedDict,
391
+ ]
392
+ ] = None,
393
+ collect_funds: Optional[
394
+ Union[components.CollectFunds, components.CollectFundsTypedDict]
395
+ ] = None,
396
+ money_transfer: Optional[
397
+ Union[components.MoneyTransfer, components.MoneyTransferTypedDict]
398
+ ] = None,
399
+ send_funds: Optional[
400
+ Union[components.SendFunds, components.SendFundsTypedDict]
401
+ ] = None,
402
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
403
+ server_url: Optional[str] = None,
404
+ timeout_ms: Optional[int] = None,
405
+ http_headers: Optional[Mapping[str, str]] = None,
406
+ ) -> operations.SaveUnderwritingResponse:
407
+ r"""Create or update the account's underwriting.
229
408
 
230
- content_type = http_res.headers.get("Content-Type")
231
- http_res_text = await utils.stream_to_text_async(http_res)
232
- raise errors.APIError(
233
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
234
- http_res.status_code,
235
- http_res_text,
236
- http_res,
409
+ Read our [underwriting guide](https://docs.moov.io/guides/accounts/requirements/underwriting/) to learn more.
410
+
411
+ To access this endpoint using an [access token](https://docs.moov.io/api/authentication/access-tokens/)
412
+ you'll need to specify the `/accounts/{accountID}/profile.write` scope.
413
+
414
+ :param account_id:
415
+ :param geographic_reach:
416
+ :param business_presence:
417
+ :param pending_litigation:
418
+ :param volume_share_by_customer_type:
419
+ :param collect_funds:
420
+ :param money_transfer:
421
+ :param send_funds:
422
+ :param retries: Override the default retry configuration for this method
423
+ :param server_url: Override the default server URL for this method
424
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
425
+ :param http_headers: Additional headers to set or replace on requests.
426
+ """
427
+ base_url = None
428
+ url_variables = None
429
+ if timeout_ms is None:
430
+ timeout_ms = self.sdk_configuration.timeout_ms
431
+
432
+ if server_url is not None:
433
+ base_url = server_url
434
+ else:
435
+ base_url = self._get_url(base_url, url_variables)
436
+
437
+ request = operations.SaveUnderwritingRequest(
438
+ account_id=account_id,
439
+ upsert_underwriting=components.UpsertUnderwriting(
440
+ geographic_reach=geographic_reach,
441
+ business_presence=business_presence,
442
+ pending_litigation=pending_litigation,
443
+ volume_share_by_customer_type=utils.get_pydantic_model(
444
+ volume_share_by_customer_type,
445
+ Optional[components.VolumeShareByCustomerType],
446
+ ),
447
+ collect_funds=utils.get_pydantic_model(
448
+ collect_funds, Optional[components.CollectFunds]
449
+ ),
450
+ money_transfer=utils.get_pydantic_model(
451
+ money_transfer, Optional[components.MoneyTransfer]
452
+ ),
453
+ send_funds=utils.get_pydantic_model(
454
+ send_funds, Optional[components.SendFunds]
455
+ ),
456
+ ),
457
+ )
458
+
459
+ req = self._build_request_async(
460
+ method="POST",
461
+ path="/accounts/{accountID}/underwriting",
462
+ base_url=base_url,
463
+ url_variables=url_variables,
464
+ request=request,
465
+ request_body_required=True,
466
+ request_has_path_params=True,
467
+ request_has_query_params=True,
468
+ user_agent_header="user-agent",
469
+ accept_header_value="application/json",
470
+ http_headers=http_headers,
471
+ _globals=operations.SaveUnderwritingGlobals(
472
+ x_moov_version=self.sdk_configuration.globals.x_moov_version,
473
+ ),
474
+ security=self.sdk_configuration.security,
475
+ get_serialized_body=lambda: utils.serialize_request_body(
476
+ request.upsert_underwriting,
477
+ False,
478
+ False,
479
+ "json",
480
+ components.UpsertUnderwriting,
481
+ ),
482
+ timeout_ms=timeout_ms,
237
483
  )
238
484
 
485
+ if retries == UNSET:
486
+ if self.sdk_configuration.retry_config is not UNSET:
487
+ retries = self.sdk_configuration.retry_config
488
+
489
+ retry_config = None
490
+ if isinstance(retries, utils.RetryConfig):
491
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
492
+
493
+ http_res = await self.do_request_async(
494
+ hook_ctx=HookContext(
495
+ config=self.sdk_configuration,
496
+ base_url=base_url or "",
497
+ operation_id="saveUnderwriting",
498
+ oauth2_scopes=[],
499
+ security_source=get_security_from_env(
500
+ self.sdk_configuration.security, components.Security
501
+ ),
502
+ ),
503
+ request=req,
504
+ error_status_codes=[
505
+ "400",
506
+ "401",
507
+ "403",
508
+ "404",
509
+ "409",
510
+ "422",
511
+ "429",
512
+ "4XX",
513
+ "500",
514
+ "504",
515
+ "5XX",
516
+ ],
517
+ retry_config=retry_config,
518
+ )
519
+
520
+ response_data: Any = None
521
+ if utils.match_response(http_res, "200", "application/json"):
522
+ return operations.SaveUnderwritingResponse(
523
+ result=utils.unmarshal_json_response(components.Underwriting, http_res),
524
+ headers=utils.get_response_headers(http_res.headers),
525
+ )
526
+ if utils.match_response(http_res, ["400", "409"], "application/json"):
527
+ response_data = utils.unmarshal_json_response(
528
+ errors.GenericErrorData, http_res
529
+ )
530
+ raise errors.GenericError(response_data, http_res)
531
+ if utils.match_response(http_res, "422", "application/json"):
532
+ response_data = utils.unmarshal_json_response(
533
+ errors.UpsertUnderwritingErrorData, http_res
534
+ )
535
+ raise errors.UpsertUnderwritingError(response_data, http_res)
536
+ if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
537
+ http_res_text = await utils.stream_to_text_async(http_res)
538
+ raise errors.APIError("API error occurred", http_res, http_res_text)
539
+ if utils.match_response(http_res, ["500", "504"], "*"):
540
+ http_res_text = await utils.stream_to_text_async(http_res)
541
+ raise errors.APIError("API error occurred", http_res, http_res_text)
542
+ if utils.match_response(http_res, "4XX", "*"):
543
+ http_res_text = await utils.stream_to_text_async(http_res)
544
+ raise errors.APIError("API error occurred", http_res, http_res_text)
545
+ if utils.match_response(http_res, "5XX", "*"):
546
+ http_res_text = await utils.stream_to_text_async(http_res)
547
+ raise errors.APIError("API error occurred", http_res, http_res_text)
548
+
549
+ raise errors.APIError("Unexpected response received", http_res)
550
+
239
551
  def upsert(
240
552
  self,
241
553
  *,
@@ -369,46 +681,33 @@ class Underwriting(BaseSDK):
369
681
  response_data: Any = None
370
682
  if utils.match_response(http_res, "200", "application/json"):
371
683
  return operations.UpsertUnderwritingResponse(
372
- result=utils.unmarshal_json(http_res.text, components.Underwriting),
684
+ result=utils.unmarshal_json_response(components.Underwriting, http_res),
373
685
  headers=utils.get_response_headers(http_res.headers),
374
686
  )
375
687
  if utils.match_response(http_res, ["400", "409"], "application/json"):
376
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
377
- raise errors.GenericError(data=response_data)
688
+ response_data = utils.unmarshal_json_response(
689
+ errors.GenericErrorData, http_res
690
+ )
691
+ raise errors.GenericError(response_data, http_res)
378
692
  if utils.match_response(http_res, "422", "application/json"):
379
- response_data = utils.unmarshal_json(
380
- http_res.text, errors.UpdateUnderwritingErrorData
693
+ response_data = utils.unmarshal_json_response(
694
+ errors.UpdateUnderwritingErrorData, http_res
381
695
  )
382
- raise errors.UpdateUnderwritingError(data=response_data)
696
+ raise errors.UpdateUnderwritingError(response_data, http_res)
383
697
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
384
698
  http_res_text = utils.stream_to_text(http_res)
385
- raise errors.APIError(
386
- "API error occurred", http_res.status_code, http_res_text, http_res
387
- )
699
+ raise errors.APIError("API error occurred", http_res, http_res_text)
388
700
  if utils.match_response(http_res, ["500", "504"], "*"):
389
701
  http_res_text = utils.stream_to_text(http_res)
390
- raise errors.APIError(
391
- "API error occurred", http_res.status_code, http_res_text, http_res
392
- )
702
+ raise errors.APIError("API error occurred", http_res, http_res_text)
393
703
  if utils.match_response(http_res, "4XX", "*"):
394
704
  http_res_text = utils.stream_to_text(http_res)
395
- raise errors.APIError(
396
- "API error occurred", http_res.status_code, http_res_text, http_res
397
- )
705
+ raise errors.APIError("API error occurred", http_res, http_res_text)
398
706
  if utils.match_response(http_res, "5XX", "*"):
399
707
  http_res_text = utils.stream_to_text(http_res)
400
- raise errors.APIError(
401
- "API error occurred", http_res.status_code, http_res_text, http_res
402
- )
708
+ raise errors.APIError("API error occurred", http_res, http_res_text)
403
709
 
404
- content_type = http_res.headers.get("Content-Type")
405
- http_res_text = utils.stream_to_text(http_res)
406
- raise errors.APIError(
407
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
408
- http_res.status_code,
409
- http_res_text,
410
- http_res,
411
- )
710
+ raise errors.APIError("Unexpected response received", http_res)
412
711
 
413
712
  async def upsert_async(
414
713
  self,
@@ -543,43 +842,30 @@ class Underwriting(BaseSDK):
543
842
  response_data: Any = None
544
843
  if utils.match_response(http_res, "200", "application/json"):
545
844
  return operations.UpsertUnderwritingResponse(
546
- result=utils.unmarshal_json(http_res.text, components.Underwriting),
845
+ result=utils.unmarshal_json_response(components.Underwriting, http_res),
547
846
  headers=utils.get_response_headers(http_res.headers),
548
847
  )
549
848
  if utils.match_response(http_res, ["400", "409"], "application/json"):
550
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
551
- raise errors.GenericError(data=response_data)
849
+ response_data = utils.unmarshal_json_response(
850
+ errors.GenericErrorData, http_res
851
+ )
852
+ raise errors.GenericError(response_data, http_res)
552
853
  if utils.match_response(http_res, "422", "application/json"):
553
- response_data = utils.unmarshal_json(
554
- http_res.text, errors.UpdateUnderwritingErrorData
854
+ response_data = utils.unmarshal_json_response(
855
+ errors.UpdateUnderwritingErrorData, http_res
555
856
  )
556
- raise errors.UpdateUnderwritingError(data=response_data)
857
+ raise errors.UpdateUnderwritingError(response_data, http_res)
557
858
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
558
859
  http_res_text = await utils.stream_to_text_async(http_res)
559
- raise errors.APIError(
560
- "API error occurred", http_res.status_code, http_res_text, http_res
561
- )
860
+ raise errors.APIError("API error occurred", http_res, http_res_text)
562
861
  if utils.match_response(http_res, ["500", "504"], "*"):
563
862
  http_res_text = await utils.stream_to_text_async(http_res)
564
- raise errors.APIError(
565
- "API error occurred", http_res.status_code, http_res_text, http_res
566
- )
863
+ raise errors.APIError("API error occurred", http_res, http_res_text)
567
864
  if utils.match_response(http_res, "4XX", "*"):
568
865
  http_res_text = await utils.stream_to_text_async(http_res)
569
- raise errors.APIError(
570
- "API error occurred", http_res.status_code, http_res_text, http_res
571
- )
866
+ raise errors.APIError("API error occurred", http_res, http_res_text)
572
867
  if utils.match_response(http_res, "5XX", "*"):
573
868
  http_res_text = await utils.stream_to_text_async(http_res)
574
- raise errors.APIError(
575
- "API error occurred", http_res.status_code, http_res_text, http_res
576
- )
869
+ raise errors.APIError("API error occurred", http_res, http_res_text)
577
870
 
578
- content_type = http_res.headers.get("Content-Type")
579
- http_res_text = await utils.stream_to_text_async(http_res)
580
- raise errors.APIError(
581
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
582
- http_res.status_code,
583
- http_res_text,
584
- http_res,
585
- )
871
+ raise errors.APIError("Unexpected response received", http_res)
@@ -29,6 +29,7 @@ if TYPE_CHECKING:
29
29
  marshal_json,
30
30
  unmarshal,
31
31
  unmarshal_json,
32
+ unmarshal_json_response,
32
33
  serialize_decimal,
33
34
  serialize_float,
34
35
  serialize_int,
@@ -98,6 +99,7 @@ __all__ = [
98
99
  "template_url",
99
100
  "unmarshal",
100
101
  "unmarshal_json",
102
+ "unmarshal_json_response",
101
103
  "validate_decimal",
102
104
  "validate_const",
103
105
  "validate_float",
@@ -152,6 +154,7 @@ _dynamic_imports: dict[str, str] = {
152
154
  "template_url": ".url",
153
155
  "unmarshal": ".serializers",
154
156
  "unmarshal_json": ".serializers",
157
+ "unmarshal_json_response": ".serializers",
155
158
  "validate_decimal": ".serializers",
156
159
  "validate_const": ".serializers",
157
160
  "validate_float": ".serializers",
@@ -4,7 +4,7 @@ from decimal import Decimal
4
4
  import functools
5
5
  import json
6
6
  import typing
7
- from typing import Any, Dict, List, Tuple, Union, get_args
7
+ from typing import Any, Dict, List, Optional, Tuple, Union, get_args
8
8
  import typing_extensions
9
9
  from typing_extensions import get_origin
10
10
 
@@ -13,6 +13,7 @@ from pydantic import ConfigDict, create_model
13
13
  from pydantic_core import from_json
14
14
 
15
15
  from ..types.basemodel import BaseModel, Nullable, OptionalNullable, Unset
16
+ from moovio_sdk.models import errors
16
17
 
17
18
 
18
19
  def serialize_decimal(as_str: bool):
@@ -140,6 +141,22 @@ def unmarshal_json(raw, typ: Any) -> Any:
140
141
  return unmarshal(from_json(raw), typ)
141
142
 
142
143
 
144
+ def unmarshal_json_response(
145
+ typ: Any, http_res: httpx.Response, body: Optional[str] = None
146
+ ) -> Any:
147
+ if body is None:
148
+ body = http_res.text
149
+ try:
150
+ return unmarshal_json(body, typ)
151
+ except Exception as e:
152
+ raise errors.ResponseValidationError(
153
+ "Response validation failed",
154
+ http_res,
155
+ e,
156
+ body,
157
+ ) from e
158
+
159
+
143
160
  def unmarshal(val, typ: Any) -> Any:
144
161
  unmarshaller = create_model(
145
162
  "Unmarshaller",
@@ -192,7 +209,9 @@ def is_union(obj: object) -> bool:
192
209
  """
193
210
  Returns True if the given object is a typing.Union or typing_extensions.Union.
194
211
  """
195
- return any(obj is typing_obj for typing_obj in _get_typing_objects_by_name_of("Union"))
212
+ return any(
213
+ obj is typing_obj for typing_obj in _get_typing_objects_by_name_of("Union")
214
+ )
196
215
 
197
216
 
198
217
  def stream_to_text(stream: httpx.Response) -> str:
@@ -245,4 +264,3 @@ def _get_typing_objects_by_name_of(name: str) -> Tuple[Any, ...]:
245
264
  f"Neither typing nor typing_extensions has an object called {name!r}"
246
265
  )
247
266
  return result
248
-