Skip to content

feat(client): add webhook secret argument #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/orb/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ class Orb(SyncAPIClient):

# client options
api_key: str
webhook_secret: str | None

def __init__(
self,
*,
api_key: str | None = None,
webhook_secret: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
max_retries: int = DEFAULT_MAX_RETRIES,
Expand All @@ -89,7 +91,9 @@ def __init__(
) -> None:
"""Construct a new synchronous orb client instance.

This automatically infers the `api_key` argument from the `ORB_API_KEY` environment variable if it is not provided.
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
- `api_key` from `ORB_API_KEY`
- `webhook_secret` from `ORB_WEBHOOK_SECRET`
"""
if api_key is None:
api_key = os.environ.get("ORB_API_KEY")
Expand All @@ -99,6 +103,10 @@ def __init__(
)
self.api_key = api_key

if webhook_secret is None:
webhook_secret = os.environ.get("ORB_WEBHOOK_SECRET")
self.webhook_secret = webhook_secret

if base_url is None:
base_url = os.environ.get("ORB_BASE_URL")
if base_url is None:
Expand Down Expand Up @@ -157,6 +165,7 @@ def copy(
self,
*,
api_key: str | None = None,
webhook_secret: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
http_client: httpx.Client | None = None,
Expand Down Expand Up @@ -191,6 +200,7 @@ def copy(
http_client = http_client or self._client
return self.__class__(
api_key=api_key or self.api_key,
webhook_secret=webhook_secret or self.webhook_secret,
base_url=base_url or self.base_url,
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
http_client=http_client,
Expand Down Expand Up @@ -305,11 +315,13 @@ class AsyncOrb(AsyncAPIClient):

# client options
api_key: str
webhook_secret: str | None

def __init__(
self,
*,
api_key: str | None = None,
webhook_secret: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
max_retries: int = DEFAULT_MAX_RETRIES,
Expand All @@ -329,7 +341,9 @@ def __init__(
) -> None:
"""Construct a new async orb client instance.

This automatically infers the `api_key` argument from the `ORB_API_KEY` environment variable if it is not provided.
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
- `api_key` from `ORB_API_KEY`
- `webhook_secret` from `ORB_WEBHOOK_SECRET`
"""
if api_key is None:
api_key = os.environ.get("ORB_API_KEY")
Expand All @@ -339,6 +353,10 @@ def __init__(
)
self.api_key = api_key

if webhook_secret is None:
webhook_secret = os.environ.get("ORB_WEBHOOK_SECRET")
self.webhook_secret = webhook_secret

if base_url is None:
base_url = os.environ.get("ORB_BASE_URL")
if base_url is None:
Expand Down Expand Up @@ -397,6 +415,7 @@ def copy(
self,
*,
api_key: str | None = None,
webhook_secret: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
http_client: httpx.AsyncClient | None = None,
Expand Down Expand Up @@ -431,6 +450,7 @@ def copy(
http_client = http_client or self._client
return self.__class__(
api_key=api_key or self.api_key,
webhook_secret=webhook_secret or self.webhook_secret,
base_url=base_url or self.base_url,
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
http_client=http_client,
Expand Down