Skip to content

Commit

Permalink
Revert "refactor(api.py): move home_studio assignment to a separate a…
Browse files Browse the repository at this point in the history
…sync method to improve code readability and maintainability"

This reverts commit 82baf91.
  • Loading branch information
NodeJSmith committed Jul 13, 2024
1 parent 82baf91 commit 5b73322
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/otf_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def __init__(
):
self.member: MemberDetail
self.home_studio: StudioDetail
self._ref = None

# Handle shutdown
try:
Expand Down Expand Up @@ -143,7 +142,7 @@ async def create(

self = cls(username=username, password=password, access_token=access_token, id_token=id_token)
self.member = await self.get_member_detail()
self._ref = asyncio.create_task(self._assign_home_studio(self.member.home_studio_id))
self.home_studio = await self.get_studio_detail(self.member.home_studio.studio_uuid)
return self

@classmethod
Expand All @@ -155,7 +154,9 @@ async def create_with_username(cls, username: str, password: str) -> "Api":
username (str): The username of the user.
password (str): The password of the user.
"""
self = cls.create(username=username, password=password)
self = cls(username, password)
self.member = await self.get_member_detail()
self.home_studio = await self.get_studio_detail(self.member.home_studio.studio_uuid)
return self

@classmethod
Expand All @@ -167,7 +168,9 @@ async def create_with_token(cls, access_token: str, id_token: str) -> "Api":
access_token (str): The access token.
id_token (str): The id token.
"""
self = cls.create(access_token=access_token, id_token=id_token)
self = cls(access_token=access_token, id_token=id_token)
self.member = await self.get_member_detail()
self.home_studio = await self.get_studio_detail(self.member.home_studio.studio_uuid)
return self

def start_background_refresh(self) -> None:
Expand Down Expand Up @@ -202,9 +205,6 @@ async def _close_session(self) -> None:
if not self.session.closed:
await self.session.close()

async def _assign_home_studio(self, studio_uuid):
self.home_studio = await self.get_studio_detail(studio_uuid)

async def _do(
self,
method: str,
Expand Down

0 comments on commit 5b73322

Please sign in to comment.