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

@@ -86,31 +86,20 @@ class Universal(BaseSDK):
86
86
 
87
87
  response_data: Any = None
88
88
  if utils.match_response(http_res, "200", "application/json"):
89
- return utils.unmarshal_json(http_res.text, models.Portfolio)
89
+ return utils.unmarshal_json_response(models.Portfolio, http_res)
90
90
  if utils.match_response(http_res, "422", "application/json"):
91
- response_data = utils.unmarshal_json(
92
- http_res.text, errors.HTTPValidationErrorData
91
+ response_data = utils.unmarshal_json_response(
92
+ errors.HTTPValidationErrorData, http_res
93
93
  )
94
- raise errors.HTTPValidationError(data=response_data)
94
+ raise errors.HTTPValidationError(response_data, http_res)
95
95
  if utils.match_response(http_res, "4XX", "*"):
96
96
  http_res_text = utils.stream_to_text(http_res)
97
- raise errors.APIError(
98
- "API error occurred", http_res.status_code, http_res_text, http_res
99
- )
97
+ raise errors.APIError("API error occurred", http_res, http_res_text)
100
98
  if utils.match_response(http_res, "5XX", "*"):
101
99
  http_res_text = utils.stream_to_text(http_res)
102
- raise errors.APIError(
103
- "API error occurred", http_res.status_code, http_res_text, http_res
104
- )
100
+ raise errors.APIError("API error occurred", http_res, http_res_text)
105
101
 
106
- content_type = http_res.headers.get("Content-Type")
107
- http_res_text = utils.stream_to_text(http_res)
108
- raise errors.APIError(
109
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
110
- http_res.status_code,
111
- http_res_text,
112
- http_res,
113
- )
102
+ raise errors.APIError("Unexpected response received", http_res)
114
103
 
115
104
  async def portfolio_async(
116
105
  self,
@@ -190,31 +179,20 @@ class Universal(BaseSDK):
190
179
 
191
180
  response_data: Any = None
192
181
  if utils.match_response(http_res, "200", "application/json"):
193
- return utils.unmarshal_json(http_res.text, models.Portfolio)
182
+ return utils.unmarshal_json_response(models.Portfolio, http_res)
194
183
  if utils.match_response(http_res, "422", "application/json"):
195
- response_data = utils.unmarshal_json(
196
- http_res.text, errors.HTTPValidationErrorData
184
+ response_data = utils.unmarshal_json_response(
185
+ errors.HTTPValidationErrorData, http_res
197
186
  )
198
- raise errors.HTTPValidationError(data=response_data)
187
+ raise errors.HTTPValidationError(response_data, http_res)
199
188
  if utils.match_response(http_res, "4XX", "*"):
200
189
  http_res_text = await utils.stream_to_text_async(http_res)
201
- raise errors.APIError(
202
- "API error occurred", http_res.status_code, http_res_text, http_res
203
- )
190
+ raise errors.APIError("API error occurred", http_res, http_res_text)
204
191
  if utils.match_response(http_res, "5XX", "*"):
205
192
  http_res_text = await utils.stream_to_text_async(http_res)
206
- raise errors.APIError(
207
- "API error occurred", http_res.status_code, http_res_text, http_res
208
- )
193
+ raise errors.APIError("API error occurred", http_res, http_res_text)
209
194
 
210
- content_type = http_res.headers.get("Content-Type")
211
- http_res_text = await utils.stream_to_text_async(http_res)
212
- raise errors.APIError(
213
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
214
- http_res.status_code,
215
- http_res_text,
216
- http_res,
217
- )
195
+ raise errors.APIError("Unexpected response received", http_res)
218
196
 
219
197
  def visualize_portfolio(
220
198
  self,
@@ -295,31 +273,20 @@ class Universal(BaseSDK):
295
273
 
296
274
  response_data: Any = None
297
275
  if utils.match_response(http_res, "200", "application/json"):
298
- return utils.unmarshal_json(http_res.text, models.Image)
276
+ return utils.unmarshal_json_response(models.Image, http_res)
299
277
  if utils.match_response(http_res, "422", "application/json"):
300
- response_data = utils.unmarshal_json(
301
- http_res.text, errors.HTTPValidationErrorData
278
+ response_data = utils.unmarshal_json_response(
279
+ errors.HTTPValidationErrorData, http_res
302
280
  )
303
- raise errors.HTTPValidationError(data=response_data)
281
+ raise errors.HTTPValidationError(response_data, http_res)
304
282
  if utils.match_response(http_res, "4XX", "*"):
305
283
  http_res_text = utils.stream_to_text(http_res)
306
- raise errors.APIError(
307
- "API error occurred", http_res.status_code, http_res_text, http_res
308
- )
284
+ raise errors.APIError("API error occurred", http_res, http_res_text)
309
285
  if utils.match_response(http_res, "5XX", "*"):
310
286
  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
- )
287
+ raise errors.APIError("API error occurred", http_res, http_res_text)
314
288
 
315
- content_type = http_res.headers.get("Content-Type")
316
- http_res_text = utils.stream_to_text(http_res)
317
- raise errors.APIError(
318
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
319
- http_res.status_code,
320
- http_res_text,
321
- http_res,
322
- )
289
+ raise errors.APIError("Unexpected response received", http_res)
323
290
 
324
291
  async def visualize_portfolio_async(
325
292
  self,
@@ -400,31 +367,20 @@ class Universal(BaseSDK):
400
367
 
401
368
  response_data: Any = None
402
369
  if utils.match_response(http_res, "200", "application/json"):
403
- return utils.unmarshal_json(http_res.text, models.Image)
370
+ return utils.unmarshal_json_response(models.Image, http_res)
404
371
  if utils.match_response(http_res, "422", "application/json"):
405
- response_data = utils.unmarshal_json(
406
- http_res.text, errors.HTTPValidationErrorData
372
+ response_data = utils.unmarshal_json_response(
373
+ errors.HTTPValidationErrorData, http_res
407
374
  )
408
- raise errors.HTTPValidationError(data=response_data)
375
+ raise errors.HTTPValidationError(response_data, http_res)
409
376
  if utils.match_response(http_res, "4XX", "*"):
410
377
  http_res_text = await utils.stream_to_text_async(http_res)
411
- raise errors.APIError(
412
- "API error occurred", http_res.status_code, http_res_text, http_res
413
- )
378
+ raise errors.APIError("API error occurred", http_res, http_res_text)
414
379
  if utils.match_response(http_res, "5XX", "*"):
415
380
  http_res_text = await utils.stream_to_text_async(http_res)
416
- raise errors.APIError(
417
- "API error occurred", http_res.status_code, http_res_text, http_res
418
- )
381
+ raise errors.APIError("API error occurred", http_res, http_res_text)
419
382
 
420
- content_type = http_res.headers.get("Content-Type")
421
- http_res_text = await utils.stream_to_text_async(http_res)
422
- raise errors.APIError(
423
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
424
- http_res.status_code,
425
- http_res_text,
426
- http_res,
427
- )
383
+ raise errors.APIError("Unexpected response received", http_res)
428
384
 
429
385
  def supported_tokens(
430
386
  self,
@@ -498,31 +454,20 @@ class Universal(BaseSDK):
498
454
 
499
455
  response_data: Any = None
500
456
  if utils.match_response(http_res, "200", "application/json"):
501
- return utils.unmarshal_json(http_res.text, models.TokenInfo)
457
+ return utils.unmarshal_json_response(models.TokenInfo, http_res)
502
458
  if utils.match_response(http_res, "422", "application/json"):
503
- response_data = utils.unmarshal_json(
504
- http_res.text, errors.HTTPValidationErrorData
459
+ response_data = utils.unmarshal_json_response(
460
+ errors.HTTPValidationErrorData, http_res
505
461
  )
506
- raise errors.HTTPValidationError(data=response_data)
462
+ raise errors.HTTPValidationError(response_data, http_res)
507
463
  if utils.match_response(http_res, "4XX", "*"):
508
464
  http_res_text = utils.stream_to_text(http_res)
509
- raise errors.APIError(
510
- "API error occurred", http_res.status_code, http_res_text, http_res
511
- )
465
+ raise errors.APIError("API error occurred", http_res, http_res_text)
512
466
  if utils.match_response(http_res, "5XX", "*"):
513
467
  http_res_text = utils.stream_to_text(http_res)
514
- raise errors.APIError(
515
- "API error occurred", http_res.status_code, http_res_text, http_res
516
- )
468
+ raise errors.APIError("API error occurred", http_res, http_res_text)
517
469
 
518
- content_type = http_res.headers.get("Content-Type")
519
- http_res_text = utils.stream_to_text(http_res)
520
- raise errors.APIError(
521
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
522
- http_res.status_code,
523
- http_res_text,
524
- http_res,
525
- )
470
+ raise errors.APIError("Unexpected response received", http_res)
526
471
 
527
472
  async def supported_tokens_async(
528
473
  self,
@@ -596,31 +541,20 @@ class Universal(BaseSDK):
596
541
 
597
542
  response_data: Any = None
598
543
  if utils.match_response(http_res, "200", "application/json"):
599
- return utils.unmarshal_json(http_res.text, models.TokenInfo)
544
+ return utils.unmarshal_json_response(models.TokenInfo, http_res)
600
545
  if utils.match_response(http_res, "422", "application/json"):
601
- response_data = utils.unmarshal_json(
602
- http_res.text, errors.HTTPValidationErrorData
546
+ response_data = utils.unmarshal_json_response(
547
+ errors.HTTPValidationErrorData, http_res
603
548
  )
604
- raise errors.HTTPValidationError(data=response_data)
549
+ raise errors.HTTPValidationError(response_data, http_res)
605
550
  if utils.match_response(http_res, "4XX", "*"):
606
551
  http_res_text = await utils.stream_to_text_async(http_res)
607
- raise errors.APIError(
608
- "API error occurred", http_res.status_code, http_res_text, http_res
609
- )
552
+ raise errors.APIError("API error occurred", http_res, http_res_text)
610
553
  if utils.match_response(http_res, "5XX", "*"):
611
554
  http_res_text = await utils.stream_to_text_async(http_res)
612
- raise errors.APIError(
613
- "API error occurred", http_res.status_code, http_res_text, http_res
614
- )
555
+ raise errors.APIError("API error occurred", http_res, http_res_text)
615
556
 
616
- content_type = http_res.headers.get("Content-Type")
617
- http_res_text = await utils.stream_to_text_async(http_res)
618
- raise errors.APIError(
619
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
620
- http_res.status_code,
621
- http_res_text,
622
- http_res,
623
- )
557
+ raise errors.APIError("Unexpected response received", http_res)
624
558
 
625
559
  def allowance(
626
560
  self,
@@ -714,31 +648,20 @@ class Universal(BaseSDK):
714
648
 
715
649
  response_data: Any = None
716
650
  if utils.match_response(http_res, "200", "application/json"):
717
- return utils.unmarshal_json(http_res.text, models.AllowanceInfoResponse)
651
+ return utils.unmarshal_json_response(models.AllowanceInfoResponse, http_res)
718
652
  if utils.match_response(http_res, "422", "application/json"):
719
- response_data = utils.unmarshal_json(
720
- http_res.text, errors.HTTPValidationErrorData
653
+ response_data = utils.unmarshal_json_response(
654
+ errors.HTTPValidationErrorData, http_res
721
655
  )
722
- raise errors.HTTPValidationError(data=response_data)
656
+ raise errors.HTTPValidationError(response_data, http_res)
723
657
  if utils.match_response(http_res, "4XX", "*"):
724
658
  http_res_text = utils.stream_to_text(http_res)
725
- raise errors.APIError(
726
- "API error occurred", http_res.status_code, http_res_text, http_res
727
- )
659
+ raise errors.APIError("API error occurred", http_res, http_res_text)
728
660
  if utils.match_response(http_res, "5XX", "*"):
729
661
  http_res_text = utils.stream_to_text(http_res)
730
- raise errors.APIError(
731
- "API error occurred", http_res.status_code, http_res_text, http_res
732
- )
662
+ raise errors.APIError("API error occurred", http_res, http_res_text)
733
663
 
734
- content_type = http_res.headers.get("Content-Type")
735
- http_res_text = utils.stream_to_text(http_res)
736
- raise errors.APIError(
737
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
738
- http_res.status_code,
739
- http_res_text,
740
- http_res,
741
- )
664
+ raise errors.APIError("Unexpected response received", http_res)
742
665
 
743
666
  async def allowance_async(
744
667
  self,
@@ -832,31 +755,20 @@ class Universal(BaseSDK):
832
755
 
833
756
  response_data: Any = None
834
757
  if utils.match_response(http_res, "200", "application/json"):
835
- return utils.unmarshal_json(http_res.text, models.AllowanceInfoResponse)
758
+ return utils.unmarshal_json_response(models.AllowanceInfoResponse, http_res)
836
759
  if utils.match_response(http_res, "422", "application/json"):
837
- response_data = utils.unmarshal_json(
838
- http_res.text, errors.HTTPValidationErrorData
760
+ response_data = utils.unmarshal_json_response(
761
+ errors.HTTPValidationErrorData, http_res
839
762
  )
840
- raise errors.HTTPValidationError(data=response_data)
763
+ raise errors.HTTPValidationError(response_data, http_res)
841
764
  if utils.match_response(http_res, "4XX", "*"):
842
765
  http_res_text = await utils.stream_to_text_async(http_res)
843
- raise errors.APIError(
844
- "API error occurred", http_res.status_code, http_res_text, http_res
845
- )
766
+ raise errors.APIError("API error occurred", http_res, http_res_text)
846
767
  if utils.match_response(http_res, "5XX", "*"):
847
768
  http_res_text = await utils.stream_to_text_async(http_res)
848
- raise errors.APIError(
849
- "API error occurred", http_res.status_code, http_res_text, http_res
850
- )
769
+ raise errors.APIError("API error occurred", http_res, http_res_text)
851
770
 
852
- content_type = http_res.headers.get("Content-Type")
853
- http_res_text = await utils.stream_to_text_async(http_res)
854
- raise errors.APIError(
855
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
856
- http_res.status_code,
857
- http_res_text,
858
- http_res,
859
- )
771
+ raise errors.APIError("Unexpected response received", http_res)
860
772
 
861
773
  def ens(
862
774
  self,
@@ -936,31 +848,20 @@ class Universal(BaseSDK):
936
848
 
937
849
  response_data: Any = None
938
850
  if utils.match_response(http_res, "200", "application/json"):
939
- return utils.unmarshal_json(http_res.text, models.EnsNameInfoResponse)
851
+ return utils.unmarshal_json_response(models.EnsNameInfoResponse, http_res)
940
852
  if utils.match_response(http_res, "422", "application/json"):
941
- response_data = utils.unmarshal_json(
942
- http_res.text, errors.HTTPValidationErrorData
853
+ response_data = utils.unmarshal_json_response(
854
+ errors.HTTPValidationErrorData, http_res
943
855
  )
944
- raise errors.HTTPValidationError(data=response_data)
856
+ raise errors.HTTPValidationError(response_data, http_res)
945
857
  if utils.match_response(http_res, "4XX", "*"):
946
858
  http_res_text = utils.stream_to_text(http_res)
947
- raise errors.APIError(
948
- "API error occurred", http_res.status_code, http_res_text, http_res
949
- )
859
+ raise errors.APIError("API error occurred", http_res, http_res_text)
950
860
  if utils.match_response(http_res, "5XX", "*"):
951
861
  http_res_text = utils.stream_to_text(http_res)
952
- raise errors.APIError(
953
- "API error occurred", http_res.status_code, http_res_text, http_res
954
- )
862
+ raise errors.APIError("API error occurred", http_res, http_res_text)
955
863
 
956
- content_type = http_res.headers.get("Content-Type")
957
- http_res_text = utils.stream_to_text(http_res)
958
- raise errors.APIError(
959
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
960
- http_res.status_code,
961
- http_res_text,
962
- http_res,
963
- )
864
+ raise errors.APIError("Unexpected response received", http_res)
964
865
 
965
866
  async def ens_async(
966
867
  self,
@@ -1040,31 +941,20 @@ class Universal(BaseSDK):
1040
941
 
1041
942
  response_data: Any = None
1042
943
  if utils.match_response(http_res, "200", "application/json"):
1043
- return utils.unmarshal_json(http_res.text, models.EnsNameInfoResponse)
944
+ return utils.unmarshal_json_response(models.EnsNameInfoResponse, http_res)
1044
945
  if utils.match_response(http_res, "422", "application/json"):
1045
- response_data = utils.unmarshal_json(
1046
- http_res.text, errors.HTTPValidationErrorData
946
+ response_data = utils.unmarshal_json_response(
947
+ errors.HTTPValidationErrorData, http_res
1047
948
  )
1048
- raise errors.HTTPValidationError(data=response_data)
949
+ raise errors.HTTPValidationError(response_data, http_res)
1049
950
  if utils.match_response(http_res, "4XX", "*"):
1050
951
  http_res_text = await utils.stream_to_text_async(http_res)
1051
- raise errors.APIError(
1052
- "API error occurred", http_res.status_code, http_res_text, http_res
1053
- )
952
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1054
953
  if utils.match_response(http_res, "5XX", "*"):
1055
954
  http_res_text = await utils.stream_to_text_async(http_res)
1056
- raise errors.APIError(
1057
- "API error occurred", http_res.status_code, http_res_text, http_res
1058
- )
955
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1059
956
 
1060
- content_type = http_res.headers.get("Content-Type")
1061
- http_res_text = await utils.stream_to_text_async(http_res)
1062
- raise errors.APIError(
1063
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1064
- http_res.status_code,
1065
- http_res_text,
1066
- http_res,
1067
- )
957
+ raise errors.APIError("Unexpected response received", http_res)
1068
958
 
1069
959
  def wrap_eth(
1070
960
  self,
@@ -1150,31 +1040,20 @@ class Universal(BaseSDK):
1150
1040
 
1151
1041
  response_data: Any = None
1152
1042
  if utils.match_response(http_res, "200", "application/json"):
1153
- return utils.unmarshal_json(http_res.text, models.TxResponse)
1043
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
1154
1044
  if utils.match_response(http_res, "422", "application/json"):
1155
- response_data = utils.unmarshal_json(
1156
- http_res.text, errors.HTTPValidationErrorData
1045
+ response_data = utils.unmarshal_json_response(
1046
+ errors.HTTPValidationErrorData, http_res
1157
1047
  )
1158
- raise errors.HTTPValidationError(data=response_data)
1048
+ raise errors.HTTPValidationError(response_data, http_res)
1159
1049
  if utils.match_response(http_res, "4XX", "*"):
1160
1050
  http_res_text = utils.stream_to_text(http_res)
1161
- raise errors.APIError(
1162
- "API error occurred", http_res.status_code, http_res_text, http_res
1163
- )
1051
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1164
1052
  if utils.match_response(http_res, "5XX", "*"):
1165
1053
  http_res_text = utils.stream_to_text(http_res)
1166
- raise errors.APIError(
1167
- "API error occurred", http_res.status_code, http_res_text, http_res
1168
- )
1054
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1169
1055
 
1170
- content_type = http_res.headers.get("Content-Type")
1171
- http_res_text = utils.stream_to_text(http_res)
1172
- raise errors.APIError(
1173
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1174
- http_res.status_code,
1175
- http_res_text,
1176
- http_res,
1177
- )
1056
+ raise errors.APIError("Unexpected response received", http_res)
1178
1057
 
1179
1058
  async def wrap_eth_async(
1180
1059
  self,
@@ -1260,31 +1139,20 @@ class Universal(BaseSDK):
1260
1139
 
1261
1140
  response_data: Any = None
1262
1141
  if utils.match_response(http_res, "200", "application/json"):
1263
- return utils.unmarshal_json(http_res.text, models.TxResponse)
1142
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
1264
1143
  if utils.match_response(http_res, "422", "application/json"):
1265
- response_data = utils.unmarshal_json(
1266
- http_res.text, errors.HTTPValidationErrorData
1144
+ response_data = utils.unmarshal_json_response(
1145
+ errors.HTTPValidationErrorData, http_res
1267
1146
  )
1268
- raise errors.HTTPValidationError(data=response_data)
1147
+ raise errors.HTTPValidationError(response_data, http_res)
1269
1148
  if utils.match_response(http_res, "4XX", "*"):
1270
1149
  http_res_text = await utils.stream_to_text_async(http_res)
1271
- raise errors.APIError(
1272
- "API error occurred", http_res.status_code, http_res_text, http_res
1273
- )
1150
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1274
1151
  if utils.match_response(http_res, "5XX", "*"):
1275
1152
  http_res_text = await utils.stream_to_text_async(http_res)
1276
- raise errors.APIError(
1277
- "API error occurred", http_res.status_code, http_res_text, http_res
1278
- )
1153
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1279
1154
 
1280
- content_type = http_res.headers.get("Content-Type")
1281
- http_res_text = await utils.stream_to_text_async(http_res)
1282
- raise errors.APIError(
1283
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1284
- http_res.status_code,
1285
- http_res_text,
1286
- http_res,
1287
- )
1155
+ raise errors.APIError("Unexpected response received", http_res)
1288
1156
 
1289
1157
  def unwrap_weth(
1290
1158
  self,
@@ -1370,31 +1238,20 @@ class Universal(BaseSDK):
1370
1238
 
1371
1239
  response_data: Any = None
1372
1240
  if utils.match_response(http_res, "200", "application/json"):
1373
- return utils.unmarshal_json(http_res.text, models.TxResponse)
1241
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
1374
1242
  if utils.match_response(http_res, "422", "application/json"):
1375
- response_data = utils.unmarshal_json(
1376
- http_res.text, errors.HTTPValidationErrorData
1243
+ response_data = utils.unmarshal_json_response(
1244
+ errors.HTTPValidationErrorData, http_res
1377
1245
  )
1378
- raise errors.HTTPValidationError(data=response_data)
1246
+ raise errors.HTTPValidationError(response_data, http_res)
1379
1247
  if utils.match_response(http_res, "4XX", "*"):
1380
1248
  http_res_text = utils.stream_to_text(http_res)
1381
- raise errors.APIError(
1382
- "API error occurred", http_res.status_code, http_res_text, http_res
1383
- )
1249
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1384
1250
  if utils.match_response(http_res, "5XX", "*"):
1385
1251
  http_res_text = utils.stream_to_text(http_res)
1386
- raise errors.APIError(
1387
- "API error occurred", http_res.status_code, http_res_text, http_res
1388
- )
1252
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1389
1253
 
1390
- content_type = http_res.headers.get("Content-Type")
1391
- http_res_text = utils.stream_to_text(http_res)
1392
- raise errors.APIError(
1393
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1394
- http_res.status_code,
1395
- http_res_text,
1396
- http_res,
1397
- )
1254
+ raise errors.APIError("Unexpected response received", http_res)
1398
1255
 
1399
1256
  async def unwrap_weth_async(
1400
1257
  self,
@@ -1480,31 +1337,20 @@ class Universal(BaseSDK):
1480
1337
 
1481
1338
  response_data: Any = None
1482
1339
  if utils.match_response(http_res, "200", "application/json"):
1483
- return utils.unmarshal_json(http_res.text, models.TxResponse)
1340
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
1484
1341
  if utils.match_response(http_res, "422", "application/json"):
1485
- response_data = utils.unmarshal_json(
1486
- http_res.text, errors.HTTPValidationErrorData
1342
+ response_data = utils.unmarshal_json_response(
1343
+ errors.HTTPValidationErrorData, http_res
1487
1344
  )
1488
- raise errors.HTTPValidationError(data=response_data)
1345
+ raise errors.HTTPValidationError(response_data, http_res)
1489
1346
  if utils.match_response(http_res, "4XX", "*"):
1490
1347
  http_res_text = await utils.stream_to_text_async(http_res)
1491
- raise errors.APIError(
1492
- "API error occurred", http_res.status_code, http_res_text, http_res
1493
- )
1348
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1494
1349
  if utils.match_response(http_res, "5XX", "*"):
1495
1350
  http_res_text = await utils.stream_to_text_async(http_res)
1496
- raise errors.APIError(
1497
- "API error occurred", http_res.status_code, http_res_text, http_res
1498
- )
1351
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1499
1352
 
1500
- content_type = http_res.headers.get("Content-Type")
1501
- http_res_text = await utils.stream_to_text_async(http_res)
1502
- raise errors.APIError(
1503
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1504
- http_res.status_code,
1505
- http_res_text,
1506
- http_res,
1507
- )
1353
+ raise errors.APIError("Unexpected response received", http_res)
1508
1354
 
1509
1355
  def allowance_set(
1510
1356
  self,
@@ -1607,31 +1453,20 @@ class Universal(BaseSDK):
1607
1453
 
1608
1454
  response_data: Any = None
1609
1455
  if utils.match_response(http_res, "200", "application/json"):
1610
- return utils.unmarshal_json(http_res.text, models.TxResponse)
1456
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
1611
1457
  if utils.match_response(http_res, "422", "application/json"):
1612
- response_data = utils.unmarshal_json(
1613
- http_res.text, errors.HTTPValidationErrorData
1458
+ response_data = utils.unmarshal_json_response(
1459
+ errors.HTTPValidationErrorData, http_res
1614
1460
  )
1615
- raise errors.HTTPValidationError(data=response_data)
1461
+ raise errors.HTTPValidationError(response_data, http_res)
1616
1462
  if utils.match_response(http_res, "4XX", "*"):
1617
1463
  http_res_text = utils.stream_to_text(http_res)
1618
- raise errors.APIError(
1619
- "API error occurred", http_res.status_code, http_res_text, http_res
1620
- )
1464
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1621
1465
  if utils.match_response(http_res, "5XX", "*"):
1622
1466
  http_res_text = utils.stream_to_text(http_res)
1623
- raise errors.APIError(
1624
- "API error occurred", http_res.status_code, http_res_text, http_res
1625
- )
1467
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1626
1468
 
1627
- content_type = http_res.headers.get("Content-Type")
1628
- http_res_text = utils.stream_to_text(http_res)
1629
- raise errors.APIError(
1630
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1631
- http_res.status_code,
1632
- http_res_text,
1633
- http_res,
1634
- )
1469
+ raise errors.APIError("Unexpected response received", http_res)
1635
1470
 
1636
1471
  async def allowance_set_async(
1637
1472
  self,
@@ -1734,28 +1569,17 @@ class Universal(BaseSDK):
1734
1569
 
1735
1570
  response_data: Any = None
1736
1571
  if utils.match_response(http_res, "200", "application/json"):
1737
- return utils.unmarshal_json(http_res.text, models.TxResponse)
1572
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
1738
1573
  if utils.match_response(http_res, "422", "application/json"):
1739
- response_data = utils.unmarshal_json(
1740
- http_res.text, errors.HTTPValidationErrorData
1574
+ response_data = utils.unmarshal_json_response(
1575
+ errors.HTTPValidationErrorData, http_res
1741
1576
  )
1742
- raise errors.HTTPValidationError(data=response_data)
1577
+ raise errors.HTTPValidationError(response_data, http_res)
1743
1578
  if utils.match_response(http_res, "4XX", "*"):
1744
1579
  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
- )
1580
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1748
1581
  if utils.match_response(http_res, "5XX", "*"):
1749
1582
  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
- )
1583
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1753
1584
 
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
- )
1585
+ raise errors.APIError("Unexpected response received", http_res)
@@ -28,6 +28,7 @@ if TYPE_CHECKING:
28
28
  marshal_json,
29
29
  unmarshal,
30
30
  unmarshal_json,
31
+ unmarshal_json_response,
31
32
  serialize_decimal,
32
33
  serialize_float,
33
34
  serialize_int,
@@ -96,6 +97,7 @@ __all__ = [
96
97
  "template_url",
97
98
  "unmarshal",
98
99
  "unmarshal_json",
100
+ "unmarshal_json_response",
99
101
  "validate_decimal",
100
102
  "validate_const",
101
103
  "validate_float",
@@ -149,6 +151,7 @@ _dynamic_imports: dict[str, str] = {
149
151
  "template_url": ".url",
150
152
  "unmarshal": ".serializers",
151
153
  "unmarshal_json": ".serializers",
154
+ "unmarshal_json_response": ".serializers",
152
155
  "validate_decimal": ".serializers",
153
156
  "validate_const": ".serializers",
154
157
  "validate_float": ".serializers",