Skip to content

Commit ea2c0ab

Browse files
feat(api): api update
1 parent 52edf87 commit ea2c0ab

File tree

158 files changed

+2745
-1314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+2745
-1314
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 229
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-bd464d151612058d8029150b376949b22d5515af23621465c0ce1c1069b91644.yml
33
openapi_spec_hash: e60e1548c523a0ee7c9daa1bd988cbc5
4-
config_hash: ca1425272e17fa23d4466d33492334fa
4+
config_hash: eecc5886c26d07c167f37f30ae505a2c

README.md

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ client = Increase(
3434

3535
account = client.accounts.create(
3636
name="New Account!",
37-
entity_id="entity_n8y8tnk2p9339ti393yi",
38-
program_id="program_i2v2os4mwza1oetokh9i",
3937
)
4038
print(account.id)
4139
```
@@ -64,8 +62,6 @@ client = AsyncIncrease(
6462
async def main() -> None:
6563
account = await client.accounts.create(
6664
name="New Account!",
67-
entity_id="entity_n8y8tnk2p9339ti393yi",
68-
program_id="program_i2v2os4mwza1oetokh9i",
6965
)
7066
print(account.id)
7167

@@ -101,8 +97,6 @@ async def main() -> None:
10197
) as client:
10298
account = await client.accounts.create(
10399
name="New Account!",
104-
entity_id="entity_n8y8tnk2p9339ti393yi",
105-
program_id="program_i2v2os4mwza1oetokh9i",
106100
)
107101
print(account.id)
108102

@@ -119,69 +113,6 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ
119113

120114
Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
121115

122-
## Pagination
123-
124-
List methods in the Increase API are paginated.
125-
126-
This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:
127-
128-
```python
129-
from increase import Increase
130-
131-
client = Increase()
132-
133-
all_accounts = []
134-
# Automatically fetches more pages as needed.
135-
for account in client.accounts.list():
136-
# Do something with account here
137-
all_accounts.append(account)
138-
print(all_accounts)
139-
```
140-
141-
Or, asynchronously:
142-
143-
```python
144-
import asyncio
145-
from increase import AsyncIncrease
146-
147-
client = AsyncIncrease()
148-
149-
150-
async def main() -> None:
151-
all_accounts = []
152-
# Iterate through items across all pages, issuing requests as needed.
153-
async for account in client.accounts.list():
154-
all_accounts.append(account)
155-
print(all_accounts)
156-
157-
158-
asyncio.run(main())
159-
```
160-
161-
Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:
162-
163-
```python
164-
first_page = await client.accounts.list()
165-
if first_page.has_next_page():
166-
print(f"will fetch next page using these details: {first_page.next_page_info()}")
167-
next_page = await first_page.get_next_page()
168-
print(f"number of items we just fetched: {len(next_page.data)}")
169-
170-
# Remove `await` for non-async usage.
171-
```
172-
173-
Or just work directly with the returned data:
174-
175-
```python
176-
first_page = await client.accounts.list()
177-
178-
print(f"next page cursor: {first_page.next_cursor}") # => "next page cursor: ..."
179-
for account in first_page.data:
180-
print(account.id)
181-
182-
# Remove `await` for non-async usage.
183-
```
184-
185116
## Nested params
186117

187118
Nested parameters are dictionaries, typed using `TypedDict`, for example:
@@ -367,8 +298,6 @@ client = Increase(
367298
# Or, configure per-request:
368299
client.with_options(max_retries=5).accounts.create(
369300
name="New Account!",
370-
entity_id="entity_n8y8tnk2p9339ti393yi",
371-
program_id="program_i2v2os4mwza1oetokh9i",
372301
)
373302
```
374303

@@ -394,8 +323,6 @@ client = Increase(
394323
# Override per-request:
395324
client.with_options(timeout=5.0).accounts.create(
396325
name="New Account!",
397-
entity_id="entity_n8y8tnk2p9339ti393yi",
398-
program_id="program_i2v2os4mwza1oetokh9i",
399326
)
400327
```
401328

@@ -439,8 +366,6 @@ from increase import Increase
439366
client = Increase()
440367
response = client.accounts.with_raw_response.create(
441368
name="New Account!",
442-
entity_id="entity_n8y8tnk2p9339ti393yi",
443-
program_id="program_i2v2os4mwza1oetokh9i",
444369
)
445370
print(response.headers.get('X-My-Header'))
446371

@@ -461,8 +386,6 @@ To stream the response body, use `.with_streaming_response` instead, which requi
461386
```python
462387
with client.accounts.with_streaming_response.create(
463388
name="New Account!",
464-
entity_id="entity_n8y8tnk2p9339ti393yi",
465-
program_id="program_i2v2os4mwza1oetokh9i",
466389
) as response:
467390
print(response.headers.get("X-My-Header"))
468391

api.md

Lines changed: 108 additions & 101 deletions
Large diffs are not rendered by default.

src/increase/pagination.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from typing import List, Generic, TypeVar, Optional
44
from typing_extensions import override
55

6+
from pydantic import Field as FieldInfo
7+
68
from ._base_client import BasePage, PageInfo, BaseSyncPage, BaseAsyncPage
79

810
__all__ = ["SyncPage", "AsyncPage"]
@@ -11,15 +13,12 @@
1113

1214

1315
class SyncPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
14-
data: List[_T]
15-
next_cursor: Optional[str] = None
16-
"""A pointer to a place in the list."""
16+
data: Optional[object] = FieldInfo(alias=":data", default=None)
17+
next_cursor: Optional[object] = FieldInfo(alias=":next_cursor", default=None)
1718

1819
@override
1920
def _get_page_items(self) -> List[_T]:
2021
data = self.data
21-
if not data:
22-
return []
2322
return data
2423

2524
@override
@@ -28,19 +27,16 @@ def next_page_info(self) -> Optional[PageInfo]:
2827
if not next_cursor:
2928
return None
3029

31-
return PageInfo(params={"cursor": next_cursor})
30+
return PageInfo(params={":cursor": next_cursor})
3231

3332

3433
class AsyncPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
35-
data: List[_T]
36-
next_cursor: Optional[str] = None
37-
"""A pointer to a place in the list."""
34+
data: Optional[object] = FieldInfo(alias=":data", default=None)
35+
next_cursor: Optional[object] = FieldInfo(alias=":next_cursor", default=None)
3836

3937
@override
4038
def _get_page_items(self) -> List[_T]:
4139
data = self.data
42-
if not data:
43-
return []
4440
return data
4541

4642
@override
@@ -49,4 +45,4 @@ def next_page_info(self) -> Optional[PageInfo]:
4945
if not next_cursor:
5046
return None
5147

52-
return PageInfo(params={"cursor": next_cursor})
48+
return PageInfo(params={":cursor": next_cursor})

src/increase/resources/account_numbers.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
async_to_raw_response_wrapper,
1818
async_to_streamed_response_wrapper,
1919
)
20-
from ..pagination import SyncPage, AsyncPage
21-
from .._base_client import AsyncPaginator, make_request_options
20+
from .._base_client import make_request_options
2221
from ..types.account_number import AccountNumber
22+
from ..types.account_number_list_response import AccountNumberListResponse
2323

2424
__all__ = ["AccountNumbersResource", "AsyncAccountNumbersResource"]
2525

@@ -222,7 +222,7 @@ def list(
222222
extra_query: Query | None = None,
223223
extra_body: Body | None = None,
224224
timeout: float | httpx.Timeout | None | NotGiven = not_given,
225-
) -> SyncPage[AccountNumber]:
225+
) -> AccountNumberListResponse:
226226
"""
227227
List Account Numbers
228228
@@ -247,9 +247,8 @@ def list(
247247
248248
timeout: Override the client-level default timeout for this request, in seconds
249249
"""
250-
return self._get_api_list(
250+
return self._get(
251251
"/account_numbers",
252-
page=SyncPage[AccountNumber],
253252
options=make_request_options(
254253
extra_headers=extra_headers,
255254
extra_query=extra_query,
@@ -268,7 +267,7 @@ def list(
268267
account_number_list_params.AccountNumberListParams,
269268
),
270269
),
271-
model=AccountNumber,
270+
cast_to=AccountNumberListResponse,
272271
)
273272

274273

@@ -454,7 +453,7 @@ async def update(
454453
cast_to=AccountNumber,
455454
)
456455

457-
def list(
456+
async def list(
458457
self,
459458
*,
460459
account_id: str | Omit = omit,
@@ -470,7 +469,7 @@ def list(
470469
extra_query: Query | None = None,
471470
extra_body: Body | None = None,
472471
timeout: float | httpx.Timeout | None | NotGiven = not_given,
473-
) -> AsyncPaginator[AccountNumber, AsyncPage[AccountNumber]]:
472+
) -> AccountNumberListResponse:
474473
"""
475474
List Account Numbers
476475
@@ -495,15 +494,14 @@ def list(
495494
496495
timeout: Override the client-level default timeout for this request, in seconds
497496
"""
498-
return self._get_api_list(
497+
return await self._get(
499498
"/account_numbers",
500-
page=AsyncPage[AccountNumber],
501499
options=make_request_options(
502500
extra_headers=extra_headers,
503501
extra_query=extra_query,
504502
extra_body=extra_body,
505503
timeout=timeout,
506-
query=maybe_transform(
504+
query=await async_maybe_transform(
507505
{
508506
"account_id": account_id,
509507
"ach_debit_status": ach_debit_status,
@@ -516,7 +514,7 @@ def list(
516514
account_number_list_params.AccountNumberListParams,
517515
),
518516
),
519-
model=AccountNumber,
517+
cast_to=AccountNumberListResponse,
520518
)
521519

522520

src/increase/resources/account_statements.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from ..types import account_statement_list_params
88
from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
9-
from .._utils import maybe_transform
9+
from .._utils import maybe_transform, async_maybe_transform
1010
from .._compat import cached_property
1111
from .._resource import SyncAPIResource, AsyncAPIResource
1212
from .._response import (
@@ -15,9 +15,9 @@
1515
async_to_raw_response_wrapper,
1616
async_to_streamed_response_wrapper,
1717
)
18-
from ..pagination import SyncPage, AsyncPage
19-
from .._base_client import AsyncPaginator, make_request_options
18+
from .._base_client import make_request_options
2019
from ..types.account_statement import AccountStatement
20+
from ..types.account_statement_list_response import AccountStatementListResponse
2121

2222
__all__ = ["AccountStatementsResource", "AsyncAccountStatementsResource"]
2323

@@ -92,7 +92,7 @@ def list(
9292
extra_query: Query | None = None,
9393
extra_body: Body | None = None,
9494
timeout: float | httpx.Timeout | None | NotGiven = not_given,
95-
) -> SyncPage[AccountStatement]:
95+
) -> AccountStatementListResponse:
9696
"""
9797
List Account Statements
9898
@@ -112,9 +112,8 @@ def list(
112112
113113
timeout: Override the client-level default timeout for this request, in seconds
114114
"""
115-
return self._get_api_list(
115+
return self._get(
116116
"/account_statements",
117-
page=SyncPage[AccountStatement],
118117
options=make_request_options(
119118
extra_headers=extra_headers,
120119
extra_query=extra_query,
@@ -130,7 +129,7 @@ def list(
130129
account_statement_list_params.AccountStatementListParams,
131130
),
132131
),
133-
model=AccountStatement,
132+
cast_to=AccountStatementListResponse,
134133
)
135134

136135

@@ -191,7 +190,7 @@ async def retrieve(
191190
cast_to=AccountStatement,
192191
)
193192

194-
def list(
193+
async def list(
195194
self,
196195
*,
197196
account_id: str | Omit = omit,
@@ -204,7 +203,7 @@ def list(
204203
extra_query: Query | None = None,
205204
extra_body: Body | None = None,
206205
timeout: float | httpx.Timeout | None | NotGiven = not_given,
207-
) -> AsyncPaginator[AccountStatement, AsyncPage[AccountStatement]]:
206+
) -> AccountStatementListResponse:
208207
"""
209208
List Account Statements
210209
@@ -224,15 +223,14 @@ def list(
224223
225224
timeout: Override the client-level default timeout for this request, in seconds
226225
"""
227-
return self._get_api_list(
226+
return await self._get(
228227
"/account_statements",
229-
page=AsyncPage[AccountStatement],
230228
options=make_request_options(
231229
extra_headers=extra_headers,
232230
extra_query=extra_query,
233231
extra_body=extra_body,
234232
timeout=timeout,
235-
query=maybe_transform(
233+
query=await async_maybe_transform(
236234
{
237235
"account_id": account_id,
238236
"cursor": cursor,
@@ -242,7 +240,7 @@ def list(
242240
account_statement_list_params.AccountStatementListParams,
243241
),
244242
),
245-
model=AccountStatement,
243+
cast_to=AccountStatementListResponse,
246244
)
247245

248246

0 commit comments

Comments
 (0)