Skip to content

Commit 1255c9b

Browse files
feat(api): api update
1 parent e835dc3 commit 1255c9b

14 files changed

Lines changed: 315 additions & 379 deletions

‎.stats.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 7
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/unlayer%2Funlayer-05f06124acf955282470ca7d863e8d10c5dd36cbde746d154482e9972277cd03.yml
3-
openapi_spec_hash: 21532f2d9416a6e55bf9107df0948cd8
4-
config_hash: 87d560e6d481bc04dc9310719a5eb946
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/unlayer%2Funlayer-14707e371ca64ee082f425e10f8bd4b7d9e2eeb28d6e69daad66902abb1b8b6b.yml
3+
openapi_spec_hash: 8198d0442f4736109bf6c49a5a8697ab
4+
config_hash: 144077318a24cfbe9ce6da795a628a80

‎README.md‎

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ import os
2929
from unlayer import Unlayer
3030

3131
client = Unlayer(
32-
access_token=os.environ.get("UNLAYER_ACCESS_TOKEN"), # This is the default and can be omitted
33-
# or 'production' | 'qa' | 'dev'; defaults to "production".
34-
environment="stage",
32+
api_key=os.environ.get("UNLAYER_API_KEY"), # This is the default and can be omitted
3533
)
3634

3735
project = client.project.retrieve(
@@ -40,10 +38,10 @@ project = client.project.retrieve(
4038
print(project.data)
4139
```
4240

43-
While you can provide a `access_token` keyword argument,
41+
While you can provide an `api_key` keyword argument,
4442
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
45-
to add `UNLAYER_ACCESS_TOKEN="My Access Token"` to your `.env` file
46-
so that your Access Token is not stored in source control.
43+
to add `UNLAYER_API_KEY="My API Key"` to your `.env` file
44+
so that your API Key is not stored in source control.
4745

4846
## Async usage
4947

@@ -55,9 +53,7 @@ import asyncio
5553
from unlayer import AsyncUnlayer
5654

5755
client = AsyncUnlayer(
58-
access_token=os.environ.get("UNLAYER_ACCESS_TOKEN"), # This is the default and can be omitted
59-
# or 'production' | 'qa' | 'dev'; defaults to "production".
60-
environment="stage",
56+
api_key=os.environ.get("UNLAYER_API_KEY"), # This is the default and can be omitted
6157
)
6258

6359

@@ -95,9 +91,7 @@ from unlayer import AsyncUnlayer
9591

9692
async def main() -> None:
9793
async with AsyncUnlayer(
98-
access_token=os.environ.get(
99-
"UNLAYER_ACCESS_TOKEN"
100-
), # This is the default and can be omitted
94+
api_key=os.environ.get("UNLAYER_API_KEY"), # This is the default and can be omitted
10195
http_client=DefaultAioHttpClient(),
10296
) as client:
10397
project = await client.project.retrieve(
@@ -132,8 +126,8 @@ client = Unlayer()
132126
all_templates = []
133127
# Automatically fetches more pages as needed.
134128
for template in client.templates.list(
135-
project_id="your-project-id",
136129
limit=10,
130+
project_id="your-project-id",
137131
):
138132
# Do something with template here
139133
all_templates.append(template)
@@ -153,8 +147,8 @@ async def main() -> None:
153147
all_templates = []
154148
# Iterate through items across all pages, issuing requests as needed.
155149
async for template in client.templates.list(
156-
project_id="your-project-id",
157150
limit=10,
151+
project_id="your-project-id",
158152
):
159153
all_templates.append(template)
160154
print(all_templates)
@@ -167,8 +161,8 @@ Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get
167161

168162
```python
169163
first_page = await client.templates.list(
170-
project_id="your-project-id",
171164
limit=10,
165+
project_id="your-project-id",
172166
)
173167
if first_page.has_next_page():
174168
print(f"will fetch next page using these details: {first_page.next_page_info()}")
@@ -182,8 +176,8 @@ Or just work directly with the returned data:
182176

183177
```python
184178
first_page = await client.templates.list(
185-
project_id="your-project-id",
186179
limit=10,
180+
project_id="your-project-id",
187181
)
188182

189183
print(f"next page cursor: {first_page.next_cursor}") # => "next page cursor: ..."

‎src/unlayer/__init__.py‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,7 @@
55
from . import types
66
from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes, omit, not_given
77
from ._utils import file_from_path
8-
from ._client import (
9-
ENVIRONMENTS,
10-
Client,
11-
Stream,
12-
Timeout,
13-
Unlayer,
14-
Transport,
15-
AsyncClient,
16-
AsyncStream,
17-
AsyncUnlayer,
18-
RequestOptions,
19-
)
8+
from ._client import Client, Stream, Timeout, Unlayer, Transport, AsyncClient, AsyncStream, AsyncUnlayer, RequestOptions
209
from ._models import BaseModel
2110
from ._version import __title__, __version__
2211
from ._response import APIResponse as APIResponse, AsyncAPIResponse as AsyncAPIResponse
@@ -74,7 +63,6 @@
7463
"AsyncStream",
7564
"Unlayer",
7665
"AsyncUnlayer",
77-
"ENVIRONMENTS",
7866
"file_from_path",
7967
"BaseModel",
8068
"DEFAULT_TIMEOUT",

0 commit comments

Comments
 (0)