compass_api_sdk 0.9.36__py3-none-any.whl → 0.9.37__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.

Potentially problematic release.


This version of compass_api_sdk might be problematic. Click here for more details.

compass_api_sdk/morpho.py CHANGED
@@ -87,31 +87,22 @@ class Morpho(BaseSDK):
87
87
 
88
88
  response_data: Any = None
89
89
  if utils.match_response(http_res, "200", "application/json"):
90
- return utils.unmarshal_json(http_res.text, models.MorphoGetVaultsResponse)
90
+ return utils.unmarshal_json_response(
91
+ models.MorphoGetVaultsResponse, http_res
92
+ )
91
93
  if utils.match_response(http_res, "422", "application/json"):
92
- response_data = utils.unmarshal_json(
93
- http_res.text, errors.HTTPValidationErrorData
94
+ response_data = utils.unmarshal_json_response(
95
+ errors.HTTPValidationErrorData, http_res
94
96
  )
95
- raise errors.HTTPValidationError(data=response_data)
97
+ raise errors.HTTPValidationError(response_data, http_res)
96
98
  if utils.match_response(http_res, "4XX", "*"):
97
99
  http_res_text = utils.stream_to_text(http_res)
98
- raise errors.APIError(
99
- "API error occurred", http_res.status_code, http_res_text, http_res
100
- )
100
+ raise errors.APIError("API error occurred", http_res, http_res_text)
101
101
  if utils.match_response(http_res, "5XX", "*"):
102
102
  http_res_text = utils.stream_to_text(http_res)
103
- raise errors.APIError(
104
- "API error occurred", http_res.status_code, http_res_text, http_res
105
- )
103
+ raise errors.APIError("API error occurred", http_res, http_res_text)
106
104
 
107
- content_type = http_res.headers.get("Content-Type")
108
- http_res_text = utils.stream_to_text(http_res)
109
- raise errors.APIError(
110
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
111
- http_res.status_code,
112
- http_res_text,
113
- http_res,
114
- )
105
+ raise errors.APIError("Unexpected response received", http_res)
115
106
 
116
107
  async def vaults_async(
117
108
  self,
@@ -192,37 +183,30 @@ class Morpho(BaseSDK):
192
183
 
193
184
  response_data: Any = None
194
185
  if utils.match_response(http_res, "200", "application/json"):
195
- return utils.unmarshal_json(http_res.text, models.MorphoGetVaultsResponse)
186
+ return utils.unmarshal_json_response(
187
+ models.MorphoGetVaultsResponse, http_res
188
+ )
196
189
  if utils.match_response(http_res, "422", "application/json"):
197
- response_data = utils.unmarshal_json(
198
- http_res.text, errors.HTTPValidationErrorData
190
+ response_data = utils.unmarshal_json_response(
191
+ errors.HTTPValidationErrorData, http_res
199
192
  )
200
- raise errors.HTTPValidationError(data=response_data)
193
+ raise errors.HTTPValidationError(response_data, http_res)
201
194
  if utils.match_response(http_res, "4XX", "*"):
202
195
  http_res_text = await utils.stream_to_text_async(http_res)
203
- raise errors.APIError(
204
- "API error occurred", http_res.status_code, http_res_text, http_res
205
- )
196
+ raise errors.APIError("API error occurred", http_res, http_res_text)
206
197
  if utils.match_response(http_res, "5XX", "*"):
207
198
  http_res_text = await utils.stream_to_text_async(http_res)
208
- raise errors.APIError(
209
- "API error occurred", http_res.status_code, http_res_text, http_res
210
- )
199
+ raise errors.APIError("API error occurred", http_res, http_res_text)
211
200
 
212
- content_type = http_res.headers.get("Content-Type")
213
- http_res_text = await utils.stream_to_text_async(http_res)
214
- raise errors.APIError(
215
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
216
- http_res.status_code,
217
- http_res_text,
218
- http_res,
219
- )
201
+ raise errors.APIError("Unexpected response received", http_res)
220
202
 
221
203
  def vault(
222
204
  self,
223
205
  *,
224
- chain: models.MorphoVaultChain = models.MorphoVaultChain.BASE_MAINNET,
225
- vault_address: str = "0xc1256Ae5FF1cf2719D4937adb3bbCCab2E00A2Ca",
206
+ chain: models.MorphoVaultChain = models.MorphoVaultChain.ETHEREUM_MAINNET,
207
+ vault_address: str = "0x182863131F9a4630fF9E27830d945B1413e347E8",
208
+ block: OptionalNullable[int] = UNSET,
209
+ user_address: OptionalNullable[str] = UNSET,
226
210
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
227
211
  server_url: Optional[str] = None,
228
212
  timeout_ms: Optional[int] = None,
@@ -239,8 +223,10 @@ class Morpho(BaseSDK):
239
223
  - Pertinent metadata
240
224
  - Whitelist status
241
225
 
242
- :param chain:
243
- :param vault_address: The vault address of the desired vault data & metrics.
226
+ :param chain: The chain to use.
227
+ :param vault_address: The vault address of the desired vault position.
228
+ :param block: Optional block number (defaults to latest).
229
+ :param user_address: The user address of the desired vault position. Only include if you would like the user position included in the response. Defaults to `None`.
244
230
  :param retries: Override the default retry configuration for this method
245
231
  :param server_url: Override the default server URL for this method
246
232
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -258,7 +244,9 @@ class Morpho(BaseSDK):
258
244
 
259
245
  request = models.MorphoVaultRequest(
260
246
  chain=chain,
247
+ block=block,
261
248
  vault_address=vault_address,
249
+ user_address=user_address,
262
250
  )
263
251
 
264
252
  req = self._build_request(
@@ -300,37 +288,30 @@ class Morpho(BaseSDK):
300
288
 
301
289
  response_data: Any = None
302
290
  if utils.match_response(http_res, "200", "application/json"):
303
- return utils.unmarshal_json(http_res.text, models.MorphoGetVaultResponse)
291
+ return utils.unmarshal_json_response(
292
+ models.MorphoGetVaultResponse, http_res
293
+ )
304
294
  if utils.match_response(http_res, "422", "application/json"):
305
- response_data = utils.unmarshal_json(
306
- http_res.text, errors.HTTPValidationErrorData
295
+ response_data = utils.unmarshal_json_response(
296
+ errors.HTTPValidationErrorData, http_res
307
297
  )
308
- raise errors.HTTPValidationError(data=response_data)
298
+ raise errors.HTTPValidationError(response_data, http_res)
309
299
  if utils.match_response(http_res, "4XX", "*"):
310
300
  http_res_text = utils.stream_to_text(http_res)
311
- raise errors.APIError(
312
- "API error occurred", http_res.status_code, http_res_text, http_res
313
- )
301
+ raise errors.APIError("API error occurred", http_res, http_res_text)
314
302
  if utils.match_response(http_res, "5XX", "*"):
315
303
  http_res_text = utils.stream_to_text(http_res)
316
- raise errors.APIError(
317
- "API error occurred", http_res.status_code, http_res_text, http_res
318
- )
304
+ raise errors.APIError("API error occurred", http_res, http_res_text)
319
305
 
320
- content_type = http_res.headers.get("Content-Type")
321
- http_res_text = utils.stream_to_text(http_res)
322
- raise errors.APIError(
323
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
324
- http_res.status_code,
325
- http_res_text,
326
- http_res,
327
- )
306
+ raise errors.APIError("Unexpected response received", http_res)
328
307
 
329
308
  async def vault_async(
330
309
  self,
331
310
  *,
332
- chain: models.MorphoVaultChain = models.MorphoVaultChain.BASE_MAINNET,
333
- vault_address: str = "0xc1256Ae5FF1cf2719D4937adb3bbCCab2E00A2Ca",
311
+ chain: models.MorphoVaultChain = models.MorphoVaultChain.ETHEREUM_MAINNET,
312
+ vault_address: str = "0x182863131F9a4630fF9E27830d945B1413e347E8",
313
+ block: OptionalNullable[int] = UNSET,
314
+ user_address: OptionalNullable[str] = UNSET,
334
315
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
335
316
  server_url: Optional[str] = None,
336
317
  timeout_ms: Optional[int] = None,
@@ -347,8 +328,10 @@ class Morpho(BaseSDK):
347
328
  - Pertinent metadata
348
329
  - Whitelist status
349
330
 
350
- :param chain:
351
- :param vault_address: The vault address of the desired vault data & metrics.
331
+ :param chain: The chain to use.
332
+ :param vault_address: The vault address of the desired vault position.
333
+ :param block: Optional block number (defaults to latest).
334
+ :param user_address: The user address of the desired vault position. Only include if you would like the user position included in the response. Defaults to `None`.
352
335
  :param retries: Override the default retry configuration for this method
353
336
  :param server_url: Override the default server URL for this method
354
337
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -366,7 +349,9 @@ class Morpho(BaseSDK):
366
349
 
367
350
  request = models.MorphoVaultRequest(
368
351
  chain=chain,
352
+ block=block,
369
353
  vault_address=vault_address,
354
+ user_address=user_address,
370
355
  )
371
356
 
372
357
  req = self._build_request_async(
@@ -408,31 +393,22 @@ class Morpho(BaseSDK):
408
393
 
409
394
  response_data: Any = None
410
395
  if utils.match_response(http_res, "200", "application/json"):
411
- return utils.unmarshal_json(http_res.text, models.MorphoGetVaultResponse)
396
+ return utils.unmarshal_json_response(
397
+ models.MorphoGetVaultResponse, http_res
398
+ )
412
399
  if utils.match_response(http_res, "422", "application/json"):
413
- response_data = utils.unmarshal_json(
414
- http_res.text, errors.HTTPValidationErrorData
400
+ response_data = utils.unmarshal_json_response(
401
+ errors.HTTPValidationErrorData, http_res
415
402
  )
416
- raise errors.HTTPValidationError(data=response_data)
403
+ raise errors.HTTPValidationError(response_data, http_res)
417
404
  if utils.match_response(http_res, "4XX", "*"):
418
405
  http_res_text = await utils.stream_to_text_async(http_res)
419
- raise errors.APIError(
420
- "API error occurred", http_res.status_code, http_res_text, http_res
421
- )
406
+ raise errors.APIError("API error occurred", http_res, http_res_text)
422
407
  if utils.match_response(http_res, "5XX", "*"):
423
408
  http_res_text = await utils.stream_to_text_async(http_res)
424
- raise errors.APIError(
425
- "API error occurred", http_res.status_code, http_res_text, http_res
426
- )
409
+ raise errors.APIError("API error occurred", http_res, http_res_text)
427
410
 
428
- content_type = http_res.headers.get("Content-Type")
429
- http_res_text = await utils.stream_to_text_async(http_res)
430
- raise errors.APIError(
431
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
432
- http_res.status_code,
433
- http_res_text,
434
- http_res,
435
- )
411
+ raise errors.APIError("Unexpected response received", http_res)
436
412
 
437
413
  def vault_position(
438
414
  self,
@@ -513,33 +489,22 @@ class Morpho(BaseSDK):
513
489
 
514
490
  response_data: Any = None
515
491
  if utils.match_response(http_res, "200", "application/json"):
516
- return utils.unmarshal_json(
517
- http_res.text, models.MorphoCheckVaultPositionResponse
492
+ return utils.unmarshal_json_response(
493
+ models.MorphoCheckVaultPositionResponse, http_res
518
494
  )
519
495
  if utils.match_response(http_res, "422", "application/json"):
520
- response_data = utils.unmarshal_json(
521
- http_res.text, errors.HTTPValidationErrorData
496
+ response_data = utils.unmarshal_json_response(
497
+ errors.HTTPValidationErrorData, http_res
522
498
  )
523
- raise errors.HTTPValidationError(data=response_data)
499
+ raise errors.HTTPValidationError(response_data, http_res)
524
500
  if utils.match_response(http_res, "4XX", "*"):
525
501
  http_res_text = utils.stream_to_text(http_res)
526
- raise errors.APIError(
527
- "API error occurred", http_res.status_code, http_res_text, http_res
528
- )
502
+ raise errors.APIError("API error occurred", http_res, http_res_text)
529
503
  if utils.match_response(http_res, "5XX", "*"):
530
504
  http_res_text = utils.stream_to_text(http_res)
531
- raise errors.APIError(
532
- "API error occurred", http_res.status_code, http_res_text, http_res
533
- )
505
+ raise errors.APIError("API error occurred", http_res, http_res_text)
534
506
 
535
- content_type = http_res.headers.get("Content-Type")
536
- http_res_text = utils.stream_to_text(http_res)
537
- raise errors.APIError(
538
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
539
- http_res.status_code,
540
- http_res_text,
541
- http_res,
542
- )
507
+ raise errors.APIError("Unexpected response received", http_res)
543
508
 
544
509
  async def vault_position_async(
545
510
  self,
@@ -620,33 +585,22 @@ class Morpho(BaseSDK):
620
585
 
621
586
  response_data: Any = None
622
587
  if utils.match_response(http_res, "200", "application/json"):
623
- return utils.unmarshal_json(
624
- http_res.text, models.MorphoCheckVaultPositionResponse
588
+ return utils.unmarshal_json_response(
589
+ models.MorphoCheckVaultPositionResponse, http_res
625
590
  )
626
591
  if utils.match_response(http_res, "422", "application/json"):
627
- response_data = utils.unmarshal_json(
628
- http_res.text, errors.HTTPValidationErrorData
592
+ response_data = utils.unmarshal_json_response(
593
+ errors.HTTPValidationErrorData, http_res
629
594
  )
630
- raise errors.HTTPValidationError(data=response_data)
595
+ raise errors.HTTPValidationError(response_data, http_res)
631
596
  if utils.match_response(http_res, "4XX", "*"):
632
597
  http_res_text = await utils.stream_to_text_async(http_res)
633
- raise errors.APIError(
634
- "API error occurred", http_res.status_code, http_res_text, http_res
635
- )
598
+ raise errors.APIError("API error occurred", http_res, http_res_text)
636
599
  if utils.match_response(http_res, "5XX", "*"):
637
600
  http_res_text = await utils.stream_to_text_async(http_res)
638
- raise errors.APIError(
639
- "API error occurred", http_res.status_code, http_res_text, http_res
640
- )
601
+ raise errors.APIError("API error occurred", http_res, http_res_text)
641
602
 
642
- content_type = http_res.headers.get("Content-Type")
643
- http_res_text = await utils.stream_to_text_async(http_res)
644
- raise errors.APIError(
645
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
646
- http_res.status_code,
647
- http_res_text,
648
- http_res,
649
- )
603
+ raise errors.APIError("Unexpected response received", http_res)
650
604
 
651
605
  def markets(
652
606
  self,
@@ -729,31 +683,22 @@ class Morpho(BaseSDK):
729
683
 
730
684
  response_data: Any = None
731
685
  if utils.match_response(http_res, "200", "application/json"):
732
- return utils.unmarshal_json(http_res.text, models.MorphoGetMarketsResponse)
686
+ return utils.unmarshal_json_response(
687
+ models.MorphoGetMarketsResponse, http_res
688
+ )
733
689
  if utils.match_response(http_res, "422", "application/json"):
734
- response_data = utils.unmarshal_json(
735
- http_res.text, errors.HTTPValidationErrorData
690
+ response_data = utils.unmarshal_json_response(
691
+ errors.HTTPValidationErrorData, http_res
736
692
  )
737
- raise errors.HTTPValidationError(data=response_data)
693
+ raise errors.HTTPValidationError(response_data, http_res)
738
694
  if utils.match_response(http_res, "4XX", "*"):
739
695
  http_res_text = utils.stream_to_text(http_res)
740
- raise errors.APIError(
741
- "API error occurred", http_res.status_code, http_res_text, http_res
742
- )
696
+ raise errors.APIError("API error occurred", http_res, http_res_text)
743
697
  if utils.match_response(http_res, "5XX", "*"):
744
698
  http_res_text = utils.stream_to_text(http_res)
745
- raise errors.APIError(
746
- "API error occurred", http_res.status_code, http_res_text, http_res
747
- )
699
+ raise errors.APIError("API error occurred", http_res, http_res_text)
748
700
 
749
- content_type = http_res.headers.get("Content-Type")
750
- http_res_text = utils.stream_to_text(http_res)
751
- raise errors.APIError(
752
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
753
- http_res.status_code,
754
- http_res_text,
755
- http_res,
756
- )
701
+ raise errors.APIError("Unexpected response received", http_res)
757
702
 
758
703
  async def markets_async(
759
704
  self,
@@ -836,31 +781,22 @@ class Morpho(BaseSDK):
836
781
 
837
782
  response_data: Any = None
838
783
  if utils.match_response(http_res, "200", "application/json"):
839
- return utils.unmarshal_json(http_res.text, models.MorphoGetMarketsResponse)
784
+ return utils.unmarshal_json_response(
785
+ models.MorphoGetMarketsResponse, http_res
786
+ )
840
787
  if utils.match_response(http_res, "422", "application/json"):
841
- response_data = utils.unmarshal_json(
842
- http_res.text, errors.HTTPValidationErrorData
788
+ response_data = utils.unmarshal_json_response(
789
+ errors.HTTPValidationErrorData, http_res
843
790
  )
844
- raise errors.HTTPValidationError(data=response_data)
791
+ raise errors.HTTPValidationError(response_data, http_res)
845
792
  if utils.match_response(http_res, "4XX", "*"):
846
793
  http_res_text = await utils.stream_to_text_async(http_res)
847
- raise errors.APIError(
848
- "API error occurred", http_res.status_code, http_res_text, http_res
849
- )
794
+ raise errors.APIError("API error occurred", http_res, http_res_text)
850
795
  if utils.match_response(http_res, "5XX", "*"):
851
796
  http_res_text = await utils.stream_to_text_async(http_res)
852
- raise errors.APIError(
853
- "API error occurred", http_res.status_code, http_res_text, http_res
854
- )
797
+ raise errors.APIError("API error occurred", http_res, http_res_text)
855
798
 
856
- content_type = http_res.headers.get("Content-Type")
857
- http_res_text = await utils.stream_to_text_async(http_res)
858
- raise errors.APIError(
859
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
860
- http_res.status_code,
861
- http_res_text,
862
- http_res,
863
- )
799
+ raise errors.APIError("Unexpected response received", http_res)
864
800
 
865
801
  def market(
866
802
  self,
@@ -946,31 +882,22 @@ class Morpho(BaseSDK):
946
882
 
947
883
  response_data: Any = None
948
884
  if utils.match_response(http_res, "200", "application/json"):
949
- return utils.unmarshal_json(http_res.text, models.MorphoGetMarketResponse)
885
+ return utils.unmarshal_json_response(
886
+ models.MorphoGetMarketResponse, http_res
887
+ )
950
888
  if utils.match_response(http_res, "422", "application/json"):
951
- response_data = utils.unmarshal_json(
952
- http_res.text, errors.HTTPValidationErrorData
889
+ response_data = utils.unmarshal_json_response(
890
+ errors.HTTPValidationErrorData, http_res
953
891
  )
954
- raise errors.HTTPValidationError(data=response_data)
892
+ raise errors.HTTPValidationError(response_data, http_res)
955
893
  if utils.match_response(http_res, "4XX", "*"):
956
894
  http_res_text = utils.stream_to_text(http_res)
957
- raise errors.APIError(
958
- "API error occurred", http_res.status_code, http_res_text, http_res
959
- )
895
+ raise errors.APIError("API error occurred", http_res, http_res_text)
960
896
  if utils.match_response(http_res, "5XX", "*"):
961
897
  http_res_text = utils.stream_to_text(http_res)
962
- raise errors.APIError(
963
- "API error occurred", http_res.status_code, http_res_text, http_res
964
- )
898
+ raise errors.APIError("API error occurred", http_res, http_res_text)
965
899
 
966
- content_type = http_res.headers.get("Content-Type")
967
- http_res_text = utils.stream_to_text(http_res)
968
- raise errors.APIError(
969
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
970
- http_res.status_code,
971
- http_res_text,
972
- http_res,
973
- )
900
+ raise errors.APIError("Unexpected response received", http_res)
974
901
 
975
902
  async def market_async(
976
903
  self,
@@ -1056,31 +983,22 @@ class Morpho(BaseSDK):
1056
983
 
1057
984
  response_data: Any = None
1058
985
  if utils.match_response(http_res, "200", "application/json"):
1059
- return utils.unmarshal_json(http_res.text, models.MorphoGetMarketResponse)
986
+ return utils.unmarshal_json_response(
987
+ models.MorphoGetMarketResponse, http_res
988
+ )
1060
989
  if utils.match_response(http_res, "422", "application/json"):
1061
- response_data = utils.unmarshal_json(
1062
- http_res.text, errors.HTTPValidationErrorData
990
+ response_data = utils.unmarshal_json_response(
991
+ errors.HTTPValidationErrorData, http_res
1063
992
  )
1064
- raise errors.HTTPValidationError(data=response_data)
993
+ raise errors.HTTPValidationError(response_data, http_res)
1065
994
  if utils.match_response(http_res, "4XX", "*"):
1066
995
  http_res_text = await utils.stream_to_text_async(http_res)
1067
- raise errors.APIError(
1068
- "API error occurred", http_res.status_code, http_res_text, http_res
1069
- )
996
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1070
997
  if utils.match_response(http_res, "5XX", "*"):
1071
998
  http_res_text = await utils.stream_to_text_async(http_res)
1072
- raise errors.APIError(
1073
- "API error occurred", http_res.status_code, http_res_text, http_res
1074
- )
999
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1075
1000
 
1076
- content_type = http_res.headers.get("Content-Type")
1077
- http_res_text = await utils.stream_to_text_async(http_res)
1078
- raise errors.APIError(
1079
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1080
- http_res.status_code,
1081
- http_res_text,
1082
- http_res,
1083
- )
1001
+ raise errors.APIError("Unexpected response received", http_res)
1084
1002
 
1085
1003
  def market_position(
1086
1004
  self,
@@ -1161,33 +1079,22 @@ class Morpho(BaseSDK):
1161
1079
 
1162
1080
  response_data: Any = None
1163
1081
  if utils.match_response(http_res, "200", "application/json"):
1164
- return utils.unmarshal_json(
1165
- http_res.text, models.MorphoCheckMarketPositionResponse
1082
+ return utils.unmarshal_json_response(
1083
+ models.MorphoCheckMarketPositionResponse, http_res
1166
1084
  )
1167
1085
  if utils.match_response(http_res, "422", "application/json"):
1168
- response_data = utils.unmarshal_json(
1169
- http_res.text, errors.HTTPValidationErrorData
1086
+ response_data = utils.unmarshal_json_response(
1087
+ errors.HTTPValidationErrorData, http_res
1170
1088
  )
1171
- raise errors.HTTPValidationError(data=response_data)
1089
+ raise errors.HTTPValidationError(response_data, http_res)
1172
1090
  if utils.match_response(http_res, "4XX", "*"):
1173
1091
  http_res_text = utils.stream_to_text(http_res)
1174
- raise errors.APIError(
1175
- "API error occurred", http_res.status_code, http_res_text, http_res
1176
- )
1092
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1177
1093
  if utils.match_response(http_res, "5XX", "*"):
1178
1094
  http_res_text = utils.stream_to_text(http_res)
1179
- raise errors.APIError(
1180
- "API error occurred", http_res.status_code, http_res_text, http_res
1181
- )
1095
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1182
1096
 
1183
- content_type = http_res.headers.get("Content-Type")
1184
- http_res_text = utils.stream_to_text(http_res)
1185
- raise errors.APIError(
1186
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1187
- http_res.status_code,
1188
- http_res_text,
1189
- http_res,
1190
- )
1097
+ raise errors.APIError("Unexpected response received", http_res)
1191
1098
 
1192
1099
  async def market_position_async(
1193
1100
  self,
@@ -1268,33 +1175,22 @@ class Morpho(BaseSDK):
1268
1175
 
1269
1176
  response_data: Any = None
1270
1177
  if utils.match_response(http_res, "200", "application/json"):
1271
- return utils.unmarshal_json(
1272
- http_res.text, models.MorphoCheckMarketPositionResponse
1178
+ return utils.unmarshal_json_response(
1179
+ models.MorphoCheckMarketPositionResponse, http_res
1273
1180
  )
1274
1181
  if utils.match_response(http_res, "422", "application/json"):
1275
- response_data = utils.unmarshal_json(
1276
- http_res.text, errors.HTTPValidationErrorData
1182
+ response_data = utils.unmarshal_json_response(
1183
+ errors.HTTPValidationErrorData, http_res
1277
1184
  )
1278
- raise errors.HTTPValidationError(data=response_data)
1185
+ raise errors.HTTPValidationError(response_data, http_res)
1279
1186
  if utils.match_response(http_res, "4XX", "*"):
1280
1187
  http_res_text = await utils.stream_to_text_async(http_res)
1281
- raise errors.APIError(
1282
- "API error occurred", http_res.status_code, http_res_text, http_res
1283
- )
1188
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1284
1189
  if utils.match_response(http_res, "5XX", "*"):
1285
1190
  http_res_text = await utils.stream_to_text_async(http_res)
1286
- raise errors.APIError(
1287
- "API error occurred", http_res.status_code, http_res_text, http_res
1288
- )
1191
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1289
1192
 
1290
- content_type = http_res.headers.get("Content-Type")
1291
- http_res_text = await utils.stream_to_text_async(http_res)
1292
- raise errors.APIError(
1293
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1294
- http_res.status_code,
1295
- http_res_text,
1296
- http_res,
1297
- )
1193
+ raise errors.APIError("Unexpected response received", http_res)
1298
1194
 
1299
1195
  def user_position(
1300
1196
  self,
@@ -1374,33 +1270,22 @@ class Morpho(BaseSDK):
1374
1270
 
1375
1271
  response_data: Any = None
1376
1272
  if utils.match_response(http_res, "200", "application/json"):
1377
- return utils.unmarshal_json(
1378
- http_res.text, models.MorphoCheckUserPositionResponse
1273
+ return utils.unmarshal_json_response(
1274
+ models.MorphoCheckUserPositionResponse, http_res
1379
1275
  )
1380
1276
  if utils.match_response(http_res, "422", "application/json"):
1381
- response_data = utils.unmarshal_json(
1382
- http_res.text, errors.HTTPValidationErrorData
1277
+ response_data = utils.unmarshal_json_response(
1278
+ errors.HTTPValidationErrorData, http_res
1383
1279
  )
1384
- raise errors.HTTPValidationError(data=response_data)
1280
+ raise errors.HTTPValidationError(response_data, http_res)
1385
1281
  if utils.match_response(http_res, "4XX", "*"):
1386
1282
  http_res_text = utils.stream_to_text(http_res)
1387
- raise errors.APIError(
1388
- "API error occurred", http_res.status_code, http_res_text, http_res
1389
- )
1283
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1390
1284
  if utils.match_response(http_res, "5XX", "*"):
1391
1285
  http_res_text = utils.stream_to_text(http_res)
1392
- raise errors.APIError(
1393
- "API error occurred", http_res.status_code, http_res_text, http_res
1394
- )
1286
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1395
1287
 
1396
- content_type = http_res.headers.get("Content-Type")
1397
- http_res_text = utils.stream_to_text(http_res)
1398
- raise errors.APIError(
1399
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1400
- http_res.status_code,
1401
- http_res_text,
1402
- http_res,
1403
- )
1288
+ raise errors.APIError("Unexpected response received", http_res)
1404
1289
 
1405
1290
  async def user_position_async(
1406
1291
  self,
@@ -1480,33 +1365,22 @@ class Morpho(BaseSDK):
1480
1365
 
1481
1366
  response_data: Any = None
1482
1367
  if utils.match_response(http_res, "200", "application/json"):
1483
- return utils.unmarshal_json(
1484
- http_res.text, models.MorphoCheckUserPositionResponse
1368
+ return utils.unmarshal_json_response(
1369
+ models.MorphoCheckUserPositionResponse, http_res
1485
1370
  )
1486
1371
  if utils.match_response(http_res, "422", "application/json"):
1487
- response_data = utils.unmarshal_json(
1488
- http_res.text, errors.HTTPValidationErrorData
1372
+ response_data = utils.unmarshal_json_response(
1373
+ errors.HTTPValidationErrorData, http_res
1489
1374
  )
1490
- raise errors.HTTPValidationError(data=response_data)
1375
+ raise errors.HTTPValidationError(response_data, http_res)
1491
1376
  if utils.match_response(http_res, "4XX", "*"):
1492
1377
  http_res_text = await utils.stream_to_text_async(http_res)
1493
- raise errors.APIError(
1494
- "API error occurred", http_res.status_code, http_res_text, http_res
1495
- )
1378
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1496
1379
  if utils.match_response(http_res, "5XX", "*"):
1497
1380
  http_res_text = await utils.stream_to_text_async(http_res)
1498
- raise errors.APIError(
1499
- "API error occurred", http_res.status_code, http_res_text, http_res
1500
- )
1381
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1501
1382
 
1502
- content_type = http_res.headers.get("Content-Type")
1503
- http_res_text = await utils.stream_to_text_async(http_res)
1504
- raise errors.APIError(
1505
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1506
- http_res.status_code,
1507
- http_res_text,
1508
- http_res,
1509
- )
1383
+ raise errors.APIError("Unexpected response received", http_res)
1510
1384
 
1511
1385
  def deposit(
1512
1386
  self,
@@ -1608,31 +1482,20 @@ class Morpho(BaseSDK):
1608
1482
 
1609
1483
  response_data: Any = None
1610
1484
  if utils.match_response(http_res, "200", "application/json"):
1611
- return utils.unmarshal_json(http_res.text, models.TxResponse)
1485
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
1612
1486
  if utils.match_response(http_res, "422", "application/json"):
1613
- response_data = utils.unmarshal_json(
1614
- http_res.text, errors.HTTPValidationErrorData
1487
+ response_data = utils.unmarshal_json_response(
1488
+ errors.HTTPValidationErrorData, http_res
1615
1489
  )
1616
- raise errors.HTTPValidationError(data=response_data)
1490
+ raise errors.HTTPValidationError(response_data, http_res)
1617
1491
  if utils.match_response(http_res, "4XX", "*"):
1618
1492
  http_res_text = utils.stream_to_text(http_res)
1619
- raise errors.APIError(
1620
- "API error occurred", http_res.status_code, http_res_text, http_res
1621
- )
1493
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1622
1494
  if utils.match_response(http_res, "5XX", "*"):
1623
1495
  http_res_text = utils.stream_to_text(http_res)
1624
- raise errors.APIError(
1625
- "API error occurred", http_res.status_code, http_res_text, http_res
1626
- )
1496
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1627
1497
 
1628
- content_type = http_res.headers.get("Content-Type")
1629
- http_res_text = utils.stream_to_text(http_res)
1630
- raise errors.APIError(
1631
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1632
- http_res.status_code,
1633
- http_res_text,
1634
- http_res,
1635
- )
1498
+ raise errors.APIError("Unexpected response received", http_res)
1636
1499
 
1637
1500
  async def deposit_async(
1638
1501
  self,
@@ -1734,31 +1597,20 @@ class Morpho(BaseSDK):
1734
1597
 
1735
1598
  response_data: Any = None
1736
1599
  if utils.match_response(http_res, "200", "application/json"):
1737
- return utils.unmarshal_json(http_res.text, models.TxResponse)
1600
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
1738
1601
  if utils.match_response(http_res, "422", "application/json"):
1739
- response_data = utils.unmarshal_json(
1740
- http_res.text, errors.HTTPValidationErrorData
1602
+ response_data = utils.unmarshal_json_response(
1603
+ errors.HTTPValidationErrorData, http_res
1741
1604
  )
1742
- raise errors.HTTPValidationError(data=response_data)
1605
+ raise errors.HTTPValidationError(response_data, http_res)
1743
1606
  if utils.match_response(http_res, "4XX", "*"):
1744
1607
  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
- )
1608
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1748
1609
  if utils.match_response(http_res, "5XX", "*"):
1749
1610
  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
- )
1611
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1753
1612
 
1754
- content_type = http_res.headers.get("Content-Type")
1755
- http_res_text = await utils.stream_to_text_async(http_res)
1756
- raise errors.APIError(
1757
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1758
- http_res.status_code,
1759
- http_res_text,
1760
- http_res,
1761
- )
1613
+ raise errors.APIError("Unexpected response received", http_res)
1762
1614
 
1763
1615
  def withdraw(
1764
1616
  self,
@@ -1857,31 +1709,20 @@ class Morpho(BaseSDK):
1857
1709
 
1858
1710
  response_data: Any = None
1859
1711
  if utils.match_response(http_res, "200", "application/json"):
1860
- return utils.unmarshal_json(http_res.text, models.TxResponse)
1712
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
1861
1713
  if utils.match_response(http_res, "422", "application/json"):
1862
- response_data = utils.unmarshal_json(
1863
- http_res.text, errors.HTTPValidationErrorData
1714
+ response_data = utils.unmarshal_json_response(
1715
+ errors.HTTPValidationErrorData, http_res
1864
1716
  )
1865
- raise errors.HTTPValidationError(data=response_data)
1717
+ raise errors.HTTPValidationError(response_data, http_res)
1866
1718
  if utils.match_response(http_res, "4XX", "*"):
1867
1719
  http_res_text = utils.stream_to_text(http_res)
1868
- raise errors.APIError(
1869
- "API error occurred", http_res.status_code, http_res_text, http_res
1870
- )
1720
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1871
1721
  if utils.match_response(http_res, "5XX", "*"):
1872
1722
  http_res_text = utils.stream_to_text(http_res)
1873
- raise errors.APIError(
1874
- "API error occurred", http_res.status_code, http_res_text, http_res
1875
- )
1723
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1876
1724
 
1877
- content_type = http_res.headers.get("Content-Type")
1878
- http_res_text = utils.stream_to_text(http_res)
1879
- raise errors.APIError(
1880
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1881
- http_res.status_code,
1882
- http_res_text,
1883
- http_res,
1884
- )
1725
+ raise errors.APIError("Unexpected response received", http_res)
1885
1726
 
1886
1727
  async def withdraw_async(
1887
1728
  self,
@@ -1980,31 +1821,20 @@ class Morpho(BaseSDK):
1980
1821
 
1981
1822
  response_data: Any = None
1982
1823
  if utils.match_response(http_res, "200", "application/json"):
1983
- return utils.unmarshal_json(http_res.text, models.TxResponse)
1824
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
1984
1825
  if utils.match_response(http_res, "422", "application/json"):
1985
- response_data = utils.unmarshal_json(
1986
- http_res.text, errors.HTTPValidationErrorData
1826
+ response_data = utils.unmarshal_json_response(
1827
+ errors.HTTPValidationErrorData, http_res
1987
1828
  )
1988
- raise errors.HTTPValidationError(data=response_data)
1829
+ raise errors.HTTPValidationError(response_data, http_res)
1989
1830
  if utils.match_response(http_res, "4XX", "*"):
1990
1831
  http_res_text = await utils.stream_to_text_async(http_res)
1991
- raise errors.APIError(
1992
- "API error occurred", http_res.status_code, http_res_text, http_res
1993
- )
1832
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1994
1833
  if utils.match_response(http_res, "5XX", "*"):
1995
1834
  http_res_text = await utils.stream_to_text_async(http_res)
1996
- raise errors.APIError(
1997
- "API error occurred", http_res.status_code, http_res_text, http_res
1998
- )
1835
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1999
1836
 
2000
- content_type = http_res.headers.get("Content-Type")
2001
- http_res_text = await utils.stream_to_text_async(http_res)
2002
- raise errors.APIError(
2003
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2004
- http_res.status_code,
2005
- http_res_text,
2006
- http_res,
2007
- )
1837
+ raise errors.APIError("Unexpected response received", http_res)
2008
1838
 
2009
1839
  def supply_collateral(
2010
1840
  self,
@@ -2104,31 +1934,20 @@ class Morpho(BaseSDK):
2104
1934
 
2105
1935
  response_data: Any = None
2106
1936
  if utils.match_response(http_res, "200", "application/json"):
2107
- return utils.unmarshal_json(http_res.text, models.TxResponse)
1937
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
2108
1938
  if utils.match_response(http_res, "422", "application/json"):
2109
- response_data = utils.unmarshal_json(
2110
- http_res.text, errors.HTTPValidationErrorData
1939
+ response_data = utils.unmarshal_json_response(
1940
+ errors.HTTPValidationErrorData, http_res
2111
1941
  )
2112
- raise errors.HTTPValidationError(data=response_data)
1942
+ raise errors.HTTPValidationError(response_data, http_res)
2113
1943
  if utils.match_response(http_res, "4XX", "*"):
2114
1944
  http_res_text = utils.stream_to_text(http_res)
2115
- raise errors.APIError(
2116
- "API error occurred", http_res.status_code, http_res_text, http_res
2117
- )
1945
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2118
1946
  if utils.match_response(http_res, "5XX", "*"):
2119
1947
  http_res_text = utils.stream_to_text(http_res)
2120
- raise errors.APIError(
2121
- "API error occurred", http_res.status_code, http_res_text, http_res
2122
- )
1948
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2123
1949
 
2124
- content_type = http_res.headers.get("Content-Type")
2125
- http_res_text = utils.stream_to_text(http_res)
2126
- raise errors.APIError(
2127
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2128
- http_res.status_code,
2129
- http_res_text,
2130
- http_res,
2131
- )
1950
+ raise errors.APIError("Unexpected response received", http_res)
2132
1951
 
2133
1952
  async def supply_collateral_async(
2134
1953
  self,
@@ -2228,31 +2047,20 @@ class Morpho(BaseSDK):
2228
2047
 
2229
2048
  response_data: Any = None
2230
2049
  if utils.match_response(http_res, "200", "application/json"):
2231
- return utils.unmarshal_json(http_res.text, models.TxResponse)
2050
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
2232
2051
  if utils.match_response(http_res, "422", "application/json"):
2233
- response_data = utils.unmarshal_json(
2234
- http_res.text, errors.HTTPValidationErrorData
2052
+ response_data = utils.unmarshal_json_response(
2053
+ errors.HTTPValidationErrorData, http_res
2235
2054
  )
2236
- raise errors.HTTPValidationError(data=response_data)
2055
+ raise errors.HTTPValidationError(response_data, http_res)
2237
2056
  if utils.match_response(http_res, "4XX", "*"):
2238
2057
  http_res_text = await utils.stream_to_text_async(http_res)
2239
- raise errors.APIError(
2240
- "API error occurred", http_res.status_code, http_res_text, http_res
2241
- )
2058
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2242
2059
  if utils.match_response(http_res, "5XX", "*"):
2243
2060
  http_res_text = await utils.stream_to_text_async(http_res)
2244
- raise errors.APIError(
2245
- "API error occurred", http_res.status_code, http_res_text, http_res
2246
- )
2061
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2247
2062
 
2248
- content_type = http_res.headers.get("Content-Type")
2249
- http_res_text = await utils.stream_to_text_async(http_res)
2250
- raise errors.APIError(
2251
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2252
- http_res.status_code,
2253
- http_res_text,
2254
- http_res,
2255
- )
2063
+ raise errors.APIError("Unexpected response received", http_res)
2256
2064
 
2257
2065
  def withdraw_collateral(
2258
2066
  self,
@@ -2352,31 +2160,20 @@ class Morpho(BaseSDK):
2352
2160
 
2353
2161
  response_data: Any = None
2354
2162
  if utils.match_response(http_res, "200", "application/json"):
2355
- return utils.unmarshal_json(http_res.text, models.TxResponse)
2163
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
2356
2164
  if utils.match_response(http_res, "422", "application/json"):
2357
- response_data = utils.unmarshal_json(
2358
- http_res.text, errors.HTTPValidationErrorData
2165
+ response_data = utils.unmarshal_json_response(
2166
+ errors.HTTPValidationErrorData, http_res
2359
2167
  )
2360
- raise errors.HTTPValidationError(data=response_data)
2168
+ raise errors.HTTPValidationError(response_data, http_res)
2361
2169
  if utils.match_response(http_res, "4XX", "*"):
2362
2170
  http_res_text = utils.stream_to_text(http_res)
2363
- raise errors.APIError(
2364
- "API error occurred", http_res.status_code, http_res_text, http_res
2365
- )
2171
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2366
2172
  if utils.match_response(http_res, "5XX", "*"):
2367
2173
  http_res_text = utils.stream_to_text(http_res)
2368
- raise errors.APIError(
2369
- "API error occurred", http_res.status_code, http_res_text, http_res
2370
- )
2174
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2371
2175
 
2372
- content_type = http_res.headers.get("Content-Type")
2373
- http_res_text = utils.stream_to_text(http_res)
2374
- raise errors.APIError(
2375
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2376
- http_res.status_code,
2377
- http_res_text,
2378
- http_res,
2379
- )
2176
+ raise errors.APIError("Unexpected response received", http_res)
2380
2177
 
2381
2178
  async def withdraw_collateral_async(
2382
2179
  self,
@@ -2476,31 +2273,20 @@ class Morpho(BaseSDK):
2476
2273
 
2477
2274
  response_data: Any = None
2478
2275
  if utils.match_response(http_res, "200", "application/json"):
2479
- return utils.unmarshal_json(http_res.text, models.TxResponse)
2276
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
2480
2277
  if utils.match_response(http_res, "422", "application/json"):
2481
- response_data = utils.unmarshal_json(
2482
- http_res.text, errors.HTTPValidationErrorData
2278
+ response_data = utils.unmarshal_json_response(
2279
+ errors.HTTPValidationErrorData, http_res
2483
2280
  )
2484
- raise errors.HTTPValidationError(data=response_data)
2281
+ raise errors.HTTPValidationError(response_data, http_res)
2485
2282
  if utils.match_response(http_res, "4XX", "*"):
2486
2283
  http_res_text = await utils.stream_to_text_async(http_res)
2487
- raise errors.APIError(
2488
- "API error occurred", http_res.status_code, http_res_text, http_res
2489
- )
2284
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2490
2285
  if utils.match_response(http_res, "5XX", "*"):
2491
2286
  http_res_text = await utils.stream_to_text_async(http_res)
2492
- raise errors.APIError(
2493
- "API error occurred", http_res.status_code, http_res_text, http_res
2494
- )
2287
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2495
2288
 
2496
- content_type = http_res.headers.get("Content-Type")
2497
- http_res_text = await utils.stream_to_text_async(http_res)
2498
- raise errors.APIError(
2499
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2500
- http_res.status_code,
2501
- http_res_text,
2502
- http_res,
2503
- )
2289
+ raise errors.APIError("Unexpected response received", http_res)
2504
2290
 
2505
2291
  def borrow(
2506
2292
  self,
@@ -2602,31 +2388,20 @@ class Morpho(BaseSDK):
2602
2388
 
2603
2389
  response_data: Any = None
2604
2390
  if utils.match_response(http_res, "200", "application/json"):
2605
- return utils.unmarshal_json(http_res.text, models.TxResponse)
2391
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
2606
2392
  if utils.match_response(http_res, "422", "application/json"):
2607
- response_data = utils.unmarshal_json(
2608
- http_res.text, errors.HTTPValidationErrorData
2393
+ response_data = utils.unmarshal_json_response(
2394
+ errors.HTTPValidationErrorData, http_res
2609
2395
  )
2610
- raise errors.HTTPValidationError(data=response_data)
2396
+ raise errors.HTTPValidationError(response_data, http_res)
2611
2397
  if utils.match_response(http_res, "4XX", "*"):
2612
2398
  http_res_text = utils.stream_to_text(http_res)
2613
- raise errors.APIError(
2614
- "API error occurred", http_res.status_code, http_res_text, http_res
2615
- )
2399
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2616
2400
  if utils.match_response(http_res, "5XX", "*"):
2617
2401
  http_res_text = utils.stream_to_text(http_res)
2618
- raise errors.APIError(
2619
- "API error occurred", http_res.status_code, http_res_text, http_res
2620
- )
2402
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2621
2403
 
2622
- content_type = http_res.headers.get("Content-Type")
2623
- http_res_text = utils.stream_to_text(http_res)
2624
- raise errors.APIError(
2625
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2626
- http_res.status_code,
2627
- http_res_text,
2628
- http_res,
2629
- )
2404
+ raise errors.APIError("Unexpected response received", http_res)
2630
2405
 
2631
2406
  async def borrow_async(
2632
2407
  self,
@@ -2728,31 +2503,20 @@ class Morpho(BaseSDK):
2728
2503
 
2729
2504
  response_data: Any = None
2730
2505
  if utils.match_response(http_res, "200", "application/json"):
2731
- return utils.unmarshal_json(http_res.text, models.TxResponse)
2506
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
2732
2507
  if utils.match_response(http_res, "422", "application/json"):
2733
- response_data = utils.unmarshal_json(
2734
- http_res.text, errors.HTTPValidationErrorData
2508
+ response_data = utils.unmarshal_json_response(
2509
+ errors.HTTPValidationErrorData, http_res
2735
2510
  )
2736
- raise errors.HTTPValidationError(data=response_data)
2511
+ raise errors.HTTPValidationError(response_data, http_res)
2737
2512
  if utils.match_response(http_res, "4XX", "*"):
2738
2513
  http_res_text = await utils.stream_to_text_async(http_res)
2739
- raise errors.APIError(
2740
- "API error occurred", http_res.status_code, http_res_text, http_res
2741
- )
2514
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2742
2515
  if utils.match_response(http_res, "5XX", "*"):
2743
2516
  http_res_text = await utils.stream_to_text_async(http_res)
2744
- raise errors.APIError(
2745
- "API error occurred", http_res.status_code, http_res_text, http_res
2746
- )
2517
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2747
2518
 
2748
- content_type = http_res.headers.get("Content-Type")
2749
- http_res_text = await utils.stream_to_text_async(http_res)
2750
- raise errors.APIError(
2751
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2752
- http_res.status_code,
2753
- http_res_text,
2754
- http_res,
2755
- )
2519
+ raise errors.APIError("Unexpected response received", http_res)
2756
2520
 
2757
2521
  def repay(
2758
2522
  self,
@@ -2849,31 +2613,20 @@ class Morpho(BaseSDK):
2849
2613
 
2850
2614
  response_data: Any = None
2851
2615
  if utils.match_response(http_res, "200", "application/json"):
2852
- return utils.unmarshal_json(http_res.text, models.TxResponse)
2616
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
2853
2617
  if utils.match_response(http_res, "422", "application/json"):
2854
- response_data = utils.unmarshal_json(
2855
- http_res.text, errors.HTTPValidationErrorData
2618
+ response_data = utils.unmarshal_json_response(
2619
+ errors.HTTPValidationErrorData, http_res
2856
2620
  )
2857
- raise errors.HTTPValidationError(data=response_data)
2621
+ raise errors.HTTPValidationError(response_data, http_res)
2858
2622
  if utils.match_response(http_res, "4XX", "*"):
2859
2623
  http_res_text = utils.stream_to_text(http_res)
2860
- raise errors.APIError(
2861
- "API error occurred", http_res.status_code, http_res_text, http_res
2862
- )
2624
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2863
2625
  if utils.match_response(http_res, "5XX", "*"):
2864
2626
  http_res_text = utils.stream_to_text(http_res)
2865
- raise errors.APIError(
2866
- "API error occurred", http_res.status_code, http_res_text, http_res
2867
- )
2627
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2868
2628
 
2869
- content_type = http_res.headers.get("Content-Type")
2870
- http_res_text = utils.stream_to_text(http_res)
2871
- raise errors.APIError(
2872
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2873
- http_res.status_code,
2874
- http_res_text,
2875
- http_res,
2876
- )
2629
+ raise errors.APIError("Unexpected response received", http_res)
2877
2630
 
2878
2631
  async def repay_async(
2879
2632
  self,
@@ -2970,28 +2723,17 @@ class Morpho(BaseSDK):
2970
2723
 
2971
2724
  response_data: Any = None
2972
2725
  if utils.match_response(http_res, "200", "application/json"):
2973
- return utils.unmarshal_json(http_res.text, models.TxResponse)
2726
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
2974
2727
  if utils.match_response(http_res, "422", "application/json"):
2975
- response_data = utils.unmarshal_json(
2976
- http_res.text, errors.HTTPValidationErrorData
2728
+ response_data = utils.unmarshal_json_response(
2729
+ errors.HTTPValidationErrorData, http_res
2977
2730
  )
2978
- raise errors.HTTPValidationError(data=response_data)
2731
+ raise errors.HTTPValidationError(response_data, http_res)
2979
2732
  if utils.match_response(http_res, "4XX", "*"):
2980
2733
  http_res_text = await utils.stream_to_text_async(http_res)
2981
- raise errors.APIError(
2982
- "API error occurred", http_res.status_code, http_res_text, http_res
2983
- )
2734
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2984
2735
  if utils.match_response(http_res, "5XX", "*"):
2985
2736
  http_res_text = await utils.stream_to_text_async(http_res)
2986
- raise errors.APIError(
2987
- "API error occurred", http_res.status_code, http_res_text, http_res
2988
- )
2737
+ raise errors.APIError("API error occurred", http_res, http_res_text)
2989
2738
 
2990
- content_type = http_res.headers.get("Content-Type")
2991
- http_res_text = await utils.stream_to_text_async(http_res)
2992
- raise errors.APIError(
2993
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
2994
- http_res.status_code,
2995
- http_res_text,
2996
- http_res,
2997
- )
2739
+ raise errors.APIError("Unexpected response received", http_res)