33
44import requests
55
6+ from edge_addons_api .responses import SubmitResponse
7+
68
79@dataclass
810class Options :
@@ -19,15 +21,17 @@ class Client:
1921 def __init__ (self , options : Options ):
2022 self .options = options
2123
22- def submit (self , file_path : str , notes : str ):
24+ def submit (self , file_path : str , notes : str ) -> SubmitResponse :
2325 if not path .exists (file_path ):
2426 raise FileNotFoundError (f"Unable to locate file at { file_path } " )
2527
2628 access_token = self ._get_access_token ()
27- self ._upload (file_path , access_token )
28- self ._publish (notes , access_token )
29+ upload = self ._upload (file_path , access_token )
30+ publish = self ._publish (notes , access_token )
31+
32+ return SubmitResponse (upload , publish )
2933
30- def _publish (self , notes : str , access_token : str ):
34+ def _publish (self , notes : str , access_token : str ) -> dict :
3135 response = requests .post (
3236 self ._publish_endpoint (),
3337 data = {"notes" : notes },
@@ -38,7 +42,9 @@ def _publish(self, notes: str, access_token: str):
3842
3943 response .raise_for_status ()
4044
41- def _upload (self , file_path : str , access_token : str ):
45+ return response .json ()
46+
47+ def _upload (self , file_path : str , access_token : str ) -> dict :
4248
4349 files = {"file" : open (file_path , "rb" )}
4450
@@ -53,6 +59,8 @@ def _upload(self, file_path: str, access_token: str):
5359
5460 response .raise_for_status ()
5561
62+ return response .json ()
63+
5664 def _get_access_token (self ) -> str :
5765 response = requests .post (
5866 self .options .access_token_url ,
0 commit comments