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
moovio_sdk/transfers.py CHANGED
@@ -133,46 +133,35 @@ class Transfers(BaseSDK):
133
133
  response_data: Any = None
134
134
  if utils.match_response(http_res, "200", "application/json"):
135
135
  return operations.CreateTransferOptionsForAccountResponse(
136
- result=utils.unmarshal_json(http_res.text, components.TransferOptions),
136
+ result=utils.unmarshal_json_response(
137
+ components.TransferOptions, http_res
138
+ ),
137
139
  headers=utils.get_response_headers(http_res.headers),
138
140
  )
139
141
  if utils.match_response(http_res, "400", "application/json"):
140
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
141
- raise errors.GenericError(data=response_data)
142
+ response_data = utils.unmarshal_json_response(
143
+ errors.GenericErrorData, http_res
144
+ )
145
+ raise errors.GenericError(response_data, http_res)
142
146
  if utils.match_response(http_res, "422", "application/json"):
143
- response_data = utils.unmarshal_json(
144
- http_res.text, errors.TransferOptionsValidationErrorData
147
+ response_data = utils.unmarshal_json_response(
148
+ errors.TransferOptionsValidationErrorData, http_res
145
149
  )
146
- raise errors.TransferOptionsValidationError(data=response_data)
150
+ raise errors.TransferOptionsValidationError(response_data, http_res)
147
151
  if utils.match_response(http_res, ["401", "403", "429"], "*"):
148
152
  http_res_text = utils.stream_to_text(http_res)
149
- raise errors.APIError(
150
- "API error occurred", http_res.status_code, http_res_text, http_res
151
- )
153
+ raise errors.APIError("API error occurred", http_res, http_res_text)
152
154
  if utils.match_response(http_res, ["500", "504"], "*"):
153
155
  http_res_text = utils.stream_to_text(http_res)
154
- raise errors.APIError(
155
- "API error occurred", http_res.status_code, http_res_text, http_res
156
- )
156
+ raise errors.APIError("API error occurred", http_res, http_res_text)
157
157
  if utils.match_response(http_res, "4XX", "*"):
158
158
  http_res_text = utils.stream_to_text(http_res)
159
- raise errors.APIError(
160
- "API error occurred", http_res.status_code, http_res_text, http_res
161
- )
159
+ raise errors.APIError("API error occurred", http_res, http_res_text)
162
160
  if utils.match_response(http_res, "5XX", "*"):
163
161
  http_res_text = utils.stream_to_text(http_res)
164
- raise errors.APIError(
165
- "API error occurred", http_res.status_code, http_res_text, http_res
166
- )
162
+ raise errors.APIError("API error occurred", http_res, http_res_text)
167
163
 
168
- content_type = http_res.headers.get("Content-Type")
169
- http_res_text = utils.stream_to_text(http_res)
170
- raise errors.APIError(
171
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
172
- http_res.status_code,
173
- http_res_text,
174
- http_res,
175
- )
164
+ raise errors.APIError("Unexpected response received", http_res)
176
165
 
177
166
  async def generate_options_for_account_async(
178
167
  self,
@@ -296,46 +285,35 @@ class Transfers(BaseSDK):
296
285
  response_data: Any = None
297
286
  if utils.match_response(http_res, "200", "application/json"):
298
287
  return operations.CreateTransferOptionsForAccountResponse(
299
- result=utils.unmarshal_json(http_res.text, components.TransferOptions),
288
+ result=utils.unmarshal_json_response(
289
+ components.TransferOptions, http_res
290
+ ),
300
291
  headers=utils.get_response_headers(http_res.headers),
301
292
  )
302
293
  if utils.match_response(http_res, "400", "application/json"):
303
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
304
- raise errors.GenericError(data=response_data)
294
+ response_data = utils.unmarshal_json_response(
295
+ errors.GenericErrorData, http_res
296
+ )
297
+ raise errors.GenericError(response_data, http_res)
305
298
  if utils.match_response(http_res, "422", "application/json"):
306
- response_data = utils.unmarshal_json(
307
- http_res.text, errors.TransferOptionsValidationErrorData
299
+ response_data = utils.unmarshal_json_response(
300
+ errors.TransferOptionsValidationErrorData, http_res
308
301
  )
309
- raise errors.TransferOptionsValidationError(data=response_data)
302
+ raise errors.TransferOptionsValidationError(response_data, http_res)
310
303
  if utils.match_response(http_res, ["401", "403", "429"], "*"):
311
304
  http_res_text = await utils.stream_to_text_async(http_res)
312
- raise errors.APIError(
313
- "API error occurred", http_res.status_code, http_res_text, http_res
314
- )
305
+ raise errors.APIError("API error occurred", http_res, http_res_text)
315
306
  if utils.match_response(http_res, ["500", "504"], "*"):
316
307
  http_res_text = await utils.stream_to_text_async(http_res)
317
- raise errors.APIError(
318
- "API error occurred", http_res.status_code, http_res_text, http_res
319
- )
308
+ raise errors.APIError("API error occurred", http_res, http_res_text)
320
309
  if utils.match_response(http_res, "4XX", "*"):
321
310
  http_res_text = await utils.stream_to_text_async(http_res)
322
- raise errors.APIError(
323
- "API error occurred", http_res.status_code, http_res_text, http_res
324
- )
311
+ raise errors.APIError("API error occurred", http_res, http_res_text)
325
312
  if utils.match_response(http_res, "5XX", "*"):
326
313
  http_res_text = await utils.stream_to_text_async(http_res)
327
- raise errors.APIError(
328
- "API error occurred", http_res.status_code, http_res_text, http_res
329
- )
314
+ raise errors.APIError("API error occurred", http_res, http_res_text)
330
315
 
331
- content_type = http_res.headers.get("Content-Type")
332
- http_res_text = await utils.stream_to_text_async(http_res)
333
- raise errors.APIError(
334
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
335
- http_res.status_code,
336
- http_res_text,
337
- http_res,
338
- )
316
+ raise errors.APIError("Unexpected response received", http_res)
339
317
 
340
318
  def create(
341
319
  self,
@@ -359,6 +337,7 @@ class Transfers(BaseSDK):
359
337
  sales_tax_amount: Optional[
360
338
  Union[components.Amount, components.AmountTypedDict]
361
339
  ] = None,
340
+ foreign_id: Optional[str] = None,
362
341
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
363
342
  server_url: Optional[str] = None,
364
343
  timeout_ms: Optional[int] = None,
@@ -381,6 +360,7 @@ class Transfers(BaseSDK):
381
360
  :param description: An optional description of the transfer that is used on receipts and for your own internal use.
382
361
  :param metadata: Free-form key-value pair list. Useful for storing information that is not captured elsewhere.
383
362
  :param sales_tax_amount: Optional sales tax amount. `transfer.amount.value` should be inclusive of any sales tax and represents the total amount charged.
363
+ :param foreign_id: Optional alias from a foreign/external system which can be used to reference this resource.
384
364
  :param retries: Override the default retry configuration for this method
385
365
  :param server_url: Override the default server URL for this method
386
366
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -416,6 +396,7 @@ class Transfers(BaseSDK):
416
396
  sales_tax_amount=utils.get_pydantic_model(
417
397
  sales_tax_amount, Optional[components.Amount]
418
398
  ),
399
+ foreign_id=foreign_id,
419
400
  ),
420
401
  )
421
402
 
@@ -477,59 +458,50 @@ class Transfers(BaseSDK):
477
458
  response_data: Any = None
478
459
  if utils.match_response(http_res, "200", "application/json"):
479
460
  return operations.CreateTransferResponse(
480
- result=utils.unmarshal_json(http_res.text, components.CreatedTransfer),
461
+ result=utils.unmarshal_json_response(
462
+ components.CreatedTransfer, http_res
463
+ ),
481
464
  headers=utils.get_response_headers(http_res.headers),
482
465
  )
483
466
  if utils.match_response(http_res, "201", "application/json"):
484
467
  return operations.CreateTransferResponse(
485
- result=utils.unmarshal_json(http_res.text, components.AsyncTransfer),
468
+ result=utils.unmarshal_json_response(
469
+ components.AsyncTransfer, http_res
470
+ ),
486
471
  headers=utils.get_response_headers(http_res.headers),
487
472
  )
488
473
  if utils.match_response(http_res, "202", "application/json"):
489
474
  return operations.CreateTransferResponse(
490
- result=utils.unmarshal_json(http_res.text, components.Transfer),
475
+ result=utils.unmarshal_json_response(components.Transfer, http_res),
491
476
  headers=utils.get_response_headers(http_res.headers),
492
477
  )
493
478
  if utils.match_response(http_res, "400", "application/json"):
494
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
495
- raise errors.GenericError(data=response_data)
479
+ response_data = utils.unmarshal_json_response(
480
+ errors.GenericErrorData, http_res
481
+ )
482
+ raise errors.GenericError(response_data, http_res)
496
483
  if utils.match_response(http_res, "409", "application/json"):
497
- response_data = utils.unmarshal_json(http_res.text, errors.TransferData)
498
- raise errors.Transfer(data=response_data)
484
+ response_data = utils.unmarshal_json_response(errors.TransferData, http_res)
485
+ raise errors.Transfer(response_data, http_res)
499
486
  if utils.match_response(http_res, "422", "application/json"):
500
- response_data = utils.unmarshal_json(
501
- http_res.text, errors.TransferValidationErrorData
487
+ response_data = utils.unmarshal_json_response(
488
+ errors.TransferValidationErrorData, http_res
502
489
  )
503
- raise errors.TransferValidationError(data=response_data)
490
+ raise errors.TransferValidationError(response_data, http_res)
504
491
  if utils.match_response(http_res, ["404", "429"], "*"):
505
492
  http_res_text = utils.stream_to_text(http_res)
506
- raise errors.APIError(
507
- "API error occurred", http_res.status_code, http_res_text, http_res
508
- )
493
+ raise errors.APIError("API error occurred", http_res, http_res_text)
509
494
  if utils.match_response(http_res, ["500", "504"], "*"):
510
495
  http_res_text = utils.stream_to_text(http_res)
511
- raise errors.APIError(
512
- "API error occurred", http_res.status_code, http_res_text, http_res
513
- )
496
+ raise errors.APIError("API error occurred", http_res, http_res_text)
514
497
  if utils.match_response(http_res, "4XX", "*"):
515
498
  http_res_text = utils.stream_to_text(http_res)
516
- raise errors.APIError(
517
- "API error occurred", http_res.status_code, http_res_text, http_res
518
- )
499
+ raise errors.APIError("API error occurred", http_res, http_res_text)
519
500
  if utils.match_response(http_res, "5XX", "*"):
520
501
  http_res_text = utils.stream_to_text(http_res)
521
- raise errors.APIError(
522
- "API error occurred", http_res.status_code, http_res_text, http_res
523
- )
502
+ raise errors.APIError("API error occurred", http_res, http_res_text)
524
503
 
525
- content_type = http_res.headers.get("Content-Type")
526
- http_res_text = utils.stream_to_text(http_res)
527
- raise errors.APIError(
528
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
529
- http_res.status_code,
530
- http_res_text,
531
- http_res,
532
- )
504
+ raise errors.APIError("Unexpected response received", http_res)
533
505
 
534
506
  async def create_async(
535
507
  self,
@@ -553,6 +525,7 @@ class Transfers(BaseSDK):
553
525
  sales_tax_amount: Optional[
554
526
  Union[components.Amount, components.AmountTypedDict]
555
527
  ] = None,
528
+ foreign_id: Optional[str] = None,
556
529
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
557
530
  server_url: Optional[str] = None,
558
531
  timeout_ms: Optional[int] = None,
@@ -575,6 +548,7 @@ class Transfers(BaseSDK):
575
548
  :param description: An optional description of the transfer that is used on receipts and for your own internal use.
576
549
  :param metadata: Free-form key-value pair list. Useful for storing information that is not captured elsewhere.
577
550
  :param sales_tax_amount: Optional sales tax amount. `transfer.amount.value` should be inclusive of any sales tax and represents the total amount charged.
551
+ :param foreign_id: Optional alias from a foreign/external system which can be used to reference this resource.
578
552
  :param retries: Override the default retry configuration for this method
579
553
  :param server_url: Override the default server URL for this method
580
554
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -610,6 +584,7 @@ class Transfers(BaseSDK):
610
584
  sales_tax_amount=utils.get_pydantic_model(
611
585
  sales_tax_amount, Optional[components.Amount]
612
586
  ),
587
+ foreign_id=foreign_id,
613
588
  ),
614
589
  )
615
590
 
@@ -671,59 +646,50 @@ class Transfers(BaseSDK):
671
646
  response_data: Any = None
672
647
  if utils.match_response(http_res, "200", "application/json"):
673
648
  return operations.CreateTransferResponse(
674
- result=utils.unmarshal_json(http_res.text, components.CreatedTransfer),
649
+ result=utils.unmarshal_json_response(
650
+ components.CreatedTransfer, http_res
651
+ ),
675
652
  headers=utils.get_response_headers(http_res.headers),
676
653
  )
677
654
  if utils.match_response(http_res, "201", "application/json"):
678
655
  return operations.CreateTransferResponse(
679
- result=utils.unmarshal_json(http_res.text, components.AsyncTransfer),
656
+ result=utils.unmarshal_json_response(
657
+ components.AsyncTransfer, http_res
658
+ ),
680
659
  headers=utils.get_response_headers(http_res.headers),
681
660
  )
682
661
  if utils.match_response(http_res, "202", "application/json"):
683
662
  return operations.CreateTransferResponse(
684
- result=utils.unmarshal_json(http_res.text, components.Transfer),
663
+ result=utils.unmarshal_json_response(components.Transfer, http_res),
685
664
  headers=utils.get_response_headers(http_res.headers),
686
665
  )
687
666
  if utils.match_response(http_res, "400", "application/json"):
688
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
689
- raise errors.GenericError(data=response_data)
667
+ response_data = utils.unmarshal_json_response(
668
+ errors.GenericErrorData, http_res
669
+ )
670
+ raise errors.GenericError(response_data, http_res)
690
671
  if utils.match_response(http_res, "409", "application/json"):
691
- response_data = utils.unmarshal_json(http_res.text, errors.TransferData)
692
- raise errors.Transfer(data=response_data)
672
+ response_data = utils.unmarshal_json_response(errors.TransferData, http_res)
673
+ raise errors.Transfer(response_data, http_res)
693
674
  if utils.match_response(http_res, "422", "application/json"):
694
- response_data = utils.unmarshal_json(
695
- http_res.text, errors.TransferValidationErrorData
675
+ response_data = utils.unmarshal_json_response(
676
+ errors.TransferValidationErrorData, http_res
696
677
  )
697
- raise errors.TransferValidationError(data=response_data)
678
+ raise errors.TransferValidationError(response_data, http_res)
698
679
  if utils.match_response(http_res, ["404", "429"], "*"):
699
680
  http_res_text = await utils.stream_to_text_async(http_res)
700
- raise errors.APIError(
701
- "API error occurred", http_res.status_code, http_res_text, http_res
702
- )
681
+ raise errors.APIError("API error occurred", http_res, http_res_text)
703
682
  if utils.match_response(http_res, ["500", "504"], "*"):
704
683
  http_res_text = await utils.stream_to_text_async(http_res)
705
- raise errors.APIError(
706
- "API error occurred", http_res.status_code, http_res_text, http_res
707
- )
684
+ raise errors.APIError("API error occurred", http_res, http_res_text)
708
685
  if utils.match_response(http_res, "4XX", "*"):
709
686
  http_res_text = await utils.stream_to_text_async(http_res)
710
- raise errors.APIError(
711
- "API error occurred", http_res.status_code, http_res_text, http_res
712
- )
687
+ raise errors.APIError("API error occurred", http_res, http_res_text)
713
688
  if utils.match_response(http_res, "5XX", "*"):
714
689
  http_res_text = await utils.stream_to_text_async(http_res)
715
- raise errors.APIError(
716
- "API error occurred", http_res.status_code, http_res_text, http_res
717
- )
690
+ raise errors.APIError("API error occurred", http_res, http_res_text)
718
691
 
719
- content_type = http_res.headers.get("Content-Type")
720
- http_res_text = await utils.stream_to_text_async(http_res)
721
- raise errors.APIError(
722
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
723
- http_res.status_code,
724
- http_res_text,
725
- http_res,
726
- )
692
+ raise errors.APIError("Unexpected response received", http_res)
727
693
 
728
694
  def list(
729
695
  self,
@@ -738,6 +704,7 @@ class Transfers(BaseSDK):
738
704
  payment_link_code: Optional[str] = None,
739
705
  refunded: Optional[bool] = None,
740
706
  disputed: Optional[bool] = None,
707
+ foreign_id: Optional[str] = None,
741
708
  skip: Optional[int] = None,
742
709
  count: Optional[int] = None,
743
710
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
@@ -767,6 +734,7 @@ class Transfers(BaseSDK):
767
734
  :param payment_link_code: Optional code to filter for transfers associated with the payment link.
768
735
  :param refunded: Optional parameter to only return refunded transfers.
769
736
  :param disputed: Optional parameter to only return disputed transfers.
737
+ :param foreign_id: Optional alias from a foreign/external system which can be used to reference this resource.
770
738
  :param skip:
771
739
  :param count:
772
740
  :param retries: Override the default retry configuration for this method
@@ -794,6 +762,7 @@ class Transfers(BaseSDK):
794
762
  payment_link_code=payment_link_code,
795
763
  refunded=refunded,
796
764
  disputed=disputed,
765
+ foreign_id=foreign_id,
797
766
  skip=skip,
798
767
  count=count,
799
768
  account_id=account_id,
@@ -843,38 +812,25 @@ class Transfers(BaseSDK):
843
812
 
844
813
  if utils.match_response(http_res, "200", "application/json"):
845
814
  return operations.ListTransfersResponse(
846
- result=utils.unmarshal_json(http_res.text, List[components.Transfer]),
815
+ result=utils.unmarshal_json_response(
816
+ List[components.Transfer], http_res
817
+ ),
847
818
  headers=utils.get_response_headers(http_res.headers),
848
819
  )
849
820
  if utils.match_response(http_res, ["401", "403", "429"], "*"):
850
821
  http_res_text = utils.stream_to_text(http_res)
851
- raise errors.APIError(
852
- "API error occurred", http_res.status_code, http_res_text, http_res
853
- )
822
+ raise errors.APIError("API error occurred", http_res, http_res_text)
854
823
  if utils.match_response(http_res, ["500", "504"], "*"):
855
824
  http_res_text = utils.stream_to_text(http_res)
856
- raise errors.APIError(
857
- "API error occurred", http_res.status_code, http_res_text, http_res
858
- )
825
+ raise errors.APIError("API error occurred", http_res, http_res_text)
859
826
  if utils.match_response(http_res, "4XX", "*"):
860
827
  http_res_text = utils.stream_to_text(http_res)
861
- raise errors.APIError(
862
- "API error occurred", http_res.status_code, http_res_text, http_res
863
- )
828
+ raise errors.APIError("API error occurred", http_res, http_res_text)
864
829
  if utils.match_response(http_res, "5XX", "*"):
865
830
  http_res_text = utils.stream_to_text(http_res)
866
- raise errors.APIError(
867
- "API error occurred", http_res.status_code, http_res_text, http_res
868
- )
831
+ raise errors.APIError("API error occurred", http_res, http_res_text)
869
832
 
870
- content_type = http_res.headers.get("Content-Type")
871
- http_res_text = utils.stream_to_text(http_res)
872
- raise errors.APIError(
873
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
874
- http_res.status_code,
875
- http_res_text,
876
- http_res,
877
- )
833
+ raise errors.APIError("Unexpected response received", http_res)
878
834
 
879
835
  async def list_async(
880
836
  self,
@@ -889,6 +845,7 @@ class Transfers(BaseSDK):
889
845
  payment_link_code: Optional[str] = None,
890
846
  refunded: Optional[bool] = None,
891
847
  disputed: Optional[bool] = None,
848
+ foreign_id: Optional[str] = None,
892
849
  skip: Optional[int] = None,
893
850
  count: Optional[int] = None,
894
851
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
@@ -918,6 +875,7 @@ class Transfers(BaseSDK):
918
875
  :param payment_link_code: Optional code to filter for transfers associated with the payment link.
919
876
  :param refunded: Optional parameter to only return refunded transfers.
920
877
  :param disputed: Optional parameter to only return disputed transfers.
878
+ :param foreign_id: Optional alias from a foreign/external system which can be used to reference this resource.
921
879
  :param skip:
922
880
  :param count:
923
881
  :param retries: Override the default retry configuration for this method
@@ -945,6 +903,7 @@ class Transfers(BaseSDK):
945
903
  payment_link_code=payment_link_code,
946
904
  refunded=refunded,
947
905
  disputed=disputed,
906
+ foreign_id=foreign_id,
948
907
  skip=skip,
949
908
  count=count,
950
909
  account_id=account_id,
@@ -994,38 +953,25 @@ class Transfers(BaseSDK):
994
953
 
995
954
  if utils.match_response(http_res, "200", "application/json"):
996
955
  return operations.ListTransfersResponse(
997
- result=utils.unmarshal_json(http_res.text, List[components.Transfer]),
956
+ result=utils.unmarshal_json_response(
957
+ List[components.Transfer], http_res
958
+ ),
998
959
  headers=utils.get_response_headers(http_res.headers),
999
960
  )
1000
961
  if utils.match_response(http_res, ["401", "403", "429"], "*"):
1001
962
  http_res_text = await utils.stream_to_text_async(http_res)
1002
- raise errors.APIError(
1003
- "API error occurred", http_res.status_code, http_res_text, http_res
1004
- )
963
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1005
964
  if utils.match_response(http_res, ["500", "504"], "*"):
1006
965
  http_res_text = await utils.stream_to_text_async(http_res)
1007
- raise errors.APIError(
1008
- "API error occurred", http_res.status_code, http_res_text, http_res
1009
- )
966
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1010
967
  if utils.match_response(http_res, "4XX", "*"):
1011
968
  http_res_text = await utils.stream_to_text_async(http_res)
1012
- raise errors.APIError(
1013
- "API error occurred", http_res.status_code, http_res_text, http_res
1014
- )
969
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1015
970
  if utils.match_response(http_res, "5XX", "*"):
1016
971
  http_res_text = await utils.stream_to_text_async(http_res)
1017
- raise errors.APIError(
1018
- "API error occurred", http_res.status_code, http_res_text, http_res
1019
- )
972
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1020
973
 
1021
- content_type = http_res.headers.get("Content-Type")
1022
- http_res_text = await utils.stream_to_text_async(http_res)
1023
- raise errors.APIError(
1024
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1025
- http_res.status_code,
1026
- http_res_text,
1027
- http_res,
1028
- )
974
+ raise errors.APIError("Unexpected response received", http_res)
1029
975
 
1030
976
  def get(
1031
977
  self,
@@ -1111,38 +1057,23 @@ class Transfers(BaseSDK):
1111
1057
 
1112
1058
  if utils.match_response(http_res, "200", "application/json"):
1113
1059
  return operations.GetTransferResponse(
1114
- result=utils.unmarshal_json(http_res.text, components.Transfer),
1060
+ result=utils.unmarshal_json_response(components.Transfer, http_res),
1115
1061
  headers=utils.get_response_headers(http_res.headers),
1116
1062
  )
1117
1063
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
1118
1064
  http_res_text = utils.stream_to_text(http_res)
1119
- raise errors.APIError(
1120
- "API error occurred", http_res.status_code, http_res_text, http_res
1121
- )
1065
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1122
1066
  if utils.match_response(http_res, ["500", "504"], "*"):
1123
1067
  http_res_text = utils.stream_to_text(http_res)
1124
- raise errors.APIError(
1125
- "API error occurred", http_res.status_code, http_res_text, http_res
1126
- )
1068
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1127
1069
  if utils.match_response(http_res, "4XX", "*"):
1128
1070
  http_res_text = utils.stream_to_text(http_res)
1129
- raise errors.APIError(
1130
- "API error occurred", http_res.status_code, http_res_text, http_res
1131
- )
1071
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1132
1072
  if utils.match_response(http_res, "5XX", "*"):
1133
1073
  http_res_text = utils.stream_to_text(http_res)
1134
- raise errors.APIError(
1135
- "API error occurred", http_res.status_code, http_res_text, http_res
1136
- )
1074
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1137
1075
 
1138
- content_type = http_res.headers.get("Content-Type")
1139
- http_res_text = utils.stream_to_text(http_res)
1140
- raise errors.APIError(
1141
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1142
- http_res.status_code,
1143
- http_res_text,
1144
- http_res,
1145
- )
1076
+ raise errors.APIError("Unexpected response received", http_res)
1146
1077
 
1147
1078
  async def get_async(
1148
1079
  self,
@@ -1228,38 +1159,23 @@ class Transfers(BaseSDK):
1228
1159
 
1229
1160
  if utils.match_response(http_res, "200", "application/json"):
1230
1161
  return operations.GetTransferResponse(
1231
- result=utils.unmarshal_json(http_res.text, components.Transfer),
1162
+ result=utils.unmarshal_json_response(components.Transfer, http_res),
1232
1163
  headers=utils.get_response_headers(http_res.headers),
1233
1164
  )
1234
1165
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
1235
1166
  http_res_text = await utils.stream_to_text_async(http_res)
1236
- raise errors.APIError(
1237
- "API error occurred", http_res.status_code, http_res_text, http_res
1238
- )
1167
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1239
1168
  if utils.match_response(http_res, ["500", "504"], "*"):
1240
1169
  http_res_text = await utils.stream_to_text_async(http_res)
1241
- raise errors.APIError(
1242
- "API error occurred", http_res.status_code, http_res_text, http_res
1243
- )
1170
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1244
1171
  if utils.match_response(http_res, "4XX", "*"):
1245
1172
  http_res_text = await utils.stream_to_text_async(http_res)
1246
- raise errors.APIError(
1247
- "API error occurred", http_res.status_code, http_res_text, http_res
1248
- )
1173
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1249
1174
  if utils.match_response(http_res, "5XX", "*"):
1250
1175
  http_res_text = await utils.stream_to_text_async(http_res)
1251
- raise errors.APIError(
1252
- "API error occurred", http_res.status_code, http_res_text, http_res
1253
- )
1176
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1254
1177
 
1255
- content_type = http_res.headers.get("Content-Type")
1256
- http_res_text = await utils.stream_to_text_async(http_res)
1257
- raise errors.APIError(
1258
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1259
- http_res.status_code,
1260
- http_res_text,
1261
- http_res,
1262
- )
1178
+ raise errors.APIError("Unexpected response received", http_res)
1263
1179
 
1264
1180
  def update(
1265
1181
  self,
@@ -1352,38 +1268,23 @@ class Transfers(BaseSDK):
1352
1268
 
1353
1269
  if utils.match_response(http_res, "200", "application/json"):
1354
1270
  return operations.UpdateTransferResponse(
1355
- result=utils.unmarshal_json(http_res.text, components.Transfer),
1271
+ result=utils.unmarshal_json_response(components.Transfer, http_res),
1356
1272
  headers=utils.get_response_headers(http_res.headers),
1357
1273
  )
1358
1274
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
1359
1275
  http_res_text = utils.stream_to_text(http_res)
1360
- raise errors.APIError(
1361
- "API error occurred", http_res.status_code, http_res_text, http_res
1362
- )
1276
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1363
1277
  if utils.match_response(http_res, ["500", "504"], "*"):
1364
1278
  http_res_text = utils.stream_to_text(http_res)
1365
- raise errors.APIError(
1366
- "API error occurred", http_res.status_code, http_res_text, http_res
1367
- )
1279
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1368
1280
  if utils.match_response(http_res, "4XX", "*"):
1369
1281
  http_res_text = utils.stream_to_text(http_res)
1370
- raise errors.APIError(
1371
- "API error occurred", http_res.status_code, http_res_text, http_res
1372
- )
1282
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1373
1283
  if utils.match_response(http_res, "5XX", "*"):
1374
1284
  http_res_text = utils.stream_to_text(http_res)
1375
- raise errors.APIError(
1376
- "API error occurred", http_res.status_code, http_res_text, http_res
1377
- )
1285
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1378
1286
 
1379
- content_type = http_res.headers.get("Content-Type")
1380
- http_res_text = utils.stream_to_text(http_res)
1381
- raise errors.APIError(
1382
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1383
- http_res.status_code,
1384
- http_res_text,
1385
- http_res,
1386
- )
1287
+ raise errors.APIError("Unexpected response received", http_res)
1387
1288
 
1388
1289
  async def update_async(
1389
1290
  self,
@@ -1476,38 +1377,23 @@ class Transfers(BaseSDK):
1476
1377
 
1477
1378
  if utils.match_response(http_res, "200", "application/json"):
1478
1379
  return operations.UpdateTransferResponse(
1479
- result=utils.unmarshal_json(http_res.text, components.Transfer),
1380
+ result=utils.unmarshal_json_response(components.Transfer, http_res),
1480
1381
  headers=utils.get_response_headers(http_res.headers),
1481
1382
  )
1482
1383
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
1483
1384
  http_res_text = await utils.stream_to_text_async(http_res)
1484
- raise errors.APIError(
1485
- "API error occurred", http_res.status_code, http_res_text, http_res
1486
- )
1385
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1487
1386
  if utils.match_response(http_res, ["500", "504"], "*"):
1488
1387
  http_res_text = await utils.stream_to_text_async(http_res)
1489
- raise errors.APIError(
1490
- "API error occurred", http_res.status_code, http_res_text, http_res
1491
- )
1388
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1492
1389
  if utils.match_response(http_res, "4XX", "*"):
1493
1390
  http_res_text = await utils.stream_to_text_async(http_res)
1494
- raise errors.APIError(
1495
- "API error occurred", http_res.status_code, http_res_text, http_res
1496
- )
1391
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1497
1392
  if utils.match_response(http_res, "5XX", "*"):
1498
1393
  http_res_text = await utils.stream_to_text_async(http_res)
1499
- raise errors.APIError(
1500
- "API error occurred", http_res.status_code, http_res_text, http_res
1501
- )
1394
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1502
1395
 
1503
- content_type = http_res.headers.get("Content-Type")
1504
- http_res_text = await utils.stream_to_text_async(http_res)
1505
- raise errors.APIError(
1506
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1507
- http_res.status_code,
1508
- http_res_text,
1509
- http_res,
1510
- )
1396
+ raise errors.APIError("Unexpected response received", http_res)
1511
1397
 
1512
1398
  def create_cancellation(
1513
1399
  self,
@@ -1601,41 +1487,28 @@ class Transfers(BaseSDK):
1601
1487
  response_data: Any = None
1602
1488
  if utils.match_response(http_res, ["200", "202"], "application/json"):
1603
1489
  return operations.CreateCancellationResponse(
1604
- result=utils.unmarshal_json(http_res.text, components.Cancellation),
1490
+ result=utils.unmarshal_json_response(components.Cancellation, http_res),
1605
1491
  headers=utils.get_response_headers(http_res.headers),
1606
1492
  )
1607
1493
  if utils.match_response(http_res, "400", "application/json"):
1608
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
1609
- raise errors.GenericError(data=response_data)
1494
+ response_data = utils.unmarshal_json_response(
1495
+ errors.GenericErrorData, http_res
1496
+ )
1497
+ raise errors.GenericError(response_data, http_res)
1610
1498
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
1611
1499
  http_res_text = utils.stream_to_text(http_res)
1612
- raise errors.APIError(
1613
- "API error occurred", http_res.status_code, http_res_text, http_res
1614
- )
1500
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1615
1501
  if utils.match_response(http_res, ["500", "504"], "*"):
1616
1502
  http_res_text = utils.stream_to_text(http_res)
1617
- raise errors.APIError(
1618
- "API error occurred", http_res.status_code, http_res_text, http_res
1619
- )
1503
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1620
1504
  if utils.match_response(http_res, "4XX", "*"):
1621
1505
  http_res_text = utils.stream_to_text(http_res)
1622
- raise errors.APIError(
1623
- "API error occurred", http_res.status_code, http_res_text, http_res
1624
- )
1506
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1625
1507
  if utils.match_response(http_res, "5XX", "*"):
1626
1508
  http_res_text = utils.stream_to_text(http_res)
1627
- raise errors.APIError(
1628
- "API error occurred", http_res.status_code, http_res_text, http_res
1629
- )
1509
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1630
1510
 
1631
- content_type = http_res.headers.get("Content-Type")
1632
- http_res_text = utils.stream_to_text(http_res)
1633
- raise errors.APIError(
1634
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1635
- http_res.status_code,
1636
- http_res_text,
1637
- http_res,
1638
- )
1511
+ raise errors.APIError("Unexpected response received", http_res)
1639
1512
 
1640
1513
  async def create_cancellation_async(
1641
1514
  self,
@@ -1729,41 +1602,28 @@ class Transfers(BaseSDK):
1729
1602
  response_data: Any = None
1730
1603
  if utils.match_response(http_res, ["200", "202"], "application/json"):
1731
1604
  return operations.CreateCancellationResponse(
1732
- result=utils.unmarshal_json(http_res.text, components.Cancellation),
1605
+ result=utils.unmarshal_json_response(components.Cancellation, http_res),
1733
1606
  headers=utils.get_response_headers(http_res.headers),
1734
1607
  )
1735
1608
  if utils.match_response(http_res, "400", "application/json"):
1736
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
1737
- raise errors.GenericError(data=response_data)
1609
+ response_data = utils.unmarshal_json_response(
1610
+ errors.GenericErrorData, http_res
1611
+ )
1612
+ raise errors.GenericError(response_data, http_res)
1738
1613
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
1739
1614
  http_res_text = await utils.stream_to_text_async(http_res)
1740
- raise errors.APIError(
1741
- "API error occurred", http_res.status_code, http_res_text, http_res
1742
- )
1615
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1743
1616
  if utils.match_response(http_res, ["500", "504"], "*"):
1744
1617
  http_res_text = await utils.stream_to_text_async(http_res)
1745
- raise errors.APIError(
1746
- "API error occurred", http_res.status_code, http_res_text, http_res
1747
- )
1618
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1748
1619
  if utils.match_response(http_res, "4XX", "*"):
1749
1620
  http_res_text = await utils.stream_to_text_async(http_res)
1750
- raise errors.APIError(
1751
- "API error occurred", http_res.status_code, http_res_text, http_res
1752
- )
1621
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1753
1622
  if utils.match_response(http_res, "5XX", "*"):
1754
1623
  http_res_text = await utils.stream_to_text_async(http_res)
1755
- raise errors.APIError(
1756
- "API error occurred", http_res.status_code, http_res_text, http_res
1757
- )
1624
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1758
1625
 
1759
- content_type = http_res.headers.get("Content-Type")
1760
- http_res_text = await utils.stream_to_text_async(http_res)
1761
- raise errors.APIError(
1762
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1763
- http_res.status_code,
1764
- http_res_text,
1765
- http_res,
1766
- )
1626
+ raise errors.APIError("Unexpected response received", http_res)
1767
1627
 
1768
1628
  def get_cancellation(
1769
1629
  self,
@@ -1849,38 +1709,23 @@ class Transfers(BaseSDK):
1849
1709
 
1850
1710
  if utils.match_response(http_res, "200", "application/json"):
1851
1711
  return operations.GetCancellationResponse(
1852
- result=utils.unmarshal_json(http_res.text, components.Cancellation),
1712
+ result=utils.unmarshal_json_response(components.Cancellation, http_res),
1853
1713
  headers=utils.get_response_headers(http_res.headers),
1854
1714
  )
1855
1715
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
1856
1716
  http_res_text = utils.stream_to_text(http_res)
1857
- raise errors.APIError(
1858
- "API error occurred", http_res.status_code, http_res_text, http_res
1859
- )
1717
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1860
1718
  if utils.match_response(http_res, ["500", "504"], "*"):
1861
1719
  http_res_text = utils.stream_to_text(http_res)
1862
- raise errors.APIError(
1863
- "API error occurred", http_res.status_code, http_res_text, http_res
1864
- )
1720
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1865
1721
  if utils.match_response(http_res, "4XX", "*"):
1866
1722
  http_res_text = utils.stream_to_text(http_res)
1867
- raise errors.APIError(
1868
- "API error occurred", http_res.status_code, http_res_text, http_res
1869
- )
1723
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1870
1724
  if utils.match_response(http_res, "5XX", "*"):
1871
1725
  http_res_text = utils.stream_to_text(http_res)
1872
- raise errors.APIError(
1873
- "API error occurred", http_res.status_code, http_res_text, http_res
1874
- )
1726
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1875
1727
 
1876
- content_type = http_res.headers.get("Content-Type")
1877
- http_res_text = utils.stream_to_text(http_res)
1878
- raise errors.APIError(
1879
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1880
- http_res.status_code,
1881
- http_res_text,
1882
- http_res,
1883
- )
1728
+ raise errors.APIError("Unexpected response received", http_res)
1884
1729
 
1885
1730
  async def get_cancellation_async(
1886
1731
  self,
@@ -1966,38 +1811,23 @@ class Transfers(BaseSDK):
1966
1811
 
1967
1812
  if utils.match_response(http_res, "200", "application/json"):
1968
1813
  return operations.GetCancellationResponse(
1969
- result=utils.unmarshal_json(http_res.text, components.Cancellation),
1814
+ result=utils.unmarshal_json_response(components.Cancellation, http_res),
1970
1815
  headers=utils.get_response_headers(http_res.headers),
1971
1816
  )
1972
1817
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
1973
1818
  http_res_text = await utils.stream_to_text_async(http_res)
1974
- raise errors.APIError(
1975
- "API error occurred", http_res.status_code, http_res_text, http_res
1976
- )
1819
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1977
1820
  if utils.match_response(http_res, ["500", "504"], "*"):
1978
1821
  http_res_text = await utils.stream_to_text_async(http_res)
1979
- raise errors.APIError(
1980
- "API error occurred", http_res.status_code, http_res_text, http_res
1981
- )
1822
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1982
1823
  if utils.match_response(http_res, "4XX", "*"):
1983
1824
  http_res_text = await utils.stream_to_text_async(http_res)
1984
- raise errors.APIError(
1985
- "API error occurred", http_res.status_code, http_res_text, http_res
1986
- )
1825
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1987
1826
  if utils.match_response(http_res, "5XX", "*"):
1988
1827
  http_res_text = await utils.stream_to_text_async(http_res)
1989
- raise errors.APIError(
1990
- "API error occurred", http_res.status_code, http_res_text, http_res
1991
- )
1828
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1992
1829
 
1993
- content_type = http_res.headers.get("Content-Type")
1994
- http_res_text = await utils.stream_to_text_async(http_res)
1995
- raise errors.APIError(
1996
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1997
- http_res.status_code,
1998
- http_res_text,
1999
- http_res,
2000
- )
1830
+ raise errors.APIError("Unexpected response received", http_res)
2001
1831
 
2002
1832
  def initiate_refund(
2003
1833
  self,
@@ -2112,60 +1942,47 @@ class Transfers(BaseSDK):
2112
1942
  response_data: Any = None
2113
1943
  if utils.match_response(http_res, "200", "application/json"):
2114
1944
  return operations.InitiateRefundResponse(
2115
- result=utils.unmarshal_json(
2116
- http_res.text, components.CreateRefundResponse
1945
+ result=utils.unmarshal_json_response(
1946
+ components.CreateRefundResponse, http_res
2117
1947
  ),
2118
1948
  headers=utils.get_response_headers(http_res.headers),
2119
1949
  )
2120
1950
  if utils.match_response(http_res, "202", "application/json"):
2121
1951
  return operations.InitiateRefundResponse(
2122
- result=utils.unmarshal_json(
2123
- http_res.text, components.CardAcquiringRefund
1952
+ result=utils.unmarshal_json_response(
1953
+ components.CardAcquiringRefund, http_res
2124
1954
  ),
2125
1955
  headers=utils.get_response_headers(http_res.headers),
2126
1956
  )
2127
1957
  if utils.match_response(http_res, "400", "application/json"):
2128
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
2129
- raise errors.GenericError(data=response_data)
1958
+ response_data = utils.unmarshal_json_response(
1959
+ errors.GenericErrorData, http_res
1960
+ )
1961
+ raise errors.GenericError(response_data, http_res)
2130
1962
  if utils.match_response(http_res, "409", "application/json"):
2131
- response_data = utils.unmarshal_json(
2132
- http_res.text, errors.CardAcquiringRefundData
1963
+ response_data = utils.unmarshal_json_response(
1964
+ errors.CardAcquiringRefundData, http_res
2133
1965
  )
2134
- raise errors.CardAcquiringRefund(data=response_data)
1966
+ raise errors.CardAcquiringRefund(response_data, http_res)
2135
1967
  if utils.match_response(http_res, "422", "application/json"):
2136
- response_data = utils.unmarshal_json(
2137
- http_res.text, errors.RefundValidationErrorData
1968
+ response_data = utils.unmarshal_json_response(
1969
+ errors.RefundValidationErrorData, http_res
2138
1970
  )
2139
- raise errors.RefundValidationError(data=response_data)
1971
+ raise errors.RefundValidationError(response_data, http_res)
2140
1972
  if utils.match_response(http_res, ["404", "429"], "*"):
2141
1973
  http_res_text = utils.stream_to_text(http_res)
2142
- raise errors.APIError(
2143
- "API error occurred", http_res.status_code, http_res_text, http_res
2144
- )
1974
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2145
1975
  if utils.match_response(http_res, ["500", "504"], "*"):
2146
1976
  http_res_text = utils.stream_to_text(http_res)
2147
- raise errors.APIError(
2148
- "API error occurred", http_res.status_code, http_res_text, http_res
2149
- )
1977
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2150
1978
  if utils.match_response(http_res, "4XX", "*"):
2151
1979
  http_res_text = utils.stream_to_text(http_res)
2152
- raise errors.APIError(
2153
- "API error occurred", http_res.status_code, http_res_text, http_res
2154
- )
1980
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2155
1981
  if utils.match_response(http_res, "5XX", "*"):
2156
1982
  http_res_text = utils.stream_to_text(http_res)
2157
- raise errors.APIError(
2158
- "API error occurred", http_res.status_code, http_res_text, http_res
2159
- )
1983
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2160
1984
 
2161
- content_type = http_res.headers.get("Content-Type")
2162
- http_res_text = utils.stream_to_text(http_res)
2163
- raise errors.APIError(
2164
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2165
- http_res.status_code,
2166
- http_res_text,
2167
- http_res,
2168
- )
1985
+ raise errors.APIError("Unexpected response received", http_res)
2169
1986
 
2170
1987
  async def initiate_refund_async(
2171
1988
  self,
@@ -2280,60 +2097,47 @@ class Transfers(BaseSDK):
2280
2097
  response_data: Any = None
2281
2098
  if utils.match_response(http_res, "200", "application/json"):
2282
2099
  return operations.InitiateRefundResponse(
2283
- result=utils.unmarshal_json(
2284
- http_res.text, components.CreateRefundResponse
2100
+ result=utils.unmarshal_json_response(
2101
+ components.CreateRefundResponse, http_res
2285
2102
  ),
2286
2103
  headers=utils.get_response_headers(http_res.headers),
2287
2104
  )
2288
2105
  if utils.match_response(http_res, "202", "application/json"):
2289
2106
  return operations.InitiateRefundResponse(
2290
- result=utils.unmarshal_json(
2291
- http_res.text, components.CardAcquiringRefund
2107
+ result=utils.unmarshal_json_response(
2108
+ components.CardAcquiringRefund, http_res
2292
2109
  ),
2293
2110
  headers=utils.get_response_headers(http_res.headers),
2294
2111
  )
2295
2112
  if utils.match_response(http_res, "400", "application/json"):
2296
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
2297
- raise errors.GenericError(data=response_data)
2113
+ response_data = utils.unmarshal_json_response(
2114
+ errors.GenericErrorData, http_res
2115
+ )
2116
+ raise errors.GenericError(response_data, http_res)
2298
2117
  if utils.match_response(http_res, "409", "application/json"):
2299
- response_data = utils.unmarshal_json(
2300
- http_res.text, errors.CardAcquiringRefundData
2118
+ response_data = utils.unmarshal_json_response(
2119
+ errors.CardAcquiringRefundData, http_res
2301
2120
  )
2302
- raise errors.CardAcquiringRefund(data=response_data)
2121
+ raise errors.CardAcquiringRefund(response_data, http_res)
2303
2122
  if utils.match_response(http_res, "422", "application/json"):
2304
- response_data = utils.unmarshal_json(
2305
- http_res.text, errors.RefundValidationErrorData
2123
+ response_data = utils.unmarshal_json_response(
2124
+ errors.RefundValidationErrorData, http_res
2306
2125
  )
2307
- raise errors.RefundValidationError(data=response_data)
2126
+ raise errors.RefundValidationError(response_data, http_res)
2308
2127
  if utils.match_response(http_res, ["404", "429"], "*"):
2309
2128
  http_res_text = await utils.stream_to_text_async(http_res)
2310
- raise errors.APIError(
2311
- "API error occurred", http_res.status_code, http_res_text, http_res
2312
- )
2129
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2313
2130
  if utils.match_response(http_res, ["500", "504"], "*"):
2314
2131
  http_res_text = await utils.stream_to_text_async(http_res)
2315
- raise errors.APIError(
2316
- "API error occurred", http_res.status_code, http_res_text, http_res
2317
- )
2132
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2318
2133
  if utils.match_response(http_res, "4XX", "*"):
2319
2134
  http_res_text = await utils.stream_to_text_async(http_res)
2320
- raise errors.APIError(
2321
- "API error occurred", http_res.status_code, http_res_text, http_res
2322
- )
2135
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2323
2136
  if utils.match_response(http_res, "5XX", "*"):
2324
2137
  http_res_text = await utils.stream_to_text_async(http_res)
2325
- raise errors.APIError(
2326
- "API error occurred", http_res.status_code, http_res_text, http_res
2327
- )
2138
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2328
2139
 
2329
- content_type = http_res.headers.get("Content-Type")
2330
- http_res_text = await utils.stream_to_text_async(http_res)
2331
- raise errors.APIError(
2332
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2333
- http_res.status_code,
2334
- http_res_text,
2335
- http_res,
2336
- )
2140
+ raise errors.APIError("Unexpected response received", http_res)
2337
2141
 
2338
2142
  def list_refunds(
2339
2143
  self,
@@ -2416,40 +2220,25 @@ class Transfers(BaseSDK):
2416
2220
 
2417
2221
  if utils.match_response(http_res, "200", "application/json"):
2418
2222
  return operations.ListRefundsResponse(
2419
- result=utils.unmarshal_json(
2420
- http_res.text, List[components.CardAcquiringRefund]
2223
+ result=utils.unmarshal_json_response(
2224
+ List[components.CardAcquiringRefund], http_res
2421
2225
  ),
2422
2226
  headers=utils.get_response_headers(http_res.headers),
2423
2227
  )
2424
2228
  if utils.match_response(http_res, ["401", "403", "429"], "*"):
2425
2229
  http_res_text = utils.stream_to_text(http_res)
2426
- raise errors.APIError(
2427
- "API error occurred", http_res.status_code, http_res_text, http_res
2428
- )
2230
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2429
2231
  if utils.match_response(http_res, ["500", "504"], "*"):
2430
2232
  http_res_text = utils.stream_to_text(http_res)
2431
- raise errors.APIError(
2432
- "API error occurred", http_res.status_code, http_res_text, http_res
2433
- )
2233
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2434
2234
  if utils.match_response(http_res, "4XX", "*"):
2435
2235
  http_res_text = utils.stream_to_text(http_res)
2436
- raise errors.APIError(
2437
- "API error occurred", http_res.status_code, http_res_text, http_res
2438
- )
2236
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2439
2237
  if utils.match_response(http_res, "5XX", "*"):
2440
2238
  http_res_text = utils.stream_to_text(http_res)
2441
- raise errors.APIError(
2442
- "API error occurred", http_res.status_code, http_res_text, http_res
2443
- )
2239
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2444
2240
 
2445
- content_type = http_res.headers.get("Content-Type")
2446
- http_res_text = utils.stream_to_text(http_res)
2447
- raise errors.APIError(
2448
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2449
- http_res.status_code,
2450
- http_res_text,
2451
- http_res,
2452
- )
2241
+ raise errors.APIError("Unexpected response received", http_res)
2453
2242
 
2454
2243
  async def list_refunds_async(
2455
2244
  self,
@@ -2532,40 +2321,25 @@ class Transfers(BaseSDK):
2532
2321
 
2533
2322
  if utils.match_response(http_res, "200", "application/json"):
2534
2323
  return operations.ListRefundsResponse(
2535
- result=utils.unmarshal_json(
2536
- http_res.text, List[components.CardAcquiringRefund]
2324
+ result=utils.unmarshal_json_response(
2325
+ List[components.CardAcquiringRefund], http_res
2537
2326
  ),
2538
2327
  headers=utils.get_response_headers(http_res.headers),
2539
2328
  )
2540
2329
  if utils.match_response(http_res, ["401", "403", "429"], "*"):
2541
2330
  http_res_text = await utils.stream_to_text_async(http_res)
2542
- raise errors.APIError(
2543
- "API error occurred", http_res.status_code, http_res_text, http_res
2544
- )
2331
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2545
2332
  if utils.match_response(http_res, ["500", "504"], "*"):
2546
2333
  http_res_text = await utils.stream_to_text_async(http_res)
2547
- raise errors.APIError(
2548
- "API error occurred", http_res.status_code, http_res_text, http_res
2549
- )
2334
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2550
2335
  if utils.match_response(http_res, "4XX", "*"):
2551
2336
  http_res_text = await utils.stream_to_text_async(http_res)
2552
- raise errors.APIError(
2553
- "API error occurred", http_res.status_code, http_res_text, http_res
2554
- )
2337
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2555
2338
  if utils.match_response(http_res, "5XX", "*"):
2556
2339
  http_res_text = await utils.stream_to_text_async(http_res)
2557
- raise errors.APIError(
2558
- "API error occurred", http_res.status_code, http_res_text, http_res
2559
- )
2340
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2560
2341
 
2561
- content_type = http_res.headers.get("Content-Type")
2562
- http_res_text = await utils.stream_to_text_async(http_res)
2563
- raise errors.APIError(
2564
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2565
- http_res.status_code,
2566
- http_res_text,
2567
- http_res,
2568
- )
2342
+ raise errors.APIError("Unexpected response received", http_res)
2569
2343
 
2570
2344
  def get_refund(
2571
2345
  self,
@@ -2651,40 +2425,25 @@ class Transfers(BaseSDK):
2651
2425
 
2652
2426
  if utils.match_response(http_res, "200", "application/json"):
2653
2427
  return operations.GetRefundResponse(
2654
- result=utils.unmarshal_json(
2655
- http_res.text, components.CardAcquiringRefund
2428
+ result=utils.unmarshal_json_response(
2429
+ components.CardAcquiringRefund, http_res
2656
2430
  ),
2657
2431
  headers=utils.get_response_headers(http_res.headers),
2658
2432
  )
2659
2433
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
2660
2434
  http_res_text = utils.stream_to_text(http_res)
2661
- raise errors.APIError(
2662
- "API error occurred", http_res.status_code, http_res_text, http_res
2663
- )
2435
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2664
2436
  if utils.match_response(http_res, ["500", "504"], "*"):
2665
2437
  http_res_text = utils.stream_to_text(http_res)
2666
- raise errors.APIError(
2667
- "API error occurred", http_res.status_code, http_res_text, http_res
2668
- )
2438
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2669
2439
  if utils.match_response(http_res, "4XX", "*"):
2670
2440
  http_res_text = utils.stream_to_text(http_res)
2671
- raise errors.APIError(
2672
- "API error occurred", http_res.status_code, http_res_text, http_res
2673
- )
2441
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2674
2442
  if utils.match_response(http_res, "5XX", "*"):
2675
2443
  http_res_text = utils.stream_to_text(http_res)
2676
- raise errors.APIError(
2677
- "API error occurred", http_res.status_code, http_res_text, http_res
2678
- )
2444
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2679
2445
 
2680
- content_type = http_res.headers.get("Content-Type")
2681
- http_res_text = utils.stream_to_text(http_res)
2682
- raise errors.APIError(
2683
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2684
- http_res.status_code,
2685
- http_res_text,
2686
- http_res,
2687
- )
2446
+ raise errors.APIError("Unexpected response received", http_res)
2688
2447
 
2689
2448
  async def get_refund_async(
2690
2449
  self,
@@ -2770,40 +2529,25 @@ class Transfers(BaseSDK):
2770
2529
 
2771
2530
  if utils.match_response(http_res, "200", "application/json"):
2772
2531
  return operations.GetRefundResponse(
2773
- result=utils.unmarshal_json(
2774
- http_res.text, components.CardAcquiringRefund
2532
+ result=utils.unmarshal_json_response(
2533
+ components.CardAcquiringRefund, http_res
2775
2534
  ),
2776
2535
  headers=utils.get_response_headers(http_res.headers),
2777
2536
  )
2778
2537
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
2779
2538
  http_res_text = await utils.stream_to_text_async(http_res)
2780
- raise errors.APIError(
2781
- "API error occurred", http_res.status_code, http_res_text, http_res
2782
- )
2539
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2783
2540
  if utils.match_response(http_res, ["500", "504"], "*"):
2784
2541
  http_res_text = await utils.stream_to_text_async(http_res)
2785
- raise errors.APIError(
2786
- "API error occurred", http_res.status_code, http_res_text, http_res
2787
- )
2542
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2788
2543
  if utils.match_response(http_res, "4XX", "*"):
2789
2544
  http_res_text = await utils.stream_to_text_async(http_res)
2790
- raise errors.APIError(
2791
- "API error occurred", http_res.status_code, http_res_text, http_res
2792
- )
2545
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2793
2546
  if utils.match_response(http_res, "5XX", "*"):
2794
2547
  http_res_text = await utils.stream_to_text_async(http_res)
2795
- raise errors.APIError(
2796
- "API error occurred", http_res.status_code, http_res_text, http_res
2797
- )
2548
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2798
2549
 
2799
- content_type = http_res.headers.get("Content-Type")
2800
- http_res_text = await utils.stream_to_text_async(http_res)
2801
- raise errors.APIError(
2802
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2803
- http_res.status_code,
2804
- http_res_text,
2805
- http_res,
2806
- )
2550
+ raise errors.APIError("Unexpected response received", http_res)
2807
2551
 
2808
2552
  def create_reversal(
2809
2553
  self,
@@ -2916,46 +2660,33 @@ class Transfers(BaseSDK):
2916
2660
  response_data: Any = None
2917
2661
  if utils.match_response(http_res, ["200", "202"], "application/json"):
2918
2662
  return operations.CreateReversalResponse(
2919
- result=utils.unmarshal_json(http_res.text, components.Reversal),
2663
+ result=utils.unmarshal_json_response(components.Reversal, http_res),
2920
2664
  headers=utils.get_response_headers(http_res.headers),
2921
2665
  )
2922
2666
  if utils.match_response(http_res, ["400", "409"], "application/json"):
2923
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
2924
- raise errors.GenericError(data=response_data)
2667
+ response_data = utils.unmarshal_json_response(
2668
+ errors.GenericErrorData, http_res
2669
+ )
2670
+ raise errors.GenericError(response_data, http_res)
2925
2671
  if utils.match_response(http_res, "422", "application/json"):
2926
- response_data = utils.unmarshal_json(
2927
- http_res.text, errors.ReversalValidationErrorData
2672
+ response_data = utils.unmarshal_json_response(
2673
+ errors.ReversalValidationErrorData, http_res
2928
2674
  )
2929
- raise errors.ReversalValidationError(data=response_data)
2675
+ raise errors.ReversalValidationError(response_data, http_res)
2930
2676
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
2931
2677
  http_res_text = utils.stream_to_text(http_res)
2932
- raise errors.APIError(
2933
- "API error occurred", http_res.status_code, http_res_text, http_res
2934
- )
2678
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2935
2679
  if utils.match_response(http_res, ["500", "504"], "*"):
2936
2680
  http_res_text = utils.stream_to_text(http_res)
2937
- raise errors.APIError(
2938
- "API error occurred", http_res.status_code, http_res_text, http_res
2939
- )
2681
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2940
2682
  if utils.match_response(http_res, "4XX", "*"):
2941
2683
  http_res_text = utils.stream_to_text(http_res)
2942
- raise errors.APIError(
2943
- "API error occurred", http_res.status_code, http_res_text, http_res
2944
- )
2684
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2945
2685
  if utils.match_response(http_res, "5XX", "*"):
2946
2686
  http_res_text = utils.stream_to_text(http_res)
2947
- raise errors.APIError(
2948
- "API error occurred", http_res.status_code, http_res_text, http_res
2949
- )
2687
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2950
2688
 
2951
- content_type = http_res.headers.get("Content-Type")
2952
- http_res_text = utils.stream_to_text(http_res)
2953
- raise errors.APIError(
2954
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2955
- http_res.status_code,
2956
- http_res_text,
2957
- http_res,
2958
- )
2689
+ raise errors.APIError("Unexpected response received", http_res)
2959
2690
 
2960
2691
  async def create_reversal_async(
2961
2692
  self,
@@ -3068,46 +2799,33 @@ class Transfers(BaseSDK):
3068
2799
  response_data: Any = None
3069
2800
  if utils.match_response(http_res, ["200", "202"], "application/json"):
3070
2801
  return operations.CreateReversalResponse(
3071
- result=utils.unmarshal_json(http_res.text, components.Reversal),
2802
+ result=utils.unmarshal_json_response(components.Reversal, http_res),
3072
2803
  headers=utils.get_response_headers(http_res.headers),
3073
2804
  )
3074
2805
  if utils.match_response(http_res, ["400", "409"], "application/json"):
3075
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
3076
- raise errors.GenericError(data=response_data)
2806
+ response_data = utils.unmarshal_json_response(
2807
+ errors.GenericErrorData, http_res
2808
+ )
2809
+ raise errors.GenericError(response_data, http_res)
3077
2810
  if utils.match_response(http_res, "422", "application/json"):
3078
- response_data = utils.unmarshal_json(
3079
- http_res.text, errors.ReversalValidationErrorData
2811
+ response_data = utils.unmarshal_json_response(
2812
+ errors.ReversalValidationErrorData, http_res
3080
2813
  )
3081
- raise errors.ReversalValidationError(data=response_data)
2814
+ raise errors.ReversalValidationError(response_data, http_res)
3082
2815
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
3083
2816
  http_res_text = await utils.stream_to_text_async(http_res)
3084
- raise errors.APIError(
3085
- "API error occurred", http_res.status_code, http_res_text, http_res
3086
- )
2817
+ raise errors.APIError("API error occurred", http_res, http_res_text)
3087
2818
  if utils.match_response(http_res, ["500", "504"], "*"):
3088
2819
  http_res_text = await utils.stream_to_text_async(http_res)
3089
- raise errors.APIError(
3090
- "API error occurred", http_res.status_code, http_res_text, http_res
3091
- )
2820
+ raise errors.APIError("API error occurred", http_res, http_res_text)
3092
2821
  if utils.match_response(http_res, "4XX", "*"):
3093
2822
  http_res_text = await utils.stream_to_text_async(http_res)
3094
- raise errors.APIError(
3095
- "API error occurred", http_res.status_code, http_res_text, http_res
3096
- )
2823
+ raise errors.APIError("API error occurred", http_res, http_res_text)
3097
2824
  if utils.match_response(http_res, "5XX", "*"):
3098
2825
  http_res_text = await utils.stream_to_text_async(http_res)
3099
- raise errors.APIError(
3100
- "API error occurred", http_res.status_code, http_res_text, http_res
3101
- )
2826
+ raise errors.APIError("API error occurred", http_res, http_res_text)
3102
2827
 
3103
- content_type = http_res.headers.get("Content-Type")
3104
- http_res_text = await utils.stream_to_text_async(http_res)
3105
- raise errors.APIError(
3106
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
3107
- http_res.status_code,
3108
- http_res_text,
3109
- http_res,
3110
- )
2828
+ raise errors.APIError("Unexpected response received", http_res)
3111
2829
 
3112
2830
  def generate_options(
3113
2831
  self,
@@ -3220,46 +2938,35 @@ class Transfers(BaseSDK):
3220
2938
  response_data: Any = None
3221
2939
  if utils.match_response(http_res, "200", "application/json"):
3222
2940
  return operations.CreateTransferOptionsResponse(
3223
- result=utils.unmarshal_json(http_res.text, components.TransferOptions),
2941
+ result=utils.unmarshal_json_response(
2942
+ components.TransferOptions, http_res
2943
+ ),
3224
2944
  headers=utils.get_response_headers(http_res.headers),
3225
2945
  )
3226
2946
  if utils.match_response(http_res, "400", "application/json"):
3227
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
3228
- raise errors.GenericError(data=response_data)
2947
+ response_data = utils.unmarshal_json_response(
2948
+ errors.GenericErrorData, http_res
2949
+ )
2950
+ raise errors.GenericError(response_data, http_res)
3229
2951
  if utils.match_response(http_res, "422", "application/json"):
3230
- response_data = utils.unmarshal_json(
3231
- http_res.text, errors.TransferOptionsValidationErrorData
2952
+ response_data = utils.unmarshal_json_response(
2953
+ errors.TransferOptionsValidationErrorData, http_res
3232
2954
  )
3233
- raise errors.TransferOptionsValidationError(data=response_data)
2955
+ raise errors.TransferOptionsValidationError(response_data, http_res)
3234
2956
  if utils.match_response(http_res, ["401", "403", "429"], "*"):
3235
2957
  http_res_text = utils.stream_to_text(http_res)
3236
- raise errors.APIError(
3237
- "API error occurred", http_res.status_code, http_res_text, http_res
3238
- )
2958
+ raise errors.APIError("API error occurred", http_res, http_res_text)
3239
2959
  if utils.match_response(http_res, ["500", "504"], "*"):
3240
2960
  http_res_text = utils.stream_to_text(http_res)
3241
- raise errors.APIError(
3242
- "API error occurred", http_res.status_code, http_res_text, http_res
3243
- )
2961
+ raise errors.APIError("API error occurred", http_res, http_res_text)
3244
2962
  if utils.match_response(http_res, "4XX", "*"):
3245
2963
  http_res_text = utils.stream_to_text(http_res)
3246
- raise errors.APIError(
3247
- "API error occurred", http_res.status_code, http_res_text, http_res
3248
- )
2964
+ raise errors.APIError("API error occurred", http_res, http_res_text)
3249
2965
  if utils.match_response(http_res, "5XX", "*"):
3250
2966
  http_res_text = utils.stream_to_text(http_res)
3251
- raise errors.APIError(
3252
- "API error occurred", http_res.status_code, http_res_text, http_res
3253
- )
2967
+ raise errors.APIError("API error occurred", http_res, http_res_text)
3254
2968
 
3255
- content_type = http_res.headers.get("Content-Type")
3256
- http_res_text = utils.stream_to_text(http_res)
3257
- raise errors.APIError(
3258
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
3259
- http_res.status_code,
3260
- http_res_text,
3261
- http_res,
3262
- )
2969
+ raise errors.APIError("Unexpected response received", http_res)
3263
2970
 
3264
2971
  async def generate_options_async(
3265
2972
  self,
@@ -3372,43 +3079,32 @@ class Transfers(BaseSDK):
3372
3079
  response_data: Any = None
3373
3080
  if utils.match_response(http_res, "200", "application/json"):
3374
3081
  return operations.CreateTransferOptionsResponse(
3375
- result=utils.unmarshal_json(http_res.text, components.TransferOptions),
3082
+ result=utils.unmarshal_json_response(
3083
+ components.TransferOptions, http_res
3084
+ ),
3376
3085
  headers=utils.get_response_headers(http_res.headers),
3377
3086
  )
3378
3087
  if utils.match_response(http_res, "400", "application/json"):
3379
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
3380
- raise errors.GenericError(data=response_data)
3088
+ response_data = utils.unmarshal_json_response(
3089
+ errors.GenericErrorData, http_res
3090
+ )
3091
+ raise errors.GenericError(response_data, http_res)
3381
3092
  if utils.match_response(http_res, "422", "application/json"):
3382
- response_data = utils.unmarshal_json(
3383
- http_res.text, errors.TransferOptionsValidationErrorData
3093
+ response_data = utils.unmarshal_json_response(
3094
+ errors.TransferOptionsValidationErrorData, http_res
3384
3095
  )
3385
- raise errors.TransferOptionsValidationError(data=response_data)
3096
+ raise errors.TransferOptionsValidationError(response_data, http_res)
3386
3097
  if utils.match_response(http_res, ["401", "403", "429"], "*"):
3387
3098
  http_res_text = await utils.stream_to_text_async(http_res)
3388
- raise errors.APIError(
3389
- "API error occurred", http_res.status_code, http_res_text, http_res
3390
- )
3099
+ raise errors.APIError("API error occurred", http_res, http_res_text)
3391
3100
  if utils.match_response(http_res, ["500", "504"], "*"):
3392
3101
  http_res_text = await utils.stream_to_text_async(http_res)
3393
- raise errors.APIError(
3394
- "API error occurred", http_res.status_code, http_res_text, http_res
3395
- )
3102
+ raise errors.APIError("API error occurred", http_res, http_res_text)
3396
3103
  if utils.match_response(http_res, "4XX", "*"):
3397
3104
  http_res_text = await utils.stream_to_text_async(http_res)
3398
- raise errors.APIError(
3399
- "API error occurred", http_res.status_code, http_res_text, http_res
3400
- )
3105
+ raise errors.APIError("API error occurred", http_res, http_res_text)
3401
3106
  if utils.match_response(http_res, "5XX", "*"):
3402
3107
  http_res_text = await utils.stream_to_text_async(http_res)
3403
- raise errors.APIError(
3404
- "API error occurred", http_res.status_code, http_res_text, http_res
3405
- )
3108
+ raise errors.APIError("API error occurred", http_res, http_res_text)
3406
3109
 
3407
- content_type = http_res.headers.get("Content-Type")
3408
- http_res_text = await utils.stream_to_text_async(http_res)
3409
- raise errors.APIError(
3410
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
3411
- http_res.status_code,
3412
- http_res_text,
3413
- http_res,
3414
- )
3110
+ raise errors.APIError("Unexpected response received", http_res)