schoolmospy 0.2.2__py3-none-any.whl → 0.2.3__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.
@@ -20,6 +20,7 @@ class BasicClient:
20
20
  self.profile_id = profile_id
21
21
  self.profile_type = profile_type
22
22
  self.timeout = timeout
23
+ self.extra_headers: dict[str, str] = {}
23
24
 
24
25
  @property
25
26
  def headers(self) -> dict[str, str]:
@@ -35,7 +36,8 @@ class BasicClient:
35
36
  headers["Profile-Id"] = str(self.profile_id)
36
37
  if self.profile_type:
37
38
  headers["Profile-Type"] = self.profile_type
38
- headers["X-Mes-Role"] = self.profile_type
39
+ if self.extra_headers:
40
+ headers.update(self.extra_headers)
39
41
  return headers
40
42
 
41
43
  async def _handle_response(
@@ -66,7 +68,10 @@ class BasicClient:
66
68
  **kwargs: Any,
67
69
  ) -> Any:
68
70
  url = f"{self.base_url}/{endpoint.lstrip('/')}"
69
- async with httpx.AsyncClient(headers=self.headers, timeout=self.timeout) as client:
71
+ headers = self.headers
72
+ if "headers" in kwargs:
73
+ headers = {**headers, **kwargs.pop("headers")}
74
+ async with httpx.AsyncClient(headers=headers, timeout=self.timeout) as client:
70
75
  try:
71
76
  resp = await client.get(url, **kwargs)
72
77
  except httpx.RequestError as e:
@@ -81,7 +86,10 @@ class BasicClient:
81
86
  **kwargs: Any,
82
87
  ) -> Any:
83
88
  url = f"{self.base_url}/{endpoint.lstrip('/')}"
84
- async with httpx.AsyncClient(headers=self.headers, timeout=self.timeout) as client:
89
+ headers = self.headers
90
+ if "headers" in kwargs:
91
+ headers = {**headers, **kwargs.pop("headers")}
92
+ async with httpx.AsyncClient(headers=headers, timeout=self.timeout) as client:
85
93
  try:
86
94
  resp = await client.post(url, json=data, **kwargs)
87
95
  except httpx.RequestError as e:
@@ -53,10 +53,11 @@ class EventClient:
53
53
  "/api/eventcalendar/v1/api/events",
54
54
  Events,
55
55
  params={
56
- "from": from_date.strftime("%Y-%m-%d"),
57
- "to": to_date.strftime("%Y-%m-%d"),
56
+ "begin_date": from_date.strftime("%Y-%m-%d"),
57
+ "end_date": to_date.strftime("%Y-%m-%d"),
58
58
  "person_ids": contingent_guid,
59
59
  "expand": "marks,homework,absence_reason_id,health_status,nonattendance_reason_id",
60
60
  "source_types": "PLAN,AE,EC,EVENTS,AFISHA,ORGANIZER,OLYMPIAD,PROF",
61
61
  },
62
+ headers={"X-Mes-Role": "student"},
62
63
  )
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: schoolmospy
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: A lightweight async Python wrapper for school.mos.ru APIs
5
5
  License: GPL-3.0-only
6
6
  License-File: LICENSE
@@ -67,19 +67,19 @@ async def main():
67
67
  print(f"Name: {profile.name}")
68
68
 
69
69
  # Get marks
70
- marks = await client.marks.get_marks(
70
+ marks = await client.marks.get(
71
71
  from_date="2024-01-01",
72
72
  to_date="2024-12-31"
73
73
  )
74
74
 
75
75
  # Get homeworks
76
- homeworks = await client.homeworks.get_homeworks(
76
+ homeworks = await client.homeworks.get(
77
77
  from_date="2024-01-01",
78
78
  to_date="2024-12-31"
79
79
  )
80
80
 
81
81
  # Get events/schedule
82
- events = await client.events.get_events(
82
+ events = await client.events.get(
83
83
  from_date="2024-01-01",
84
84
  to_date="2024-12-31"
85
85
  )
@@ -103,6 +103,3 @@ This project is licensed under the GPL-3.0 License. See the [LICENSE](LICENSE) f
103
103
  Ivan Kriventsev - [xd2dd@icloud.com](mailto:xd2dd@icloud.com)
104
104
 
105
105
  ---
106
-
107
- ⭐ If you like this project, please give it a star on GitHub!
108
-
@@ -1,10 +1,11 @@
1
1
  schoolmospy/__init__.py,sha256=veFE2dpRaFNhv2GhCGv9cwU341HKt2SoXIGEn3BWGZA,188
2
2
  schoolmospy/__main__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- schoolmospy/core/basic_client.py,sha256=jXe94Q0ioWFHBYYeiE7T217QMYpVHzHDXW9AMpvNxsc,3103
4
- schoolmospy/core/events_client.py,sha256=MCtXj8aR8pEPh_kYtrzVYWZcDBPoHBUyxi2qNIVwaNk,2134
3
+ schoolmospy/core/basic_client.py,sha256=WeRiIqHzQf4RjJRf9Wa_SvApoNQ7MxxtyQ1jYSYkRCo,3409
4
+ schoolmospy/core/events_client.py,sha256=mZwC5yhf9On4Lc4aDiVezD0ppg6RbtGO6OmOIH1Srec,2193
5
5
  schoolmospy/core/homeworks_client.py,sha256=ycXPs5Za1opuoz0Y2A63ZLgT2K8M0SeE_45Wdy3jm6U,1825
6
6
  schoolmospy/core/marks_client.py,sha256=ukBB-eYs9rlZb2otxNZu7ak1u8s4M16NtSeuIgAnocA,1554
7
7
  schoolmospy/core/student_client.py,sha256=MfW24G7oDzGN643GDUV-Kye_BJmHgSKLa-tRFnXix4k,1343
8
+ schoolmospy/models/enums/usertype.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
9
  schoolmospy/models/events.py,sha256=NCqfqjMIMEKZJGf0gWF1tnJfCAg3ET-SJG6wRKTJG6c,867
9
10
  schoolmospy/models/homeworks.py,sha256=oiHHe2jTifc_5oIWKopymcsL4MBZQgoPb3c9q3hPl7E,976
10
11
  schoolmospy/models/marks.py,sha256=Vd3c-7c8SNul4oPcrbK2T-4apSE4kl97GuwaHH5gNuA,754
@@ -12,7 +13,7 @@ schoolmospy/models/profile.py,sha256=vphn7so3X0gxqkmrwDzk6i5KP1U2ejOjeqKyVPLlFJo
12
13
  schoolmospy/models/userinfo.py,sha256=G7uphP0CdviQxpdjGdv1xpCA84EzkID83F6TI4W57Wo,984
13
14
  schoolmospy/utils/exceptions.py,sha256=XemBxgi_7NElaO7W-_6xLZHmAU9NIAeNH2yZqAzgHtQ,570
14
15
  schoolmospy/utils/logging.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- schoolmospy-0.2.2.dist-info/METADATA,sha256=8D26pY9mAJij3SVnFA9YRMDeSj7aNzA_jENP3T0w_Kc,2953
16
- schoolmospy-0.2.2.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
17
- schoolmospy-0.2.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
18
- schoolmospy-0.2.2.dist-info/RECORD,,
16
+ schoolmospy-0.2.3.dist-info/METADATA,sha256=2iyF05f_TF2wpYK7Qax3-Z8FnU-SQYXO06KXPpjdaf8,2865
17
+ schoolmospy-0.2.3.dist-info/WHEEL,sha256=kJCRJT_g0adfAJzTx2GUMmS80rTJIVHRCfG0DQgLq3o,88
18
+ schoolmospy-0.2.3.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
19
+ schoolmospy-0.2.3.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.2.1
2
+ Generator: poetry-core 2.3.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any