moovio_sdk 0.12.0__py3-none-any.whl → 0.13.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- moovio_sdk/_version.py +3 -3
- moovio_sdk/account_terminal_applications.py +70 -186
- moovio_sdk/accounts.py +168 -408
- moovio_sdk/adjustments.py +28 -84
- moovio_sdk/apple_pay.py +102 -236
- moovio_sdk/authentication.py +50 -102
- moovio_sdk/avatars.py +10 -38
- moovio_sdk/bank_accounts.py +174 -420
- moovio_sdk/basesdk.py +4 -4
- moovio_sdk/branding.py +106 -198
- moovio_sdk/capabilities.py +76 -180
- moovio_sdk/card_issuing.py +94 -228
- moovio_sdk/cards.py +94 -232
- moovio_sdk/disputes.py +204 -500
- moovio_sdk/end_to_end_encryption.py +28 -80
- moovio_sdk/enriched_address.py +14 -44
- moovio_sdk/enriched_profile.py +14 -44
- moovio_sdk/fee_plans.py +116 -314
- moovio_sdk/files.py +52 -138
- moovio_sdk/industries.py +14 -44
- moovio_sdk/institutions.py +36 -92
- moovio_sdk/issuing_transactions.py +70 -220
- moovio_sdk/models/components/__init__.py +39 -0
- moovio_sdk/models/components/createticket.py +24 -0
- moovio_sdk/models/components/createticketcontacterror.py +17 -0
- moovio_sdk/models/components/ticket.py +44 -0
- moovio_sdk/models/components/ticketcontact.py +17 -0
- moovio_sdk/models/components/ticketmessage.py +21 -0
- moovio_sdk/models/components/ticketstatus.py +11 -0
- moovio_sdk/models/components/updateticket.py +19 -0
- moovio_sdk/models/components/updateticketstatus.py +8 -0
- moovio_sdk/models/errors/__init__.py +19 -0
- moovio_sdk/models/errors/accountterminalapplicationerror.py +11 -6
- moovio_sdk/models/errors/addcapabilitieserror.py +11 -6
- moovio_sdk/models/errors/apierror.py +30 -14
- moovio_sdk/models/errors/assigncountrieserror.py +12 -6
- moovio_sdk/models/errors/authtokenrequesterror.py +11 -6
- moovio_sdk/models/errors/bankaccountvalidationerror.py +11 -6
- moovio_sdk/models/errors/brandvalidationerror.py +11 -6
- moovio_sdk/models/errors/cardacquiringrefund.py +11 -6
- moovio_sdk/models/errors/createaccount.py +12 -6
- moovio_sdk/models/errors/createpaymentlinkerror.py +11 -6
- moovio_sdk/models/errors/createsweepconfigerror.py +11 -6
- moovio_sdk/models/errors/createticketerror.py +34 -0
- moovio_sdk/models/errors/feeplanagreementerror.py +11 -6
- moovio_sdk/models/errors/fileuploadvalidationerror.py +11 -6
- moovio_sdk/models/errors/filevalidationerror.py +11 -6
- moovio_sdk/models/errors/genericerror.py +12 -6
- moovio_sdk/models/errors/linkapplepayerror.py +11 -6
- moovio_sdk/models/errors/linkcarderror.py +11 -6
- moovio_sdk/models/errors/microdepositvalidationerror.py +11 -6
- moovio_sdk/models/errors/mooverror.py +26 -0
- moovio_sdk/models/errors/no_response_error.py +13 -0
- moovio_sdk/models/errors/onboardinginviteerror.py +11 -6
- moovio_sdk/models/errors/patchsweepconfigerror.py +11 -6
- moovio_sdk/models/errors/refundvalidationerror.py +11 -6
- moovio_sdk/models/errors/representativevalidationerror.py +11 -6
- moovio_sdk/models/errors/requestcarderror.py +11 -6
- moovio_sdk/models/errors/responsevalidationerror.py +25 -0
- moovio_sdk/models/errors/reversalvalidationerror.py +11 -6
- moovio_sdk/models/errors/revoketokenrequesterror.py +11 -6
- moovio_sdk/models/errors/schedulevalidationerror.py +11 -6
- moovio_sdk/models/errors/terminalapplicationerror.py +11 -6
- moovio_sdk/models/errors/transfer.py +11 -6
- moovio_sdk/models/errors/transferoptionsvalidationerror.py +11 -6
- moovio_sdk/models/errors/transfervalidationerror.py +11 -6
- moovio_sdk/models/errors/updateaccount.py +12 -6
- moovio_sdk/models/errors/updatecarderror.py +11 -6
- moovio_sdk/models/errors/updateissuedcarderror.py +11 -6
- moovio_sdk/models/errors/updatepaymentlinkerror.py +11 -6
- moovio_sdk/models/errors/updateticketerror.py +25 -0
- moovio_sdk/models/errors/updateunderwritingerror.py +11 -6
- moovio_sdk/models/errors/upsertunderwritingerror.py +11 -6
- moovio_sdk/models/operations/__init__.py +100 -0
- moovio_sdk/models/operations/createticket.py +78 -0
- moovio_sdk/models/operations/getticket.py +71 -0
- moovio_sdk/models/operations/listticketmessages.py +88 -0
- moovio_sdk/models/operations/listtickets.py +81 -0
- moovio_sdk/models/operations/updateticket.py +85 -0
- moovio_sdk/onboarding.py +66 -166
- moovio_sdk/payment_links.py +106 -272
- moovio_sdk/payment_methods.py +30 -86
- moovio_sdk/ping.py +10 -40
- moovio_sdk/receipts.py +36 -92
- moovio_sdk/representatives.py +102 -228
- moovio_sdk/scheduling.py +122 -278
- moovio_sdk/sdk.py +3 -0
- moovio_sdk/support.py +1153 -0
- moovio_sdk/sweeps.py +102 -274
- moovio_sdk/terminal_applications.py +74 -186
- moovio_sdk/transfers.py +266 -582
- moovio_sdk/underwriting.py +64 -146
- moovio_sdk/utils/__init__.py +3 -0
- moovio_sdk/utils/serializers.py +21 -3
- moovio_sdk/wallet_transactions.py +28 -88
- moovio_sdk/wallets.py +24 -84
- {moovio_sdk-0.12.0.dist-info → moovio_sdk-0.13.0.dist-info}/METADATA +103 -28
- {moovio_sdk-0.12.0.dist-info → moovio_sdk-0.13.0.dist-info}/RECORD +99 -80
- {moovio_sdk-0.12.0.dist-info → moovio_sdk-0.13.0.dist-info}/WHEEL +0 -0
moovio_sdk/underwriting.py
CHANGED
@@ -90,38 +90,23 @@ class Underwriting(BaseSDK):
|
|
90
90
|
|
91
91
|
if utils.match_response(http_res, "200", "application/json"):
|
92
92
|
return operations.GetUnderwritingResponse(
|
93
|
-
result=utils.
|
93
|
+
result=utils.unmarshal_json_response(components.Underwriting, http_res),
|
94
94
|
headers=utils.get_response_headers(http_res.headers),
|
95
95
|
)
|
96
96
|
if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
|
97
97
|
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
|
-
)
|
98
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
101
99
|
if utils.match_response(http_res, ["500", "504"], "*"):
|
102
100
|
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
|
-
)
|
101
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
106
102
|
if utils.match_response(http_res, "4XX", "*"):
|
107
103
|
http_res_text = utils.stream_to_text(http_res)
|
108
|
-
raise errors.APIError(
|
109
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
110
|
-
)
|
104
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
111
105
|
if utils.match_response(http_res, "5XX", "*"):
|
112
106
|
http_res_text = utils.stream_to_text(http_res)
|
113
|
-
raise errors.APIError(
|
114
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
115
|
-
)
|
107
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
116
108
|
|
117
|
-
|
118
|
-
http_res_text = utils.stream_to_text(http_res)
|
119
|
-
raise errors.APIError(
|
120
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
121
|
-
http_res.status_code,
|
122
|
-
http_res_text,
|
123
|
-
http_res,
|
124
|
-
)
|
109
|
+
raise errors.APIError("Unexpected response received", http_res)
|
125
110
|
|
126
111
|
async def get_async(
|
127
112
|
self,
|
@@ -203,38 +188,23 @@ class Underwriting(BaseSDK):
|
|
203
188
|
|
204
189
|
if utils.match_response(http_res, "200", "application/json"):
|
205
190
|
return operations.GetUnderwritingResponse(
|
206
|
-
result=utils.
|
191
|
+
result=utils.unmarshal_json_response(components.Underwriting, http_res),
|
207
192
|
headers=utils.get_response_headers(http_res.headers),
|
208
193
|
)
|
209
194
|
if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
|
210
195
|
http_res_text = await utils.stream_to_text_async(http_res)
|
211
|
-
raise errors.APIError(
|
212
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
213
|
-
)
|
196
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
214
197
|
if utils.match_response(http_res, ["500", "504"], "*"):
|
215
198
|
http_res_text = await utils.stream_to_text_async(http_res)
|
216
|
-
raise errors.APIError(
|
217
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
218
|
-
)
|
199
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
219
200
|
if utils.match_response(http_res, "4XX", "*"):
|
220
201
|
http_res_text = await utils.stream_to_text_async(http_res)
|
221
|
-
raise errors.APIError(
|
222
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
223
|
-
)
|
202
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
224
203
|
if utils.match_response(http_res, "5XX", "*"):
|
225
204
|
http_res_text = await utils.stream_to_text_async(http_res)
|
226
|
-
raise errors.APIError(
|
227
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
228
|
-
)
|
205
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
229
206
|
|
230
|
-
|
231
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
232
|
-
raise errors.APIError(
|
233
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
234
|
-
http_res.status_code,
|
235
|
-
http_res_text,
|
236
|
-
http_res,
|
237
|
-
)
|
207
|
+
raise errors.APIError("Unexpected response received", http_res)
|
238
208
|
|
239
209
|
def save(
|
240
210
|
self,
|
@@ -379,46 +349,33 @@ class Underwriting(BaseSDK):
|
|
379
349
|
response_data: Any = None
|
380
350
|
if utils.match_response(http_res, "200", "application/json"):
|
381
351
|
return operations.SaveUnderwritingResponse(
|
382
|
-
result=utils.
|
352
|
+
result=utils.unmarshal_json_response(components.Underwriting, http_res),
|
383
353
|
headers=utils.get_response_headers(http_res.headers),
|
384
354
|
)
|
385
355
|
if utils.match_response(http_res, ["400", "409"], "application/json"):
|
386
|
-
response_data = utils.
|
387
|
-
|
356
|
+
response_data = utils.unmarshal_json_response(
|
357
|
+
errors.GenericErrorData, http_res
|
358
|
+
)
|
359
|
+
raise errors.GenericError(response_data, http_res)
|
388
360
|
if utils.match_response(http_res, "422", "application/json"):
|
389
|
-
response_data = utils.
|
390
|
-
|
361
|
+
response_data = utils.unmarshal_json_response(
|
362
|
+
errors.UpsertUnderwritingErrorData, http_res
|
391
363
|
)
|
392
|
-
raise errors.UpsertUnderwritingError(
|
364
|
+
raise errors.UpsertUnderwritingError(response_data, http_res)
|
393
365
|
if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
|
394
366
|
http_res_text = utils.stream_to_text(http_res)
|
395
|
-
raise errors.APIError(
|
396
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
397
|
-
)
|
367
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
398
368
|
if utils.match_response(http_res, ["500", "504"], "*"):
|
399
369
|
http_res_text = utils.stream_to_text(http_res)
|
400
|
-
raise errors.APIError(
|
401
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
402
|
-
)
|
370
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
403
371
|
if utils.match_response(http_res, "4XX", "*"):
|
404
372
|
http_res_text = utils.stream_to_text(http_res)
|
405
|
-
raise errors.APIError(
|
406
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
407
|
-
)
|
373
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
408
374
|
if utils.match_response(http_res, "5XX", "*"):
|
409
375
|
http_res_text = utils.stream_to_text(http_res)
|
410
|
-
raise errors.APIError(
|
411
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
412
|
-
)
|
376
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
413
377
|
|
414
|
-
|
415
|
-
http_res_text = utils.stream_to_text(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
|
-
)
|
378
|
+
raise errors.APIError("Unexpected response received", http_res)
|
422
379
|
|
423
380
|
async def save_async(
|
424
381
|
self,
|
@@ -563,46 +520,33 @@ class Underwriting(BaseSDK):
|
|
563
520
|
response_data: Any = None
|
564
521
|
if utils.match_response(http_res, "200", "application/json"):
|
565
522
|
return operations.SaveUnderwritingResponse(
|
566
|
-
result=utils.
|
523
|
+
result=utils.unmarshal_json_response(components.Underwriting, http_res),
|
567
524
|
headers=utils.get_response_headers(http_res.headers),
|
568
525
|
)
|
569
526
|
if utils.match_response(http_res, ["400", "409"], "application/json"):
|
570
|
-
response_data = utils.
|
571
|
-
|
527
|
+
response_data = utils.unmarshal_json_response(
|
528
|
+
errors.GenericErrorData, http_res
|
529
|
+
)
|
530
|
+
raise errors.GenericError(response_data, http_res)
|
572
531
|
if utils.match_response(http_res, "422", "application/json"):
|
573
|
-
response_data = utils.
|
574
|
-
|
532
|
+
response_data = utils.unmarshal_json_response(
|
533
|
+
errors.UpsertUnderwritingErrorData, http_res
|
575
534
|
)
|
576
|
-
raise errors.UpsertUnderwritingError(
|
535
|
+
raise errors.UpsertUnderwritingError(response_data, http_res)
|
577
536
|
if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
|
578
537
|
http_res_text = await utils.stream_to_text_async(http_res)
|
579
|
-
raise errors.APIError(
|
580
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
581
|
-
)
|
538
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
582
539
|
if utils.match_response(http_res, ["500", "504"], "*"):
|
583
540
|
http_res_text = await utils.stream_to_text_async(http_res)
|
584
|
-
raise errors.APIError(
|
585
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
586
|
-
)
|
541
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
587
542
|
if utils.match_response(http_res, "4XX", "*"):
|
588
543
|
http_res_text = await utils.stream_to_text_async(http_res)
|
589
|
-
raise errors.APIError(
|
590
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
591
|
-
)
|
544
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
592
545
|
if utils.match_response(http_res, "5XX", "*"):
|
593
546
|
http_res_text = await utils.stream_to_text_async(http_res)
|
594
|
-
raise errors.APIError(
|
595
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
596
|
-
)
|
547
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
597
548
|
|
598
|
-
|
599
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
600
|
-
raise errors.APIError(
|
601
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
602
|
-
http_res.status_code,
|
603
|
-
http_res_text,
|
604
|
-
http_res,
|
605
|
-
)
|
549
|
+
raise errors.APIError("Unexpected response received", http_res)
|
606
550
|
|
607
551
|
def upsert(
|
608
552
|
self,
|
@@ -737,46 +681,33 @@ class Underwriting(BaseSDK):
|
|
737
681
|
response_data: Any = None
|
738
682
|
if utils.match_response(http_res, "200", "application/json"):
|
739
683
|
return operations.UpsertUnderwritingResponse(
|
740
|
-
result=utils.
|
684
|
+
result=utils.unmarshal_json_response(components.Underwriting, http_res),
|
741
685
|
headers=utils.get_response_headers(http_res.headers),
|
742
686
|
)
|
743
687
|
if utils.match_response(http_res, ["400", "409"], "application/json"):
|
744
|
-
response_data = utils.
|
745
|
-
|
688
|
+
response_data = utils.unmarshal_json_response(
|
689
|
+
errors.GenericErrorData, http_res
|
690
|
+
)
|
691
|
+
raise errors.GenericError(response_data, http_res)
|
746
692
|
if utils.match_response(http_res, "422", "application/json"):
|
747
|
-
response_data = utils.
|
748
|
-
|
693
|
+
response_data = utils.unmarshal_json_response(
|
694
|
+
errors.UpdateUnderwritingErrorData, http_res
|
749
695
|
)
|
750
|
-
raise errors.UpdateUnderwritingError(
|
696
|
+
raise errors.UpdateUnderwritingError(response_data, http_res)
|
751
697
|
if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
|
752
698
|
http_res_text = utils.stream_to_text(http_res)
|
753
|
-
raise errors.APIError(
|
754
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
755
|
-
)
|
699
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
756
700
|
if utils.match_response(http_res, ["500", "504"], "*"):
|
757
701
|
http_res_text = utils.stream_to_text(http_res)
|
758
|
-
raise errors.APIError(
|
759
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
760
|
-
)
|
702
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
761
703
|
if utils.match_response(http_res, "4XX", "*"):
|
762
704
|
http_res_text = utils.stream_to_text(http_res)
|
763
|
-
raise errors.APIError(
|
764
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
765
|
-
)
|
705
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
766
706
|
if utils.match_response(http_res, "5XX", "*"):
|
767
707
|
http_res_text = utils.stream_to_text(http_res)
|
768
|
-
raise errors.APIError(
|
769
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
770
|
-
)
|
708
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
771
709
|
|
772
|
-
|
773
|
-
http_res_text = utils.stream_to_text(http_res)
|
774
|
-
raise errors.APIError(
|
775
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
776
|
-
http_res.status_code,
|
777
|
-
http_res_text,
|
778
|
-
http_res,
|
779
|
-
)
|
710
|
+
raise errors.APIError("Unexpected response received", http_res)
|
780
711
|
|
781
712
|
async def upsert_async(
|
782
713
|
self,
|
@@ -911,43 +842,30 @@ class Underwriting(BaseSDK):
|
|
911
842
|
response_data: Any = None
|
912
843
|
if utils.match_response(http_res, "200", "application/json"):
|
913
844
|
return operations.UpsertUnderwritingResponse(
|
914
|
-
result=utils.
|
845
|
+
result=utils.unmarshal_json_response(components.Underwriting, http_res),
|
915
846
|
headers=utils.get_response_headers(http_res.headers),
|
916
847
|
)
|
917
848
|
if utils.match_response(http_res, ["400", "409"], "application/json"):
|
918
|
-
response_data = utils.
|
919
|
-
|
849
|
+
response_data = utils.unmarshal_json_response(
|
850
|
+
errors.GenericErrorData, http_res
|
851
|
+
)
|
852
|
+
raise errors.GenericError(response_data, http_res)
|
920
853
|
if utils.match_response(http_res, "422", "application/json"):
|
921
|
-
response_data = utils.
|
922
|
-
|
854
|
+
response_data = utils.unmarshal_json_response(
|
855
|
+
errors.UpdateUnderwritingErrorData, http_res
|
923
856
|
)
|
924
|
-
raise errors.UpdateUnderwritingError(
|
857
|
+
raise errors.UpdateUnderwritingError(response_data, http_res)
|
925
858
|
if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
|
926
859
|
http_res_text = await utils.stream_to_text_async(http_res)
|
927
|
-
raise errors.APIError(
|
928
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
929
|
-
)
|
860
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
930
861
|
if utils.match_response(http_res, ["500", "504"], "*"):
|
931
862
|
http_res_text = await utils.stream_to_text_async(http_res)
|
932
|
-
raise errors.APIError(
|
933
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
934
|
-
)
|
863
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
935
864
|
if utils.match_response(http_res, "4XX", "*"):
|
936
865
|
http_res_text = await utils.stream_to_text_async(http_res)
|
937
|
-
raise errors.APIError(
|
938
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
939
|
-
)
|
866
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
940
867
|
if utils.match_response(http_res, "5XX", "*"):
|
941
868
|
http_res_text = await utils.stream_to_text_async(http_res)
|
942
|
-
raise errors.APIError(
|
943
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
944
|
-
)
|
869
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
945
870
|
|
946
|
-
|
947
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
948
|
-
raise errors.APIError(
|
949
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
950
|
-
http_res.status_code,
|
951
|
-
http_res_text,
|
952
|
-
http_res,
|
953
|
-
)
|
871
|
+
raise errors.APIError("Unexpected response received", http_res)
|
moovio_sdk/utils/__init__.py
CHANGED
@@ -29,6 +29,7 @@ if TYPE_CHECKING:
|
|
29
29
|
marshal_json,
|
30
30
|
unmarshal,
|
31
31
|
unmarshal_json,
|
32
|
+
unmarshal_json_response,
|
32
33
|
serialize_decimal,
|
33
34
|
serialize_float,
|
34
35
|
serialize_int,
|
@@ -98,6 +99,7 @@ __all__ = [
|
|
98
99
|
"template_url",
|
99
100
|
"unmarshal",
|
100
101
|
"unmarshal_json",
|
102
|
+
"unmarshal_json_response",
|
101
103
|
"validate_decimal",
|
102
104
|
"validate_const",
|
103
105
|
"validate_float",
|
@@ -152,6 +154,7 @@ _dynamic_imports: dict[str, str] = {
|
|
152
154
|
"template_url": ".url",
|
153
155
|
"unmarshal": ".serializers",
|
154
156
|
"unmarshal_json": ".serializers",
|
157
|
+
"unmarshal_json_response": ".serializers",
|
155
158
|
"validate_decimal": ".serializers",
|
156
159
|
"validate_const": ".serializers",
|
157
160
|
"validate_float": ".serializers",
|
moovio_sdk/utils/serializers.py
CHANGED
@@ -4,7 +4,7 @@ from decimal import Decimal
|
|
4
4
|
import functools
|
5
5
|
import json
|
6
6
|
import typing
|
7
|
-
from typing import Any, Dict, List, Tuple, Union, get_args
|
7
|
+
from typing import Any, Dict, List, Optional, Tuple, Union, get_args
|
8
8
|
import typing_extensions
|
9
9
|
from typing_extensions import get_origin
|
10
10
|
|
@@ -13,6 +13,7 @@ from pydantic import ConfigDict, create_model
|
|
13
13
|
from pydantic_core import from_json
|
14
14
|
|
15
15
|
from ..types.basemodel import BaseModel, Nullable, OptionalNullable, Unset
|
16
|
+
from moovio_sdk.models import errors
|
16
17
|
|
17
18
|
|
18
19
|
def serialize_decimal(as_str: bool):
|
@@ -140,6 +141,22 @@ def unmarshal_json(raw, typ: Any) -> Any:
|
|
140
141
|
return unmarshal(from_json(raw), typ)
|
141
142
|
|
142
143
|
|
144
|
+
def unmarshal_json_response(
|
145
|
+
typ: Any, http_res: httpx.Response, body: Optional[str] = None
|
146
|
+
) -> Any:
|
147
|
+
if body is None:
|
148
|
+
body = http_res.text
|
149
|
+
try:
|
150
|
+
return unmarshal_json(body, typ)
|
151
|
+
except Exception as e:
|
152
|
+
raise errors.ResponseValidationError(
|
153
|
+
"Response validation failed",
|
154
|
+
http_res,
|
155
|
+
e,
|
156
|
+
body,
|
157
|
+
) from e
|
158
|
+
|
159
|
+
|
143
160
|
def unmarshal(val, typ: Any) -> Any:
|
144
161
|
unmarshaller = create_model(
|
145
162
|
"Unmarshaller",
|
@@ -192,7 +209,9 @@ def is_union(obj: object) -> bool:
|
|
192
209
|
"""
|
193
210
|
Returns True if the given object is a typing.Union or typing_extensions.Union.
|
194
211
|
"""
|
195
|
-
return any(
|
212
|
+
return any(
|
213
|
+
obj is typing_obj for typing_obj in _get_typing_objects_by_name_of("Union")
|
214
|
+
)
|
196
215
|
|
197
216
|
|
198
217
|
def stream_to_text(stream: httpx.Response) -> str:
|
@@ -245,4 +264,3 @@ def _get_typing_objects_by_name_of(name: str) -> Tuple[Any, ...]:
|
|
245
264
|
f"Neither typing nor typing_extensions has an object called {name!r}"
|
246
265
|
)
|
247
266
|
return result
|
248
|
-
|
@@ -130,40 +130,25 @@ class WalletTransactions(BaseSDK):
|
|
130
130
|
|
131
131
|
if utils.match_response(http_res, "200", "application/json"):
|
132
132
|
return operations.ListWalletTransactionsResponse(
|
133
|
-
result=utils.
|
134
|
-
|
133
|
+
result=utils.unmarshal_json_response(
|
134
|
+
List[components.WalletTransaction], http_res
|
135
135
|
),
|
136
136
|
headers=utils.get_response_headers(http_res.headers),
|
137
137
|
)
|
138
138
|
if utils.match_response(http_res, ["401", "403", "429"], "*"):
|
139
139
|
http_res_text = utils.stream_to_text(http_res)
|
140
|
-
raise errors.APIError(
|
141
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
142
|
-
)
|
140
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
143
141
|
if utils.match_response(http_res, ["500", "504"], "*"):
|
144
142
|
http_res_text = utils.stream_to_text(http_res)
|
145
|
-
raise errors.APIError(
|
146
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
147
|
-
)
|
143
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
148
144
|
if utils.match_response(http_res, "4XX", "*"):
|
149
145
|
http_res_text = utils.stream_to_text(http_res)
|
150
|
-
raise errors.APIError(
|
151
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
152
|
-
)
|
146
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
153
147
|
if utils.match_response(http_res, "5XX", "*"):
|
154
148
|
http_res_text = utils.stream_to_text(http_res)
|
155
|
-
raise errors.APIError(
|
156
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
157
|
-
)
|
149
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
158
150
|
|
159
|
-
|
160
|
-
http_res_text = utils.stream_to_text(http_res)
|
161
|
-
raise errors.APIError(
|
162
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
163
|
-
http_res.status_code,
|
164
|
-
http_res_text,
|
165
|
-
http_res,
|
166
|
-
)
|
151
|
+
raise errors.APIError("Unexpected response received", http_res)
|
167
152
|
|
168
153
|
async def list_async(
|
169
154
|
self,
|
@@ -284,40 +269,25 @@ class WalletTransactions(BaseSDK):
|
|
284
269
|
|
285
270
|
if utils.match_response(http_res, "200", "application/json"):
|
286
271
|
return operations.ListWalletTransactionsResponse(
|
287
|
-
result=utils.
|
288
|
-
|
272
|
+
result=utils.unmarshal_json_response(
|
273
|
+
List[components.WalletTransaction], http_res
|
289
274
|
),
|
290
275
|
headers=utils.get_response_headers(http_res.headers),
|
291
276
|
)
|
292
277
|
if utils.match_response(http_res, ["401", "403", "429"], "*"):
|
293
278
|
http_res_text = await utils.stream_to_text_async(http_res)
|
294
|
-
raise errors.APIError(
|
295
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
296
|
-
)
|
279
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
297
280
|
if utils.match_response(http_res, ["500", "504"], "*"):
|
298
281
|
http_res_text = await utils.stream_to_text_async(http_res)
|
299
|
-
raise errors.APIError(
|
300
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
301
|
-
)
|
282
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
302
283
|
if utils.match_response(http_res, "4XX", "*"):
|
303
284
|
http_res_text = await utils.stream_to_text_async(http_res)
|
304
|
-
raise errors.APIError(
|
305
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
306
|
-
)
|
285
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
307
286
|
if utils.match_response(http_res, "5XX", "*"):
|
308
287
|
http_res_text = await utils.stream_to_text_async(http_res)
|
309
|
-
raise errors.APIError(
|
310
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
311
|
-
)
|
288
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
312
289
|
|
313
|
-
|
314
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
315
|
-
raise errors.APIError(
|
316
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
317
|
-
http_res.status_code,
|
318
|
-
http_res_text,
|
319
|
-
http_res,
|
320
|
-
)
|
290
|
+
raise errors.APIError("Unexpected response received", http_res)
|
321
291
|
|
322
292
|
def get(
|
323
293
|
self,
|
@@ -405,40 +375,25 @@ class WalletTransactions(BaseSDK):
|
|
405
375
|
|
406
376
|
if utils.match_response(http_res, "200", "application/json"):
|
407
377
|
return operations.GetWalletTransactionResponse(
|
408
|
-
result=utils.
|
409
|
-
|
378
|
+
result=utils.unmarshal_json_response(
|
379
|
+
components.WalletTransaction, http_res
|
410
380
|
),
|
411
381
|
headers=utils.get_response_headers(http_res.headers),
|
412
382
|
)
|
413
383
|
if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
|
414
384
|
http_res_text = utils.stream_to_text(http_res)
|
415
|
-
raise errors.APIError(
|
416
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
417
|
-
)
|
385
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
418
386
|
if utils.match_response(http_res, ["500", "504"], "*"):
|
419
387
|
http_res_text = utils.stream_to_text(http_res)
|
420
|
-
raise errors.APIError(
|
421
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
422
|
-
)
|
388
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
423
389
|
if utils.match_response(http_res, "4XX", "*"):
|
424
390
|
http_res_text = utils.stream_to_text(http_res)
|
425
|
-
raise errors.APIError(
|
426
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
427
|
-
)
|
391
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
428
392
|
if utils.match_response(http_res, "5XX", "*"):
|
429
393
|
http_res_text = utils.stream_to_text(http_res)
|
430
|
-
raise errors.APIError(
|
431
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
432
|
-
)
|
394
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
433
395
|
|
434
|
-
|
435
|
-
http_res_text = utils.stream_to_text(http_res)
|
436
|
-
raise errors.APIError(
|
437
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
438
|
-
http_res.status_code,
|
439
|
-
http_res_text,
|
440
|
-
http_res,
|
441
|
-
)
|
396
|
+
raise errors.APIError("Unexpected response received", http_res)
|
442
397
|
|
443
398
|
async def get_async(
|
444
399
|
self,
|
@@ -526,37 +481,22 @@ class WalletTransactions(BaseSDK):
|
|
526
481
|
|
527
482
|
if utils.match_response(http_res, "200", "application/json"):
|
528
483
|
return operations.GetWalletTransactionResponse(
|
529
|
-
result=utils.
|
530
|
-
|
484
|
+
result=utils.unmarshal_json_response(
|
485
|
+
components.WalletTransaction, http_res
|
531
486
|
),
|
532
487
|
headers=utils.get_response_headers(http_res.headers),
|
533
488
|
)
|
534
489
|
if utils.match_response(http_res, ["401", "403", "404", "429"], "*"):
|
535
490
|
http_res_text = await utils.stream_to_text_async(http_res)
|
536
|
-
raise errors.APIError(
|
537
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
538
|
-
)
|
491
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
539
492
|
if utils.match_response(http_res, ["500", "504"], "*"):
|
540
493
|
http_res_text = await utils.stream_to_text_async(http_res)
|
541
|
-
raise errors.APIError(
|
542
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
543
|
-
)
|
494
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
544
495
|
if utils.match_response(http_res, "4XX", "*"):
|
545
496
|
http_res_text = await utils.stream_to_text_async(http_res)
|
546
|
-
raise errors.APIError(
|
547
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
548
|
-
)
|
497
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
549
498
|
if utils.match_response(http_res, "5XX", "*"):
|
550
499
|
http_res_text = await utils.stream_to_text_async(http_res)
|
551
|
-
raise errors.APIError(
|
552
|
-
"API error occurred", http_res.status_code, http_res_text, http_res
|
553
|
-
)
|
500
|
+
raise errors.APIError("API error occurred", http_res, http_res_text)
|
554
501
|
|
555
|
-
|
556
|
-
http_res_text = await utils.stream_to_text_async(http_res)
|
557
|
-
raise errors.APIError(
|
558
|
-
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
559
|
-
http_res.status_code,
|
560
|
-
http_res_text,
|
561
|
-
http_res,
|
562
|
-
)
|
502
|
+
raise errors.APIError("Unexpected response received", http_res)
|