usos-api 0.2.0__tar.gz → 0.3.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.
- {usos_api-0.2.0 → usos_api-0.3.0}/PKG-INFO +4 -2
- {usos_api-0.2.0 → usos_api-0.3.0}/pyproject.toml +2 -2
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/client.py +16 -7
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/models/__init__.py +14 -0
- usos_api-0.3.0/usos_api/models/registration.py +73 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/services/__init__.py +2 -0
- usos_api-0.3.0/usos_api/services/registrations.py +112 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/README.md +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/__init__.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/auth.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/connection.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/exceptions.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/helper.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/logger.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/models/api_documentation.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/models/consumer.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/models/course.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/models/grade.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/models/group.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/models/lang_dict.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/models/programme.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/models/term.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/models/user.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/services/api_documentation.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/services/api_server.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/services/courses.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/services/grades.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/services/groups.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/services/terms.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/services/users.py +0 -0
- {usos_api-0.2.0 → usos_api-0.3.0}/usos_api/utils/__init__.py +0 -0
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: usos-api
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Asynchronous USOS API for Python
|
|
5
5
|
Home-page: https://github.com/Antoni-Czaplicki/usos-api
|
|
6
6
|
Author: Antoni-Czaplicki
|
|
7
7
|
Author-email: 56671347+Antoni-Czaplicki@users.noreply.github.com
|
|
8
|
-
Requires-Python: >=3.
|
|
8
|
+
Requires-Python: >=3.10,<4.0
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
11
13
|
Requires-Dist: aiohttp (>=3.9.5,<4.0.0)
|
|
12
14
|
Requires-Dist: oauthlib (>=3.2.2,<4.0.0)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "usos-api"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.3.0"
|
|
4
4
|
description = "Asynchronous USOS API for Python"
|
|
5
5
|
authors = ["Antoni-Czaplicki <56671347+Antoni-Czaplicki@users.noreply.github.com>"]
|
|
6
6
|
readme = "README.md"
|
|
@@ -9,7 +9,7 @@ repository = "https://github.com/Antoni-Czaplicki/usos-api"
|
|
|
9
9
|
documentation = "https://usos-api.readthedocs.io"
|
|
10
10
|
|
|
11
11
|
[tool.poetry.dependencies]
|
|
12
|
-
python = "^3.
|
|
12
|
+
python = "^3.10"
|
|
13
13
|
aiohttp = "^3.9.5"
|
|
14
14
|
pydantic = "^2.8.2"
|
|
15
15
|
oauthlib = "^3.2.2"
|
|
@@ -3,13 +3,16 @@ import json
|
|
|
3
3
|
from .connection import USOSAPIConnection
|
|
4
4
|
from .helper import APIHelper
|
|
5
5
|
from .logger import get_logger
|
|
6
|
-
from .services import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
from .services import (
|
|
7
|
+
APIDocumentationService,
|
|
8
|
+
APIServerService,
|
|
9
|
+
CourseService,
|
|
10
|
+
GradeService,
|
|
11
|
+
GroupService,
|
|
12
|
+
RegistrationService,
|
|
13
|
+
TermService,
|
|
14
|
+
UserService,
|
|
15
|
+
)
|
|
13
16
|
|
|
14
17
|
_LOGGER = get_logger("USOSClient")
|
|
15
18
|
|
|
@@ -21,6 +24,11 @@ class USOSClient:
|
|
|
21
24
|
:var UserService user_service: The user service.
|
|
22
25
|
:var GroupService group_service: The group service.
|
|
23
26
|
:var APIServerService api_server_service: The API server service.
|
|
27
|
+
:var APIDocumentationService api_documentation_service: The API documentation service.
|
|
28
|
+
:var CourseService course_service: The course service.
|
|
29
|
+
:var TermService term_service: The term service.
|
|
30
|
+
:var GradeService grade_service: The grade service.
|
|
31
|
+
:var RegistrationService registration_service: The registration service.
|
|
24
32
|
|
|
25
33
|
:ivar USOSAPIConnection connection: The connection to the USOS API, used for making requests.
|
|
26
34
|
"""
|
|
@@ -45,6 +53,7 @@ class USOSClient:
|
|
|
45
53
|
self.grade_service = GradeService(self.connection)
|
|
46
54
|
self.api_server_service = APIServerService(self.connection)
|
|
47
55
|
self.api_documentation_service = APIDocumentationService(self.connection)
|
|
56
|
+
self.registration_service = RegistrationService(self.connection)
|
|
48
57
|
|
|
49
58
|
self.helper = APIHelper(self)
|
|
50
59
|
|
|
@@ -20,6 +20,14 @@ from .grade import Grade
|
|
|
20
20
|
from .group import Group
|
|
21
21
|
from .lang_dict import LangDict
|
|
22
22
|
from .programme import Programme, StudentProgramme
|
|
23
|
+
from .registration import (
|
|
24
|
+
CoursesCart,
|
|
25
|
+
Link,
|
|
26
|
+
Registration,
|
|
27
|
+
RegistrationCourse,
|
|
28
|
+
RegistrationRound,
|
|
29
|
+
Stage,
|
|
30
|
+
)
|
|
23
31
|
from .term import Term
|
|
24
32
|
from .user import (
|
|
25
33
|
EmailAccess,
|
|
@@ -75,4 +83,10 @@ __all__ = [
|
|
|
75
83
|
"APIMethodIndexItem",
|
|
76
84
|
"APIModuleInfo",
|
|
77
85
|
"ScopeInfo",
|
|
86
|
+
"Registration",
|
|
87
|
+
"RegistrationRound",
|
|
88
|
+
"RegistrationCourse",
|
|
89
|
+
"Stage",
|
|
90
|
+
"Link",
|
|
91
|
+
"CoursesCart",
|
|
78
92
|
]
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel
|
|
4
|
+
|
|
5
|
+
from usos_api.models import LangDict
|
|
6
|
+
from usos_api.models.course import Course
|
|
7
|
+
from usos_api.models.programme import Programme
|
|
8
|
+
from usos_api.models.term import Term
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Registration(BaseModel):
|
|
12
|
+
id: str | None = None
|
|
13
|
+
description: LangDict | None = None
|
|
14
|
+
message: LangDict | None = None
|
|
15
|
+
type: str | None = None
|
|
16
|
+
status: str | None = None
|
|
17
|
+
faculty: str | None = None
|
|
18
|
+
is_linkage_required: bool | None = None
|
|
19
|
+
www_instance: str | None = None
|
|
20
|
+
|
|
21
|
+
rounds: list["RegistrationRound"] | None = None
|
|
22
|
+
related_courses: list["RegistrationCourse"] | None = None
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class RegistrationRound(BaseModel):
|
|
26
|
+
id: str | None = None
|
|
27
|
+
name: LangDict | None = None
|
|
28
|
+
status: str | None = None
|
|
29
|
+
registration_mode: str | None = None
|
|
30
|
+
start_date: datetime | None = None
|
|
31
|
+
end_date: datetime | None = None
|
|
32
|
+
selection_limit: int | None = None
|
|
33
|
+
is_dedicated: bool | None = None
|
|
34
|
+
is_overflow_allowed: bool | None = None
|
|
35
|
+
is_exchange: bool | None = None
|
|
36
|
+
is_only_entitled: bool | None = None
|
|
37
|
+
rank_code: str | None = None
|
|
38
|
+
ranking: dict | None = None
|
|
39
|
+
is_processed: bool | None = None
|
|
40
|
+
registration: Registration | None = None
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class RegistrationCourse(BaseModel):
|
|
44
|
+
registration_id: str | None = None
|
|
45
|
+
course_id: str | None = None
|
|
46
|
+
term_id: str | None = None
|
|
47
|
+
status: str | None = None
|
|
48
|
+
limits: dict | None = None
|
|
49
|
+
www_instance: str | None = None
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class Stage(BaseModel):
|
|
53
|
+
id: str | None = None
|
|
54
|
+
name: LangDict | None = None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class Link(BaseModel):
|
|
58
|
+
programme: Programme | None = None
|
|
59
|
+
stage: Stage | None = None
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class CoursesCart(BaseModel):
|
|
63
|
+
links: list[Link] | None = None
|
|
64
|
+
course: Course | None = None
|
|
65
|
+
term: Term | None = None
|
|
66
|
+
user_registration_status: str | None = None
|
|
67
|
+
is_registration_valid: bool | None = None
|
|
68
|
+
choice_number: int | None = None
|
|
69
|
+
limits: int | None = None
|
|
70
|
+
is_linkage_required: bool | None = None
|
|
71
|
+
registrations_count: int | None = None
|
|
72
|
+
registration_status: str | None = None
|
|
73
|
+
active_registration_round_id: str | None = None
|
|
@@ -3,6 +3,7 @@ from .api_server import APIServerService
|
|
|
3
3
|
from .courses import CourseService
|
|
4
4
|
from .grades import GradeService
|
|
5
5
|
from .groups import GroupService
|
|
6
|
+
from .registrations import RegistrationService
|
|
6
7
|
from .terms import TermService
|
|
7
8
|
from .users import UserService
|
|
8
9
|
|
|
@@ -14,4 +15,5 @@ __all__ = [
|
|
|
14
15
|
"GroupService",
|
|
15
16
|
"TermService",
|
|
16
17
|
"UserService",
|
|
18
|
+
"RegistrationService",
|
|
17
19
|
]
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
from ..connection import USOSAPIConnection
|
|
2
|
+
from ..models import CoursesCart, Registration
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class RegistrationService:
|
|
6
|
+
"""
|
|
7
|
+
A service for registration-related operations.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
def __init__(self, connection: USOSAPIConnection):
|
|
11
|
+
"""
|
|
12
|
+
Initialize the registration service.
|
|
13
|
+
|
|
14
|
+
:param connection: The connection to use.
|
|
15
|
+
"""
|
|
16
|
+
self.connection = connection
|
|
17
|
+
|
|
18
|
+
async def get_user_registrations(
|
|
19
|
+
self, active_only: bool = True, fields: list[str] = None
|
|
20
|
+
) -> list[Registration]:
|
|
21
|
+
"""
|
|
22
|
+
Get user registrations.
|
|
23
|
+
|
|
24
|
+
:param active_only: Whether to return only active registrations.
|
|
25
|
+
:param fields: Selector of result fields you are interested in (optional, default is specified fields).
|
|
26
|
+
:return: The user registrations.
|
|
27
|
+
"""
|
|
28
|
+
fields = "|".join(fields) if fields else None
|
|
29
|
+
|
|
30
|
+
response = await self.connection.post(
|
|
31
|
+
"services/registrations/user_registrations",
|
|
32
|
+
fields=fields,
|
|
33
|
+
active_only=active_only,
|
|
34
|
+
)
|
|
35
|
+
return [Registration(**registration) for registration in response]
|
|
36
|
+
|
|
37
|
+
async def get_registration(
|
|
38
|
+
self, registration_id: str, fields: list[str] = None
|
|
39
|
+
) -> Registration:
|
|
40
|
+
"""
|
|
41
|
+
Get a registration.
|
|
42
|
+
|
|
43
|
+
:param registration_id: The ID of the registration.
|
|
44
|
+
:param fields: Selector of result fields you are interested in (optional, default is specified fields).
|
|
45
|
+
:return: The registration.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
fields = "|".join(fields) if fields else None
|
|
49
|
+
|
|
50
|
+
response = await self.connection.post(
|
|
51
|
+
"services/registrations/registration", id=registration_id, fields=fields
|
|
52
|
+
)
|
|
53
|
+
return Registration(**response)
|
|
54
|
+
|
|
55
|
+
async def register_to_course(
|
|
56
|
+
self,
|
|
57
|
+
round_id: str,
|
|
58
|
+
course_id: str,
|
|
59
|
+
term_id: str,
|
|
60
|
+
user_programme_id: str = None,
|
|
61
|
+
user_stage_id: str = None,
|
|
62
|
+
) -> dict:
|
|
63
|
+
"""
|
|
64
|
+
Register to a course.
|
|
65
|
+
|
|
66
|
+
:param round_id: Registration round ID.
|
|
67
|
+
:param course_id: Course code.
|
|
68
|
+
:param term_id: Cycle code.
|
|
69
|
+
:param user_programme_id: User program ID (optional).
|
|
70
|
+
:param user_stage_id: User stage ID (optional).
|
|
71
|
+
:return: Empty dict on success.
|
|
72
|
+
"""
|
|
73
|
+
data = {
|
|
74
|
+
"round_id": round_id,
|
|
75
|
+
"course_id": course_id,
|
|
76
|
+
"term_id": term_id,
|
|
77
|
+
}
|
|
78
|
+
if user_programme_id:
|
|
79
|
+
data["user_programme_id"] = user_programme_id
|
|
80
|
+
if user_stage_id:
|
|
81
|
+
data["user_stage_id"] = user_stage_id
|
|
82
|
+
|
|
83
|
+
response = await self.connection.post("services/registrations/register", **data)
|
|
84
|
+
return response
|
|
85
|
+
|
|
86
|
+
async def get_courses_cart(self, fields: list[str] = None) -> list[CoursesCart]:
|
|
87
|
+
"""
|
|
88
|
+
Get user courses cart with registrations information.
|
|
89
|
+
|
|
90
|
+
:param fields: Selector of result fields you are interested in (optional, default is specified fields).
|
|
91
|
+
:return: A CoursesCartResponse object.
|
|
92
|
+
"""
|
|
93
|
+
if fields is None:
|
|
94
|
+
fields = [
|
|
95
|
+
"links",
|
|
96
|
+
"course",
|
|
97
|
+
"term",
|
|
98
|
+
"user_registration_status",
|
|
99
|
+
"is_registration_valid",
|
|
100
|
+
"choice_number",
|
|
101
|
+
"limits",
|
|
102
|
+
"is_linkage_required",
|
|
103
|
+
"registrations_count",
|
|
104
|
+
"registration_status",
|
|
105
|
+
"active_registration_round_id",
|
|
106
|
+
]
|
|
107
|
+
fields = "|".join(fields)
|
|
108
|
+
|
|
109
|
+
response = await self.connection.post(
|
|
110
|
+
"services/registrations/courses_cart", fields=fields
|
|
111
|
+
)
|
|
112
|
+
return [CoursesCart(**course) for course in response]
|
|
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
|