Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
timeout-minutes: 10
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/prelude-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
steps:
- uses: actions/checkout@v6

Expand All @@ -38,7 +38,7 @@ jobs:
run: ./scripts/lint

build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
timeout-minutes: 10
name: build
permissions:
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.11.0"
".": "0.12.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 19
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/prelude%2Fprelude-c9124c257dd54dd0728cb57306b9082007439bfefac11642542605edb3e7606d.yml
openapi_spec_hash: 61dc64cc814d10975a8825ec88fd9c1c
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/prelude%2Fprelude-91198c43ae28a64921f9740a0708e878ebdc14777a5b29d55b7948c927fc2866.yml
openapi_spec_hash: c6cf7647a39bb0feb15b937f73e69eba
config_hash: 107ae5754168e80c4ad2cd779a75bc36
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Changelog

## 0.12.0 (2026-04-10)

Full Changelog: [v0.11.0...v0.12.0](https://github.com/prelude-so/python-sdk/compare/v0.11.0...v0.12.0)

### Features

* **api:** api update ([90730f2](https://github.com/prelude-so/python-sdk/commit/90730f2450572b41201c0a14b3c7fcaf9630061e))
* **internal:** implement indices array format for query and form serialization ([437e308](https://github.com/prelude-so/python-sdk/commit/437e30885b2ac87a05b9939b907e74bb70466fe3))


### Bug Fixes

* **client:** preserve hardcoded query params when merging with user params ([666864b](https://github.com/prelude-so/python-sdk/commit/666864b1a2c85449206dbb817a3411a6ab6f6b5d))
* ensure file data are only sent as 1 parameter ([b9c71b4](https://github.com/prelude-so/python-sdk/commit/b9c71b448298e2be4a6f73bb8a35516f89ed3d63))


### Chores

* **ci:** skip lint on metadata-only changes ([4dadcbb](https://github.com/prelude-so/python-sdk/commit/4dadcbbfbef3b9174c33611f01af1c9f954bc82c))
* **tests:** bump steady to v0.19.6 ([8c37a2c](https://github.com/prelude-so/python-sdk/commit/8c37a2c11e843b0134aeba5ea0e49df5dd21292c))
* **tests:** bump steady to v0.19.7 ([20ad4f4](https://github.com/prelude-so/python-sdk/commit/20ad4f44a65807c4ff84961e8fe6ef507f39f3e6))
* **tests:** bump steady to v0.20.1 ([31e19fa](https://github.com/prelude-so/python-sdk/commit/31e19fab13431abe6fab56177a0e6f2aba05300a))
* **tests:** bump steady to v0.20.2 ([584457f](https://github.com/prelude-so/python-sdk/commit/584457f3077406dedfaeb17f3b3c0cc8150d6ed2))

## 0.11.0 (2026-03-23)

Full Changelog: [v0.10.0...v0.11.0](https://github.com/prelude-so/python-sdk/compare/v0.10.0...v0.11.0)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "prelude-python-sdk"
version = "0.11.0"
version = "0.12.0"
description = "The official Python library for the Prelude API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
6 changes: 3 additions & 3 deletions scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}"
# Run steady mock on the given spec
if [ "$1" == "--daemon" ]; then
# Pre-install the package so the download doesn't eat into the startup timeout
npm exec --package=@stdy/cli@0.19.5 -- steady --version
npm exec --package=@stdy/cli@0.20.2 -- steady --version

npm exec --package=@stdy/cli@0.19.5 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=comma --validator-query-array-format=comma --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log &
npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log &

# Wait for server to come online via health endpoint (max 30s)
echo -n "Waiting for server"
Expand All @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then

echo
else
npm exec --package=@stdy/cli@0.19.5 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=comma --validator-query-array-format=comma --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL"
npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL"
fi
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ elif ! steady_is_running ; then
echo -e "To run the server, pass in the path or url of your OpenAPI"
echo -e "spec to the steady command:"
echo
echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.5 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=comma --validator-query-array-format=comma --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}"
echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.2 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}"
echo

exit 1
Expand Down
4 changes: 4 additions & 0 deletions src/prelude_python_sdk/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,10 @@ def _build_request(
files = cast(HttpxRequestFiles, ForceMultipartDict())

prepared_url = self._prepare_url(options.url)
# preserve hard-coded query params from the url
if params and prepared_url.query:
params = {**dict(prepared_url.params.items()), **params}
prepared_url = prepared_url.copy_with(raw_path=prepared_url.raw_path.split(b"?", 1)[0])
if "_" in prepared_url.host:
# work around https://github.com/encode/httpx/discussions/2880
kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")}
Expand Down
5 changes: 4 additions & 1 deletion src/prelude_python_sdk/_qs.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ def _stringify_item(
items.extend(self._stringify_item(key, item, opts))
return items
elif array_format == "indices":
raise NotImplementedError("The array indices format is not supported yet")
items = []
for i, item in enumerate(value):
items.extend(self._stringify_item(f"{key}[{i}]", item, opts))
return items
elif array_format == "brackets":
items = []
key = key + "[]"
Expand Down
5 changes: 3 additions & 2 deletions src/prelude_python_sdk/_utils/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ def _extract_items(
index += 1
if is_dict(obj):
try:
# We are at the last entry in the path so we must remove the field
if (len(path)) == index:
# Remove the field if there are no more dict keys in the path,
# only "<array>" traversal markers or end.
if all(p == "<array>" for p in path[index:]):
item = obj.pop(key)
else:
item = obj[key]
Expand Down
2 changes: 1 addition & 1 deletion src/prelude_python_sdk/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "prelude_python_sdk"
__version__ = "0.11.0" # x-release-please-version
__version__ = "0.12.0" # x-release-please-version
16 changes: 8 additions & 8 deletions src/prelude_python_sdk/resources/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def send(
expires_at: Union[str, datetime] | Omit = omit,
from_: str | Omit = omit,
locale: str | Omit = omit,
preferred_channel: Literal["sms", "whatsapp"] | Omit = omit,
preferred_channel: Literal["sms", "rcs", "whatsapp"] | Omit = omit,
schedule_at: Union[str, datetime] | Omit = omit,
variables: Dict[str, str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand All @@ -322,8 +322,8 @@ def send(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> NotifySendResponse:
"""
Send transactional and marketing messages to your users via SMS and WhatsApp
with automatic compliance enforcement.
Send transactional and marketing messages to your users via SMS, RCS and
WhatsApp with automatic compliance enforcement.

Args:
template_id: The template identifier configured by your Customer Success team.
Expand Down Expand Up @@ -401,7 +401,7 @@ def send_batch(
expires_at: Union[str, datetime] | Omit = omit,
from_: str | Omit = omit,
locale: str | Omit = omit,
preferred_channel: Literal["sms", "whatsapp"] | Omit = omit,
preferred_channel: Literal["sms", "rcs", "whatsapp"] | Omit = omit,
schedule_at: Union[str, datetime] | Omit = omit,
variables: Dict[str, str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand Down Expand Up @@ -745,7 +745,7 @@ async def send(
expires_at: Union[str, datetime] | Omit = omit,
from_: str | Omit = omit,
locale: str | Omit = omit,
preferred_channel: Literal["sms", "whatsapp"] | Omit = omit,
preferred_channel: Literal["sms", "rcs", "whatsapp"] | Omit = omit,
schedule_at: Union[str, datetime] | Omit = omit,
variables: Dict[str, str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand All @@ -756,8 +756,8 @@ async def send(
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> NotifySendResponse:
"""
Send transactional and marketing messages to your users via SMS and WhatsApp
with automatic compliance enforcement.
Send transactional and marketing messages to your users via SMS, RCS and
WhatsApp with automatic compliance enforcement.

Args:
template_id: The template identifier configured by your Customer Success team.
Expand Down Expand Up @@ -835,7 +835,7 @@ async def send_batch(
expires_at: Union[str, datetime] | Omit = omit,
from_: str | Omit = omit,
locale: str | Omit = omit,
preferred_channel: Literal["sms", "whatsapp"] | Omit = omit,
preferred_channel: Literal["sms", "rcs", "whatsapp"] | Omit = omit,
schedule_at: Union[str, datetime] | Omit = omit,
variables: Dict[str, str] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand Down
2 changes: 1 addition & 1 deletion src/prelude_python_sdk/types/notify_send_batch_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class NotifySendBatchParams(TypedDict, total=False):
locale: str
"""A BCP-47 formatted locale string."""

preferred_channel: Literal["sms", "whatsapp"]
preferred_channel: Literal["sms", "rcs", "whatsapp"]
"""Preferred channel for delivery. If unavailable, automatic fallback applies."""

schedule_at: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]
Expand Down
2 changes: 1 addition & 1 deletion src/prelude_python_sdk/types/notify_send_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class NotifySendParams(TypedDict, total=False):
set on the template will be used.
"""

preferred_channel: Literal["sms", "whatsapp"]
preferred_channel: Literal["sms", "rcs", "whatsapp"]
"""The preferred channel to be used in priority for message delivery.

If the channel is unavailable, the system will fallback to other available
Expand Down
48 changes: 48 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,30 @@ def test_default_query_option(self) -> None:

client.close()

def test_hardcoded_query_params_in_url(self, client: Prelude) -> None:
request = client._build_request(FinalRequestOptions(method="get", url="/foo?beta=true"))
url = httpx.URL(request.url)
assert dict(url.params) == {"beta": "true"}

request = client._build_request(
FinalRequestOptions(
method="get",
url="/foo?beta=true",
params={"limit": "10", "page": "abc"},
)
)
url = httpx.URL(request.url)
assert dict(url.params) == {"beta": "true", "limit": "10", "page": "abc"}

request = client._build_request(
FinalRequestOptions(
method="get",
url="/files/a%2Fb?beta=true",
params={"limit": "10"},
)
)
assert request.url.raw_path == b"/files/a%2Fb?beta=true&limit=10"

def test_request_extra_json(self, client: Prelude) -> None:
request = client._build_request(
FinalRequestOptions(
Expand Down Expand Up @@ -1363,6 +1387,30 @@ async def test_default_query_option(self) -> None:

await client.close()

async def test_hardcoded_query_params_in_url(self, async_client: AsyncPrelude) -> None:
request = async_client._build_request(FinalRequestOptions(method="get", url="/foo?beta=true"))
url = httpx.URL(request.url)
assert dict(url.params) == {"beta": "true"}

request = async_client._build_request(
FinalRequestOptions(
method="get",
url="/foo?beta=true",
params={"limit": "10", "page": "abc"},
)
)
url = httpx.URL(request.url)
assert dict(url.params) == {"beta": "true", "limit": "10", "page": "abc"}

request = async_client._build_request(
FinalRequestOptions(
method="get",
url="/files/a%2Fb?beta=true",
params={"limit": "10"},
)
)
assert request.url.raw_path == b"/files/a%2Fb?beta=true&limit=10"

def test_request_extra_json(self, client: Prelude) -> None:
request = client._build_request(
FinalRequestOptions(
Expand Down
9 changes: 9 additions & 0 deletions tests/test_extract_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ def test_multiple_files() -> None:
assert query == {"documents": [{}, {}]}


def test_top_level_file_array() -> None:
query = {"files": [b"file one", b"file two"], "title": "hello"}
assert extract_files(query, paths=[["files", "<array>"]]) == [
("files[]", b"file one"),
("files[]", b"file two"),
]
assert query == {"title": "hello"}


@pytest.mark.parametrize(
"query,paths,expected",
[
Expand Down