moovio_sdk 0.12.0__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 (99) 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 +39 -0
  24. moovio_sdk/models/components/createticket.py +24 -0
  25. moovio_sdk/models/components/createticketcontacterror.py +17 -0
  26. moovio_sdk/models/components/ticket.py +44 -0
  27. moovio_sdk/models/components/ticketcontact.py +17 -0
  28. moovio_sdk/models/components/ticketmessage.py +21 -0
  29. moovio_sdk/models/components/ticketstatus.py +11 -0
  30. moovio_sdk/models/components/updateticket.py +19 -0
  31. moovio_sdk/models/components/updateticketstatus.py +8 -0
  32. moovio_sdk/models/errors/__init__.py +19 -0
  33. moovio_sdk/models/errors/accountterminalapplicationerror.py +11 -6
  34. moovio_sdk/models/errors/addcapabilitieserror.py +11 -6
  35. moovio_sdk/models/errors/apierror.py +30 -14
  36. moovio_sdk/models/errors/assigncountrieserror.py +12 -6
  37. moovio_sdk/models/errors/authtokenrequesterror.py +11 -6
  38. moovio_sdk/models/errors/bankaccountvalidationerror.py +11 -6
  39. moovio_sdk/models/errors/brandvalidationerror.py +11 -6
  40. moovio_sdk/models/errors/cardacquiringrefund.py +11 -6
  41. moovio_sdk/models/errors/createaccount.py +12 -6
  42. moovio_sdk/models/errors/createpaymentlinkerror.py +11 -6
  43. moovio_sdk/models/errors/createsweepconfigerror.py +11 -6
  44. moovio_sdk/models/errors/createticketerror.py +34 -0
  45. moovio_sdk/models/errors/feeplanagreementerror.py +11 -6
  46. moovio_sdk/models/errors/fileuploadvalidationerror.py +11 -6
  47. moovio_sdk/models/errors/filevalidationerror.py +11 -6
  48. moovio_sdk/models/errors/genericerror.py +12 -6
  49. moovio_sdk/models/errors/linkapplepayerror.py +11 -6
  50. moovio_sdk/models/errors/linkcarderror.py +11 -6
  51. moovio_sdk/models/errors/microdepositvalidationerror.py +11 -6
  52. moovio_sdk/models/errors/mooverror.py +26 -0
  53. moovio_sdk/models/errors/no_response_error.py +13 -0
  54. moovio_sdk/models/errors/onboardinginviteerror.py +11 -6
  55. moovio_sdk/models/errors/patchsweepconfigerror.py +11 -6
  56. moovio_sdk/models/errors/refundvalidationerror.py +11 -6
  57. moovio_sdk/models/errors/representativevalidationerror.py +11 -6
  58. moovio_sdk/models/errors/requestcarderror.py +11 -6
  59. moovio_sdk/models/errors/responsevalidationerror.py +25 -0
  60. moovio_sdk/models/errors/reversalvalidationerror.py +11 -6
  61. moovio_sdk/models/errors/revoketokenrequesterror.py +11 -6
  62. moovio_sdk/models/errors/schedulevalidationerror.py +11 -6
  63. moovio_sdk/models/errors/terminalapplicationerror.py +11 -6
  64. moovio_sdk/models/errors/transfer.py +11 -6
  65. moovio_sdk/models/errors/transferoptionsvalidationerror.py +11 -6
  66. moovio_sdk/models/errors/transfervalidationerror.py +11 -6
  67. moovio_sdk/models/errors/updateaccount.py +12 -6
  68. moovio_sdk/models/errors/updatecarderror.py +11 -6
  69. moovio_sdk/models/errors/updateissuedcarderror.py +11 -6
  70. moovio_sdk/models/errors/updatepaymentlinkerror.py +11 -6
  71. moovio_sdk/models/errors/updateticketerror.py +25 -0
  72. moovio_sdk/models/errors/updateunderwritingerror.py +11 -6
  73. moovio_sdk/models/errors/upsertunderwritingerror.py +11 -6
  74. moovio_sdk/models/operations/__init__.py +100 -0
  75. moovio_sdk/models/operations/createticket.py +78 -0
  76. moovio_sdk/models/operations/getticket.py +71 -0
  77. moovio_sdk/models/operations/listticketmessages.py +88 -0
  78. moovio_sdk/models/operations/listtickets.py +81 -0
  79. moovio_sdk/models/operations/updateticket.py +85 -0
  80. moovio_sdk/onboarding.py +66 -166
  81. moovio_sdk/payment_links.py +106 -272
  82. moovio_sdk/payment_methods.py +30 -86
  83. moovio_sdk/ping.py +10 -40
  84. moovio_sdk/receipts.py +36 -92
  85. moovio_sdk/representatives.py +102 -228
  86. moovio_sdk/scheduling.py +122 -278
  87. moovio_sdk/sdk.py +3 -0
  88. moovio_sdk/support.py +1153 -0
  89. moovio_sdk/sweeps.py +102 -274
  90. moovio_sdk/terminal_applications.py +74 -186
  91. moovio_sdk/transfers.py +266 -582
  92. moovio_sdk/underwriting.py +64 -146
  93. moovio_sdk/utils/__init__.py +3 -0
  94. moovio_sdk/utils/serializers.py +21 -3
  95. moovio_sdk/wallet_transactions.py +28 -88
  96. moovio_sdk/wallets.py +24 -84
  97. {moovio_sdk-0.12.0.dist-info → moovio_sdk-0.13.0.dist-info}/METADATA +103 -28
  98. {moovio_sdk-0.12.0.dist-info → moovio_sdk-0.13.0.dist-info}/RECORD +99 -80
  99. {moovio_sdk-0.12.0.dist-info → moovio_sdk-0.13.0.dist-info}/WHEEL +0 -0
moovio_sdk/accounts.py CHANGED
@@ -152,46 +152,33 @@ class Accounts(BaseSDK):
152
152
  response_data: Any = None
153
153
  if utils.match_response(http_res, "200", "application/json"):
154
154
  return operations.CreateAccountResponse(
155
- result=utils.unmarshal_json(http_res.text, components.Account),
155
+ result=utils.unmarshal_json_response(components.Account, http_res),
156
156
  headers=utils.get_response_headers(http_res.headers),
157
157
  )
158
158
  if utils.match_response(http_res, ["400", "409"], "application/json"):
159
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
160
- raise errors.GenericError(data=response_data)
159
+ response_data = utils.unmarshal_json_response(
160
+ errors.GenericErrorData, http_res
161
+ )
162
+ raise errors.GenericError(response_data, http_res)
161
163
  if utils.match_response(http_res, "422", "application/json"):
162
- response_data = utils.unmarshal_json(
163
- http_res.text, errors.CreateAccountResponseBodyData
164
+ response_data = utils.unmarshal_json_response(
165
+ errors.CreateAccountResponseBodyData, http_res
164
166
  )
165
- raise errors.CreateAccountResponseBody(data=response_data)
167
+ raise errors.CreateAccountResponseBody(response_data, http_res)
166
168
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
167
169
  http_res_text = utils.stream_to_text(http_res)
168
- raise errors.APIError(
169
- "API error occurred", http_res.status_code, http_res_text, http_res
170
- )
170
+ raise errors.APIError("API error occurred", http_res, http_res_text)
171
171
  if utils.match_response(http_res, ["500", "504"], "*"):
172
172
  http_res_text = utils.stream_to_text(http_res)
173
- raise errors.APIError(
174
- "API error occurred", http_res.status_code, http_res_text, http_res
175
- )
173
+ raise errors.APIError("API error occurred", http_res, http_res_text)
176
174
  if utils.match_response(http_res, "4XX", "*"):
177
175
  http_res_text = utils.stream_to_text(http_res)
178
- raise errors.APIError(
179
- "API error occurred", http_res.status_code, http_res_text, http_res
180
- )
176
+ raise errors.APIError("API error occurred", http_res, http_res_text)
181
177
  if utils.match_response(http_res, "5XX", "*"):
182
178
  http_res_text = utils.stream_to_text(http_res)
183
- raise errors.APIError(
184
- "API error occurred", http_res.status_code, http_res_text, http_res
185
- )
179
+ raise errors.APIError("API error occurred", http_res, http_res_text)
186
180
 
187
- content_type = http_res.headers.get("Content-Type")
188
- http_res_text = utils.stream_to_text(http_res)
189
- raise errors.APIError(
190
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
191
- http_res.status_code,
192
- http_res_text,
193
- http_res,
194
- )
181
+ raise errors.APIError("Unexpected response received", http_res)
195
182
 
196
183
  async def create_async(
197
184
  self,
@@ -335,46 +322,33 @@ class Accounts(BaseSDK):
335
322
  response_data: Any = None
336
323
  if utils.match_response(http_res, "200", "application/json"):
337
324
  return operations.CreateAccountResponse(
338
- result=utils.unmarshal_json(http_res.text, components.Account),
325
+ result=utils.unmarshal_json_response(components.Account, http_res),
339
326
  headers=utils.get_response_headers(http_res.headers),
340
327
  )
341
328
  if utils.match_response(http_res, ["400", "409"], "application/json"):
342
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
343
- raise errors.GenericError(data=response_data)
329
+ response_data = utils.unmarshal_json_response(
330
+ errors.GenericErrorData, http_res
331
+ )
332
+ raise errors.GenericError(response_data, http_res)
344
333
  if utils.match_response(http_res, "422", "application/json"):
345
- response_data = utils.unmarshal_json(
346
- http_res.text, errors.CreateAccountResponseBodyData
334
+ response_data = utils.unmarshal_json_response(
335
+ errors.CreateAccountResponseBodyData, http_res
347
336
  )
348
- raise errors.CreateAccountResponseBody(data=response_data)
337
+ raise errors.CreateAccountResponseBody(response_data, http_res)
349
338
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
350
339
  http_res_text = await utils.stream_to_text_async(http_res)
351
- raise errors.APIError(
352
- "API error occurred", http_res.status_code, http_res_text, http_res
353
- )
340
+ raise errors.APIError("API error occurred", http_res, http_res_text)
354
341
  if utils.match_response(http_res, ["500", "504"], "*"):
355
342
  http_res_text = await utils.stream_to_text_async(http_res)
356
- raise errors.APIError(
357
- "API error occurred", http_res.status_code, http_res_text, http_res
358
- )
343
+ raise errors.APIError("API error occurred", http_res, http_res_text)
359
344
  if utils.match_response(http_res, "4XX", "*"):
360
345
  http_res_text = await utils.stream_to_text_async(http_res)
361
- raise errors.APIError(
362
- "API error occurred", http_res.status_code, http_res_text, http_res
363
- )
346
+ raise errors.APIError("API error occurred", http_res, http_res_text)
364
347
  if utils.match_response(http_res, "5XX", "*"):
365
348
  http_res_text = await utils.stream_to_text_async(http_res)
366
- raise errors.APIError(
367
- "API error occurred", http_res.status_code, http_res_text, http_res
368
- )
349
+ raise errors.APIError("API error occurred", http_res, http_res_text)
369
350
 
370
- content_type = http_res.headers.get("Content-Type")
371
- http_res_text = await utils.stream_to_text_async(http_res)
372
- raise errors.APIError(
373
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
374
- http_res.status_code,
375
- http_res_text,
376
- http_res,
377
- )
351
+ raise errors.APIError("Unexpected response received", http_res)
378
352
 
379
353
  def list(
380
354
  self,
@@ -485,38 +459,25 @@ class Accounts(BaseSDK):
485
459
 
486
460
  if utils.match_response(http_res, "200", "application/json"):
487
461
  return operations.ListAccountsResponse(
488
- result=utils.unmarshal_json(http_res.text, List[components.Account]),
462
+ result=utils.unmarshal_json_response(
463
+ List[components.Account], http_res
464
+ ),
489
465
  headers=utils.get_response_headers(http_res.headers),
490
466
  )
491
467
  if utils.match_response(http_res, ["401", "403", "429"], "*"):
492
468
  http_res_text = utils.stream_to_text(http_res)
493
- raise errors.APIError(
494
- "API error occurred", http_res.status_code, http_res_text, http_res
495
- )
469
+ raise errors.APIError("API error occurred", http_res, http_res_text)
496
470
  if utils.match_response(http_res, ["500", "504"], "*"):
497
471
  http_res_text = utils.stream_to_text(http_res)
498
- raise errors.APIError(
499
- "API error occurred", http_res.status_code, http_res_text, http_res
500
- )
472
+ raise errors.APIError("API error occurred", http_res, http_res_text)
501
473
  if utils.match_response(http_res, "4XX", "*"):
502
474
  http_res_text = utils.stream_to_text(http_res)
503
- raise errors.APIError(
504
- "API error occurred", http_res.status_code, http_res_text, http_res
505
- )
475
+ raise errors.APIError("API error occurred", http_res, http_res_text)
506
476
  if utils.match_response(http_res, "5XX", "*"):
507
477
  http_res_text = utils.stream_to_text(http_res)
508
- raise errors.APIError(
509
- "API error occurred", http_res.status_code, http_res_text, http_res
510
- )
478
+ raise errors.APIError("API error occurred", http_res, http_res_text)
511
479
 
512
- content_type = http_res.headers.get("Content-Type")
513
- http_res_text = utils.stream_to_text(http_res)
514
- raise errors.APIError(
515
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
516
- http_res.status_code,
517
- http_res_text,
518
- http_res,
519
- )
480
+ raise errors.APIError("Unexpected response received", http_res)
520
481
 
521
482
  async def list_async(
522
483
  self,
@@ -627,38 +588,25 @@ class Accounts(BaseSDK):
627
588
 
628
589
  if utils.match_response(http_res, "200", "application/json"):
629
590
  return operations.ListAccountsResponse(
630
- result=utils.unmarshal_json(http_res.text, List[components.Account]),
591
+ result=utils.unmarshal_json_response(
592
+ List[components.Account], http_res
593
+ ),
631
594
  headers=utils.get_response_headers(http_res.headers),
632
595
  )
633
596
  if utils.match_response(http_res, ["401", "403", "429"], "*"):
634
597
  http_res_text = await utils.stream_to_text_async(http_res)
635
- raise errors.APIError(
636
- "API error occurred", http_res.status_code, http_res_text, http_res
637
- )
598
+ raise errors.APIError("API error occurred", http_res, http_res_text)
638
599
  if utils.match_response(http_res, ["500", "504"], "*"):
639
600
  http_res_text = await utils.stream_to_text_async(http_res)
640
- raise errors.APIError(
641
- "API error occurred", http_res.status_code, http_res_text, http_res
642
- )
601
+ raise errors.APIError("API error occurred", http_res, http_res_text)
643
602
  if utils.match_response(http_res, "4XX", "*"):
644
603
  http_res_text = await utils.stream_to_text_async(http_res)
645
- raise errors.APIError(
646
- "API error occurred", http_res.status_code, http_res_text, http_res
647
- )
604
+ raise errors.APIError("API error occurred", http_res, http_res_text)
648
605
  if utils.match_response(http_res, "5XX", "*"):
649
606
  http_res_text = await utils.stream_to_text_async(http_res)
650
- raise errors.APIError(
651
- "API error occurred", http_res.status_code, http_res_text, http_res
652
- )
607
+ raise errors.APIError("API error occurred", http_res, http_res_text)
653
608
 
654
- content_type = http_res.headers.get("Content-Type")
655
- http_res_text = await utils.stream_to_text_async(http_res)
656
- raise errors.APIError(
657
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
658
- http_res.status_code,
659
- http_res_text,
660
- http_res,
661
- )
609
+ raise errors.APIError("Unexpected response received", http_res)
662
610
 
663
611
  def get(
664
612
  self,
@@ -738,38 +686,23 @@ class Accounts(BaseSDK):
738
686
 
739
687
  if utils.match_response(http_res, "200", "application/json"):
740
688
  return operations.GetAccountResponse(
741
- result=utils.unmarshal_json(http_res.text, components.Account),
689
+ result=utils.unmarshal_json_response(components.Account, http_res),
742
690
  headers=utils.get_response_headers(http_res.headers),
743
691
  )
744
692
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
745
693
  http_res_text = utils.stream_to_text(http_res)
746
- raise errors.APIError(
747
- "API error occurred", http_res.status_code, http_res_text, http_res
748
- )
694
+ raise errors.APIError("API error occurred", http_res, http_res_text)
749
695
  if utils.match_response(http_res, ["500", "504"], "*"):
750
696
  http_res_text = utils.stream_to_text(http_res)
751
- raise errors.APIError(
752
- "API error occurred", http_res.status_code, http_res_text, http_res
753
- )
697
+ raise errors.APIError("API error occurred", http_res, http_res_text)
754
698
  if utils.match_response(http_res, "4XX", "*"):
755
699
  http_res_text = utils.stream_to_text(http_res)
756
- raise errors.APIError(
757
- "API error occurred", http_res.status_code, http_res_text, http_res
758
- )
700
+ raise errors.APIError("API error occurred", http_res, http_res_text)
759
701
  if utils.match_response(http_res, "5XX", "*"):
760
702
  http_res_text = utils.stream_to_text(http_res)
761
- raise errors.APIError(
762
- "API error occurred", http_res.status_code, http_res_text, http_res
763
- )
703
+ raise errors.APIError("API error occurred", http_res, http_res_text)
764
704
 
765
- content_type = http_res.headers.get("Content-Type")
766
- http_res_text = utils.stream_to_text(http_res)
767
- raise errors.APIError(
768
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
769
- http_res.status_code,
770
- http_res_text,
771
- http_res,
772
- )
705
+ raise errors.APIError("Unexpected response received", http_res)
773
706
 
774
707
  async def get_async(
775
708
  self,
@@ -849,38 +782,23 @@ class Accounts(BaseSDK):
849
782
 
850
783
  if utils.match_response(http_res, "200", "application/json"):
851
784
  return operations.GetAccountResponse(
852
- result=utils.unmarshal_json(http_res.text, components.Account),
785
+ result=utils.unmarshal_json_response(components.Account, http_res),
853
786
  headers=utils.get_response_headers(http_res.headers),
854
787
  )
855
788
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
856
789
  http_res_text = await utils.stream_to_text_async(http_res)
857
- raise errors.APIError(
858
- "API error occurred", http_res.status_code, http_res_text, http_res
859
- )
790
+ raise errors.APIError("API error occurred", http_res, http_res_text)
860
791
  if utils.match_response(http_res, ["500", "504"], "*"):
861
792
  http_res_text = await utils.stream_to_text_async(http_res)
862
- raise errors.APIError(
863
- "API error occurred", http_res.status_code, http_res_text, http_res
864
- )
793
+ raise errors.APIError("API error occurred", http_res, http_res_text)
865
794
  if utils.match_response(http_res, "4XX", "*"):
866
795
  http_res_text = await utils.stream_to_text_async(http_res)
867
- raise errors.APIError(
868
- "API error occurred", http_res.status_code, http_res_text, http_res
869
- )
796
+ raise errors.APIError("API error occurred", http_res, http_res_text)
870
797
  if utils.match_response(http_res, "5XX", "*"):
871
798
  http_res_text = await utils.stream_to_text_async(http_res)
872
- raise errors.APIError(
873
- "API error occurred", http_res.status_code, http_res_text, http_res
874
- )
799
+ raise errors.APIError("API error occurred", http_res, http_res_text)
875
800
 
876
- content_type = http_res.headers.get("Content-Type")
877
- http_res_text = await utils.stream_to_text_async(http_res)
878
- raise errors.APIError(
879
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
880
- http_res.status_code,
881
- http_res_text,
882
- http_res,
883
- )
801
+ raise errors.APIError("Unexpected response received", http_res)
884
802
 
885
803
  def update(
886
804
  self,
@@ -1030,46 +948,33 @@ class Accounts(BaseSDK):
1030
948
  response_data: Any = None
1031
949
  if utils.match_response(http_res, "200", "application/json"):
1032
950
  return operations.UpdateAccountResponse(
1033
- result=utils.unmarshal_json(http_res.text, components.Account),
951
+ result=utils.unmarshal_json_response(components.Account, http_res),
1034
952
  headers=utils.get_response_headers(http_res.headers),
1035
953
  )
1036
954
  if utils.match_response(http_res, ["400", "409"], "application/json"):
1037
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
1038
- raise errors.GenericError(data=response_data)
955
+ response_data = utils.unmarshal_json_response(
956
+ errors.GenericErrorData, http_res
957
+ )
958
+ raise errors.GenericError(response_data, http_res)
1039
959
  if utils.match_response(http_res, "422", "application/json"):
1040
- response_data = utils.unmarshal_json(
1041
- http_res.text, errors.UpdateAccountResponseBodyData
960
+ response_data = utils.unmarshal_json_response(
961
+ errors.UpdateAccountResponseBodyData, http_res
1042
962
  )
1043
- raise errors.UpdateAccountResponseBody(data=response_data)
963
+ raise errors.UpdateAccountResponseBody(response_data, http_res)
1044
964
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
1045
965
  http_res_text = utils.stream_to_text(http_res)
1046
- raise errors.APIError(
1047
- "API error occurred", http_res.status_code, http_res_text, http_res
1048
- )
966
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1049
967
  if utils.match_response(http_res, ["500", "504"], "*"):
1050
968
  http_res_text = utils.stream_to_text(http_res)
1051
- raise errors.APIError(
1052
- "API error occurred", http_res.status_code, http_res_text, http_res
1053
- )
969
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1054
970
  if utils.match_response(http_res, "4XX", "*"):
1055
971
  http_res_text = utils.stream_to_text(http_res)
1056
- raise errors.APIError(
1057
- "API error occurred", http_res.status_code, http_res_text, http_res
1058
- )
972
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1059
973
  if utils.match_response(http_res, "5XX", "*"):
1060
974
  http_res_text = utils.stream_to_text(http_res)
1061
- raise errors.APIError(
1062
- "API error occurred", http_res.status_code, http_res_text, http_res
1063
- )
975
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1064
976
 
1065
- content_type = http_res.headers.get("Content-Type")
1066
- http_res_text = utils.stream_to_text(http_res)
1067
- raise errors.APIError(
1068
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1069
- http_res.status_code,
1070
- http_res_text,
1071
- http_res,
1072
- )
977
+ raise errors.APIError("Unexpected response received", http_res)
1073
978
 
1074
979
  async def update_async(
1075
980
  self,
@@ -1219,46 +1124,33 @@ class Accounts(BaseSDK):
1219
1124
  response_data: Any = None
1220
1125
  if utils.match_response(http_res, "200", "application/json"):
1221
1126
  return operations.UpdateAccountResponse(
1222
- result=utils.unmarshal_json(http_res.text, components.Account),
1127
+ result=utils.unmarshal_json_response(components.Account, http_res),
1223
1128
  headers=utils.get_response_headers(http_res.headers),
1224
1129
  )
1225
1130
  if utils.match_response(http_res, ["400", "409"], "application/json"):
1226
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
1227
- raise errors.GenericError(data=response_data)
1131
+ response_data = utils.unmarshal_json_response(
1132
+ errors.GenericErrorData, http_res
1133
+ )
1134
+ raise errors.GenericError(response_data, http_res)
1228
1135
  if utils.match_response(http_res, "422", "application/json"):
1229
- response_data = utils.unmarshal_json(
1230
- http_res.text, errors.UpdateAccountResponseBodyData
1136
+ response_data = utils.unmarshal_json_response(
1137
+ errors.UpdateAccountResponseBodyData, http_res
1231
1138
  )
1232
- raise errors.UpdateAccountResponseBody(data=response_data)
1139
+ raise errors.UpdateAccountResponseBody(response_data, http_res)
1233
1140
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
1234
1141
  http_res_text = await utils.stream_to_text_async(http_res)
1235
- raise errors.APIError(
1236
- "API error occurred", http_res.status_code, http_res_text, http_res
1237
- )
1142
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1238
1143
  if utils.match_response(http_res, ["500", "504"], "*"):
1239
1144
  http_res_text = await utils.stream_to_text_async(http_res)
1240
- raise errors.APIError(
1241
- "API error occurred", http_res.status_code, http_res_text, http_res
1242
- )
1145
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1243
1146
  if utils.match_response(http_res, "4XX", "*"):
1244
1147
  http_res_text = await utils.stream_to_text_async(http_res)
1245
- raise errors.APIError(
1246
- "API error occurred", http_res.status_code, http_res_text, http_res
1247
- )
1148
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1248
1149
  if utils.match_response(http_res, "5XX", "*"):
1249
1150
  http_res_text = await utils.stream_to_text_async(http_res)
1250
- raise errors.APIError(
1251
- "API error occurred", http_res.status_code, http_res_text, http_res
1252
- )
1151
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1253
1152
 
1254
- content_type = http_res.headers.get("Content-Type")
1255
- http_res_text = await utils.stream_to_text_async(http_res)
1256
- raise errors.APIError(
1257
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1258
- http_res.status_code,
1259
- http_res_text,
1260
- http_res,
1261
- )
1153
+ raise errors.APIError("Unexpected response received", http_res)
1262
1154
 
1263
1155
  def disconnect(
1264
1156
  self,
@@ -1355,37 +1247,24 @@ class Accounts(BaseSDK):
1355
1247
  headers=utils.get_response_headers(http_res.headers)
1356
1248
  )
1357
1249
  if utils.match_response(http_res, ["400", "409"], "application/json"):
1358
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
1359
- raise errors.GenericError(data=response_data)
1250
+ response_data = utils.unmarshal_json_response(
1251
+ errors.GenericErrorData, http_res
1252
+ )
1253
+ raise errors.GenericError(response_data, http_res)
1360
1254
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
1361
1255
  http_res_text = utils.stream_to_text(http_res)
1362
- raise errors.APIError(
1363
- "API error occurred", http_res.status_code, http_res_text, http_res
1364
- )
1256
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1365
1257
  if utils.match_response(http_res, ["500", "504"], "*"):
1366
1258
  http_res_text = utils.stream_to_text(http_res)
1367
- raise errors.APIError(
1368
- "API error occurred", http_res.status_code, http_res_text, http_res
1369
- )
1259
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1370
1260
  if utils.match_response(http_res, "4XX", "*"):
1371
1261
  http_res_text = utils.stream_to_text(http_res)
1372
- raise errors.APIError(
1373
- "API error occurred", http_res.status_code, http_res_text, http_res
1374
- )
1262
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1375
1263
  if utils.match_response(http_res, "5XX", "*"):
1376
1264
  http_res_text = utils.stream_to_text(http_res)
1377
- raise errors.APIError(
1378
- "API error occurred", http_res.status_code, http_res_text, http_res
1379
- )
1265
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1380
1266
 
1381
- content_type = http_res.headers.get("Content-Type")
1382
- http_res_text = utils.stream_to_text(http_res)
1383
- raise errors.APIError(
1384
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1385
- http_res.status_code,
1386
- http_res_text,
1387
- http_res,
1388
- )
1267
+ raise errors.APIError("Unexpected response received", http_res)
1389
1268
 
1390
1269
  async def disconnect_async(
1391
1270
  self,
@@ -1482,37 +1361,24 @@ class Accounts(BaseSDK):
1482
1361
  headers=utils.get_response_headers(http_res.headers)
1483
1362
  )
1484
1363
  if utils.match_response(http_res, ["400", "409"], "application/json"):
1485
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
1486
- raise errors.GenericError(data=response_data)
1364
+ response_data = utils.unmarshal_json_response(
1365
+ errors.GenericErrorData, http_res
1366
+ )
1367
+ raise errors.GenericError(response_data, http_res)
1487
1368
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
1488
1369
  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
- )
1370
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1492
1371
  if utils.match_response(http_res, ["500", "504"], "*"):
1493
1372
  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
- )
1373
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1497
1374
  if utils.match_response(http_res, "4XX", "*"):
1498
1375
  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
- )
1376
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1502
1377
  if utils.match_response(http_res, "5XX", "*"):
1503
1378
  http_res_text = await utils.stream_to_text_async(http_res)
1504
- raise errors.APIError(
1505
- "API error occurred", http_res.status_code, http_res_text, http_res
1506
- )
1379
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1507
1380
 
1508
- content_type = http_res.headers.get("Content-Type")
1509
- http_res_text = await utils.stream_to_text_async(http_res)
1510
- raise errors.APIError(
1511
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1512
- http_res.status_code,
1513
- http_res_text,
1514
- http_res,
1515
- )
1381
+ raise errors.APIError("Unexpected response received", http_res)
1516
1382
 
1517
1383
  def get_countries(
1518
1384
  self,
@@ -1592,38 +1458,25 @@ class Accounts(BaseSDK):
1592
1458
 
1593
1459
  if utils.match_response(http_res, "200", "application/json"):
1594
1460
  return operations.GetAccountCountriesResponse(
1595
- result=utils.unmarshal_json(http_res.text, components.AccountCountries),
1461
+ result=utils.unmarshal_json_response(
1462
+ components.AccountCountries, http_res
1463
+ ),
1596
1464
  headers=utils.get_response_headers(http_res.headers),
1597
1465
  )
1598
1466
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
1599
1467
  http_res_text = utils.stream_to_text(http_res)
1600
- raise errors.APIError(
1601
- "API error occurred", http_res.status_code, http_res_text, http_res
1602
- )
1468
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1603
1469
  if utils.match_response(http_res, ["500", "504"], "*"):
1604
1470
  http_res_text = utils.stream_to_text(http_res)
1605
- raise errors.APIError(
1606
- "API error occurred", http_res.status_code, http_res_text, http_res
1607
- )
1471
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1608
1472
  if utils.match_response(http_res, "4XX", "*"):
1609
1473
  http_res_text = utils.stream_to_text(http_res)
1610
- raise errors.APIError(
1611
- "API error occurred", http_res.status_code, http_res_text, http_res
1612
- )
1474
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1613
1475
  if utils.match_response(http_res, "5XX", "*"):
1614
1476
  http_res_text = utils.stream_to_text(http_res)
1615
- raise errors.APIError(
1616
- "API error occurred", http_res.status_code, http_res_text, http_res
1617
- )
1477
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1618
1478
 
1619
- content_type = http_res.headers.get("Content-Type")
1620
- http_res_text = utils.stream_to_text(http_res)
1621
- raise errors.APIError(
1622
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1623
- http_res.status_code,
1624
- http_res_text,
1625
- http_res,
1626
- )
1479
+ raise errors.APIError("Unexpected response received", http_res)
1627
1480
 
1628
1481
  async def get_countries_async(
1629
1482
  self,
@@ -1703,38 +1556,25 @@ class Accounts(BaseSDK):
1703
1556
 
1704
1557
  if utils.match_response(http_res, "200", "application/json"):
1705
1558
  return operations.GetAccountCountriesResponse(
1706
- result=utils.unmarshal_json(http_res.text, components.AccountCountries),
1559
+ result=utils.unmarshal_json_response(
1560
+ components.AccountCountries, http_res
1561
+ ),
1707
1562
  headers=utils.get_response_headers(http_res.headers),
1708
1563
  )
1709
1564
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
1710
1565
  http_res_text = await utils.stream_to_text_async(http_res)
1711
- raise errors.APIError(
1712
- "API error occurred", http_res.status_code, http_res_text, http_res
1713
- )
1566
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1714
1567
  if utils.match_response(http_res, ["500", "504"], "*"):
1715
1568
  http_res_text = await utils.stream_to_text_async(http_res)
1716
- raise errors.APIError(
1717
- "API error occurred", http_res.status_code, http_res_text, http_res
1718
- )
1569
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1719
1570
  if utils.match_response(http_res, "4XX", "*"):
1720
1571
  http_res_text = await utils.stream_to_text_async(http_res)
1721
- raise errors.APIError(
1722
- "API error occurred", http_res.status_code, http_res_text, http_res
1723
- )
1572
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1724
1573
  if utils.match_response(http_res, "5XX", "*"):
1725
1574
  http_res_text = await utils.stream_to_text_async(http_res)
1726
- raise errors.APIError(
1727
- "API error occurred", http_res.status_code, http_res_text, http_res
1728
- )
1575
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1729
1576
 
1730
- content_type = http_res.headers.get("Content-Type")
1731
- http_res_text = await utils.stream_to_text_async(http_res)
1732
- raise errors.APIError(
1733
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1734
- http_res.status_code,
1735
- http_res_text,
1736
- http_res,
1737
- )
1577
+ raise errors.APIError("Unexpected response received", http_res)
1738
1578
 
1739
1579
  def assign_countries(
1740
1580
  self,
@@ -1841,46 +1681,35 @@ class Accounts(BaseSDK):
1841
1681
  response_data: Any = None
1842
1682
  if utils.match_response(http_res, "200", "application/json"):
1843
1683
  return operations.AssignAccountCountriesResponse(
1844
- result=utils.unmarshal_json(http_res.text, components.AccountCountries),
1684
+ result=utils.unmarshal_json_response(
1685
+ components.AccountCountries, http_res
1686
+ ),
1845
1687
  headers=utils.get_response_headers(http_res.headers),
1846
1688
  )
1847
1689
  if utils.match_response(http_res, ["400", "409"], "application/json"):
1848
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
1849
- raise errors.GenericError(data=response_data)
1690
+ response_data = utils.unmarshal_json_response(
1691
+ errors.GenericErrorData, http_res
1692
+ )
1693
+ raise errors.GenericError(response_data, http_res)
1850
1694
  if utils.match_response(http_res, "422", "application/json"):
1851
- response_data = utils.unmarshal_json(
1852
- http_res.text, errors.AssignCountriesErrorData
1695
+ response_data = utils.unmarshal_json_response(
1696
+ errors.AssignCountriesErrorData, http_res
1853
1697
  )
1854
- raise errors.AssignCountriesError(data=response_data)
1698
+ raise errors.AssignCountriesError(response_data, http_res)
1855
1699
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
1856
1700
  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
- )
1701
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1860
1702
  if utils.match_response(http_res, ["500", "504"], "*"):
1861
1703
  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
- )
1704
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1865
1705
  if utils.match_response(http_res, "4XX", "*"):
1866
1706
  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
- )
1707
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1870
1708
  if utils.match_response(http_res, "5XX", "*"):
1871
1709
  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
- )
1710
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1875
1711
 
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
- )
1712
+ raise errors.APIError("Unexpected response received", http_res)
1884
1713
 
1885
1714
  async def assign_countries_async(
1886
1715
  self,
@@ -1987,46 +1816,35 @@ class Accounts(BaseSDK):
1987
1816
  response_data: Any = None
1988
1817
  if utils.match_response(http_res, "200", "application/json"):
1989
1818
  return operations.AssignAccountCountriesResponse(
1990
- result=utils.unmarshal_json(http_res.text, components.AccountCountries),
1819
+ result=utils.unmarshal_json_response(
1820
+ components.AccountCountries, http_res
1821
+ ),
1991
1822
  headers=utils.get_response_headers(http_res.headers),
1992
1823
  )
1993
1824
  if utils.match_response(http_res, ["400", "409"], "application/json"):
1994
- response_data = utils.unmarshal_json(http_res.text, errors.GenericErrorData)
1995
- raise errors.GenericError(data=response_data)
1825
+ response_data = utils.unmarshal_json_response(
1826
+ errors.GenericErrorData, http_res
1827
+ )
1828
+ raise errors.GenericError(response_data, http_res)
1996
1829
  if utils.match_response(http_res, "422", "application/json"):
1997
- response_data = utils.unmarshal_json(
1998
- http_res.text, errors.AssignCountriesErrorData
1830
+ response_data = utils.unmarshal_json_response(
1831
+ errors.AssignCountriesErrorData, http_res
1999
1832
  )
2000
- raise errors.AssignCountriesError(data=response_data)
1833
+ raise errors.AssignCountriesError(response_data, http_res)
2001
1834
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
2002
1835
  http_res_text = await utils.stream_to_text_async(http_res)
2003
- raise errors.APIError(
2004
- "API error occurred", http_res.status_code, http_res_text, http_res
2005
- )
1836
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2006
1837
  if utils.match_response(http_res, ["500", "504"], "*"):
2007
1838
  http_res_text = await utils.stream_to_text_async(http_res)
2008
- raise errors.APIError(
2009
- "API error occurred", http_res.status_code, http_res_text, http_res
2010
- )
1839
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2011
1840
  if utils.match_response(http_res, "4XX", "*"):
2012
1841
  http_res_text = await utils.stream_to_text_async(http_res)
2013
- raise errors.APIError(
2014
- "API error occurred", http_res.status_code, http_res_text, http_res
2015
- )
1842
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2016
1843
  if utils.match_response(http_res, "5XX", "*"):
2017
1844
  http_res_text = await utils.stream_to_text_async(http_res)
2018
- raise errors.APIError(
2019
- "API error occurred", http_res.status_code, http_res_text, http_res
2020
- )
1845
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2021
1846
 
2022
- content_type = http_res.headers.get("Content-Type")
2023
- http_res_text = await utils.stream_to_text_async(http_res)
2024
- raise errors.APIError(
2025
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2026
- http_res.status_code,
2027
- http_res_text,
2028
- http_res,
2029
- )
1847
+ raise errors.APIError("Unexpected response received", http_res)
2030
1848
 
2031
1849
  def get_merchant_processing_agreement(
2032
1850
  self,
@@ -2111,33 +1929,19 @@ class Accounts(BaseSDK):
2111
1929
  )
2112
1930
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
2113
1931
  http_res_text = utils.stream_to_text(http_res)
2114
- raise errors.APIError(
2115
- "API error occurred", http_res.status_code, http_res_text, http_res
2116
- )
1932
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2117
1933
  if utils.match_response(http_res, ["500", "504"], "*"):
2118
1934
  http_res_text = utils.stream_to_text(http_res)
2119
- raise errors.APIError(
2120
- "API error occurred", http_res.status_code, http_res_text, http_res
2121
- )
1935
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2122
1936
  if utils.match_response(http_res, "4XX", "*"):
2123
1937
  http_res_text = utils.stream_to_text(http_res)
2124
- raise errors.APIError(
2125
- "API error occurred", http_res.status_code, http_res_text, http_res
2126
- )
1938
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2127
1939
  if utils.match_response(http_res, "5XX", "*"):
2128
1940
  http_res_text = utils.stream_to_text(http_res)
2129
- raise errors.APIError(
2130
- "API error occurred", http_res.status_code, http_res_text, http_res
2131
- )
1941
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2132
1942
 
2133
- content_type = http_res.headers.get("Content-Type")
2134
1943
  http_res_text = utils.stream_to_text(http_res)
2135
- raise errors.APIError(
2136
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2137
- http_res.status_code,
2138
- http_res_text,
2139
- http_res,
2140
- )
1944
+ raise errors.APIError("Unexpected response received", http_res, http_res_text)
2141
1945
 
2142
1946
  async def get_merchant_processing_agreement_async(
2143
1947
  self,
@@ -2222,33 +2026,19 @@ class Accounts(BaseSDK):
2222
2026
  )
2223
2027
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
2224
2028
  http_res_text = await utils.stream_to_text_async(http_res)
2225
- raise errors.APIError(
2226
- "API error occurred", http_res.status_code, http_res_text, http_res
2227
- )
2029
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2228
2030
  if utils.match_response(http_res, ["500", "504"], "*"):
2229
2031
  http_res_text = await utils.stream_to_text_async(http_res)
2230
- raise errors.APIError(
2231
- "API error occurred", http_res.status_code, http_res_text, http_res
2232
- )
2032
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2233
2033
  if utils.match_response(http_res, "4XX", "*"):
2234
2034
  http_res_text = await utils.stream_to_text_async(http_res)
2235
- raise errors.APIError(
2236
- "API error occurred", http_res.status_code, http_res_text, http_res
2237
- )
2035
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2238
2036
  if utils.match_response(http_res, "5XX", "*"):
2239
2037
  http_res_text = await utils.stream_to_text_async(http_res)
2240
- raise errors.APIError(
2241
- "API error occurred", http_res.status_code, http_res_text, http_res
2242
- )
2038
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2243
2039
 
2244
- content_type = http_res.headers.get("Content-Type")
2245
2040
  http_res_text = await utils.stream_to_text_async(http_res)
2246
- raise errors.APIError(
2247
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2248
- http_res.status_code,
2249
- http_res_text,
2250
- http_res,
2251
- )
2041
+ raise errors.APIError("Unexpected response received", http_res, http_res_text)
2252
2042
 
2253
2043
  def get_terms_of_service_token(
2254
2044
  self,
@@ -2332,40 +2122,25 @@ class Accounts(BaseSDK):
2332
2122
 
2333
2123
  if utils.match_response(http_res, "200", "application/json"):
2334
2124
  return operations.GetTermsOfServiceTokenResponse(
2335
- result=utils.unmarshal_json(
2336
- http_res.text, components.TermsOfServiceToken
2125
+ result=utils.unmarshal_json_response(
2126
+ components.TermsOfServiceToken, http_res
2337
2127
  ),
2338
2128
  headers=utils.get_response_headers(http_res.headers),
2339
2129
  )
2340
2130
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
2341
2131
  http_res_text = utils.stream_to_text(http_res)
2342
- raise errors.APIError(
2343
- "API error occurred", http_res.status_code, http_res_text, http_res
2344
- )
2132
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2345
2133
  if utils.match_response(http_res, ["500", "504"], "*"):
2346
2134
  http_res_text = utils.stream_to_text(http_res)
2347
- raise errors.APIError(
2348
- "API error occurred", http_res.status_code, http_res_text, http_res
2349
- )
2135
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2350
2136
  if utils.match_response(http_res, "4XX", "*"):
2351
2137
  http_res_text = utils.stream_to_text(http_res)
2352
- raise errors.APIError(
2353
- "API error occurred", http_res.status_code, http_res_text, http_res
2354
- )
2138
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2355
2139
  if utils.match_response(http_res, "5XX", "*"):
2356
2140
  http_res_text = utils.stream_to_text(http_res)
2357
- raise errors.APIError(
2358
- "API error occurred", http_res.status_code, http_res_text, http_res
2359
- )
2141
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2360
2142
 
2361
- content_type = http_res.headers.get("Content-Type")
2362
- http_res_text = utils.stream_to_text(http_res)
2363
- raise errors.APIError(
2364
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2365
- http_res.status_code,
2366
- http_res_text,
2367
- http_res,
2368
- )
2143
+ raise errors.APIError("Unexpected response received", http_res)
2369
2144
 
2370
2145
  async def get_terms_of_service_token_async(
2371
2146
  self,
@@ -2449,37 +2224,22 @@ class Accounts(BaseSDK):
2449
2224
 
2450
2225
  if utils.match_response(http_res, "200", "application/json"):
2451
2226
  return operations.GetTermsOfServiceTokenResponse(
2452
- result=utils.unmarshal_json(
2453
- http_res.text, components.TermsOfServiceToken
2227
+ result=utils.unmarshal_json_response(
2228
+ components.TermsOfServiceToken, http_res
2454
2229
  ),
2455
2230
  headers=utils.get_response_headers(http_res.headers),
2456
2231
  )
2457
2232
  if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
2458
2233
  http_res_text = await utils.stream_to_text_async(http_res)
2459
- raise errors.APIError(
2460
- "API error occurred", http_res.status_code, http_res_text, http_res
2461
- )
2234
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2462
2235
  if utils.match_response(http_res, ["500", "504"], "*"):
2463
2236
  http_res_text = await utils.stream_to_text_async(http_res)
2464
- raise errors.APIError(
2465
- "API error occurred", http_res.status_code, http_res_text, http_res
2466
- )
2237
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2467
2238
  if utils.match_response(http_res, "4XX", "*"):
2468
2239
  http_res_text = await utils.stream_to_text_async(http_res)
2469
- raise errors.APIError(
2470
- "API error occurred", http_res.status_code, http_res_text, http_res
2471
- )
2240
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2472
2241
  if utils.match_response(http_res, "5XX", "*"):
2473
2242
  http_res_text = await utils.stream_to_text_async(http_res)
2474
- raise errors.APIError(
2475
- "API error occurred", http_res.status_code, http_res_text, http_res
2476
- )
2243
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2477
2244
 
2478
- content_type = http_res.headers.get("Content-Type")
2479
- http_res_text = await utils.stream_to_text_async(http_res)
2480
- raise errors.APIError(
2481
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2482
- http_res.status_code,
2483
- http_res_text,
2484
- http_res,
2485
- )
2245
+ raise errors.APIError("Unexpected response received", http_res)