-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,122 +1,95 @@ | ||
from __future__ import annotations | ||
|
||
from datetime import UTC, datetime | ||
from typing import TYPE_CHECKING | ||
|
||
from . import utils | ||
from .types.flag import Flag as FlagPayload | ||
from .types.flag import ( | ||
FlagAttributes, | ||
FlagRelationships | ||
) | ||
|
||
from datetime import datetime, UTC | ||
from .types.flag import FlagAttributes, FlagRelationships | ||
|
||
if TYPE_CHECKING: | ||
from .http import HTTPClient | ||
|
||
__all__ = ("Flag",) | ||
|
||
|
||
class Flag: | ||
"""Represents a Flag""" | ||
"""Represents a Flag.""" | ||
|
||
def __init__(self, *, data :FlagPayload, http : HTTPClient) -> None: | ||
def __init__(self, *, data: FlagPayload, http: HTTPClient) -> None: | ||
|
||
self._http = http | ||
|
||
self._data : FlagPayload = FlagPayload(**data) | ||
self._attributes : FlagAttributes = data.get("attributes") | ||
self._relationships : FlagRelationships = ( | ||
utils.format_relationships( | ||
# type: ignore [reportAttributeAccessIssue] | ||
data.get("relationships") | ||
) | ||
self._data: FlagPayload = FlagPayload(**data) | ||
self._attributes: FlagAttributes = data.get("attributes") | ||
self._relationships: FlagRelationships = utils.format_relationships( | ||
# type: ignore [reportAttributeAccessIssue] | ||
data.get("relationships"), | ||
) | ||
|
||
def __str__(self) -> str: | ||
"""Return when the string method is run on this Flag""" | ||
return self._attributes.get("name") | ||
"""Return when the string method is run on this Flag.""" | ||
return self._attributes.get("name") | ||
|
||
@property | ||
def id(self) -> str: | ||
"""Returns ID of the Flag""" | ||
"""Returns ID of the Flag.""" | ||
return self._data.get("id") | ||
|
||
|
||
|
||
@property | ||
def name(self) -> str: | ||
"""Returns Name of the Flag""" | ||
"""Returns Name of the Flag.""" | ||
return self._attributes.get("name") | ||
|
||
@property | ||
def description(self) -> str | None: | ||
"""Returns Description of the Flag""" | ||
"""Returns Description of the Flag.""" | ||
return self._attributes.get("description") | ||
|
||
@property | ||
def color(self) -> str: | ||
"""Returns Color of the Flag""" | ||
"""Returns Color of the Flag.""" | ||
return self._attributes.get("color") | ||
|
||
@property | ||
def created_at(self) -> datetime: | ||
"""Returns creation date of the Flag""" | ||
|
||
"""Returns creation date of the Flag.""" | ||
return datetime.strptime( | ||
self._attributes.get("createdAt"), | ||
"%Y-%m-%dT%H:%M:%S.%fZ", | ||
).replace( | ||
tzinfo=UTC, | ||
) | ||
|
||
@property | ||
def updated_at(self) -> datetime: | ||
"""Returns updated date of the Flag""" | ||
"""Returns updated date of the Flag.""" | ||
return datetime.strptime( | ||
self._attributes.get("updatedAt"), | ||
"%Y-%m-%dT%H:%M:%S.%fZ", | ||
).replace( | ||
tzinfo=UTC, | ||
) | ||
|
||
|
||
|
||
@property | ||
def icon(self) -> str | None: | ||
"""Returns Icon of the Flag""" | ||
"""Returns Icon of the Flag.""" | ||
return self._attributes.get("icon") | ||
|
||
|
||
|
||
|
||
@property | ||
def organization_id(self) -> int: | ||
"""Returns Organization ID of the Flag""" | ||
"""Returns Organization ID of the Flag.""" | ||
return self._relationships.get("organization_id") | ||
|
||
@property | ||
def user_id(self) -> int: | ||
"""Returns user ID of the Flag""" | ||
"""Returns user ID of the Flag.""" | ||
return self._relationships.get("user_id") | ||
|
||
|
||
# TODO : add def Player Flag Update | ||
|
||
# TODO : add def Player Flag Delete | ||
|
||
async def update(self): | ||
... | ||
|
||
async def delete(self): | ||
... | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
async def update(self) -> None: ... # noqa: D102 | ||
|
||
|
||
async def delete(self) -> None: ... # noqa: D102 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
from typing import TypedDict | ||
|
||
|
||
|
||
class FlagAttributes(TypedDict): | ||
"""Represents the attributes of a Flag.""" | ||
|
||
name : str | ||
description : str | None | ||
|
||
color : str | ||
icon : str | None | ||
name: str | ||
description: str | None | ||
color: str | ||
icon: str | None | ||
createdAt: str | ||
updatedAt: str | ||
|
||
createdAt : str | ||
updatedAt : str | ||
|
||
class FlagRelationships(TypedDict): | ||
"""Represents the relationships of a Flag.""" | ||
|
||
user_id : int | ||
organization_id : int | ||
user_id: int | ||
organization_id: int | ||
|
||
class Flag(TypedDict): | ||
|
||
id : str | ||
type : str | ||
attributes : FlagAttributes | ||
relationships : FlagRelationships | ||
|
||
class Flag(TypedDict): | ||
"""Represents a Flag.""" | ||
|
||
id: str | ||
type: str | ||
attributes: FlagAttributes | ||
relationships: FlagRelationships |