-
Notifications
You must be signed in to change notification settings - Fork 3
/
airtable_client.py
59 lines (47 loc) · 1.38 KB
/
airtable_client.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from airtable import Airtable
from config import CONFIG
TABLE_NAMES = [
"Projects",
"Tasks",
"Onboarding Events",
"Members",
"Volunteers",
"Teams",
"Actions"
]
class Tables:
def __init__(self):
self.staging = False
self._tables = {}
self._tables_staging = {}
self.reset()
def reset(self):
for table_name in TABLE_NAMES:
self._tables[table_name] = Airtable(
CONFIG.airtable_base_id, table_name,
api_key=CONFIG.airtable_token)
def get_table(self, name: str) -> Airtable:
assert name in TABLE_NAMES, f"There is no table named {name}"
return self._tables[name]
@property
def projects(self) -> Airtable:
return self.get_table("Projects")
@property
def tasks(self) -> Airtable:
return self.get_table("Tasks")
@property
def onboarding_events(self) -> Airtable:
return self.get_table("Onboarding Events")
@property
def members(self) -> Airtable:
return self.get_table("Members")
@property
def volunteers(self) -> Airtable:
return self.get_table("Volunteers")
@property
def teams(self) -> Airtable:
return self.get_table("Teams")
@property
def actions(self) -> Airtable:
return self.get_table("Actions")
TABLES = Tables()