-
Notifications
You must be signed in to change notification settings - Fork 12
/
example.py
35 lines (26 loc) · 955 Bytes
/
example.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
import asyncio
from pyporscheconnectapi.connection import Connection
from pyporscheconnectapi.client import Client
from sys import argv
import logging
logging.basicConfig()
# By default the root logger is set to WARNING and all loggers you define
# inherit that value. Here we set the root logger to NOTSET. This logging
# level is automatically inherited by all existing and new sub-loggers
# that do not set a less verbose level.
logging.root.setLevel(logging.DEBUG)
email = argv[1]
password = argv[2]
async def vehicles() -> None:
conn = Connection(email, password)
tokens = await conn.getAllTokens()
print(tokens)
client = Client(conn)
vehicles = await client.getVehicles()
for vehicle in vehicles:
print(
f"VIN: {vehicle['vin']} Model: {vehicle['modelDescription']} Year: {vehicle['modelYear']}"
)
await conn.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(vehicles())