educabiz 0.0.1__py3-none-any.whl

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.
educabiz/__init__.py ADDED
@@ -0,0 +1,16 @@
1
+ from typing import TYPE_CHECKING
2
+
3
+ if TYPE_CHECKING:
4
+ from typing import Tuple, Union
5
+
6
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
7
+ else:
8
+ VERSION_TUPLE = object
9
+
10
+ version: str
11
+ __version__: str
12
+ __version_tuple__: VERSION_TUPLE
13
+ version_tuple: VERSION_TUPLE
14
+
15
+ __version__ = version = '0.0.1'
16
+ __version_tuple__ = version_tuple = tuple(map(int, version.split('.')))
educabiz/__main__.py ADDED
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env -S python3 -u
2
+
3
+ import requests
4
+ import dotenv
5
+ import os
6
+ from datetime import datetime, date
7
+
8
+
9
+ class Client(requests.Session):
10
+ URL = 'https://mobile.educabiz.com'
11
+
12
+ def request(self, method, url, *a, **b):
13
+ if url[0] == '/':
14
+ url = f'{self.URL}{url}'
15
+ return super().request(method, url, *a, **b)
16
+
17
+ def login(self, username, password):
18
+ r = self.post('/mobile/login', data={'username': username, 'password': password})
19
+ r.raise_for_status()
20
+ r = r.json()
21
+ assert r['status'] == 'ok'
22
+ return r
23
+
24
+ def home(self):
25
+ r = self.get('/educators/home')
26
+ r.raise_for_status()
27
+ return r.json()
28
+
29
+ def notifications(self):
30
+ r = self.get('/educators/notifications')
31
+ r.raise_for_status()
32
+ return r.json()
33
+
34
+ def child_payments(self, child):
35
+ r = self.get(f'/child/{child}/payments')
36
+ r.raise_for_status()
37
+ return r.json()
38
+
39
+ def child_report(self, child, page=0, build_page=False):
40
+ r = self.post(f'/child/{child}/report', data={'page': page, 'buildPage': build_page})
41
+ r.raise_for_status()
42
+ return r.json()
43
+
44
+ def child_messages(self, child, page=1):
45
+ r = self.get(f'/child/{child}/messages/income', params={'page': page})
46
+ r.raise_for_status()
47
+ return r.json()
48
+
49
+ def child_services(self, child):
50
+ r = self.get(f'/child/{child}/services')
51
+ r.raise_for_status()
52
+ return r.json()
53
+
54
+ def child_timetable(self, child):
55
+ r = self.get(f'/child/{child}/timetable')
56
+ r.raise_for_status()
57
+ return r.json()
58
+
59
+ def child_gallery(self, child, page=1, build_page=False):
60
+ r = self.get(
61
+ f'/child/{child}/gallery',
62
+ params={
63
+ 'page': page,
64
+ 'buildPage': build_page,
65
+ 'childId': child,
66
+ 'serviceId': '',
67
+ },
68
+ )
69
+ r.raise_for_status()
70
+ return r.json()
71
+
72
+ def school_qrcodeinfo(self):
73
+ r = self.get(
74
+ '/school/qrcodeinfo',
75
+ )
76
+ r.raise_for_status()
77
+ return r.json()
78
+
79
+ def _bool(self, b):
80
+ return 'true' if b else 'false'
81
+
82
+ def _schoolctrl_save_presence(
83
+ self,
84
+ path: str,
85
+ child_id: str,
86
+ date: date,
87
+ notes='',
88
+ absent=False,
89
+ is_checked=True,
90
+ is_enter=False,
91
+ number_day=1,
92
+ ):
93
+ r = self.post(
94
+ f'/schoolctrl/{path}',
95
+ data={
96
+ 'colabId': '',
97
+ 'date': date.strftime('%d-%m-%Y'),
98
+ 'notes': notes,
99
+ 'absent': self._bool(absent),
100
+ 'isChecked': self._bool(is_checked),
101
+ 'isEnter': self._bool(is_enter),
102
+ 'numberDay': number_day,
103
+ 'childId': child_id,
104
+ },
105
+ )
106
+ r.raise_for_status()
107
+ return r.json()
108
+
109
+ def schoolctrl_save_presence_note(self, child_id: str, date: datetime.date, notes=''):
110
+ return self._schoolctrl_save_presence('savepresencesinglenote', child_id, date, notes=notes, absent=True)
111
+
112
+ def schoolctrl_save_presence_out(self, child_id: str, date: datetime.date):
113
+ return self._schoolctrl_save_presence('savepresenceout', child_id, date)
114
+
115
+ def schoolctrl_save_presence_in(self, child_id: str, date: datetime.date):
116
+ return self._schoolctrl_save_presence('savepresencein', child_id, date, is_enter=True)
117
+
118
+
119
+ def cli():
120
+ dotenv.load_dotenv()
121
+ c = Client()
122
+ c.login(os.getenv('EDUCA_USERNAME'), os.getenv('EDUCA_PASSWORD'))
123
+ data = c.home()
124
+ print(f'School: {data["schoolname"]}')
125
+ for child_id, child in data['children'].items():
126
+ print(f'{child_id}:')
127
+ print(f'* Name: {child["name"]}')
128
+
129
+
130
+ if __name__ == '__main__':
131
+ cli()
educabiz/client.py ADDED
@@ -0,0 +1,112 @@
1
+ from datetime import date
2
+ import requests
3
+
4
+
5
+ class Client(requests.Session):
6
+ URL = 'https://mobile.educabiz.com'
7
+
8
+ def request(self, method, url, *a, **b):
9
+ if url[0] == '/':
10
+ url = f'{self.URL}{url}'
11
+ return super().request(method, url, *a, **b)
12
+
13
+ def login(self, username, password):
14
+ r = self.post('/mobile/login', data={'username': username, 'password': password})
15
+ r.raise_for_status()
16
+ r = r.json()
17
+ assert r['status'] == 'ok'
18
+ return r
19
+
20
+ def home(self):
21
+ r = self.get('/educators/home')
22
+ r.raise_for_status()
23
+ return r.json()
24
+
25
+ def notifications(self):
26
+ r = self.get('/educators/notifications')
27
+ r.raise_for_status()
28
+ return r.json()
29
+
30
+ def child_payments(self, child):
31
+ r = self.get(f'/child/{child}/payments')
32
+ r.raise_for_status()
33
+ return r.json()
34
+
35
+ def child_report(self, child, page=0, build_page=False):
36
+ r = self.post(f'/child/{child}/report', data={'page': page, 'buildPage': build_page})
37
+ r.raise_for_status()
38
+ return r.json()
39
+
40
+ def child_messages(self, child, page=1):
41
+ r = self.get(f'/child/{child}/messages/income', params={'page': page})
42
+ r.raise_for_status()
43
+ return r.json()
44
+
45
+ def child_services(self, child):
46
+ r = self.get(f'/child/{child}/services')
47
+ r.raise_for_status()
48
+ return r.json()
49
+
50
+ def child_timetable(self, child):
51
+ r = self.get(f'/child/{child}/timetable')
52
+ r.raise_for_status()
53
+ return r.json()
54
+
55
+ def child_gallery(self, child, page=1, build_page=False):
56
+ r = self.get(
57
+ f'/child/{child}/gallery',
58
+ params={
59
+ 'page': page,
60
+ 'buildPage': build_page,
61
+ 'childId': child,
62
+ 'serviceId': '',
63
+ },
64
+ )
65
+ r.raise_for_status()
66
+ return r.json()
67
+
68
+ def school_qrcodeinfo(self):
69
+ r = self.get(
70
+ '/school/qrcodeinfo',
71
+ )
72
+ r.raise_for_status()
73
+ return r.json()
74
+
75
+ def _bool(self, b):
76
+ return 'true' if b else 'false'
77
+
78
+ def _schoolctrl_save_presence(
79
+ self,
80
+ path: str,
81
+ child_id: str,
82
+ date: date,
83
+ notes='',
84
+ absent=False,
85
+ is_checked=True,
86
+ is_enter=False,
87
+ number_day=1,
88
+ ):
89
+ r = self.post(
90
+ f'/schoolctrl/{path}',
91
+ data={
92
+ 'colabId': '',
93
+ 'date': date.strftime('%d-%m-%Y'),
94
+ 'notes': notes,
95
+ 'absent': self._bool(absent),
96
+ 'isChecked': self._bool(is_checked),
97
+ 'isEnter': self._bool(is_enter),
98
+ 'numberDay': number_day,
99
+ 'childId': child_id,
100
+ },
101
+ )
102
+ r.raise_for_status()
103
+ return r.json()
104
+
105
+ def schoolctrl_save_presence_note(self, child_id: str, date: date, notes=''):
106
+ return self._schoolctrl_save_presence('savepresencesinglenote', child_id, date, notes=notes, absent=True)
107
+
108
+ def schoolctrl_save_presence_out(self, child_id: str, date: date):
109
+ return self._schoolctrl_save_presence('savepresenceout', child_id, date)
110
+
111
+ def schoolctrl_save_presence_in(self, child_id: str, date: date):
112
+ return self._schoolctrl_save_presence('savepresencein', child_id, date, is_enter=True)
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Filipe Pina
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,25 @@
1
+ Metadata-Version: 2.1
2
+ Name: educabiz
3
+ Version: 0.0.1
4
+ Summary: API client for *.educabiz.com
5
+ Author-email: Filipe Pina <shelf-corncob-said@duck.com>
6
+ Project-URL: Homepage, https://github.com/fopina/python-educabiz
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+
11
+ # python package template
12
+
13
+ ## Content
14
+
15
+ * `pytest` for tests: `make test`
16
+ * `ruff` for linting/formatting: `make lint` (replaces both `black` and `isort`)
17
+ * `.github` with actions ready to test PRs and publish releases
18
+
19
+ ## New project checklist
20
+
21
+ * [ ] Replace `example` with *the* package
22
+ * [ ] Replace `LICENSE` if MIT does not apply
23
+ * [ ] Search the project for `# TODO` to find the (minimum list of) places that need to be changed.
24
+ * [ ] Add PYPI credentials to secrets
25
+
@@ -0,0 +1,9 @@
1
+ educabiz/__init__.py,sha256=h_raVwYsn76uDMIDjYlCzRXsHWvegpSDl4iUhWlySTU,368
2
+ educabiz/__main__.py,sha256=vQuK8jerWSua1NCcJ6W17DG_mn_F7mDwvAUrG4S3pUc,3830
3
+ educabiz/client.py,sha256=rwVz0VXs8ZdcBAPgff8f2iD44pA_CBcAAAN4L-q69tM,3387
4
+ educabiz-0.0.1.dist-info/LICENSE,sha256=VhFKvmhFGR5Zd6R5B2Nnq2qISn_ZpvhVwZHt_0MllMA,1067
5
+ educabiz-0.0.1.dist-info/METADATA,sha256=z1BI740sYpyUi1wqXkWPMa5cGsdBfd-zcVvTcyQF694,773
6
+ educabiz-0.0.1.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
7
+ educabiz-0.0.1.dist-info/entry_points.txt,sha256=1GW-T98D-ULaawcYU44y08vHLJt1NAb_nFSn4Dt1lKo,56
8
+ educabiz-0.0.1.dist-info/top_level.txt,sha256=w6VYjSREBu7MGSXHYC5aXXzyLkgWh3Msl1pUpeOEx7g,9
9
+ educabiz-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.44.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ admindocs-cli = educabiz.__main__:cli
@@ -0,0 +1 @@
1
+ educabiz