Skip to content

Commit 805c2f2

Browse files
authored
Add SubmitResponse to submit (#3)
1 parent 20ffba9 commit 805c2f2

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

edge_addons_api/client.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import requests
55

6+
from edge_addons_api.responses import SubmitResponse
7+
68

79
@dataclass
810
class 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,

edge_addons_api/responses.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from dataclasses import dataclass
2+
3+
4+
@dataclass
5+
class SubmitResponse:
6+
upload: dict
7+
publish: dict

0 commit comments

Comments
 (0)