-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathteams.py
More file actions
43 lines (32 loc) · 1.15 KB
/
teams.py
File metadata and controls
43 lines (32 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from enum import Enum
class TeammateRole(Enum):
"""Teammate Roles Enum"""
Labeler = "labeler"
Member = "member"
Manager = "manager"
Admin = "admin"
class Teammate:
"""Teammate class, containing teammate information."""
def __init__(self, json, client):
self._json = json
self.email: str = json["email"]
self.role = json["role"]
self._client = client
# fill in rest here (non-optional fields)
self.company = json.get("company")
self.first_name = json.get("firstName")
self.last_name = json.get("lastName")
self.is_studio_labeler = json.get("isStudioLabeler")
self.expiry = json.get("expiry")
def __hash__(self):
return hash(self.email)
def __str__(self):
return f"Teammate(email={self.email})"
def __repr__(self):
return f"Teammate({self._json})"
def as_dict(self):
"""Returns all attributes as a dictionary"""
return self._json
def update_teammate_role(self, new_role: TeammateRole):
"""Updates teammate role"""
return self._client.update_teammates_role([self.email], new_role)