3
3
4
4
import requests
5
5
6
+ from edge_addons_api .responses import SubmitResponse
7
+
6
8
7
9
@dataclass
8
10
class Options :
@@ -19,15 +21,17 @@ class Client:
19
21
def __init__ (self , options : Options ):
20
22
self .options = options
21
23
22
- def submit (self , file_path : str , notes : str ):
24
+ def submit (self , file_path : str , notes : str ) -> SubmitResponse :
23
25
if not path .exists (file_path ):
24
26
raise FileNotFoundError (f"Unable to locate file at { file_path } " )
25
27
26
28
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 )
29
33
30
- def _publish (self , notes : str , access_token : str ):
34
+ def _publish (self , notes : str , access_token : str ) -> dict :
31
35
response = requests .post (
32
36
self ._publish_endpoint (),
33
37
data = {"notes" : notes },
@@ -38,7 +42,9 @@ def _publish(self, notes: str, access_token: str):
38
42
39
43
response .raise_for_status ()
40
44
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 :
42
48
43
49
files = {"file" : open (file_path , "rb" )}
44
50
@@ -53,6 +59,8 @@ def _upload(self, file_path: str, access_token: str):
53
59
54
60
response .raise_for_status ()
55
61
62
+ return response .json ()
63
+
56
64
def _get_access_token (self ) -> str :
57
65
response = requests .post (
58
66
self .options .access_token_url ,
0 commit comments