payi 0.1.0a89__py3-none-any.whl → 0.1.0a90__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.

Potentially problematic release.


This version of payi might be problematic. Click here for more details.

payi/__init__.py CHANGED
@@ -26,7 +26,7 @@ from ._exceptions import (
26
26
  UnprocessableEntityError,
27
27
  APIResponseValidationError,
28
28
  )
29
- from ._base_client import DefaultHttpxClient, DefaultAsyncHttpxClient
29
+ from ._base_client import DefaultHttpxClient, DefaultAioHttpClient, DefaultAsyncHttpxClient
30
30
  from ._utils._logs import setup_logging as _setup_logging
31
31
 
32
32
  __all__ = [
@@ -68,6 +68,7 @@ __all__ = [
68
68
  "DEFAULT_CONNECTION_LIMITS",
69
69
  "DefaultHttpxClient",
70
70
  "DefaultAsyncHttpxClient",
71
+ "DefaultAioHttpClient",
71
72
  ]
72
73
 
73
74
  if not _t.TYPE_CHECKING:
payi/_base_client.py CHANGED
@@ -1071,7 +1071,14 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1071
1071
  ) -> ResponseT:
1072
1072
  origin = get_origin(cast_to) or cast_to
1073
1073
 
1074
- if inspect.isclass(origin) and issubclass(origin, BaseAPIResponse):
1074
+ if (
1075
+ inspect.isclass(origin)
1076
+ and issubclass(origin, BaseAPIResponse)
1077
+ # we only want to actually return the custom BaseAPIResponse class if we're
1078
+ # returning the raw response, or if we're not streaming SSE, as if we're streaming
1079
+ # SSE then `cast_to` doesn't actively reflect the type we need to parse into
1080
+ and (not stream or bool(response.request.headers.get(RAW_RESPONSE_HEADER)))
1081
+ ):
1075
1082
  if not issubclass(origin, APIResponse):
1076
1083
  raise TypeError(f"API Response types must subclass {APIResponse}; Received {origin}")
1077
1084
 
@@ -1282,6 +1289,24 @@ class _DefaultAsyncHttpxClient(httpx.AsyncClient):
1282
1289
  super().__init__(**kwargs)
1283
1290
 
1284
1291
 
1292
+ try:
1293
+ import httpx_aiohttp
1294
+ except ImportError:
1295
+
1296
+ class _DefaultAioHttpClient(httpx.AsyncClient):
1297
+ def __init__(self, **_kwargs: Any) -> None:
1298
+ raise RuntimeError("To use the aiohttp client you must have installed the package with the `aiohttp` extra")
1299
+ else:
1300
+
1301
+ class _DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore
1302
+ def __init__(self, **kwargs: Any) -> None:
1303
+ kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
1304
+ kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
1305
+ kwargs.setdefault("follow_redirects", True)
1306
+
1307
+ super().__init__(**kwargs)
1308
+
1309
+
1285
1310
  if TYPE_CHECKING:
1286
1311
  DefaultAsyncHttpxClient = httpx.AsyncClient
1287
1312
  """An alias to `httpx.AsyncClient` that provides the same defaults that this SDK
@@ -1290,8 +1315,12 @@ if TYPE_CHECKING:
1290
1315
  This is useful because overriding the `http_client` with your own instance of
1291
1316
  `httpx.AsyncClient` will result in httpx's defaults being used, not ours.
1292
1317
  """
1318
+
1319
+ DefaultAioHttpClient = httpx.AsyncClient
1320
+ """An alias to `httpx.AsyncClient` that changes the default HTTP transport to `aiohttp`."""
1293
1321
  else:
1294
1322
  DefaultAsyncHttpxClient = _DefaultAsyncHttpxClient
1323
+ DefaultAioHttpClient = _DefaultAioHttpClient
1295
1324
 
1296
1325
 
1297
1326
  class AsyncHttpxClientWrapper(DefaultAsyncHttpxClient):
@@ -1574,7 +1603,14 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1574
1603
  ) -> ResponseT:
1575
1604
  origin = get_origin(cast_to) or cast_to
1576
1605
 
1577
- if inspect.isclass(origin) and issubclass(origin, BaseAPIResponse):
1606
+ if (
1607
+ inspect.isclass(origin)
1608
+ and issubclass(origin, BaseAPIResponse)
1609
+ # we only want to actually return the custom BaseAPIResponse class if we're
1610
+ # returning the raw response, or if we're not streaming SSE, as if we're streaming
1611
+ # SSE then `cast_to` doesn't actively reflect the type we need to parse into
1612
+ and (not stream or bool(response.request.headers.get(RAW_RESPONSE_HEADER)))
1613
+ ):
1578
1614
  if not issubclass(origin, AsyncAPIResponse):
1579
1615
  raise TypeError(f"API Response types must subclass {AsyncAPIResponse}; Received {origin}")
1580
1616
 
payi/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "payi"
4
- __version__ = "0.1.0-alpha.89" # x-release-please-version
4
+ __version__ = "0.1.0-alpha.90" # x-release-please-version
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: payi
3
- Version: 0.1.0a89
3
+ Version: 0.1.0a90
4
4
  Summary: The official Python library for the payi API
5
5
  Project-URL: Homepage, https://github.com/Pay-i/pay-i-python
6
6
  Project-URL: Repository, https://github.com/Pay-i/pay-i-python
@@ -30,11 +30,14 @@ Requires-Dist: sniffio
30
30
  Requires-Dist: tiktoken>=0.8.0
31
31
  Requires-Dist: typing-extensions<5,>=4.10
32
32
  Requires-Dist: wrapt>=1.17.2
33
+ Provides-Extra: aiohttp
34
+ Requires-Dist: aiohttp; extra == 'aiohttp'
35
+ Requires-Dist: httpx-aiohttp>=0.1.6; extra == 'aiohttp'
33
36
  Description-Content-Type: text/markdown
34
37
 
35
38
  # Payi Python API library
36
39
 
37
- [![PyPI version](https://img.shields.io/pypi/v/payi.svg)](https://pypi.org/project/payi/)
40
+ [![PyPI version](https://github.com/Pay-i/pay-i-python/tree/main/<https://img.shields.io/pypi/v/payi.svg?label=pypi%20(stable)>)](https://pypi.org/project/payi/)
38
41
 
39
42
  The Payi Python library provides convenient access to the Payi REST API from any Python 3.8+
40
43
  application. The library includes type definitions for all request params and response fields,
@@ -104,6 +107,41 @@ asyncio.run(main())
104
107
 
105
108
  Functionality between the synchronous and asynchronous clients is otherwise identical.
106
109
 
110
+ ### With aiohttp
111
+
112
+ By default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.
113
+
114
+ You can enable this by installing `aiohttp`:
115
+
116
+ ```sh
117
+ # install from PyPI
118
+ pip install --pre payi[aiohttp]
119
+ ```
120
+
121
+ Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
122
+
123
+ ```python
124
+ import os
125
+ import asyncio
126
+ from payi import DefaultAioHttpClient
127
+ from payi import AsyncPayi
128
+
129
+
130
+ async def main() -> None:
131
+ async with AsyncPayi(
132
+ api_key=os.environ.get("PAYI_API_KEY"), # This is the default and can be omitted
133
+ http_client=DefaultAioHttpClient(),
134
+ ) as client:
135
+ use_case_definition = await client.use_cases.definitions.create(
136
+ description="Sample Use Case Definition Description",
137
+ name="SampleUseCaseDefinition",
138
+ )
139
+ print(use_case_definition.request_id)
140
+
141
+
142
+ asyncio.run(main())
143
+ ```
144
+
107
145
  ## Using types
108
146
 
109
147
  Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:
@@ -264,7 +302,7 @@ client.with_options(max_retries=5).use_cases.definitions.create(
264
302
  ### Timeouts
265
303
 
266
304
  By default requests time out after 1 minute. You can configure this with a `timeout` option,
267
- which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:
305
+ which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:
268
306
 
269
307
  ```python
270
308
  from payi import Payi
@@ -1,5 +1,5 @@
1
- payi/__init__.py,sha256=4FRZqYbTvadWzWaSOtI2PmlFVjY4Z-jAi-T0DZAqR8c,2510
2
- payi/_base_client.py,sha256=b8EliKyjMXslDv4v36gTGE_tIg3h9wi8eQmwAJ2xaBg,65090
1
+ payi/__init__.py,sha256=D0Hb0f0CuE6t648U7C0qOOKez56wyNcIndIYcNuamlU,2560
2
+ payi/_base_client.py,sha256=Euo_HnDuz_74WmLbzSJZe5mBIbXNQIixMiOvCSRZFiI,66713
3
3
  payi/_client.py,sha256=NoznzJFIQsFjEcPZWGJpHr94mOTMaQBuH-U_WGdjB10,17882
4
4
  payi/_compat.py,sha256=VWemUKbj6DDkQ-O4baSpHVLJafotzeXmCQGJugfVTIw,6580
5
5
  payi/_constants.py,sha256=S14PFzyN9-I31wiV7SmIlL5Ga0MLHxdvegInGdXH7tM,462
@@ -11,7 +11,7 @@ payi/_resource.py,sha256=j2jIkTr8OIC8sU6-05nxSaCyj4MaFlbZrwlyg4_xJos,1088
11
11
  payi/_response.py,sha256=rh9oJAvCKcPwQFm4iqH_iVrmK8bNx--YP_A2a4kN1OU,28776
12
12
  payi/_streaming.py,sha256=Z_wIyo206T6Jqh2rolFg2VXZgX24PahLmpURp0-NssU,10092
13
13
  payi/_types.py,sha256=7jE5MoQQFVoVxw5vVzvZ2Ao0kcjfNOGsBgyJfLBEnMo,6195
14
- payi/_version.py,sha256=GTJ8Nh5qU2OJwemicx-uYEo7CsIqWAVGkyXHqGAuizc,165
14
+ payi/_version.py,sha256=tXFgPEeKbWMp7R7RIanP0VvZ88LuzOsIwp2Fn20klHs,165
15
15
  payi/pagination.py,sha256=k2356QGPOUSjRF2vHpwLBdF6P-2vnQzFfRIJQAHGQ7A,1258
16
16
  payi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  payi/_utils/__init__.py,sha256=PNZ_QJuzZEgyYXqkO1HVhGkj5IU9bglVUcw7H-Knjzw,2062
@@ -145,7 +145,7 @@ payi/types/use_cases/definitions/kpi_retrieve_response.py,sha256=uQXliSvS3k-yDYw
145
145
  payi/types/use_cases/definitions/kpi_update_params.py,sha256=jbawdWAdMnsTWVH0qfQGb8W7_TXe3lq4zjSRu44d8p8,373
146
146
  payi/types/use_cases/definitions/kpi_update_response.py,sha256=zLyEoT0S8d7XHsnXZYT8tM7yDw0Aze0Mk-_Z6QeMtc8,459
147
147
  payi/types/use_cases/definitions/limit_config_create_params.py,sha256=pzQza_16N3z8cFNEKr6gPbFvuGFrwNuGxAYb--Kbo2M,449
148
- payi-0.1.0a89.dist-info/METADATA,sha256=5O69xC5pNrymPWBi0WgiUyKoCTS4Jc1eSOV-NktrwRE,15180
149
- payi-0.1.0a89.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
150
- payi-0.1.0a89.dist-info/licenses/LICENSE,sha256=CQt03aM-P4a3Yg5qBg3JSLVoQS3smMyvx7tYg_6V7Gk,11334
151
- payi-0.1.0a89.dist-info/RECORD,,
148
+ payi-0.1.0a90.dist-info/METADATA,sha256=gyCugCALPCJppx1mvByADB01sZ2mbBFbWJTEynnccjg,16333
149
+ payi-0.1.0a90.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
150
+ payi-0.1.0a90.dist-info/licenses/LICENSE,sha256=CQt03aM-P4a3Yg5qBg3JSLVoQS3smMyvx7tYg_6V7Gk,11334
151
+ payi-0.1.0a90.dist-info/RECORD,,