-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
40 lines (29 loc) · 941 Bytes
/
main.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
import os
from time import sleep
from pydantic import SecretStr
from structlog import get_logger
from things_cloud import ThingsClient
from things_cloud.api.account import Account, Credentials
from things_cloud.models import TodoItem
log = get_logger()
EMAIL = os.environ["THINGS_EMAIL"]
PASSWORD = os.environ["THINGS_PASSWORD"]
def main():
credentials = Credentials(email=EMAIL, password=SecretStr(PASSWORD))
account = Account.login(credentials)
things = ThingsClient(account)
# create a new project
project = TodoItem(title="Things Cloud Project").as_project()
things.commit(project)
log.debug("created project", uuid=project.uuid)
sleep(10)
# create a todo inside project
todo = TodoItem(title="Try out Things Cloud")
todo.project = project
things.commit(todo)
sleep(10)
# schedule for today
todo.today()
things.commit(todo)
if __name__ == "__main__":
main()