Skip to content

Commit d0bb085

Browse files
feat(api): api update
1 parent eaab341 commit d0bb085

118 files changed

Lines changed: 8121 additions & 4978 deletions

File tree

Some content is hidden

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

‎.stats.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 25
1+
configured_endpoints: 27
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/unlayer%2Funlayer-077d753eb6d4f805b2f84bf887289213f91c1da5f5a3a4e1e36e1da3689efb46.yml
33
openapi_spec_hash: b210022cf72d9a38fe1baee599054518
4-
config_hash: ae90f2806448a012e25917d01699b3a5
4+
config_hash: 15a2f2b4c1b498b9b314d587d6a331d0

‎README.md‎

Lines changed: 28 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ client = Unlayer(
3737
environment="stage",
3838
)
3939

40-
response = client.project.current_list(
41-
project_id="your-project-id",
40+
full_to_simple = client.convert.full_to_simple.create(
41+
design={"body": {}},
4242
)
43-
print(response.data)
43+
print(full_to_simple.data)
4444
```
4545

4646
While you can provide a `access_token` keyword argument,
@@ -65,10 +65,10 @@ client = AsyncUnlayer(
6565

6666

6767
async def main() -> None:
68-
response = await client.project.current_list(
69-
project_id="your-project-id",
68+
full_to_simple = await client.convert.full_to_simple.create(
69+
design={"body": {}},
7070
)
71-
print(response.data)
71+
print(full_to_simple.data)
7272

7373

7474
asyncio.run(main())
@@ -103,10 +103,10 @@ async def main() -> None:
103103
), # This is the default and can be omitted
104104
http_client=DefaultAioHttpClient(),
105105
) as client:
106-
response = await client.project.current_list(
107-
project_id="your-project-id",
106+
full_to_simple = await client.convert.full_to_simple.create(
107+
design={"body": {}},
108108
)
109-
print(response.data)
109+
print(full_to_simple.data)
110110

111111

112112
asyncio.run(main())
@@ -121,79 +121,19 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ
121121

122122
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`.
123123

124-
## Pagination
124+
## Nested params
125125

126-
List methods in the Unlayer API are paginated.
127-
128-
This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:
126+
Nested parameters are dictionaries, typed using `TypedDict`, for example:
129127

130128
```python
131129
from unlayer import Unlayer
132130

133131
client = Unlayer()
134132

135-
all_projects = []
136-
# Automatically fetches more pages as needed.
137-
for project in client.project.templates_list(
138-
project_id="your-project-id",
139-
limit=10,
140-
):
141-
# Do something with project here
142-
all_projects.append(project)
143-
print(all_projects)
144-
```
145-
146-
Or, asynchronously:
147-
148-
```python
149-
import asyncio
150-
from unlayer import AsyncUnlayer
151-
152-
client = AsyncUnlayer()
153-
154-
155-
async def main() -> None:
156-
all_projects = []
157-
# Iterate through items across all pages, issuing requests as needed.
158-
async for project in client.project.templates_list(
159-
project_id="your-project-id",
160-
limit=10,
161-
):
162-
all_projects.append(project)
163-
print(all_projects)
164-
165-
166-
asyncio.run(main())
167-
```
168-
169-
Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:
170-
171-
```python
172-
first_page = await client.project.templates_list(
173-
project_id="your-project-id",
174-
limit=10,
133+
full_to_simple = client.convert.full_to_simple.create(
134+
design={"body": {}},
175135
)
176-
if first_page.has_next_page():
177-
print(f"will fetch next page using these details: {first_page.next_page_info()}")
178-
next_page = await first_page.get_next_page()
179-
print(f"number of items we just fetched: {len(next_page.data)}")
180-
181-
# Remove `await` for non-async usage.
182-
```
183-
184-
Or just work directly with the returned data:
185-
186-
```python
187-
first_page = await client.project.templates_list(
188-
project_id="your-project-id",
189-
limit=10,
190-
)
191-
192-
print(f"next page cursor: {first_page.next_cursor}") # => "next page cursor: ..."
193-
for project in first_page.data:
194-
print(project.id)
195-
196-
# Remove `await` for non-async usage.
136+
print(full_to_simple.design)
197137
```
198138

199139
## Handling errors
@@ -212,8 +152,8 @@ from unlayer import Unlayer
212152
client = Unlayer()
213153

214154
try:
215-
client.project.current_list(
216-
project_id="your-project-id",
155+
client.convert.full_to_simple.create(
156+
design={"body": {}},
217157
)
218158
except unlayer.APIConnectionError as e:
219159
print("The server could not be reached")
@@ -257,8 +197,8 @@ client = Unlayer(
257197
)
258198

259199
# Or, configure per-request:
260-
client.with_options(max_retries=5).project.current_list(
261-
project_id="your-project-id",
200+
client.with_options(max_retries=5).convert.full_to_simple.create(
201+
design={"body": {}},
262202
)
263203
```
264204

@@ -282,8 +222,8 @@ client = Unlayer(
282222
)
283223

284224
# Override per-request:
285-
client.with_options(timeout=5.0).project.current_list(
286-
project_id="your-project-id",
225+
client.with_options(timeout=5.0).convert.full_to_simple.create(
226+
design={"body": {}},
287227
)
288228
```
289229

@@ -325,13 +265,15 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
325265
from unlayer import Unlayer
326266

327267
client = Unlayer()
328-
response = client.project.with_raw_response.current_list(
329-
project_id="your-project-id",
268+
response = client.convert.full_to_simple.with_raw_response.create(
269+
design={
270+
"body": {}
271+
},
330272
)
331273
print(response.headers.get('X-My-Header'))
332274

333-
project = response.parse() # get the object that `project.current_list()` would have returned
334-
print(project.data)
275+
full_to_simple = response.parse() # get the object that `convert.full_to_simple.create()` would have returned
276+
print(full_to_simple.data)
335277
```
336278

337279
These methods return an [`APIResponse`](https://github.com/stainless-sdks/unlayer-python/tree/main/src/unlayer/_response.py) object.
@@ -345,8 +287,8 @@ The above interface eagerly reads the full response body when you make the reque
345287
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
346288

347289
```python
348-
with client.project.with_streaming_response.current_list(
349-
project_id="your-project-id",
290+
with client.convert.full_to_simple.with_streaming_response.create(
291+
design={"body": {}},
350292
) as response:
351293
print(response.headers.get("X-My-Header"))
352294

0 commit comments

Comments
 (0)