Skip to content

Commit

Permalink
add articles.Article properties
Browse files Browse the repository at this point in the history
  • Loading branch information
flashdagger committed Oct 17, 2023
1 parent 466f445 commit 3020bdd
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions zammadoo/articles.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from .client import Client
from .tickets import Ticket
from .users import User
from .utils import JsonDict, PathType

OptionalFiles = Union[None, "PathType", Iterable["PathType"]]
Expand Down Expand Up @@ -127,7 +128,6 @@ class Article(Resource):
cc: Optional[str] #:
content_type: str #:
created_at: datetime #:
created_by: str #:
from_: str #:
internal: bool #:
message_id: Optional[str] #:
Expand All @@ -136,7 +136,21 @@ class Article(Resource):
subject: Optional[str] #:
to: Optional[str] #:
updated_at: datetime #:
updated_by: str #:

@property
def created_by(self) -> "User":
uid = self["created_by_id"]
return self.parent.client.users(uid)

@property
def origin_by(self) -> Optional["User"]:
oid = self["origin_by_id"]
return self.parent.client.users(oid)

@property
def updated_by(self) -> "User":
uid = self["updated_by_id"]
return self.parent.client.users(uid)

@property
def ticket(self) -> "Ticket":
Expand Down

0 comments on commit 3020bdd

Please sign in to comment.