Skip to content

Commit 2b46ccc

Browse files
feat(client): add webhook secret argument (#212)
1 parent fa39b8e commit 2b46ccc

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/orb/_client.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ class Orb(SyncAPIClient):
6565

6666
# client options
6767
api_key: str
68+
webhook_secret: str | None
6869

6970
def __init__(
7071
self,
7172
*,
7273
api_key: str | None = None,
74+
webhook_secret: str | None = None,
7375
base_url: str | httpx.URL | None = None,
7476
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
7577
max_retries: int = DEFAULT_MAX_RETRIES,
@@ -89,7 +91,9 @@ def __init__(
8991
) -> None:
9092
"""Construct a new synchronous orb client instance.
9193
92-
This automatically infers the `api_key` argument from the `ORB_API_KEY` environment variable if it is not provided.
94+
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
95+
- `api_key` from `ORB_API_KEY`
96+
- `webhook_secret` from `ORB_WEBHOOK_SECRET`
9397
"""
9498
if api_key is None:
9599
api_key = os.environ.get("ORB_API_KEY")
@@ -99,6 +103,10 @@ def __init__(
99103
)
100104
self.api_key = api_key
101105

106+
if webhook_secret is None:
107+
webhook_secret = os.environ.get("ORB_WEBHOOK_SECRET")
108+
self.webhook_secret = webhook_secret
109+
102110
if base_url is None:
103111
base_url = os.environ.get("ORB_BASE_URL")
104112
if base_url is None:
@@ -157,6 +165,7 @@ def copy(
157165
self,
158166
*,
159167
api_key: str | None = None,
168+
webhook_secret: str | None = None,
160169
base_url: str | httpx.URL | None = None,
161170
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
162171
http_client: httpx.Client | None = None,
@@ -191,6 +200,7 @@ def copy(
191200
http_client = http_client or self._client
192201
return self.__class__(
193202
api_key=api_key or self.api_key,
203+
webhook_secret=webhook_secret or self.webhook_secret,
194204
base_url=base_url or self.base_url,
195205
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
196206
http_client=http_client,
@@ -305,11 +315,13 @@ class AsyncOrb(AsyncAPIClient):
305315

306316
# client options
307317
api_key: str
318+
webhook_secret: str | None
308319

309320
def __init__(
310321
self,
311322
*,
312323
api_key: str | None = None,
324+
webhook_secret: str | None = None,
313325
base_url: str | httpx.URL | None = None,
314326
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
315327
max_retries: int = DEFAULT_MAX_RETRIES,
@@ -329,7 +341,9 @@ def __init__(
329341
) -> None:
330342
"""Construct a new async orb client instance.
331343
332-
This automatically infers the `api_key` argument from the `ORB_API_KEY` environment variable if it is not provided.
344+
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
345+
- `api_key` from `ORB_API_KEY`
346+
- `webhook_secret` from `ORB_WEBHOOK_SECRET`
333347
"""
334348
if api_key is None:
335349
api_key = os.environ.get("ORB_API_KEY")
@@ -339,6 +353,10 @@ def __init__(
339353
)
340354
self.api_key = api_key
341355

356+
if webhook_secret is None:
357+
webhook_secret = os.environ.get("ORB_WEBHOOK_SECRET")
358+
self.webhook_secret = webhook_secret
359+
342360
if base_url is None:
343361
base_url = os.environ.get("ORB_BASE_URL")
344362
if base_url is None:
@@ -397,6 +415,7 @@ def copy(
397415
self,
398416
*,
399417
api_key: str | None = None,
418+
webhook_secret: str | None = None,
400419
base_url: str | httpx.URL | None = None,
401420
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
402421
http_client: httpx.AsyncClient | None = None,
@@ -431,6 +450,7 @@ def copy(
431450
http_client = http_client or self._client
432451
return self.__class__(
433452
api_key=api_key or self.api_key,
453+
webhook_secret=webhook_secret or self.webhook_secret,
434454
base_url=base_url or self.base_url,
435455
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
436456
http_client=http_client,

0 commit comments

Comments
 (0)