schoolapp-api 2.0.0__tar.gz → 2.1.1__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.
- schoolapp_api-2.1.1/PKG-INFO +62 -0
- schoolapp_api-2.1.1/README.md +50 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/pyproject.toml +1 -1
- schoolapp_api-2.1.1/schoolapp_api.egg-info/PKG-INFO +62 -0
- schoolapp_api-2.0.0/PKG-INFO +0 -91
- schoolapp_api-2.0.0/README.md +0 -79
- schoolapp_api-2.0.0/schoolapp_api.egg-info/PKG-INFO +0 -91
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/LICENSE +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/__init__.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/auth.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/constants.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/http_client.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/managers/__init__.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/managers/attendance_manager.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/managers/base_manager.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/managers/course_manager.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/managers/grades_manager.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/managers/profile_manager.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/parsers/__init__.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/parsers/absences.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/parsers/annees.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/parsers/filieres.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/parsers/modules.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/parsers/note_elem.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/parsers/note_mod.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/parsers/profile.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/parsers/sanctions.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/parsers/semestres.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/parsers/stats.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/school_app_client.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/types/__init__.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/types/annee.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/types/base.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/types/element.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/types/module.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api/types/semestre.py +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api.egg-info/SOURCES.txt +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api.egg-info/dependency_links.txt +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api.egg-info/requires.txt +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/schoolapp_api.egg-info/top_level.txt +0 -0
- {schoolapp_api-2.0.0 → schoolapp_api-2.1.1}/setup.cfg +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: schoolapp-api
|
|
3
|
+
Version: 2.1.1
|
|
4
|
+
Summary: Professional client for interacting with the School App API
|
|
5
|
+
Author: Aferiad Kamal
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.7
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: beautifulsoup4>=4.9.0
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# SchoolApp API
|
|
14
|
+
|
|
15
|
+
A Python library designed to make interacting with the SchoolApp platform a lot less painful. Instead of wrestling with session cookies and manual HTML scraping, this library gives you a clean, object-oriented way to access your grades, attendance, and profile data.
|
|
16
|
+
|
|
17
|
+
## Why This Exists
|
|
18
|
+
Browsing the SchoolApp web interface manually for updates is slow. If you want to build a custom dashboard, a grade tracker, or a notification bot, you need a reliable way to get that data programmatically. This library takes care of:
|
|
19
|
+
- **Authentication**: Solid session management with automatic CSRF token handling.
|
|
20
|
+
- **Data Cleanup**: Converts messy HTML tables into structured Python objects.
|
|
21
|
+
- **Smart Logic**: Handles nested modules, element-level statistics, and transcript parsing out of the box.
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### Installation
|
|
26
|
+
You can install the library locally using:
|
|
27
|
+
```bash
|
|
28
|
+
pip install schoolapp-api
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Basic Usage
|
|
32
|
+
Getting your data is as simple as this:
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from schoolapp_api import SchoolAppClient
|
|
36
|
+
|
|
37
|
+
# Initialize and log in
|
|
38
|
+
client = SchoolAppClient()
|
|
39
|
+
if client.login("your.email@example.com", "password"):
|
|
40
|
+
|
|
41
|
+
# Get your basic info
|
|
42
|
+
profile = client.get_profile()
|
|
43
|
+
print(f"Hello, {profile['basic_info']['full_name']}!")
|
|
44
|
+
|
|
45
|
+
# Fetch your current semester grades
|
|
46
|
+
grades = client.get_current_elem_note()
|
|
47
|
+
for item in grades:
|
|
48
|
+
print(f"{item.CodeElem}: {item.Moy}")
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Project Layout
|
|
52
|
+
The library is organized into several specific managers, so you always know where to find what you need:
|
|
53
|
+
|
|
54
|
+
- **`grades`**: Handle module marks, element notes, and academic year results.
|
|
55
|
+
- **`attendance`**: Track your absences and see any sanctions.
|
|
56
|
+
- **`profile`**: Access your personal data and administrative files.
|
|
57
|
+
- **`courses`**: Browse the study plan and available modules.
|
|
58
|
+
|
|
59
|
+
For the full details on every class and function, head over to the [**/docs**](./docs/README.md) folder.
|
|
60
|
+
|
|
61
|
+
## Contributions
|
|
62
|
+
Found a bug or have an idea for a new feature? Feel free to open an issue or submit a pull request. Any help making this library better for everyone is appreciated!
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# SchoolApp API
|
|
2
|
+
|
|
3
|
+
A Python library designed to make interacting with the SchoolApp platform a lot less painful. Instead of wrestling with session cookies and manual HTML scraping, this library gives you a clean, object-oriented way to access your grades, attendance, and profile data.
|
|
4
|
+
|
|
5
|
+
## Why This Exists
|
|
6
|
+
Browsing the SchoolApp web interface manually for updates is slow. If you want to build a custom dashboard, a grade tracker, or a notification bot, you need a reliable way to get that data programmatically. This library takes care of:
|
|
7
|
+
- **Authentication**: Solid session management with automatic CSRF token handling.
|
|
8
|
+
- **Data Cleanup**: Converts messy HTML tables into structured Python objects.
|
|
9
|
+
- **Smart Logic**: Handles nested modules, element-level statistics, and transcript parsing out of the box.
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
### Installation
|
|
14
|
+
You can install the library locally using:
|
|
15
|
+
```bash
|
|
16
|
+
pip install schoolapp-api
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Basic Usage
|
|
20
|
+
Getting your data is as simple as this:
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from schoolapp_api import SchoolAppClient
|
|
24
|
+
|
|
25
|
+
# Initialize and log in
|
|
26
|
+
client = SchoolAppClient()
|
|
27
|
+
if client.login("your.email@example.com", "password"):
|
|
28
|
+
|
|
29
|
+
# Get your basic info
|
|
30
|
+
profile = client.get_profile()
|
|
31
|
+
print(f"Hello, {profile['basic_info']['full_name']}!")
|
|
32
|
+
|
|
33
|
+
# Fetch your current semester grades
|
|
34
|
+
grades = client.get_current_elem_note()
|
|
35
|
+
for item in grades:
|
|
36
|
+
print(f"{item.CodeElem}: {item.Moy}")
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Project Layout
|
|
40
|
+
The library is organized into several specific managers, so you always know where to find what you need:
|
|
41
|
+
|
|
42
|
+
- **`grades`**: Handle module marks, element notes, and academic year results.
|
|
43
|
+
- **`attendance`**: Track your absences and see any sanctions.
|
|
44
|
+
- **`profile`**: Access your personal data and administrative files.
|
|
45
|
+
- **`courses`**: Browse the study plan and available modules.
|
|
46
|
+
|
|
47
|
+
For the full details on every class and function, head over to the [**/docs**](./docs/README.md) folder.
|
|
48
|
+
|
|
49
|
+
## Contributions
|
|
50
|
+
Found a bug or have an idea for a new feature? Feel free to open an issue or submit a pull request. Any help making this library better for everyone is appreciated!
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: schoolapp-api
|
|
3
|
+
Version: 2.1.1
|
|
4
|
+
Summary: Professional client for interacting with the School App API
|
|
5
|
+
Author: Aferiad Kamal
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.7
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: beautifulsoup4>=4.9.0
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# SchoolApp API
|
|
14
|
+
|
|
15
|
+
A Python library designed to make interacting with the SchoolApp platform a lot less painful. Instead of wrestling with session cookies and manual HTML scraping, this library gives you a clean, object-oriented way to access your grades, attendance, and profile data.
|
|
16
|
+
|
|
17
|
+
## Why This Exists
|
|
18
|
+
Browsing the SchoolApp web interface manually for updates is slow. If you want to build a custom dashboard, a grade tracker, or a notification bot, you need a reliable way to get that data programmatically. This library takes care of:
|
|
19
|
+
- **Authentication**: Solid session management with automatic CSRF token handling.
|
|
20
|
+
- **Data Cleanup**: Converts messy HTML tables into structured Python objects.
|
|
21
|
+
- **Smart Logic**: Handles nested modules, element-level statistics, and transcript parsing out of the box.
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### Installation
|
|
26
|
+
You can install the library locally using:
|
|
27
|
+
```bash
|
|
28
|
+
pip install schoolapp-api
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Basic Usage
|
|
32
|
+
Getting your data is as simple as this:
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from schoolapp_api import SchoolAppClient
|
|
36
|
+
|
|
37
|
+
# Initialize and log in
|
|
38
|
+
client = SchoolAppClient()
|
|
39
|
+
if client.login("your.email@example.com", "password"):
|
|
40
|
+
|
|
41
|
+
# Get your basic info
|
|
42
|
+
profile = client.get_profile()
|
|
43
|
+
print(f"Hello, {profile['basic_info']['full_name']}!")
|
|
44
|
+
|
|
45
|
+
# Fetch your current semester grades
|
|
46
|
+
grades = client.get_current_elem_note()
|
|
47
|
+
for item in grades:
|
|
48
|
+
print(f"{item.CodeElem}: {item.Moy}")
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Project Layout
|
|
52
|
+
The library is organized into several specific managers, so you always know where to find what you need:
|
|
53
|
+
|
|
54
|
+
- **`grades`**: Handle module marks, element notes, and academic year results.
|
|
55
|
+
- **`attendance`**: Track your absences and see any sanctions.
|
|
56
|
+
- **`profile`**: Access your personal data and administrative files.
|
|
57
|
+
- **`courses`**: Browse the study plan and available modules.
|
|
58
|
+
|
|
59
|
+
For the full details on every class and function, head over to the [**/docs**](./docs/README.md) folder.
|
|
60
|
+
|
|
61
|
+
## Contributions
|
|
62
|
+
Found a bug or have an idea for a new feature? Feel free to open an issue or submit a pull request. Any help making this library better for everyone is appreciated!
|
schoolapp_api-2.0.0/PKG-INFO
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: schoolapp-api
|
|
3
|
-
Version: 2.0.0
|
|
4
|
-
Summary: Professional client for interacting with the School App API
|
|
5
|
-
Author: Aferiad Kamal
|
|
6
|
-
License: MIT
|
|
7
|
-
Requires-Python: >=3.7
|
|
8
|
-
Description-Content-Type: text/markdown
|
|
9
|
-
License-File: LICENSE
|
|
10
|
-
Requires-Dist: beautifulsoup4>=4.9.0
|
|
11
|
-
Dynamic: license-file
|
|
12
|
-
|
|
13
|
-
# School App Client - Refactored
|
|
14
|
-
|
|
15
|
-
Clean, organized structure for the School App client with proper separation of concerns.
|
|
16
|
-
|
|
17
|
-
## 📁 Project Structure
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
├── http_client.py # Base HTTP client (GET/POST requests, cookie management)
|
|
21
|
-
├── auth.py # Authentication & CSRF token handling
|
|
22
|
-
├── school_app_client.py # Main API client (combines everything)
|
|
23
|
-
└── example_usage.py # Usage example
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## 🎯 Architecture
|
|
27
|
-
|
|
28
|
-
### 1. **http_client.py** - HTTP Layer
|
|
29
|
-
- Handles raw HTTP operations (GET/POST)
|
|
30
|
-
- Cookie jar and session management
|
|
31
|
-
- Common headers configuration
|
|
32
|
-
- Error handling for network requests
|
|
33
|
-
|
|
34
|
-
### 2. **auth.py** - Authentication Layer
|
|
35
|
-
- Login flow management
|
|
36
|
-
- CSRF token extraction and updates
|
|
37
|
-
- Session state tracking
|
|
38
|
-
- Decoupled from HTTP implementation
|
|
39
|
-
|
|
40
|
-
### 3. **school_app_client.py** - API Layer
|
|
41
|
-
- High-level API methods (`get_filieres()`, `get_modules()`)
|
|
42
|
-
- Orchestrates HTTP client and auth manager
|
|
43
|
-
- Business logic for School App endpoints
|
|
44
|
-
|
|
45
|
-
## 🚀 Usage
|
|
46
|
-
|
|
47
|
-
```python
|
|
48
|
-
from school_app_client import SchoolAppClient
|
|
49
|
-
|
|
50
|
-
# Initialize
|
|
51
|
-
client = SchoolAppClient()
|
|
52
|
-
|
|
53
|
-
# Login
|
|
54
|
-
client.login("your.email@example.com", "password")
|
|
55
|
-
|
|
56
|
-
# Fetch data
|
|
57
|
-
filieres = client.get_filieres()
|
|
58
|
-
modules = client.get_modules(niveau="1A", filiere="API-MPT", semestre="S1")
|
|
59
|
-
|
|
60
|
-
# If you encounter 403 errors, force CSRF refresh
|
|
61
|
-
modules = client.get_modules(
|
|
62
|
-
niveau="1A",
|
|
63
|
-
filiere="API-MPT",
|
|
64
|
-
semestre="S1",
|
|
65
|
-
refresh_csrf=True
|
|
66
|
-
)
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## ✨ Benefits of This Structure
|
|
70
|
-
|
|
71
|
-
- **Separation of Concerns**: Each module has a single responsibility
|
|
72
|
-
- **Testability**: Easy to mock and unit test each layer
|
|
73
|
-
- **Maintainability**: Changes in one layer don't affect others
|
|
74
|
-
- **Extensibility**: Easy to add new endpoints or authentication methods
|
|
75
|
-
- **Reusability**: HTTP client can be used for other projects
|
|
76
|
-
|
|
77
|
-
## 🎯 Key Features
|
|
78
|
-
|
|
79
|
-
- **Automatic CSRF Management**: CSRF tokens are automatically refreshed from page content
|
|
80
|
-
- **Session Persistence**: Cookie-based session management keeps you logged in
|
|
81
|
-
- **Smart Error Handling**: Detects 403 errors and suggests CSRF refresh
|
|
82
|
-
- **Optional CSRF Force Refresh**: Use `refresh_csrf=True` to force token refresh before requests
|
|
83
|
-
- **Clean Separation**: HTTP, Auth, and API layers are completely decoupled
|
|
84
|
-
|
|
85
|
-
## 🔧 Potential Extensions
|
|
86
|
-
|
|
87
|
-
- Add logging module
|
|
88
|
-
- Implement response parsers (HTML → structured data)
|
|
89
|
-
- Add caching layer
|
|
90
|
-
- Create async version using `aiohttp`
|
|
91
|
-
- Add retry logic with exponential backoff
|
schoolapp_api-2.0.0/README.md
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# School App Client - Refactored
|
|
2
|
-
|
|
3
|
-
Clean, organized structure for the School App client with proper separation of concerns.
|
|
4
|
-
|
|
5
|
-
## 📁 Project Structure
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
├── http_client.py # Base HTTP client (GET/POST requests, cookie management)
|
|
9
|
-
├── auth.py # Authentication & CSRF token handling
|
|
10
|
-
├── school_app_client.py # Main API client (combines everything)
|
|
11
|
-
└── example_usage.py # Usage example
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## 🎯 Architecture
|
|
15
|
-
|
|
16
|
-
### 1. **http_client.py** - HTTP Layer
|
|
17
|
-
- Handles raw HTTP operations (GET/POST)
|
|
18
|
-
- Cookie jar and session management
|
|
19
|
-
- Common headers configuration
|
|
20
|
-
- Error handling for network requests
|
|
21
|
-
|
|
22
|
-
### 2. **auth.py** - Authentication Layer
|
|
23
|
-
- Login flow management
|
|
24
|
-
- CSRF token extraction and updates
|
|
25
|
-
- Session state tracking
|
|
26
|
-
- Decoupled from HTTP implementation
|
|
27
|
-
|
|
28
|
-
### 3. **school_app_client.py** - API Layer
|
|
29
|
-
- High-level API methods (`get_filieres()`, `get_modules()`)
|
|
30
|
-
- Orchestrates HTTP client and auth manager
|
|
31
|
-
- Business logic for School App endpoints
|
|
32
|
-
|
|
33
|
-
## 🚀 Usage
|
|
34
|
-
|
|
35
|
-
```python
|
|
36
|
-
from school_app_client import SchoolAppClient
|
|
37
|
-
|
|
38
|
-
# Initialize
|
|
39
|
-
client = SchoolAppClient()
|
|
40
|
-
|
|
41
|
-
# Login
|
|
42
|
-
client.login("your.email@example.com", "password")
|
|
43
|
-
|
|
44
|
-
# Fetch data
|
|
45
|
-
filieres = client.get_filieres()
|
|
46
|
-
modules = client.get_modules(niveau="1A", filiere="API-MPT", semestre="S1")
|
|
47
|
-
|
|
48
|
-
# If you encounter 403 errors, force CSRF refresh
|
|
49
|
-
modules = client.get_modules(
|
|
50
|
-
niveau="1A",
|
|
51
|
-
filiere="API-MPT",
|
|
52
|
-
semestre="S1",
|
|
53
|
-
refresh_csrf=True
|
|
54
|
-
)
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## ✨ Benefits of This Structure
|
|
58
|
-
|
|
59
|
-
- **Separation of Concerns**: Each module has a single responsibility
|
|
60
|
-
- **Testability**: Easy to mock and unit test each layer
|
|
61
|
-
- **Maintainability**: Changes in one layer don't affect others
|
|
62
|
-
- **Extensibility**: Easy to add new endpoints or authentication methods
|
|
63
|
-
- **Reusability**: HTTP client can be used for other projects
|
|
64
|
-
|
|
65
|
-
## 🎯 Key Features
|
|
66
|
-
|
|
67
|
-
- **Automatic CSRF Management**: CSRF tokens are automatically refreshed from page content
|
|
68
|
-
- **Session Persistence**: Cookie-based session management keeps you logged in
|
|
69
|
-
- **Smart Error Handling**: Detects 403 errors and suggests CSRF refresh
|
|
70
|
-
- **Optional CSRF Force Refresh**: Use `refresh_csrf=True` to force token refresh before requests
|
|
71
|
-
- **Clean Separation**: HTTP, Auth, and API layers are completely decoupled
|
|
72
|
-
|
|
73
|
-
## 🔧 Potential Extensions
|
|
74
|
-
|
|
75
|
-
- Add logging module
|
|
76
|
-
- Implement response parsers (HTML → structured data)
|
|
77
|
-
- Add caching layer
|
|
78
|
-
- Create async version using `aiohttp`
|
|
79
|
-
- Add retry logic with exponential backoff
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: schoolapp-api
|
|
3
|
-
Version: 2.0.0
|
|
4
|
-
Summary: Professional client for interacting with the School App API
|
|
5
|
-
Author: Aferiad Kamal
|
|
6
|
-
License: MIT
|
|
7
|
-
Requires-Python: >=3.7
|
|
8
|
-
Description-Content-Type: text/markdown
|
|
9
|
-
License-File: LICENSE
|
|
10
|
-
Requires-Dist: beautifulsoup4>=4.9.0
|
|
11
|
-
Dynamic: license-file
|
|
12
|
-
|
|
13
|
-
# School App Client - Refactored
|
|
14
|
-
|
|
15
|
-
Clean, organized structure for the School App client with proper separation of concerns.
|
|
16
|
-
|
|
17
|
-
## 📁 Project Structure
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
├── http_client.py # Base HTTP client (GET/POST requests, cookie management)
|
|
21
|
-
├── auth.py # Authentication & CSRF token handling
|
|
22
|
-
├── school_app_client.py # Main API client (combines everything)
|
|
23
|
-
└── example_usage.py # Usage example
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## 🎯 Architecture
|
|
27
|
-
|
|
28
|
-
### 1. **http_client.py** - HTTP Layer
|
|
29
|
-
- Handles raw HTTP operations (GET/POST)
|
|
30
|
-
- Cookie jar and session management
|
|
31
|
-
- Common headers configuration
|
|
32
|
-
- Error handling for network requests
|
|
33
|
-
|
|
34
|
-
### 2. **auth.py** - Authentication Layer
|
|
35
|
-
- Login flow management
|
|
36
|
-
- CSRF token extraction and updates
|
|
37
|
-
- Session state tracking
|
|
38
|
-
- Decoupled from HTTP implementation
|
|
39
|
-
|
|
40
|
-
### 3. **school_app_client.py** - API Layer
|
|
41
|
-
- High-level API methods (`get_filieres()`, `get_modules()`)
|
|
42
|
-
- Orchestrates HTTP client and auth manager
|
|
43
|
-
- Business logic for School App endpoints
|
|
44
|
-
|
|
45
|
-
## 🚀 Usage
|
|
46
|
-
|
|
47
|
-
```python
|
|
48
|
-
from school_app_client import SchoolAppClient
|
|
49
|
-
|
|
50
|
-
# Initialize
|
|
51
|
-
client = SchoolAppClient()
|
|
52
|
-
|
|
53
|
-
# Login
|
|
54
|
-
client.login("your.email@example.com", "password")
|
|
55
|
-
|
|
56
|
-
# Fetch data
|
|
57
|
-
filieres = client.get_filieres()
|
|
58
|
-
modules = client.get_modules(niveau="1A", filiere="API-MPT", semestre="S1")
|
|
59
|
-
|
|
60
|
-
# If you encounter 403 errors, force CSRF refresh
|
|
61
|
-
modules = client.get_modules(
|
|
62
|
-
niveau="1A",
|
|
63
|
-
filiere="API-MPT",
|
|
64
|
-
semestre="S1",
|
|
65
|
-
refresh_csrf=True
|
|
66
|
-
)
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## ✨ Benefits of This Structure
|
|
70
|
-
|
|
71
|
-
- **Separation of Concerns**: Each module has a single responsibility
|
|
72
|
-
- **Testability**: Easy to mock and unit test each layer
|
|
73
|
-
- **Maintainability**: Changes in one layer don't affect others
|
|
74
|
-
- **Extensibility**: Easy to add new endpoints or authentication methods
|
|
75
|
-
- **Reusability**: HTTP client can be used for other projects
|
|
76
|
-
|
|
77
|
-
## 🎯 Key Features
|
|
78
|
-
|
|
79
|
-
- **Automatic CSRF Management**: CSRF tokens are automatically refreshed from page content
|
|
80
|
-
- **Session Persistence**: Cookie-based session management keeps you logged in
|
|
81
|
-
- **Smart Error Handling**: Detects 403 errors and suggests CSRF refresh
|
|
82
|
-
- **Optional CSRF Force Refresh**: Use `refresh_csrf=True` to force token refresh before requests
|
|
83
|
-
- **Clean Separation**: HTTP, Auth, and API layers are completely decoupled
|
|
84
|
-
|
|
85
|
-
## 🔧 Potential Extensions
|
|
86
|
-
|
|
87
|
-
- Add logging module
|
|
88
|
-
- Implement response parsers (HTML → structured data)
|
|
89
|
-
- Add caching layer
|
|
90
|
-
- Create async version using `aiohttp`
|
|
91
|
-
- Add retry logic with exponential backoff
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|