Skip to content

Commit

Permalink
🚀 better starting
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Jul 23, 2023
1 parent e60b133 commit c59fa34
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
3 changes: 1 addition & 2 deletions codeboxapi/box/basebox.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from uuid import uuid4
from datetime import datetime
from typing_extensions import Self
from abc import ABC, abstractmethod
Expand All @@ -15,7 +14,7 @@ class BaseBox(ABC):
"""

def __init__(self) -> None:
self.id = uuid4().int
self.id: int | None = None
self.last_interaction = datetime.now()

def _update(self) -> None:
Expand Down
23 changes: 16 additions & 7 deletions codeboxapi/box/codebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.session: Optional[ClientSession] = None

def start(self) -> CodeBoxStatus:
return self.status()

async def astart(self) -> CodeBoxStatus:
self.session = ClientSession()
return await self.astatus()

def codebox_request(
self,
method,
Expand Down Expand Up @@ -62,6 +55,22 @@ async def acodebox_request(
*args, **kwargs
)

def start(self) -> CodeBoxStatus:
self.id = base_request(
method="GET",
endpoint="/codebox/start",
)["id"]
return CodeBoxStatus(status="started")

async def astart(self) -> CodeBoxStatus:
self.session = ClientSession()
self.id = (await abase_request(
self.session,
method="GET",
endpoint="/codebox/start",
))["id"]
return CodeBoxStatus(status="started")

def status(self):
return CodeBoxStatus(
** self.codebox_request(
Expand Down

0 comments on commit c59fa34

Please sign in to comment.