smspva-sdk 0.1.0__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.
smspva/__init__.py ADDED
@@ -0,0 +1,6 @@
1
+ from ._client import SMSPVA, AsyncSMSPVA
2
+ from ._polling import is_pending, is_no_stock
3
+ from .errors import SMSPVAError, ApiError, ProtocolError, TransportError, RequestTimeoutError, PollingTimeoutError, ValidationError
4
+
5
+ __version__ = "0.1.0"
6
+ __all__ = ["SMSPVA", "AsyncSMSPVA", "is_pending", "is_no_stock", "SMSPVAError", "ApiError", "ProtocolError", "TransportError", "RequestTimeoutError", "PollingTimeoutError", "ValidationError"]
smspva/_client.py ADDED
@@ -0,0 +1,43 @@
1
+ from __future__ import annotations
2
+
3
+ from types import TracebackType
4
+ import httpx
5
+
6
+ from ._transport import Transport, AsyncTransport
7
+ from ._resources import Activation, Rental, Email, AsyncActivation, AsyncRental, AsyncEmail
8
+
9
+
10
+ class SMSPVA:
11
+ def __init__(self, api_key: str | None = None, *, timeout: float = 30, activation_base_url: str | None = None,
12
+ rental_base_url: str | None = None, email_base_url: str | None = None, transport: httpx.BaseTransport | None = None):
13
+ self._transport = Transport(api_key, timeout, {"activation": activation_base_url, "rental": rental_base_url, "email": email_base_url}, transport)
14
+ self.activation = Activation(self._transport)
15
+ self.rental = Rental(self._transport)
16
+ self.email = Email(self._transport)
17
+
18
+ def close(self) -> None:
19
+ self._transport.close()
20
+
21
+ def __enter__(self) -> SMSPVA:
22
+ return self
23
+
24
+ def __exit__(self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) -> None:
25
+ self.close()
26
+
27
+
28
+ class AsyncSMSPVA:
29
+ def __init__(self, api_key: str | None = None, *, timeout: float = 30, activation_base_url: str | None = None,
30
+ rental_base_url: str | None = None, email_base_url: str | None = None, transport: httpx.AsyncBaseTransport | None = None):
31
+ self._transport = AsyncTransport(api_key, timeout, {"activation": activation_base_url, "rental": rental_base_url, "email": email_base_url}, transport)
32
+ self.activation = AsyncActivation(self._transport)
33
+ self.rental = AsyncRental(self._transport)
34
+ self.email = AsyncEmail(self._transport)
35
+
36
+ async def aclose(self) -> None:
37
+ await self._transport.close()
38
+
39
+ async def __aenter__(self) -> AsyncSMSPVA:
40
+ return self
41
+
42
+ async def __aexit__(self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None) -> None:
43
+ await self.aclose()