pyznuny 0.0.1__py3-none-any.whl → 0.0.4__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.
- pyznuny/ticket/__init__.py +1 -3
- pyznuny/ticket/client.py +29 -8
- pyznuny/ticket/endpoints.py +1 -1
- pyznuny/ticket/exceptions.py +4 -1
- pyznuny/ticket/models.py +0 -1
- {pyznuny-0.0.1.dist-info → pyznuny-0.0.4.dist-info}/METADATA +2 -2
- pyznuny-0.0.4.dist-info/RECORD +11 -0
- pyznuny-0.0.1.dist-info/RECORD +0 -11
- {pyznuny-0.0.1.dist-info → pyznuny-0.0.4.dist-info}/WHEEL +0 -0
- {pyznuny-0.0.1.dist-info → pyznuny-0.0.4.dist-info}/top_level.txt +0 -0
pyznuny/ticket/__init__.py
CHANGED
pyznuny/ticket/client.py
CHANGED
|
@@ -10,23 +10,35 @@ if __name__ == "__main__" and __package__ is None:
|
|
|
10
10
|
import sys
|
|
11
11
|
|
|
12
12
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")))
|
|
13
|
-
from pyznuny.ticket.endpoints import
|
|
13
|
+
from pyznuny.ticket.endpoints import (
|
|
14
|
+
_DEFAULT_ENDPOINT_IDENTIFIERS,
|
|
15
|
+
_DEFAULT_ENDPOINTS,
|
|
16
|
+
Endpoint,
|
|
17
|
+
EndpointSetter,
|
|
18
|
+
EndpointsRegistry,
|
|
19
|
+
)
|
|
20
|
+
from pyznuny.ticket.exceptions import TicketClientError
|
|
14
21
|
from pyznuny.ticket.models import (
|
|
15
22
|
TicketCreateArticle,
|
|
16
23
|
TicketCreatePayload,
|
|
17
24
|
TicketCreateTicket,
|
|
18
25
|
)
|
|
19
|
-
from pyznuny.ticket.
|
|
20
|
-
from pyznuny.ticket.routes import TicketRoutes, SessionRoutes
|
|
26
|
+
from pyznuny.ticket.routes import SessionRoutes, TicketRoutes
|
|
21
27
|
else:
|
|
22
|
-
from .endpoints import
|
|
28
|
+
from .endpoints import (
|
|
29
|
+
_DEFAULT_ENDPOINT_IDENTIFIERS,
|
|
30
|
+
_DEFAULT_ENDPOINTS,
|
|
31
|
+
Endpoint,
|
|
32
|
+
EndpointSetter,
|
|
33
|
+
EndpointsRegistry,
|
|
34
|
+
)
|
|
35
|
+
from .exceptions import TicketClientError
|
|
23
36
|
from .models import (
|
|
24
37
|
TicketCreateArticle,
|
|
25
38
|
TicketCreatePayload,
|
|
26
39
|
TicketCreateTicket,
|
|
27
40
|
)
|
|
28
|
-
from .routes import
|
|
29
|
-
from .exceptions import TicketClientError
|
|
41
|
+
from .routes import SessionRoutes, TicketRoutes
|
|
30
42
|
|
|
31
43
|
|
|
32
44
|
|
|
@@ -171,10 +183,19 @@ class TicketClient:
|
|
|
171
183
|
endpoint_path = endpoint_path.format(**path_params)
|
|
172
184
|
response = self._client.request(endpoint_method, endpoint_path, **kwargs)
|
|
173
185
|
|
|
174
|
-
|
|
186
|
+
try:
|
|
187
|
+
response.raise_for_status()
|
|
188
|
+
except httpx.HTTPStatusError:
|
|
189
|
+
try:
|
|
190
|
+
error = response.json().get("Error")
|
|
191
|
+
except Exception:
|
|
192
|
+
error = response.text
|
|
193
|
+
# TODO: improve error to handle status codes
|
|
194
|
+
self._raise_error(error)
|
|
195
|
+
|
|
175
196
|
if error := response.json().get("Error"):
|
|
176
197
|
self._raise_error(error)
|
|
177
|
-
|
|
198
|
+
|
|
178
199
|
return response
|
|
179
200
|
|
|
180
201
|
def _raise_error(self, error: Mapping[str, Any]) -> None:
|
pyznuny/ticket/endpoints.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from typing import TYPE_CHECKING, Iterable, Mapping, MutableMapping
|
|
3
4
|
|
|
4
5
|
from .models import Endpoint
|
|
5
|
-
from typing import Iterable, Mapping, MutableMapping, TYPE_CHECKING
|
|
6
6
|
|
|
7
7
|
if TYPE_CHECKING:
|
|
8
8
|
from pyznuny.ticket.client import TicketClient
|
pyznuny/ticket/exceptions.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from typing import Any, Mapping
|
|
4
4
|
|
|
5
|
+
|
|
5
6
|
class TicketClientError(Exception):
|
|
6
7
|
"""
|
|
7
8
|
Docstring for TicketClientError
|
|
@@ -11,5 +12,7 @@ class TicketClientError(Exception):
|
|
|
11
12
|
|
|
12
13
|
self.error = error
|
|
13
14
|
code = error.get("ErrorCode") if isinstance(error, dict) else error
|
|
14
|
-
message = error.get("ErrorMessage") or "Unknown error"
|
|
15
|
+
message = error.get("ErrorMessage") or "Unknown error" \
|
|
16
|
+
if isinstance(error, dict) else str(error)
|
|
17
|
+
|
|
15
18
|
super().__init__(f"{code}: {message}" if code else str(message))
|
pyznuny/ticket/models.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyznuny
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.4
|
|
4
4
|
Summary: A Python client for interacting with the Znuny ticketing system API.
|
|
5
5
|
Author-email: Junior Rosa <jr.dasrosas@gmail.com>, Pablo Gascon <pablogasconiel445@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/Junior-Rosa/py-znuny
|
|
7
7
|
Project-URL: Repository, https://github.com/Junior-Rosa/py-znuny
|
|
8
8
|
Project-URL: Issues, https://github.com/Junior-Rosa/py-znuny/issues
|
|
9
|
-
Requires-Python: >=3.
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
11
|
Requires-Dist: httpx>=0.28.1
|
|
12
12
|
Requires-Dist: pydantic>=2.12.5
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
pyznuny/__init__.py,sha256=2hs3juXhAKpKyn_poQYzFr8ns0jmf_uBNKxT6u6w4Wo,68
|
|
2
|
+
pyznuny/ticket/__init__.py,sha256=uaGAnpyrTyhoevoVqdPTslcPuKAnmuQP1o7LmCvjXaY,68
|
|
3
|
+
pyznuny/ticket/client.py,sha256=WgPPs6Sy2Xa1_vCBdvldLCWxagaddp1TlSSli2VAbFM,9033
|
|
4
|
+
pyznuny/ticket/endpoints.py,sha256=ArLl_BnUnZAQaWOA-T9EnTQHF1vl1XUG2kCgxlzr7vc,4444
|
|
5
|
+
pyznuny/ticket/exceptions.py,sha256=0pK5I0TjF_yR19eUWITGd0DryG1BrD_3ggA1YXbmPxI,563
|
|
6
|
+
pyznuny/ticket/models.py,sha256=oLn3asm3cDvRvi4LfR5HOKPsyP7tG-y7d7stD-QnNjc,4691
|
|
7
|
+
pyznuny/ticket/routes.py,sha256=54cr08Z2NM9JwWCkY47E1Kj94Uen9d1PJXrJ24mb2nM,2514
|
|
8
|
+
pyznuny-0.0.4.dist-info/METADATA,sha256=kb8hrELFud7M2GrRHkjN1vyLCuLOsTKF95KLlo4psz4,544
|
|
9
|
+
pyznuny-0.0.4.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
10
|
+
pyznuny-0.0.4.dist-info/top_level.txt,sha256=ki9uLRbo2oQCeiEaaYUcnYMj1mD_dkIhQroMCdJJXmk,8
|
|
11
|
+
pyznuny-0.0.4.dist-info/RECORD,,
|
pyznuny-0.0.1.dist-info/RECORD
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
pyznuny/__init__.py,sha256=2hs3juXhAKpKyn_poQYzFr8ns0jmf_uBNKxT6u6w4Wo,68
|
|
2
|
-
pyznuny/ticket/__init__.py,sha256=lnWfZ1Al7LLLogUK_EUS_8WSNrRKzoJdbuYxpMXnUcA,215
|
|
3
|
-
pyznuny/ticket/client.py,sha256=kfYZIKFrCEJ7-A7aHF9ZMl_uw3tVj_1FAy3vrRw8JlI,8641
|
|
4
|
-
pyznuny/ticket/endpoints.py,sha256=nX5zJxOtwiwg3rtnt_7h4tRgSTyKPwof0i1sqqxljug,4444
|
|
5
|
-
pyznuny/ticket/exceptions.py,sha256=fqJFlMY1wl3Fb98Fz2odolOIyaDhKEwH1kP8Uv2k9-s,535
|
|
6
|
-
pyznuny/ticket/models.py,sha256=ezUxGc_Ftot0J2Entz5NXB7oXAeBIiuulN7NlxXTVTc,4692
|
|
7
|
-
pyznuny/ticket/routes.py,sha256=54cr08Z2NM9JwWCkY47E1Kj94Uen9d1PJXrJ24mb2nM,2514
|
|
8
|
-
pyznuny-0.0.1.dist-info/METADATA,sha256=xQPKpX-wpBmKYxvy5iFeyPLBaO-cNY-Z4xw2uD0pc_U,544
|
|
9
|
-
pyznuny-0.0.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
10
|
-
pyznuny-0.0.1.dist-info/top_level.txt,sha256=ki9uLRbo2oQCeiEaaYUcnYMj1mD_dkIhQroMCdJJXmk,8
|
|
11
|
-
pyznuny-0.0.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|