compass_api_sdk 0.9.35__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/sky.py CHANGED
@@ -80,31 +80,22 @@ class Sky(BaseSDK):
80
80
 
81
81
  response_data: Any = None
82
82
  if utils.match_response(http_res, "200", "application/json"):
83
- return utils.unmarshal_json(http_res.text, models.SkyCheckPositionResponse)
83
+ return utils.unmarshal_json_response(
84
+ models.SkyCheckPositionResponse, http_res
85
+ )
84
86
  if utils.match_response(http_res, "422", "application/json"):
85
- response_data = utils.unmarshal_json(
86
- http_res.text, errors.HTTPValidationErrorData
87
+ response_data = utils.unmarshal_json_response(
88
+ errors.HTTPValidationErrorData, http_res
87
89
  )
88
- raise errors.HTTPValidationError(data=response_data)
90
+ raise errors.HTTPValidationError(response_data, http_res)
89
91
  if utils.match_response(http_res, "4XX", "*"):
90
92
  http_res_text = utils.stream_to_text(http_res)
91
- raise errors.APIError(
92
- "API error occurred", http_res.status_code, http_res_text, http_res
93
- )
93
+ raise errors.APIError("API error occurred", http_res, http_res_text)
94
94
  if utils.match_response(http_res, "5XX", "*"):
95
95
  http_res_text = utils.stream_to_text(http_res)
96
- raise errors.APIError(
97
- "API error occurred", http_res.status_code, http_res_text, http_res
98
- )
96
+ raise errors.APIError("API error occurred", http_res, http_res_text)
99
97
 
100
- content_type = http_res.headers.get("Content-Type")
101
- http_res_text = utils.stream_to_text(http_res)
102
- raise errors.APIError(
103
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
104
- http_res.status_code,
105
- http_res_text,
106
- http_res,
107
- )
98
+ raise errors.APIError("Unexpected response received", http_res)
108
99
 
109
100
  async def position_async(
110
101
  self,
@@ -178,31 +169,22 @@ class Sky(BaseSDK):
178
169
 
179
170
  response_data: Any = None
180
171
  if utils.match_response(http_res, "200", "application/json"):
181
- return utils.unmarshal_json(http_res.text, models.SkyCheckPositionResponse)
172
+ return utils.unmarshal_json_response(
173
+ models.SkyCheckPositionResponse, http_res
174
+ )
182
175
  if utils.match_response(http_res, "422", "application/json"):
183
- response_data = utils.unmarshal_json(
184
- http_res.text, errors.HTTPValidationErrorData
176
+ response_data = utils.unmarshal_json_response(
177
+ errors.HTTPValidationErrorData, http_res
185
178
  )
186
- raise errors.HTTPValidationError(data=response_data)
179
+ raise errors.HTTPValidationError(response_data, http_res)
187
180
  if utils.match_response(http_res, "4XX", "*"):
188
181
  http_res_text = await utils.stream_to_text_async(http_res)
189
- raise errors.APIError(
190
- "API error occurred", http_res.status_code, http_res_text, http_res
191
- )
182
+ raise errors.APIError("API error occurred", http_res, http_res_text)
192
183
  if utils.match_response(http_res, "5XX", "*"):
193
184
  http_res_text = await utils.stream_to_text_async(http_res)
194
- raise errors.APIError(
195
- "API error occurred", http_res.status_code, http_res_text, http_res
196
- )
185
+ raise errors.APIError("API error occurred", http_res, http_res_text)
197
186
 
198
- content_type = http_res.headers.get("Content-Type")
199
- http_res_text = await utils.stream_to_text_async(http_res)
200
- raise errors.APIError(
201
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
202
- http_res.status_code,
203
- http_res_text,
204
- http_res,
205
- )
187
+ raise errors.APIError("Unexpected response received", http_res)
206
188
 
207
189
  def buy(
208
190
  self,
@@ -291,31 +273,20 @@ class Sky(BaseSDK):
291
273
 
292
274
  response_data: Any = None
293
275
  if utils.match_response(http_res, "200", "application/json"):
294
- return utils.unmarshal_json(http_res.text, models.TxResponse)
276
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
295
277
  if utils.match_response(http_res, "422", "application/json"):
296
- response_data = utils.unmarshal_json(
297
- http_res.text, errors.HTTPValidationErrorData
278
+ response_data = utils.unmarshal_json_response(
279
+ errors.HTTPValidationErrorData, http_res
298
280
  )
299
- raise errors.HTTPValidationError(data=response_data)
281
+ raise errors.HTTPValidationError(response_data, http_res)
300
282
  if utils.match_response(http_res, "4XX", "*"):
301
283
  http_res_text = utils.stream_to_text(http_res)
302
- raise errors.APIError(
303
- "API error occurred", http_res.status_code, http_res_text, http_res
304
- )
284
+ raise errors.APIError("API error occurred", http_res, http_res_text)
305
285
  if utils.match_response(http_res, "5XX", "*"):
306
286
  http_res_text = utils.stream_to_text(http_res)
307
- raise errors.APIError(
308
- "API error occurred", http_res.status_code, http_res_text, http_res
309
- )
287
+ raise errors.APIError("API error occurred", http_res, http_res_text)
310
288
 
311
- content_type = http_res.headers.get("Content-Type")
312
- http_res_text = utils.stream_to_text(http_res)
313
- raise errors.APIError(
314
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
315
- http_res.status_code,
316
- http_res_text,
317
- http_res,
318
- )
289
+ raise errors.APIError("Unexpected response received", http_res)
319
290
 
320
291
  async def buy_async(
321
292
  self,
@@ -404,31 +375,20 @@ class Sky(BaseSDK):
404
375
 
405
376
  response_data: Any = None
406
377
  if utils.match_response(http_res, "200", "application/json"):
407
- return utils.unmarshal_json(http_res.text, models.TxResponse)
378
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
408
379
  if utils.match_response(http_res, "422", "application/json"):
409
- response_data = utils.unmarshal_json(
410
- http_res.text, errors.HTTPValidationErrorData
380
+ response_data = utils.unmarshal_json_response(
381
+ errors.HTTPValidationErrorData, http_res
411
382
  )
412
- raise errors.HTTPValidationError(data=response_data)
383
+ raise errors.HTTPValidationError(response_data, http_res)
413
384
  if utils.match_response(http_res, "4XX", "*"):
414
385
  http_res_text = await utils.stream_to_text_async(http_res)
415
- raise errors.APIError(
416
- "API error occurred", http_res.status_code, http_res_text, http_res
417
- )
386
+ raise errors.APIError("API error occurred", http_res, http_res_text)
418
387
  if utils.match_response(http_res, "5XX", "*"):
419
388
  http_res_text = await utils.stream_to_text_async(http_res)
420
- raise errors.APIError(
421
- "API error occurred", http_res.status_code, http_res_text, http_res
422
- )
389
+ raise errors.APIError("API error occurred", http_res, http_res_text)
423
390
 
424
- content_type = http_res.headers.get("Content-Type")
425
- http_res_text = await utils.stream_to_text_async(http_res)
426
- raise errors.APIError(
427
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
428
- http_res.status_code,
429
- http_res_text,
430
- http_res,
431
- )
391
+ raise errors.APIError("Unexpected response received", http_res)
432
392
 
433
393
  def sell(
434
394
  self,
@@ -519,31 +479,20 @@ class Sky(BaseSDK):
519
479
 
520
480
  response_data: Any = None
521
481
  if utils.match_response(http_res, "200", "application/json"):
522
- return utils.unmarshal_json(http_res.text, models.TxResponse)
482
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
523
483
  if utils.match_response(http_res, "422", "application/json"):
524
- response_data = utils.unmarshal_json(
525
- http_res.text, errors.HTTPValidationErrorData
484
+ response_data = utils.unmarshal_json_response(
485
+ errors.HTTPValidationErrorData, http_res
526
486
  )
527
- raise errors.HTTPValidationError(data=response_data)
487
+ raise errors.HTTPValidationError(response_data, http_res)
528
488
  if utils.match_response(http_res, "4XX", "*"):
529
489
  http_res_text = utils.stream_to_text(http_res)
530
- raise errors.APIError(
531
- "API error occurred", http_res.status_code, http_res_text, http_res
532
- )
490
+ raise errors.APIError("API error occurred", http_res, http_res_text)
533
491
  if utils.match_response(http_res, "5XX", "*"):
534
492
  http_res_text = utils.stream_to_text(http_res)
535
- raise errors.APIError(
536
- "API error occurred", http_res.status_code, http_res_text, http_res
537
- )
493
+ raise errors.APIError("API error occurred", http_res, http_res_text)
538
494
 
539
- content_type = http_res.headers.get("Content-Type")
540
- http_res_text = utils.stream_to_text(http_res)
541
- raise errors.APIError(
542
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
543
- http_res.status_code,
544
- http_res_text,
545
- http_res,
546
- )
495
+ raise errors.APIError("Unexpected response received", http_res)
547
496
 
548
497
  async def sell_async(
549
498
  self,
@@ -634,31 +583,20 @@ class Sky(BaseSDK):
634
583
 
635
584
  response_data: Any = None
636
585
  if utils.match_response(http_res, "200", "application/json"):
637
- return utils.unmarshal_json(http_res.text, models.TxResponse)
586
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
638
587
  if utils.match_response(http_res, "422", "application/json"):
639
- response_data = utils.unmarshal_json(
640
- http_res.text, errors.HTTPValidationErrorData
588
+ response_data = utils.unmarshal_json_response(
589
+ errors.HTTPValidationErrorData, http_res
641
590
  )
642
- raise errors.HTTPValidationError(data=response_data)
591
+ raise errors.HTTPValidationError(response_data, http_res)
643
592
  if utils.match_response(http_res, "4XX", "*"):
644
593
  http_res_text = await utils.stream_to_text_async(http_res)
645
- raise errors.APIError(
646
- "API error occurred", http_res.status_code, http_res_text, http_res
647
- )
594
+ raise errors.APIError("API error occurred", http_res, http_res_text)
648
595
  if utils.match_response(http_res, "5XX", "*"):
649
596
  http_res_text = await utils.stream_to_text_async(http_res)
650
- raise errors.APIError(
651
- "API error occurred", http_res.status_code, http_res_text, http_res
652
- )
597
+ raise errors.APIError("API error occurred", http_res, http_res_text)
653
598
 
654
- content_type = http_res.headers.get("Content-Type")
655
- http_res_text = await utils.stream_to_text_async(http_res)
656
- raise errors.APIError(
657
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
658
- http_res.status_code,
659
- http_res_text,
660
- http_res,
661
- )
599
+ raise errors.APIError("Unexpected response received", http_res)
662
600
 
663
601
  def deposit(
664
602
  self,
@@ -745,31 +683,20 @@ class Sky(BaseSDK):
745
683
 
746
684
  response_data: Any = None
747
685
  if utils.match_response(http_res, "200", "application/json"):
748
- return utils.unmarshal_json(http_res.text, models.TxResponse)
686
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
749
687
  if utils.match_response(http_res, "422", "application/json"):
750
- response_data = utils.unmarshal_json(
751
- http_res.text, errors.HTTPValidationErrorData
688
+ response_data = utils.unmarshal_json_response(
689
+ errors.HTTPValidationErrorData, http_res
752
690
  )
753
- raise errors.HTTPValidationError(data=response_data)
691
+ raise errors.HTTPValidationError(response_data, http_res)
754
692
  if utils.match_response(http_res, "4XX", "*"):
755
693
  http_res_text = utils.stream_to_text(http_res)
756
- raise errors.APIError(
757
- "API error occurred", http_res.status_code, http_res_text, http_res
758
- )
694
+ raise errors.APIError("API error occurred", http_res, http_res_text)
759
695
  if utils.match_response(http_res, "5XX", "*"):
760
696
  http_res_text = utils.stream_to_text(http_res)
761
- raise errors.APIError(
762
- "API error occurred", http_res.status_code, http_res_text, http_res
763
- )
697
+ raise errors.APIError("API error occurred", http_res, http_res_text)
764
698
 
765
- content_type = http_res.headers.get("Content-Type")
766
- http_res_text = utils.stream_to_text(http_res)
767
- raise errors.APIError(
768
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
769
- http_res.status_code,
770
- http_res_text,
771
- http_res,
772
- )
699
+ raise errors.APIError("Unexpected response received", http_res)
773
700
 
774
701
  async def deposit_async(
775
702
  self,
@@ -856,31 +783,20 @@ class Sky(BaseSDK):
856
783
 
857
784
  response_data: Any = None
858
785
  if utils.match_response(http_res, "200", "application/json"):
859
- return utils.unmarshal_json(http_res.text, models.TxResponse)
786
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
860
787
  if utils.match_response(http_res, "422", "application/json"):
861
- response_data = utils.unmarshal_json(
862
- http_res.text, errors.HTTPValidationErrorData
788
+ response_data = utils.unmarshal_json_response(
789
+ errors.HTTPValidationErrorData, http_res
863
790
  )
864
- raise errors.HTTPValidationError(data=response_data)
791
+ raise errors.HTTPValidationError(response_data, http_res)
865
792
  if utils.match_response(http_res, "4XX", "*"):
866
793
  http_res_text = await utils.stream_to_text_async(http_res)
867
- raise errors.APIError(
868
- "API error occurred", http_res.status_code, http_res_text, http_res
869
- )
794
+ raise errors.APIError("API error occurred", http_res, http_res_text)
870
795
  if utils.match_response(http_res, "5XX", "*"):
871
796
  http_res_text = await utils.stream_to_text_async(http_res)
872
- raise errors.APIError(
873
- "API error occurred", http_res.status_code, http_res_text, http_res
874
- )
797
+ raise errors.APIError("API error occurred", http_res, http_res_text)
875
798
 
876
- content_type = http_res.headers.get("Content-Type")
877
- http_res_text = await utils.stream_to_text_async(http_res)
878
- raise errors.APIError(
879
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
880
- http_res.status_code,
881
- http_res_text,
882
- http_res,
883
- )
799
+ raise errors.APIError("Unexpected response received", http_res)
884
800
 
885
801
  def withdraw(
886
802
  self,
@@ -963,31 +879,20 @@ class Sky(BaseSDK):
963
879
 
964
880
  response_data: Any = None
965
881
  if utils.match_response(http_res, "200", "application/json"):
966
- return utils.unmarshal_json(http_res.text, models.TxResponse)
882
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
967
883
  if utils.match_response(http_res, "422", "application/json"):
968
- response_data = utils.unmarshal_json(
969
- http_res.text, errors.HTTPValidationErrorData
884
+ response_data = utils.unmarshal_json_response(
885
+ errors.HTTPValidationErrorData, http_res
970
886
  )
971
- raise errors.HTTPValidationError(data=response_data)
887
+ raise errors.HTTPValidationError(response_data, http_res)
972
888
  if utils.match_response(http_res, "4XX", "*"):
973
889
  http_res_text = utils.stream_to_text(http_res)
974
- raise errors.APIError(
975
- "API error occurred", http_res.status_code, http_res_text, http_res
976
- )
890
+ raise errors.APIError("API error occurred", http_res, http_res_text)
977
891
  if utils.match_response(http_res, "5XX", "*"):
978
892
  http_res_text = utils.stream_to_text(http_res)
979
- raise errors.APIError(
980
- "API error occurred", http_res.status_code, http_res_text, http_res
981
- )
893
+ raise errors.APIError("API error occurred", http_res, http_res_text)
982
894
 
983
- content_type = http_res.headers.get("Content-Type")
984
- http_res_text = utils.stream_to_text(http_res)
985
- raise errors.APIError(
986
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
987
- http_res.status_code,
988
- http_res_text,
989
- http_res,
990
- )
895
+ raise errors.APIError("Unexpected response received", http_res)
991
896
 
992
897
  async def withdraw_async(
993
898
  self,
@@ -1070,28 +975,17 @@ class Sky(BaseSDK):
1070
975
 
1071
976
  response_data: Any = None
1072
977
  if utils.match_response(http_res, "200", "application/json"):
1073
- return utils.unmarshal_json(http_res.text, models.TxResponse)
978
+ return utils.unmarshal_json_response(models.TxResponse, http_res)
1074
979
  if utils.match_response(http_res, "422", "application/json"):
1075
- response_data = utils.unmarshal_json(
1076
- http_res.text, errors.HTTPValidationErrorData
980
+ response_data = utils.unmarshal_json_response(
981
+ errors.HTTPValidationErrorData, http_res
1077
982
  )
1078
- raise errors.HTTPValidationError(data=response_data)
983
+ raise errors.HTTPValidationError(response_data, http_res)
1079
984
  if utils.match_response(http_res, "4XX", "*"):
1080
985
  http_res_text = await utils.stream_to_text_async(http_res)
1081
- raise errors.APIError(
1082
- "API error occurred", http_res.status_code, http_res_text, http_res
1083
- )
986
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1084
987
  if utils.match_response(http_res, "5XX", "*"):
1085
988
  http_res_text = await utils.stream_to_text_async(http_res)
1086
- raise errors.APIError(
1087
- "API error occurred", http_res.status_code, http_res_text, http_res
1088
- )
989
+ raise errors.APIError("API error occurred", http_res, http_res_text)
1089
990
 
1090
- content_type = http_res.headers.get("Content-Type")
1091
- http_res_text = await utils.stream_to_text_async(http_res)
1092
- raise errors.APIError(
1093
- f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1094
- http_res.status_code,
1095
- http_res_text,
1096
- http_res,
1097
- )
991
+ raise errors.APIError("Unexpected response received", http_res)
@@ -91,33 +91,22 @@ class SmartAccount(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.BatchedUserOperationsResponse
94
+ return utils.unmarshal_json_response(
95
+ models.BatchedUserOperationsResponse, 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 account_batched_user_operations_async(
123
112
  self,
@@ -202,30 +191,19 @@ class SmartAccount(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.BatchedUserOperationsResponse
194
+ return utils.unmarshal_json_response(
195
+ models.BatchedUserOperationsResponse, 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)