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.

@@ -83,31 +83,20 @@ class TokenSDK(BaseSDK):
83
83
 
84
84
  response_data: Any = None
85
85
  if utils.match_response(http_res, "200", "application/json"):
86
- return utils.unmarshal_json(http_res.text, models.TokenAddressResponse)
86
+ return utils.unmarshal_json_response(models.TokenAddressResponse, http_res)
87
87
  if utils.match_response(http_res, "422", "application/json"):
88
- response_data = utils.unmarshal_json(
89
- http_res.text, errors.HTTPValidationErrorData
88
+ response_data = utils.unmarshal_json_response(
89
+ errors.HTTPValidationErrorData, http_res
90
90
  )
91
- raise errors.HTTPValidationError(data=response_data)
91
+ raise errors.HTTPValidationError(response_data, http_res)
92
92
  if utils.match_response(http_res, "4XX", "*"):
93
93
  http_res_text = utils.stream_to_text(http_res)
94
- raise errors.APIError(
95
- "API error occurred", http_res.status_code, http_res_text, http_res
96
- )
94
+ raise errors.APIError("API error occurred", http_res, http_res_text)
97
95
  if utils.match_response(http_res, "5XX", "*"):
98
96
  http_res_text = utils.stream_to_text(http_res)
99
- raise errors.APIError(
100
- "API error occurred", http_res.status_code, http_res_text, http_res
101
- )
97
+ raise errors.APIError("API error occurred", http_res, http_res_text)
102
98
 
103
- content_type = http_res.headers.get("Content-Type")
104
- http_res_text = utils.stream_to_text(http_res)
105
- raise errors.APIError(
106
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
107
- http_res.status_code,
108
- http_res_text,
109
- http_res,
110
- )
99
+ raise errors.APIError("Unexpected response received", http_res)
111
100
 
112
101
  async def address_async(
113
102
  self,
@@ -184,37 +173,27 @@ class TokenSDK(BaseSDK):
184
173
 
185
174
  response_data: Any = None
186
175
  if utils.match_response(http_res, "200", "application/json"):
187
- return utils.unmarshal_json(http_res.text, models.TokenAddressResponse)
176
+ return utils.unmarshal_json_response(models.TokenAddressResponse, http_res)
188
177
  if utils.match_response(http_res, "422", "application/json"):
189
- response_data = utils.unmarshal_json(
190
- http_res.text, errors.HTTPValidationErrorData
178
+ response_data = utils.unmarshal_json_response(
179
+ errors.HTTPValidationErrorData, http_res
191
180
  )
192
- raise errors.HTTPValidationError(data=response_data)
181
+ raise errors.HTTPValidationError(response_data, http_res)
193
182
  if utils.match_response(http_res, "4XX", "*"):
194
183
  http_res_text = await utils.stream_to_text_async(http_res)
195
- raise errors.APIError(
196
- "API error occurred", http_res.status_code, http_res_text, http_res
197
- )
184
+ raise errors.APIError("API error occurred", http_res, http_res_text)
198
185
  if utils.match_response(http_res, "5XX", "*"):
199
186
  http_res_text = await utils.stream_to_text_async(http_res)
200
- raise errors.APIError(
201
- "API error occurred", http_res.status_code, http_res_text, http_res
202
- )
187
+ raise errors.APIError("API error occurred", http_res, http_res_text)
203
188
 
204
- content_type = http_res.headers.get("Content-Type")
205
- http_res_text = await utils.stream_to_text_async(http_res)
206
- raise errors.APIError(
207
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
208
- http_res.status_code,
209
- http_res_text,
210
- http_res,
211
- )
189
+ raise errors.APIError("Unexpected response received", http_res)
212
190
 
213
191
  def price(
214
192
  self,
215
193
  *,
216
194
  chain: models.TokenPriceChain = models.TokenPriceChain.ETHEREUM_MAINNET,
217
195
  token: models.TokenPriceToken = models.TokenPriceToken.AAVE,
196
+ block: OptionalNullable[int] = UNSET,
218
197
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
219
198
  server_url: Optional[str] = None,
220
199
  timeout_ms: Optional[int] = None,
@@ -230,6 +209,7 @@ class TokenSDK(BaseSDK):
230
209
 
231
210
  :param chain: The chain to use.
232
211
  :param token: The symbol of the token for which to get the price.
212
+ :param block: Optional block number (defaults to latest).
233
213
  :param retries: Override the default retry configuration for this method
234
214
  :param server_url: Override the default server URL for this method
235
215
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -247,6 +227,7 @@ class TokenSDK(BaseSDK):
247
227
 
248
228
  request = models.TokenPriceRequest(
249
229
  chain=chain,
230
+ block=block,
250
231
  token=token,
251
232
  )
252
233
 
@@ -289,37 +270,27 @@ class TokenSDK(BaseSDK):
289
270
 
290
271
  response_data: Any = None
291
272
  if utils.match_response(http_res, "200", "application/json"):
292
- return utils.unmarshal_json(http_res.text, models.TokenPriceResponse)
273
+ return utils.unmarshal_json_response(models.TokenPriceResponse, http_res)
293
274
  if utils.match_response(http_res, "422", "application/json"):
294
- response_data = utils.unmarshal_json(
295
- http_res.text, errors.HTTPValidationErrorData
275
+ response_data = utils.unmarshal_json_response(
276
+ errors.HTTPValidationErrorData, http_res
296
277
  )
297
- raise errors.HTTPValidationError(data=response_data)
278
+ raise errors.HTTPValidationError(response_data, http_res)
298
279
  if utils.match_response(http_res, "4XX", "*"):
299
280
  http_res_text = utils.stream_to_text(http_res)
300
- raise errors.APIError(
301
- "API error occurred", http_res.status_code, http_res_text, http_res
302
- )
281
+ raise errors.APIError("API error occurred", http_res, http_res_text)
303
282
  if utils.match_response(http_res, "5XX", "*"):
304
283
  http_res_text = utils.stream_to_text(http_res)
305
- raise errors.APIError(
306
- "API error occurred", http_res.status_code, http_res_text, http_res
307
- )
284
+ raise errors.APIError("API error occurred", http_res, http_res_text)
308
285
 
309
- content_type = http_res.headers.get("Content-Type")
310
- http_res_text = utils.stream_to_text(http_res)
311
- raise errors.APIError(
312
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
313
- http_res.status_code,
314
- http_res_text,
315
- http_res,
316
- )
286
+ raise errors.APIError("Unexpected response received", http_res)
317
287
 
318
288
  async def price_async(
319
289
  self,
320
290
  *,
321
291
  chain: models.TokenPriceChain = models.TokenPriceChain.ETHEREUM_MAINNET,
322
292
  token: models.TokenPriceToken = models.TokenPriceToken.AAVE,
293
+ block: OptionalNullable[int] = UNSET,
323
294
  retries: OptionalNullable[utils.RetryConfig] = UNSET,
324
295
  server_url: Optional[str] = None,
325
296
  timeout_ms: Optional[int] = None,
@@ -335,6 +306,7 @@ class TokenSDK(BaseSDK):
335
306
 
336
307
  :param chain: The chain to use.
337
308
  :param token: The symbol of the token for which to get the price.
309
+ :param block: Optional block number (defaults to latest).
338
310
  :param retries: Override the default retry configuration for this method
339
311
  :param server_url: Override the default server URL for this method
340
312
  :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -352,6 +324,7 @@ class TokenSDK(BaseSDK):
352
324
 
353
325
  request = models.TokenPriceRequest(
354
326
  chain=chain,
327
+ block=block,
355
328
  token=token,
356
329
  )
357
330
 
@@ -394,31 +367,20 @@ class TokenSDK(BaseSDK):
394
367
 
395
368
  response_data: Any = None
396
369
  if utils.match_response(http_res, "200", "application/json"):
397
- return utils.unmarshal_json(http_res.text, models.TokenPriceResponse)
370
+ return utils.unmarshal_json_response(models.TokenPriceResponse, http_res)
398
371
  if utils.match_response(http_res, "422", "application/json"):
399
- response_data = utils.unmarshal_json(
400
- http_res.text, errors.HTTPValidationErrorData
372
+ response_data = utils.unmarshal_json_response(
373
+ errors.HTTPValidationErrorData, http_res
401
374
  )
402
- raise errors.HTTPValidationError(data=response_data)
375
+ raise errors.HTTPValidationError(response_data, http_res)
403
376
  if utils.match_response(http_res, "4XX", "*"):
404
377
  http_res_text = await utils.stream_to_text_async(http_res)
405
- raise errors.APIError(
406
- "API error occurred", http_res.status_code, http_res_text, http_res
407
- )
378
+ raise errors.APIError("API error occurred", http_res, http_res_text)
408
379
  if utils.match_response(http_res, "5XX", "*"):
409
380
  http_res_text = await utils.stream_to_text_async(http_res)
410
- raise errors.APIError(
411
- "API error occurred", http_res.status_code, http_res_text, http_res
412
- )
381
+ raise errors.APIError("API error occurred", http_res, http_res_text)
413
382
 
414
- content_type = http_res.headers.get("Content-Type")
415
- http_res_text = await utils.stream_to_text_async(http_res)
416
- raise errors.APIError(
417
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
418
- http_res.status_code,
419
- http_res_text,
420
- http_res,
421
- )
383
+ raise errors.APIError("Unexpected response received", http_res)
422
384
 
423
385
  def balance(
424
386
  self,
@@ -498,31 +460,20 @@ class TokenSDK(BaseSDK):
498
460
 
499
461
  response_data: Any = None
500
462
  if utils.match_response(http_res, "200", "application/json"):
501
- return utils.unmarshal_json(http_res.text, models.TokenBalanceResponse)
463
+ return utils.unmarshal_json_response(models.TokenBalanceResponse, http_res)
502
464
  if utils.match_response(http_res, "422", "application/json"):
503
- response_data = utils.unmarshal_json(
504
- http_res.text, errors.HTTPValidationErrorData
465
+ response_data = utils.unmarshal_json_response(
466
+ errors.HTTPValidationErrorData, http_res
505
467
  )
506
- raise errors.HTTPValidationError(data=response_data)
468
+ raise errors.HTTPValidationError(response_data, http_res)
507
469
  if utils.match_response(http_res, "4XX", "*"):
508
470
  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
- )
471
+ raise errors.APIError("API error occurred", http_res, http_res_text)
512
472
  if utils.match_response(http_res, "5XX", "*"):
513
473
  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
- )
474
+ raise errors.APIError("API error occurred", http_res, http_res_text)
517
475
 
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
- )
476
+ raise errors.APIError("Unexpected response received", http_res)
526
477
 
527
478
  async def balance_async(
528
479
  self,
@@ -602,31 +553,20 @@ class TokenSDK(BaseSDK):
602
553
 
603
554
  response_data: Any = None
604
555
  if utils.match_response(http_res, "200", "application/json"):
605
- return utils.unmarshal_json(http_res.text, models.TokenBalanceResponse)
556
+ return utils.unmarshal_json_response(models.TokenBalanceResponse, http_res)
606
557
  if utils.match_response(http_res, "422", "application/json"):
607
- response_data = utils.unmarshal_json(
608
- http_res.text, errors.HTTPValidationErrorData
558
+ response_data = utils.unmarshal_json_response(
559
+ errors.HTTPValidationErrorData, http_res
609
560
  )
610
- raise errors.HTTPValidationError(data=response_data)
561
+ raise errors.HTTPValidationError(response_data, http_res)
611
562
  if utils.match_response(http_res, "4XX", "*"):
612
563
  http_res_text = await utils.stream_to_text_async(http_res)
613
- raise errors.APIError(
614
- "API error occurred", http_res.status_code, http_res_text, http_res
615
- )
564
+ raise errors.APIError("API error occurred", http_res, http_res_text)
616
565
  if utils.match_response(http_res, "5XX", "*"):
617
566
  http_res_text = await utils.stream_to_text_async(http_res)
618
- raise errors.APIError(
619
- "API error occurred", http_res.status_code, http_res_text, http_res
620
- )
567
+ raise errors.APIError("API error occurred", http_res, http_res_text)
621
568
 
622
- content_type = http_res.headers.get("Content-Type")
623
- http_res_text = await utils.stream_to_text_async(http_res)
624
- raise errors.APIError(
625
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
626
- http_res.status_code,
627
- http_res_text,
628
- http_res,
629
- )
569
+ raise errors.APIError("Unexpected response received", http_res)
630
570
 
631
571
  def transfer(
632
572
  self,
@@ -720,31 +660,20 @@ class TokenSDK(BaseSDK):
720
660
 
721
661
  response_data: Any = None
722
662
  if utils.match_response(http_res, "200", "application/json"):
723
- return utils.unmarshal_json(http_res.text, models.TxResponse)
663
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
724
664
  if utils.match_response(http_res, "422", "application/json"):
725
- response_data = utils.unmarshal_json(
726
- http_res.text, errors.HTTPValidationErrorData
665
+ response_data = utils.unmarshal_json_response(
666
+ errors.HTTPValidationErrorData, http_res
727
667
  )
728
- raise errors.HTTPValidationError(data=response_data)
668
+ raise errors.HTTPValidationError(response_data, http_res)
729
669
  if utils.match_response(http_res, "4XX", "*"):
730
670
  http_res_text = utils.stream_to_text(http_res)
731
- raise errors.APIError(
732
- "API error occurred", http_res.status_code, http_res_text, http_res
733
- )
671
+ raise errors.APIError("API error occurred", http_res, http_res_text)
734
672
  if utils.match_response(http_res, "5XX", "*"):
735
673
  http_res_text = utils.stream_to_text(http_res)
736
- raise errors.APIError(
737
- "API error occurred", http_res.status_code, http_res_text, http_res
738
- )
674
+ raise errors.APIError("API error occurred", http_res, http_res_text)
739
675
 
740
- content_type = http_res.headers.get("Content-Type")
741
- http_res_text = utils.stream_to_text(http_res)
742
- raise errors.APIError(
743
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
744
- http_res.status_code,
745
- http_res_text,
746
- http_res,
747
- )
676
+ raise errors.APIError("Unexpected response received", http_res)
748
677
 
749
678
  async def transfer_async(
750
679
  self,
@@ -838,28 +767,17 @@ class TokenSDK(BaseSDK):
838
767
 
839
768
  response_data: Any = None
840
769
  if utils.match_response(http_res, "200", "application/json"):
841
- return utils.unmarshal_json(http_res.text, models.TxResponse)
770
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
842
771
  if utils.match_response(http_res, "422", "application/json"):
843
- response_data = utils.unmarshal_json(
844
- http_res.text, errors.HTTPValidationErrorData
772
+ response_data = utils.unmarshal_json_response(
773
+ errors.HTTPValidationErrorData, http_res
845
774
  )
846
- raise errors.HTTPValidationError(data=response_data)
775
+ raise errors.HTTPValidationError(response_data, http_res)
847
776
  if utils.match_response(http_res, "4XX", "*"):
848
777
  http_res_text = await utils.stream_to_text_async(http_res)
849
- raise errors.APIError(
850
- "API error occurred", http_res.status_code, http_res_text, http_res
851
- )
778
+ raise errors.APIError("API error occurred", http_res, http_res_text)
852
779
  if utils.match_response(http_res, "5XX", "*"):
853
780
  http_res_text = await utils.stream_to_text_async(http_res)
854
- raise errors.APIError(
855
- "API error occurred", http_res.status_code, http_res_text, http_res
856
- )
781
+ raise errors.APIError("API error occurred", http_res, http_res_text)
857
782
 
858
- content_type = http_res.headers.get("Content-Type")
859
- http_res_text = await utils.stream_to_text_async(http_res)
860
- raise errors.APIError(
861
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
862
- http_res.status_code,
863
- http_res_text,
864
- http_res,
865
- )
783
+ raise errors.APIError("Unexpected response received", http_res)
@@ -91,33 +91,22 @@ class TransactionBundler(BaseSDK):
91
91
 
92
92
  response_data: Any = None
93
93
  if utils.match_response(http_res, "200", "application/json"):
94
- return utils.unmarshal_json(
95
- http_res.text, models.MulticallAuthorizationResponse
94
+ return utils.unmarshal_json_response(
95
+ models.MulticallAuthorizationResponse, http_res
96
96
  )
97
97
  if utils.match_response(http_res, "422", "application/json"):
98
- response_data = utils.unmarshal_json(
99
- http_res.text, errors.HTTPValidationErrorData
98
+ response_data = utils.unmarshal_json_response(
99
+ errors.HTTPValidationErrorData, http_res
100
100
  )
101
- raise errors.HTTPValidationError(data=response_data)
101
+ raise errors.HTTPValidationError(response_data, http_res)
102
102
  if utils.match_response(http_res, "4XX", "*"):
103
103
  http_res_text = utils.stream_to_text(http_res)
104
- raise errors.APIError(
105
- "API error occurred", http_res.status_code, http_res_text, http_res
106
- )
104
+ raise errors.APIError("API error occurred", http_res, http_res_text)
107
105
  if utils.match_response(http_res, "5XX", "*"):
108
106
  http_res_text = utils.stream_to_text(http_res)
109
- raise errors.APIError(
110
- "API error occurred", http_res.status_code, http_res_text, http_res
111
- )
107
+ raise errors.APIError("API error occurred", http_res, http_res_text)
112
108
 
113
- content_type = http_res.headers.get("Content-Type")
114
- http_res_text = utils.stream_to_text(http_res)
115
- raise errors.APIError(
116
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
117
- http_res.status_code,
118
- http_res_text,
119
- http_res,
120
- )
109
+ raise errors.APIError("Unexpected response received", http_res)
121
110
 
122
111
  async def bundler_authorization_async(
123
112
  self,
@@ -202,33 +191,22 @@ class TransactionBundler(BaseSDK):
202
191
 
203
192
  response_data: Any = None
204
193
  if utils.match_response(http_res, "200", "application/json"):
205
- return utils.unmarshal_json(
206
- http_res.text, models.MulticallAuthorizationResponse
194
+ return utils.unmarshal_json_response(
195
+ models.MulticallAuthorizationResponse, http_res
207
196
  )
208
197
  if utils.match_response(http_res, "422", "application/json"):
209
- response_data = utils.unmarshal_json(
210
- http_res.text, errors.HTTPValidationErrorData
198
+ response_data = utils.unmarshal_json_response(
199
+ errors.HTTPValidationErrorData, http_res
211
200
  )
212
- raise errors.HTTPValidationError(data=response_data)
201
+ raise errors.HTTPValidationError(response_data, http_res)
213
202
  if utils.match_response(http_res, "4XX", "*"):
214
203
  http_res_text = await utils.stream_to_text_async(http_res)
215
- raise errors.APIError(
216
- "API error occurred", http_res.status_code, http_res_text, http_res
217
- )
204
+ raise errors.APIError("API error occurred", http_res, http_res_text)
218
205
  if utils.match_response(http_res, "5XX", "*"):
219
206
  http_res_text = await utils.stream_to_text_async(http_res)
220
- raise errors.APIError(
221
- "API error occurred", http_res.status_code, http_res_text, http_res
222
- )
207
+ raise errors.APIError("API error occurred", http_res, http_res_text)
223
208
 
224
- content_type = http_res.headers.get("Content-Type")
225
- http_res_text = await utils.stream_to_text_async(http_res)
226
- raise errors.APIError(
227
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
228
- http_res.status_code,
229
- http_res_text,
230
- http_res,
231
- )
209
+ raise errors.APIError("Unexpected response received", http_res)
232
210
 
233
211
  def bundler_execute(
234
212
  self,
@@ -324,33 +302,22 @@ class TransactionBundler(BaseSDK):
324
302
 
325
303
  response_data: Any = None
326
304
  if utils.match_response(http_res, "200", "application/json"):
327
- return utils.unmarshal_json(
328
- http_res.text, models.UnsignedMulticallTransaction
305
+ return utils.unmarshal_json_response(
306
+ models.UnsignedMulticallTransaction, http_res
329
307
  )
330
308
  if utils.match_response(http_res, "422", "application/json"):
331
- response_data = utils.unmarshal_json(
332
- http_res.text, errors.HTTPValidationErrorData
309
+ response_data = utils.unmarshal_json_response(
310
+ errors.HTTPValidationErrorData, http_res
333
311
  )
334
- raise errors.HTTPValidationError(data=response_data)
312
+ raise errors.HTTPValidationError(response_data, http_res)
335
313
  if utils.match_response(http_res, "4XX", "*"):
336
314
  http_res_text = utils.stream_to_text(http_res)
337
- raise errors.APIError(
338
- "API error occurred", http_res.status_code, http_res_text, http_res
339
- )
315
+ raise errors.APIError("API error occurred", http_res, http_res_text)
340
316
  if utils.match_response(http_res, "5XX", "*"):
341
317
  http_res_text = utils.stream_to_text(http_res)
342
- raise errors.APIError(
343
- "API error occurred", http_res.status_code, http_res_text, http_res
344
- )
318
+ raise errors.APIError("API error occurred", http_res, http_res_text)
345
319
 
346
- content_type = http_res.headers.get("Content-Type")
347
- http_res_text = utils.stream_to_text(http_res)
348
- raise errors.APIError(
349
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
350
- http_res.status_code,
351
- http_res_text,
352
- http_res,
353
- )
320
+ raise errors.APIError("Unexpected response received", http_res)
354
321
 
355
322
  async def bundler_execute_async(
356
323
  self,
@@ -446,33 +413,22 @@ class TransactionBundler(BaseSDK):
446
413
 
447
414
  response_data: Any = None
448
415
  if utils.match_response(http_res, "200", "application/json"):
449
- return utils.unmarshal_json(
450
- http_res.text, models.UnsignedMulticallTransaction
416
+ return utils.unmarshal_json_response(
417
+ models.UnsignedMulticallTransaction, http_res
451
418
  )
452
419
  if utils.match_response(http_res, "422", "application/json"):
453
- response_data = utils.unmarshal_json(
454
- http_res.text, errors.HTTPValidationErrorData
420
+ response_data = utils.unmarshal_json_response(
421
+ errors.HTTPValidationErrorData, http_res
455
422
  )
456
- raise errors.HTTPValidationError(data=response_data)
423
+ raise errors.HTTPValidationError(response_data, http_res)
457
424
  if utils.match_response(http_res, "4XX", "*"):
458
425
  http_res_text = await utils.stream_to_text_async(http_res)
459
- raise errors.APIError(
460
- "API error occurred", http_res.status_code, http_res_text, http_res
461
- )
426
+ raise errors.APIError("API error occurred", http_res, http_res_text)
462
427
  if utils.match_response(http_res, "5XX", "*"):
463
428
  http_res_text = await utils.stream_to_text_async(http_res)
464
- raise errors.APIError(
465
- "API error occurred", http_res.status_code, http_res_text, http_res
466
- )
429
+ raise errors.APIError("API error occurred", http_res, http_res_text)
467
430
 
468
- content_type = http_res.headers.get("Content-Type")
469
- http_res_text = await utils.stream_to_text_async(http_res)
470
- raise errors.APIError(
471
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
472
- http_res.status_code,
473
- http_res_text,
474
- http_res,
475
- )
431
+ raise errors.APIError("Unexpected response received", http_res)
476
432
 
477
433
  def bundler_aave_loop(
478
434
  self,
@@ -591,33 +547,22 @@ class TransactionBundler(BaseSDK):
591
547
 
592
548
  response_data: Any = None
593
549
  if utils.match_response(http_res, "200", "application/json"):
594
- return utils.unmarshal_json(
595
- http_res.text, models.UnsignedMulticallTransaction
550
+ return utils.unmarshal_json_response(
551
+ models.UnsignedMulticallTransaction, http_res
596
552
  )
597
553
  if utils.match_response(http_res, "422", "application/json"):
598
- response_data = utils.unmarshal_json(
599
- http_res.text, errors.HTTPValidationErrorData
554
+ response_data = utils.unmarshal_json_response(
555
+ errors.HTTPValidationErrorData, http_res
600
556
  )
601
- raise errors.HTTPValidationError(data=response_data)
557
+ raise errors.HTTPValidationError(response_data, http_res)
602
558
  if utils.match_response(http_res, "4XX", "*"):
603
559
  http_res_text = utils.stream_to_text(http_res)
604
- raise errors.APIError(
605
- "API error occurred", http_res.status_code, http_res_text, http_res
606
- )
560
+ raise errors.APIError("API error occurred", http_res, http_res_text)
607
561
  if utils.match_response(http_res, "5XX", "*"):
608
562
  http_res_text = utils.stream_to_text(http_res)
609
- raise errors.APIError(
610
- "API error occurred", http_res.status_code, http_res_text, http_res
611
- )
563
+ raise errors.APIError("API error occurred", http_res, http_res_text)
612
564
 
613
- content_type = http_res.headers.get("Content-Type")
614
- http_res_text = utils.stream_to_text(http_res)
615
- raise errors.APIError(
616
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
617
- http_res.status_code,
618
- http_res_text,
619
- http_res,
620
- )
565
+ raise errors.APIError("Unexpected response received", http_res)
621
566
 
622
567
  async def bundler_aave_loop_async(
623
568
  self,
@@ -736,30 +681,19 @@ class TransactionBundler(BaseSDK):
736
681
 
737
682
  response_data: Any = None
738
683
  if utils.match_response(http_res, "200", "application/json"):
739
- return utils.unmarshal_json(
740
- http_res.text, models.UnsignedMulticallTransaction
684
+ return utils.unmarshal_json_response(
685
+ models.UnsignedMulticallTransaction, http_res
741
686
  )
742
687
  if utils.match_response(http_res, "422", "application/json"):
743
- response_data = utils.unmarshal_json(
744
- http_res.text, errors.HTTPValidationErrorData
688
+ response_data = utils.unmarshal_json_response(
689
+ errors.HTTPValidationErrorData, http_res
745
690
  )
746
- raise errors.HTTPValidationError(data=response_data)
691
+ raise errors.HTTPValidationError(response_data, http_res)
747
692
  if utils.match_response(http_res, "4XX", "*"):
748
693
  http_res_text = await utils.stream_to_text_async(http_res)
749
- raise errors.APIError(
750
- "API error occurred", http_res.status_code, http_res_text, http_res
751
- )
694
+ raise errors.APIError("API error occurred", http_res, http_res_text)
752
695
  if utils.match_response(http_res, "5XX", "*"):
753
696
  http_res_text = await utils.stream_to_text_async(http_res)
754
- raise errors.APIError(
755
- "API error occurred", http_res.status_code, http_res_text, http_res
756
- )
697
+ raise errors.APIError("API error occurred", http_res, http_res_text)
757
698
 
758
- content_type = http_res.headers.get("Content-Type")
759
- http_res_text = await utils.stream_to_text_async(http_res)
760
- raise errors.APIError(
761
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
762
- http_res.status_code,
763
- http_res_text,
764
- http_res,
765
- )
699
+ raise errors.APIError("Unexpected response received", http_res)