schoolmospy 0.2.2__tar.gz → 0.2.3__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.
@@ -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
-
@@ -44,19 +44,19 @@ async def main():
44
44
  print(f"Name: {profile.name}")
45
45
 
46
46
  # Get marks
47
- marks = await client.marks.get_marks(
47
+ marks = await client.marks.get(
48
48
  from_date="2024-01-01",
49
49
  to_date="2024-12-31"
50
50
  )
51
51
 
52
52
  # Get homeworks
53
- homeworks = await client.homeworks.get_homeworks(
53
+ homeworks = await client.homeworks.get(
54
54
  from_date="2024-01-01",
55
55
  to_date="2024-12-31"
56
56
  )
57
57
 
58
58
  # Get events/schedule
59
- events = await client.events.get_events(
59
+ events = await client.events.get(
60
60
  from_date="2024-01-01",
61
61
  to_date="2024-12-31"
62
62
  )
@@ -79,6 +79,4 @@ This project is licensed under the GPL-3.0 License. See the [LICENSE](LICENSE) f
79
79
 
80
80
  Ivan Kriventsev - [xd2dd@icloud.com](mailto:xd2dd@icloud.com)
81
81
 
82
- ---
83
-
84
- ⭐ If you like this project, please give it a star on GitHub!
82
+ ---
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "schoolmospy"
3
- version = "0.2.2"
3
+ version = "0.2.3"
4
4
  description = "A lightweight async Python wrapper for school.mos.ru APIs"
5
5
  authors = [{ name = "Ivan Kriventsev", email = "xd2dd@icloud.com" }]
6
6
  readme = "README.md"
@@ -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
File without changes