myskoda 0.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- myskoda-0.0.0/LICENSE +7 -0
- myskoda-0.0.0/PKG-INFO +183 -0
- myskoda-0.0.0/README.md +153 -0
- myskoda-0.0.0/myskoda/__init__.py +50 -0
- myskoda-0.0.0/myskoda/__version__.py +3 -0
- myskoda-0.0.0/myskoda/anonymize.py +132 -0
- myskoda-0.0.0/myskoda/auth/__init__.py +1 -0
- myskoda-0.0.0/myskoda/auth/authorization.py +326 -0
- myskoda-0.0.0/myskoda/auth/csrf_parser.py +67 -0
- myskoda-0.0.0/myskoda/auth/utils.py +8 -0
- myskoda-0.0.0/myskoda/cli/__init__.py +176 -0
- myskoda-0.0.0/myskoda/cli/gen_fixtures.py +63 -0
- myskoda-0.0.0/myskoda/cli/mqtt.py +46 -0
- myskoda-0.0.0/myskoda/cli/operations.py +340 -0
- myskoda-0.0.0/myskoda/cli/requests.py +141 -0
- myskoda-0.0.0/myskoda/cli/utils.py +57 -0
- myskoda-0.0.0/myskoda/const.py +53 -0
- myskoda-0.0.0/myskoda/event.py +103 -0
- myskoda-0.0.0/myskoda/models/__init__.py +1 -0
- myskoda-0.0.0/myskoda/models/air_conditioning.py +167 -0
- myskoda-0.0.0/myskoda/models/auxiliary_heating.py +85 -0
- myskoda-0.0.0/myskoda/models/charging.py +125 -0
- myskoda-0.0.0/myskoda/models/common.py +101 -0
- myskoda-0.0.0/myskoda/models/driving_range.py +43 -0
- myskoda-0.0.0/myskoda/models/fixtures.py +78 -0
- myskoda-0.0.0/myskoda/models/garage.py +53 -0
- myskoda-0.0.0/myskoda/models/health.py +41 -0
- myskoda-0.0.0/myskoda/models/info.py +308 -0
- myskoda-0.0.0/myskoda/models/maintenance.py +94 -0
- myskoda-0.0.0/myskoda/models/operation_request.py +61 -0
- myskoda-0.0.0/myskoda/models/position.py +39 -0
- myskoda-0.0.0/myskoda/models/service_event.py +192 -0
- myskoda-0.0.0/myskoda/models/spin.py +31 -0
- myskoda-0.0.0/myskoda/models/status.py +132 -0
- myskoda-0.0.0/myskoda/models/trip_statistics.py +68 -0
- myskoda-0.0.0/myskoda/models/user.py +40 -0
- myskoda-0.0.0/myskoda/mqtt.py +323 -0
- myskoda-0.0.0/myskoda/myskoda.py +463 -0
- myskoda-0.0.0/myskoda/rest_api.py +524 -0
- myskoda-0.0.0/myskoda/vehicle.py +46 -0
- myskoda-0.0.0/pyproject.toml +85 -0
myskoda-0.0.0/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2024 Frederick Gnodtke
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
myskoda-0.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: myskoda
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Library for interaction with the MySkoda APIs.
|
|
5
|
+
Author: Frederick Gnodtke
|
|
6
|
+
Author-email: frederick@gnodtke.net
|
|
7
|
+
Requires-Python: >=3.12.0,<4.0
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
11
|
+
Provides-Extra: cli
|
|
12
|
+
Provides-Extra: docs
|
|
13
|
+
Requires-Dist: aiohttp (>=3,<4)
|
|
14
|
+
Requires-Dist: aiomqtt (>=2.0,<3.0)
|
|
15
|
+
Requires-Dist: asyncclick (>=8.1.7.2,<9.0.0.0) ; extra == "cli"
|
|
16
|
+
Requires-Dist: asyncio (>=3,<4)
|
|
17
|
+
Requires-Dist: coloredlogs (>=15.0.1,<16.0.0) ; extra == "cli"
|
|
18
|
+
Requires-Dist: mashumaro[orjson] (>=3.13.1,<4.0.0)
|
|
19
|
+
Requires-Dist: mkdocs-gen-files (>=0.5.0,<0.6.0) ; extra == "docs"
|
|
20
|
+
Requires-Dist: mkdocs-literate-nav (>=0.6.1,<0.7.0) ; extra == "docs"
|
|
21
|
+
Requires-Dist: mkdocs[gen-files] (>=1.6.1,<2.0.0) ; extra == "docs"
|
|
22
|
+
Requires-Dist: mkdocstrings[python] (>=0.26.1,<0.28.0) ; extra == "docs"
|
|
23
|
+
Requires-Dist: paho-mqtt (>=1,<2)
|
|
24
|
+
Requires-Dist: pygments (>=2.18.0,<3.0.0) ; extra == "cli"
|
|
25
|
+
Requires-Dist: pyjwt (>=2,<3)
|
|
26
|
+
Requires-Dist: pyyaml (>=6,<7)
|
|
27
|
+
Requires-Dist: termcolor (>=2.4.0,<3.0.0) ; extra == "cli"
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
[](https://github.com/skodaconnect/myskoda/releases)
|
|
31
|
+
[](https://pypi.org/project/myskoda/)
|
|
32
|
+
[](https://pypi.org/project/myskoda/)
|
|
33
|
+
[](https://myskoda.readthedocs.io/en/latest/)
|
|
34
|
+
[](https://discord.gg/t7az2hSJXq)
|
|
35
|
+
[](https://coveralls.io/github/skodaconnect/myskoda)
|
|
36
|
+
|
|
37
|
+
# MySkoda
|
|
38
|
+
|
|
39
|
+
This Python library can be used to work with the MySkoda API.
|
|
40
|
+
<!-- TOC -->
|
|
41
|
+
|
|
42
|
+
- [MySkoda](#myskoda)
|
|
43
|
+
- [Get In Touch](#get-in-touch)
|
|
44
|
+
- [Quick Start](#quick-start)
|
|
45
|
+
- [Basic example](#basic-example)
|
|
46
|
+
- [Documentation](#documentation)
|
|
47
|
+
- [As Library](#as-library)
|
|
48
|
+
- [As CLI](#as-cli)
|
|
49
|
+
- [Contribute your Fixtures](#contribute-your-fixtures)
|
|
50
|
+
- [Disclaimer](#disclaimer)
|
|
51
|
+
|
|
52
|
+
<!-- /TOC -->
|
|
53
|
+
|
|
54
|
+
## Get In Touch
|
|
55
|
+
|
|
56
|
+
We have an active community in our discord. [Feel free to join](https://discord.gg/t7az2hSJXq).
|
|
57
|
+
|
|
58
|
+
If you have any issues, please report them in our issue tracker.
|
|
59
|
+
|
|
60
|
+
## Quick Start
|
|
61
|
+
|
|
62
|
+
The MySkoda package is published to Pypi and can be found [here](https://pypi.org/project/myskoda/).
|
|
63
|
+
|
|
64
|
+
It can be installed the usual way:
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
pip install myskoda
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Basic example
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from aiohttp import ClientSession
|
|
74
|
+
from myskoda import MySkoda
|
|
75
|
+
|
|
76
|
+
session = ClientSession()
|
|
77
|
+
myskoda = MySkoda(session)
|
|
78
|
+
await myskoda.connect(email, password)
|
|
79
|
+
|
|
80
|
+
for vin in await myskoda.list_vehicle_vins():
|
|
81
|
+
print(vin)
|
|
82
|
+
|
|
83
|
+
myskoda.disconnect()
|
|
84
|
+
await session.close()
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Documentation
|
|
88
|
+
|
|
89
|
+
Detailed documentation [is available at read the docs](https://myskoda.readthedocs.io/en/latest/):
|
|
90
|
+
* [Fetching Data](https://myskoda.readthedocs.io/en/latest/fetching_data/)
|
|
91
|
+
* [Subscribing to Events](https://myskoda.readthedocs.io/en/latest/events/)
|
|
92
|
+
* [Primer](https://myskoda.readthedocs.io/en/latest/primer/)
|
|
93
|
+
|
|
94
|
+
## As Library
|
|
95
|
+
|
|
96
|
+
MySkoda relies on [aiohttp](https://pypi.org/project/aiohttp/) which must be installed.
|
|
97
|
+
A `ClientSession` must be opened and passed to `MySkoda` upon initialization.
|
|
98
|
+
|
|
99
|
+
After connecting, operations can be performed, events can be subscribed to and data can be loaded from the API.
|
|
100
|
+
|
|
101
|
+
Don't forget to close the session and disconnect MySkoda after you're done.
|
|
102
|
+
|
|
103
|
+
## As CLI
|
|
104
|
+
|
|
105
|
+
The MySkoda package features a CLI.
|
|
106
|
+
You will have to install it with extras `cli`:
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
pip install "myskoda[cli]"
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Afterwards, the CLI is available in your current environment by invoking `myskoda`.
|
|
113
|
+
|
|
114
|
+
Username and password must be provided to the CLI for every request as options, before selecting a sub command:
|
|
115
|
+
|
|
116
|
+
```sh
|
|
117
|
+
myskoda --user "user@example.com" --password "super secret" list-vehicles
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Help can be accessed the usual way:
|
|
121
|
+
|
|
122
|
+
```sh
|
|
123
|
+
myskoda --help
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Contribute your Fixtures
|
|
127
|
+
|
|
128
|
+
Please contribute fixtures for our tests by running this command:
|
|
129
|
+
|
|
130
|
+
```sh
|
|
131
|
+
# Export all endpoints for all vehicles.
|
|
132
|
+
myskoda \
|
|
133
|
+
--user user \
|
|
134
|
+
--password password \
|
|
135
|
+
gen-fixtures \
|
|
136
|
+
--name my_cars \
|
|
137
|
+
--description "My cars in no specific state."
|
|
138
|
+
--vehicle all \
|
|
139
|
+
get all
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
It is also possible to just contribute a single vehicle:
|
|
143
|
+
|
|
144
|
+
```sh
|
|
145
|
+
# Export all endpoints for a specific vehicle.
|
|
146
|
+
myskoda \
|
|
147
|
+
--user user \
|
|
148
|
+
--password password \
|
|
149
|
+
gen-fixtures \
|
|
150
|
+
--name my_favorite_car \
|
|
151
|
+
--description "My favorite car in no specific state."
|
|
152
|
+
--vehicle TMOCKAA0AA000000 \
|
|
153
|
+
get all
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Or even narrow down to an inidividual endpoint for an individual vehicle:
|
|
157
|
+
|
|
158
|
+
```sh
|
|
159
|
+
# Export a specific endpoint for a specific vehicle.
|
|
160
|
+
myskoda \
|
|
161
|
+
--user user \
|
|
162
|
+
--password password \
|
|
163
|
+
gen-fixtures \
|
|
164
|
+
--name my_favorite_car_info \
|
|
165
|
+
--description "Info for my favorite car in no specific state."
|
|
166
|
+
--vehicle TMOCKAA0AA000000 \
|
|
167
|
+
get info
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
This will call all the selected get-routes and load all data from your vehicles (no actions will be performed).
|
|
171
|
+
|
|
172
|
+
The data will be anonymized (vin and personal data are replaced) and serves as unit tests.
|
|
173
|
+
|
|
174
|
+
Please create a pull request with the resulting data to help us cover more vehicles.
|
|
175
|
+
|
|
176
|
+
## Disclaimer
|
|
177
|
+
|
|
178
|
+
This project is an unofficial API client for the Skoda API and is not affiliated with, endorsed by, or associated with Skoda Auto or any of its subsidiaries.
|
|
179
|
+
|
|
180
|
+
Use this project at your own risk. Skoda Auto may update or modify its API without notice, which could render this client inoperative or non-compliant. The maintainers of this project are not responsible for any misuse, legal implications, or damages arising from its use.
|
|
181
|
+
|
|
182
|
+
Ensure compliance with Skoda Auto's terms of service and any applicable laws when using this software.
|
|
183
|
+
|
myskoda-0.0.0/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
[](https://github.com/skodaconnect/myskoda/releases)
|
|
2
|
+
[](https://pypi.org/project/myskoda/)
|
|
3
|
+
[](https://pypi.org/project/myskoda/)
|
|
4
|
+
[](https://myskoda.readthedocs.io/en/latest/)
|
|
5
|
+
[](https://discord.gg/t7az2hSJXq)
|
|
6
|
+
[](https://coveralls.io/github/skodaconnect/myskoda)
|
|
7
|
+
|
|
8
|
+
# MySkoda
|
|
9
|
+
|
|
10
|
+
This Python library can be used to work with the MySkoda API.
|
|
11
|
+
<!-- TOC -->
|
|
12
|
+
|
|
13
|
+
- [MySkoda](#myskoda)
|
|
14
|
+
- [Get In Touch](#get-in-touch)
|
|
15
|
+
- [Quick Start](#quick-start)
|
|
16
|
+
- [Basic example](#basic-example)
|
|
17
|
+
- [Documentation](#documentation)
|
|
18
|
+
- [As Library](#as-library)
|
|
19
|
+
- [As CLI](#as-cli)
|
|
20
|
+
- [Contribute your Fixtures](#contribute-your-fixtures)
|
|
21
|
+
- [Disclaimer](#disclaimer)
|
|
22
|
+
|
|
23
|
+
<!-- /TOC -->
|
|
24
|
+
|
|
25
|
+
## Get In Touch
|
|
26
|
+
|
|
27
|
+
We have an active community in our discord. [Feel free to join](https://discord.gg/t7az2hSJXq).
|
|
28
|
+
|
|
29
|
+
If you have any issues, please report them in our issue tracker.
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
The MySkoda package is published to Pypi and can be found [here](https://pypi.org/project/myskoda/).
|
|
34
|
+
|
|
35
|
+
It can be installed the usual way:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
pip install myskoda
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Basic example
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from aiohttp import ClientSession
|
|
45
|
+
from myskoda import MySkoda
|
|
46
|
+
|
|
47
|
+
session = ClientSession()
|
|
48
|
+
myskoda = MySkoda(session)
|
|
49
|
+
await myskoda.connect(email, password)
|
|
50
|
+
|
|
51
|
+
for vin in await myskoda.list_vehicle_vins():
|
|
52
|
+
print(vin)
|
|
53
|
+
|
|
54
|
+
myskoda.disconnect()
|
|
55
|
+
await session.close()
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Documentation
|
|
59
|
+
|
|
60
|
+
Detailed documentation [is available at read the docs](https://myskoda.readthedocs.io/en/latest/):
|
|
61
|
+
* [Fetching Data](https://myskoda.readthedocs.io/en/latest/fetching_data/)
|
|
62
|
+
* [Subscribing to Events](https://myskoda.readthedocs.io/en/latest/events/)
|
|
63
|
+
* [Primer](https://myskoda.readthedocs.io/en/latest/primer/)
|
|
64
|
+
|
|
65
|
+
## As Library
|
|
66
|
+
|
|
67
|
+
MySkoda relies on [aiohttp](https://pypi.org/project/aiohttp/) which must be installed.
|
|
68
|
+
A `ClientSession` must be opened and passed to `MySkoda` upon initialization.
|
|
69
|
+
|
|
70
|
+
After connecting, operations can be performed, events can be subscribed to and data can be loaded from the API.
|
|
71
|
+
|
|
72
|
+
Don't forget to close the session and disconnect MySkoda after you're done.
|
|
73
|
+
|
|
74
|
+
## As CLI
|
|
75
|
+
|
|
76
|
+
The MySkoda package features a CLI.
|
|
77
|
+
You will have to install it with extras `cli`:
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
pip install "myskoda[cli]"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Afterwards, the CLI is available in your current environment by invoking `myskoda`.
|
|
84
|
+
|
|
85
|
+
Username and password must be provided to the CLI for every request as options, before selecting a sub command:
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
myskoda --user "user@example.com" --password "super secret" list-vehicles
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Help can be accessed the usual way:
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
myskoda --help
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Contribute your Fixtures
|
|
98
|
+
|
|
99
|
+
Please contribute fixtures for our tests by running this command:
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
# Export all endpoints for all vehicles.
|
|
103
|
+
myskoda \
|
|
104
|
+
--user user \
|
|
105
|
+
--password password \
|
|
106
|
+
gen-fixtures \
|
|
107
|
+
--name my_cars \
|
|
108
|
+
--description "My cars in no specific state."
|
|
109
|
+
--vehicle all \
|
|
110
|
+
get all
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
It is also possible to just contribute a single vehicle:
|
|
114
|
+
|
|
115
|
+
```sh
|
|
116
|
+
# Export all endpoints for a specific vehicle.
|
|
117
|
+
myskoda \
|
|
118
|
+
--user user \
|
|
119
|
+
--password password \
|
|
120
|
+
gen-fixtures \
|
|
121
|
+
--name my_favorite_car \
|
|
122
|
+
--description "My favorite car in no specific state."
|
|
123
|
+
--vehicle TMOCKAA0AA000000 \
|
|
124
|
+
get all
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Or even narrow down to an inidividual endpoint for an individual vehicle:
|
|
128
|
+
|
|
129
|
+
```sh
|
|
130
|
+
# Export a specific endpoint for a specific vehicle.
|
|
131
|
+
myskoda \
|
|
132
|
+
--user user \
|
|
133
|
+
--password password \
|
|
134
|
+
gen-fixtures \
|
|
135
|
+
--name my_favorite_car_info \
|
|
136
|
+
--description "Info for my favorite car in no specific state."
|
|
137
|
+
--vehicle TMOCKAA0AA000000 \
|
|
138
|
+
get info
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
This will call all the selected get-routes and load all data from your vehicles (no actions will be performed).
|
|
142
|
+
|
|
143
|
+
The data will be anonymized (vin and personal data are replaced) and serves as unit tests.
|
|
144
|
+
|
|
145
|
+
Please create a pull request with the resulting data to help us cover more vehicles.
|
|
146
|
+
|
|
147
|
+
## Disclaimer
|
|
148
|
+
|
|
149
|
+
This project is an unofficial API client for the Skoda API and is not affiliated with, endorsed by, or associated with Skoda Auto or any of its subsidiaries.
|
|
150
|
+
|
|
151
|
+
Use this project at your own risk. Skoda Auto may update or modify its API without notice, which could render this client inoperative or non-compliant. The maintainers of this project are not responsible for any misuse, legal implications, or damages arising from its use.
|
|
152
|
+
|
|
153
|
+
Ensure compliance with Skoda Auto's terms of service and any applicable laws when using this software.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""A library for interacting with the MySkoda APIs."""
|
|
2
|
+
|
|
3
|
+
from .__version__ import __version__
|
|
4
|
+
from .auth.authorization import (
|
|
5
|
+
Authorization,
|
|
6
|
+
AuthorizationError,
|
|
7
|
+
AuthorizationFailedError,
|
|
8
|
+
IDKAuthorizationCode,
|
|
9
|
+
IDKSession,
|
|
10
|
+
)
|
|
11
|
+
from .models import (
|
|
12
|
+
air_conditioning,
|
|
13
|
+
charging,
|
|
14
|
+
common,
|
|
15
|
+
health,
|
|
16
|
+
info,
|
|
17
|
+
operation_request,
|
|
18
|
+
position,
|
|
19
|
+
service_event,
|
|
20
|
+
status,
|
|
21
|
+
user,
|
|
22
|
+
)
|
|
23
|
+
from .mqtt import MySkodaMqttClient
|
|
24
|
+
from .myskoda import TRACE_CONFIG, MySkoda
|
|
25
|
+
from .rest_api import RestApi
|
|
26
|
+
from .vehicle import Vehicle
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
"TRACE_CONFIG",
|
|
30
|
+
"Authorization",
|
|
31
|
+
"AuthorizationError",
|
|
32
|
+
"AuthorizationFailedError",
|
|
33
|
+
"IDKAuthorizationCode",
|
|
34
|
+
"IDKSession",
|
|
35
|
+
"MySkoda",
|
|
36
|
+
"MySkodaMqttClient",
|
|
37
|
+
"RestApi",
|
|
38
|
+
"Vehicle",
|
|
39
|
+
"__version__",
|
|
40
|
+
"air_conditioning",
|
|
41
|
+
"charging",
|
|
42
|
+
"common",
|
|
43
|
+
"health",
|
|
44
|
+
"info",
|
|
45
|
+
"operation_request",
|
|
46
|
+
"position",
|
|
47
|
+
"service_event",
|
|
48
|
+
"status",
|
|
49
|
+
"user",
|
|
50
|
+
]
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"""Methods for anonymizing data from the API."""
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
|
|
5
|
+
ACCESS_TOKEN = "eyJ0eXAiOiI0ODEyODgzZi05Y2FiLTQwMWMtYTI5OC0wZmEyMTA5Y2ViY2EiLCJhbGciOiJSUzI1NiJ9" # noqa: S105
|
|
6
|
+
USER_ID = "b8bc126c-ee36-402b-8723-2c1c3dff8dec"
|
|
7
|
+
VIN = "TMOCKAA0AA000000"
|
|
8
|
+
VIN_REGEX = re.compile(r"TMB\w{14}")
|
|
9
|
+
ADDRESS = {
|
|
10
|
+
"city": "Example City",
|
|
11
|
+
"street": "Example Avenue",
|
|
12
|
+
"houseNumber": "15",
|
|
13
|
+
"zipCode": "54321",
|
|
14
|
+
"countryCode": "DEU",
|
|
15
|
+
}
|
|
16
|
+
SERVICE_PARTNER_ID = "DEU11111"
|
|
17
|
+
PARTNER_NUMBER = "1111"
|
|
18
|
+
PARTNER_NAME = "Example Service Partner"
|
|
19
|
+
LOCATION = {
|
|
20
|
+
"latitude": 53.470636,
|
|
21
|
+
"longitude": 9.689872,
|
|
22
|
+
}
|
|
23
|
+
EMAIL = "user@example.com"
|
|
24
|
+
PHONE = "+49 1234 567890"
|
|
25
|
+
VEHICLE_NAME = "Example Car"
|
|
26
|
+
LICENSE_PLATE = "HH AA 1234"
|
|
27
|
+
URL = "https://example.com"
|
|
28
|
+
FIRST_NAME = "John"
|
|
29
|
+
LAST_NAME = "Dough"
|
|
30
|
+
NICKNAME = "Johnny D."
|
|
31
|
+
PROFILE_PICTURE_URL = "https://example.com/profile.jpg"
|
|
32
|
+
DATE_OF_BIRTH = "2000-01-01"
|
|
33
|
+
|
|
34
|
+
SERVICE_PARTNER = {
|
|
35
|
+
"name": PARTNER_NAME,
|
|
36
|
+
"partnerNumber": PARTNER_NUMBER,
|
|
37
|
+
"id": SERVICE_PARTNER_ID,
|
|
38
|
+
"contact": {
|
|
39
|
+
"phone": PHONE,
|
|
40
|
+
"url": URL,
|
|
41
|
+
"email": EMAIL,
|
|
42
|
+
},
|
|
43
|
+
"address": ADDRESS,
|
|
44
|
+
"location": LOCATION,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def anonymize_info(data: dict) -> dict:
|
|
49
|
+
data["vin"] = VIN
|
|
50
|
+
data["name"] = VEHICLE_NAME
|
|
51
|
+
if "licensePlate" in data:
|
|
52
|
+
data["licensePlate"] = LICENSE_PLATE
|
|
53
|
+
if "servicePartner" in data:
|
|
54
|
+
data["servicePartner"]["servicePartnerId"] = SERVICE_PARTNER_ID
|
|
55
|
+
return data
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def anonymize_maintenance(data: dict) -> dict:
|
|
59
|
+
if "preferredServicePartner" in data:
|
|
60
|
+
data["preferredServicePartner"].update(SERVICE_PARTNER)
|
|
61
|
+
if "predictiveMaintenance" in data:
|
|
62
|
+
data["predictiveMaintenance"]["setting"]["email"] = EMAIL
|
|
63
|
+
data["predictiveMaintenance"]["setting"]["phone"] = PHONE
|
|
64
|
+
for booking in data.get("customerService", {}).get("bookingHistory", []):
|
|
65
|
+
booking["servicePartner"].update(SERVICE_PARTNER)
|
|
66
|
+
for booking in data.get("customerService", {}).get("bookingHistory", []):
|
|
67
|
+
booking["servicePartner"].update(SERVICE_PARTNER)
|
|
68
|
+
return data
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def anonymize_charging(data: dict) -> dict:
|
|
72
|
+
return data
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def anonymize_status(data: dict) -> dict:
|
|
76
|
+
return data
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def anonymize_air_conditioning(data: dict) -> dict:
|
|
80
|
+
return data
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def anonymize_auxiliary_heating(data: dict) -> dict:
|
|
84
|
+
return data
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def anonymize_positions(data: dict) -> dict:
|
|
88
|
+
if "positions" in data:
|
|
89
|
+
for position in data["positions"]:
|
|
90
|
+
position["gpsCoordinates"] = LOCATION
|
|
91
|
+
position["address"] = ADDRESS
|
|
92
|
+
return data
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def anonymize_driving_range(data: dict) -> dict:
|
|
96
|
+
return data
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def anonymize_trip_statistics(data: dict) -> dict:
|
|
100
|
+
return data
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def anonymize_health(data: dict) -> dict:
|
|
104
|
+
return data
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def anonymize_user(data: dict) -> dict:
|
|
108
|
+
data["email"] = EMAIL
|
|
109
|
+
data["firstName"] = FIRST_NAME
|
|
110
|
+
data["lastName"] = LAST_NAME
|
|
111
|
+
data["nickname"] = NICKNAME
|
|
112
|
+
data["profilePictureUrl"] = PROFILE_PICTURE_URL
|
|
113
|
+
data["dateOfBirth"] = DATE_OF_BIRTH
|
|
114
|
+
data["phone"] = PHONE
|
|
115
|
+
|
|
116
|
+
return data
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def anonymize_garage_entry(data: dict) -> dict:
|
|
120
|
+
data["vin"] = VIN
|
|
121
|
+
data["name"] = VEHICLE_NAME
|
|
122
|
+
return data
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def anonymize_garage(data: dict) -> dict:
|
|
126
|
+
if "vehicles" in data:
|
|
127
|
+
data["vehicles"] = [anonymize_garage_entry(vehicle) for vehicle in data["vehicles"]]
|
|
128
|
+
return data
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def anonymize_url(url: str) -> str:
|
|
132
|
+
return VIN_REGEX.sub(VIN, url)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Authorization for VW IDK servers."""
|