From ad870fb8a30f20b4193f7eed5a96755a9a656228 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 Apr 2026 17:33:57 +0000 Subject: [PATCH 01/14] perf(client): optimize file structure copying in multipart requests --- src/postgrid/_files.py | 56 ++++++++++++++++++- src/postgrid/_utils/__init__.py | 1 - src/postgrid/_utils/_utils.py | 15 ----- tests/test_deepcopy.py | 58 ------------------- tests/test_files.py | 99 ++++++++++++++++++++++++++++++++- 5 files changed, 151 insertions(+), 78 deletions(-) delete mode 100644 tests/test_deepcopy.py diff --git a/src/postgrid/_files.py b/src/postgrid/_files.py index cc14c14..0fdce17 100644 --- a/src/postgrid/_files.py +++ b/src/postgrid/_files.py @@ -3,8 +3,8 @@ import io import os import pathlib -from typing import overload -from typing_extensions import TypeGuard +from typing import Sequence, cast, overload +from typing_extensions import TypeVar, TypeGuard import anyio @@ -17,7 +17,9 @@ HttpxFileContent, HttpxRequestFiles, ) -from ._utils import is_tuple_t, is_mapping_t, is_sequence_t +from ._utils import is_list, is_mapping, is_tuple_t, is_mapping_t, is_sequence_t + +_T = TypeVar("_T") def is_base64_file_input(obj: object) -> TypeGuard[Base64FileInput]: @@ -121,3 +123,51 @@ async def async_read_file_content(file: FileContent) -> HttpxFileContent: return await anyio.Path(file).read_bytes() return file + + +def deepcopy_with_paths(item: _T, paths: Sequence[Sequence[str]]) -> _T: + """Copy only the containers along the given paths. + + Used to guard against mutation by extract_files without copying the entire structure. + Only dicts and lists that lie on a path are copied; everything else + is returned by reference. + + For example, given paths=[["foo", "files", "file"]] and the structure: + { + "foo": { + "bar": {"baz": {}}, + "files": {"file": } + } + } + The root dict, "foo", and "files" are copied (they lie on the path). + "bar" and "baz" are returned by reference (off the path). + """ + return _deepcopy_with_paths(item, paths, 0) + + +def _deepcopy_with_paths(item: _T, paths: Sequence[Sequence[str]], index: int) -> _T: + if not paths: + return item + if is_mapping(item): + key_to_paths: dict[str, list[Sequence[str]]] = {} + for path in paths: + if index < len(path): + key_to_paths.setdefault(path[index], []).append(path) + + # if no path continues through this mapping, it won't be mutated and copying it is redundant + if not key_to_paths: + return item + + result = dict(item) + for key, subpaths in key_to_paths.items(): + if key in result: + result[key] = _deepcopy_with_paths(result[key], subpaths, index + 1) + return cast(_T, result) + if is_list(item): + array_paths = [path for path in paths if index < len(path) and path[index] == ""] + + # if no path expects a list here, nothing will be mutated inside it - return by reference + if not array_paths: + return cast(_T, item) + return cast(_T, [_deepcopy_with_paths(entry, array_paths, index + 1) for entry in item]) + return item diff --git a/src/postgrid/_utils/__init__.py b/src/postgrid/_utils/__init__.py index 10cb66d..1c090e5 100644 --- a/src/postgrid/_utils/__init__.py +++ b/src/postgrid/_utils/__init__.py @@ -24,7 +24,6 @@ coerce_integer as coerce_integer, file_from_path as file_from_path, strip_not_given as strip_not_given, - deepcopy_minimal as deepcopy_minimal, get_async_library as get_async_library, maybe_coerce_float as maybe_coerce_float, get_required_header as get_required_header, diff --git a/src/postgrid/_utils/_utils.py b/src/postgrid/_utils/_utils.py index 63b8cd6..771859f 100644 --- a/src/postgrid/_utils/_utils.py +++ b/src/postgrid/_utils/_utils.py @@ -177,21 +177,6 @@ def is_iterable(obj: object) -> TypeGuard[Iterable[object]]: return isinstance(obj, Iterable) -def deepcopy_minimal(item: _T) -> _T: - """Minimal reimplementation of copy.deepcopy() that will only copy certain object types: - - - mappings, e.g. `dict` - - list - - This is done for performance reasons. - """ - if is_mapping(item): - return cast(_T, {k: deepcopy_minimal(v) for k, v in item.items()}) - if is_list(item): - return cast(_T, [deepcopy_minimal(entry) for entry in item]) - return item - - # copied from https://github.com/Rapptz/RoboDanny def human_join(seq: Sequence[str], *, delim: str = ", ", final: str = "or") -> str: size = len(seq) diff --git a/tests/test_deepcopy.py b/tests/test_deepcopy.py deleted file mode 100644 index c6a9dd0..0000000 --- a/tests/test_deepcopy.py +++ /dev/null @@ -1,58 +0,0 @@ -from postgrid._utils import deepcopy_minimal - - -def assert_different_identities(obj1: object, obj2: object) -> None: - assert obj1 == obj2 - assert id(obj1) != id(obj2) - - -def test_simple_dict() -> None: - obj1 = {"foo": "bar"} - obj2 = deepcopy_minimal(obj1) - assert_different_identities(obj1, obj2) - - -def test_nested_dict() -> None: - obj1 = {"foo": {"bar": True}} - obj2 = deepcopy_minimal(obj1) - assert_different_identities(obj1, obj2) - assert_different_identities(obj1["foo"], obj2["foo"]) - - -def test_complex_nested_dict() -> None: - obj1 = {"foo": {"bar": [{"hello": "world"}]}} - obj2 = deepcopy_minimal(obj1) - assert_different_identities(obj1, obj2) - assert_different_identities(obj1["foo"], obj2["foo"]) - assert_different_identities(obj1["foo"]["bar"], obj2["foo"]["bar"]) - assert_different_identities(obj1["foo"]["bar"][0], obj2["foo"]["bar"][0]) - - -def test_simple_list() -> None: - obj1 = ["a", "b", "c"] - obj2 = deepcopy_minimal(obj1) - assert_different_identities(obj1, obj2) - - -def test_nested_list() -> None: - obj1 = ["a", [1, 2, 3]] - obj2 = deepcopy_minimal(obj1) - assert_different_identities(obj1, obj2) - assert_different_identities(obj1[1], obj2[1]) - - -class MyObject: ... - - -def test_ignores_other_types() -> None: - # custom classes - my_obj = MyObject() - obj1 = {"foo": my_obj} - obj2 = deepcopy_minimal(obj1) - assert_different_identities(obj1, obj2) - assert obj1["foo"] is my_obj - - # tuples - obj3 = ("a", "b") - obj4 = deepcopy_minimal(obj3) - assert obj3 is obj4 diff --git a/tests/test_files.py b/tests/test_files.py index d2a877a..5cfa36e 100644 --- a/tests/test_files.py +++ b/tests/test_files.py @@ -4,7 +4,8 @@ import pytest from dirty_equals import IsDict, IsList, IsBytes, IsTuple -from postgrid._files import to_httpx_files, async_to_httpx_files +from postgrid._files import to_httpx_files, deepcopy_with_paths, async_to_httpx_files +from postgrid._utils import extract_files readme_path = Path(__file__).parent.parent.joinpath("README.md") @@ -49,3 +50,99 @@ def test_string_not_allowed() -> None: "file": "foo", # type: ignore } ) + + +def assert_different_identities(obj1: object, obj2: object) -> None: + assert obj1 == obj2 + assert obj1 is not obj2 + + +class TestDeepcopyWithPaths: + def test_copies_top_level_dict(self) -> None: + original = {"file": b"data", "other": "value"} + result = deepcopy_with_paths(original, [["file"]]) + assert_different_identities(result, original) + + def test_file_value_is_same_reference(self) -> None: + file_bytes = b"contents" + original = {"file": file_bytes} + result = deepcopy_with_paths(original, [["file"]]) + assert_different_identities(result, original) + assert result["file"] is file_bytes + + def test_list_popped_wholesale(self) -> None: + files = [b"f1", b"f2"] + original = {"files": files, "title": "t"} + result = deepcopy_with_paths(original, [["files", ""]]) + assert_different_identities(result, original) + result_files = result["files"] + assert isinstance(result_files, list) + assert_different_identities(result_files, files) + + def test_nested_array_path_copies_list_and_elements(self) -> None: + elem1 = {"file": b"f1", "extra": 1} + elem2 = {"file": b"f2", "extra": 2} + original = {"items": [elem1, elem2]} + result = deepcopy_with_paths(original, [["items", "", "file"]]) + assert_different_identities(result, original) + result_items = result["items"] + assert isinstance(result_items, list) + assert_different_identities(result_items, original["items"]) + assert_different_identities(result_items[0], elem1) + assert_different_identities(result_items[1], elem2) + + def test_empty_paths_returns_same_object(self) -> None: + original = {"foo": "bar"} + result = deepcopy_with_paths(original, []) + assert result is original + + def test_multiple_paths(self) -> None: + f1 = b"file1" + f2 = b"file2" + original = {"a": f1, "b": f2, "c": "unchanged"} + result = deepcopy_with_paths(original, [["a"], ["b"]]) + assert_different_identities(result, original) + assert result["a"] is f1 + assert result["b"] is f2 + assert result["c"] is original["c"] + + def test_extract_files_does_not_mutate_original_top_level(self) -> None: + file_bytes = b"contents" + original = {"file": file_bytes, "other": "value"} + + copied = deepcopy_with_paths(original, [["file"]]) + extracted = extract_files(copied, paths=[["file"]]) + + assert extracted == [("file", file_bytes)] + assert original == {"file": file_bytes, "other": "value"} + assert copied == {"other": "value"} + + def test_extract_files_does_not_mutate_original_nested_array_path(self) -> None: + file1 = b"f1" + file2 = b"f2" + original = { + "items": [ + {"file": file1, "extra": 1}, + {"file": file2, "extra": 2}, + ], + "title": "example", + } + + copied = deepcopy_with_paths(original, [["items", "", "file"]]) + extracted = extract_files(copied, paths=[["items", "", "file"]]) + + assert extracted == [("items[][file]", file1), ("items[][file]", file2)] + assert original == { + "items": [ + {"file": file1, "extra": 1}, + {"file": file2, "extra": 2}, + ], + "title": "example", + } + assert copied == { + "items": [ + {"extra": 1}, + {"extra": 2}, + ], + "title": "example", + } From e3ae21534f0e6048dd59631aa02c04d5c1f3a681 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 22 Apr 2026 13:53:59 +0000 Subject: [PATCH 02/14] chore(internal): more robust bootstrap script --- scripts/bootstrap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/bootstrap b/scripts/bootstrap index b430fee..fe8451e 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,7 +4,7 @@ set -e cd "$(dirname "$0")/.." -if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "${SKIP_BREW:-}" != "1" ] && [ -t 0 ]; then brew bundle check >/dev/null 2>&1 || { echo -n "==> Install Homebrew dependencies? (y/N): " read -r response From 4662cc7a36251fb808df1ac04ee5bbecfeaf9ebb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 Apr 2026 14:59:34 +0000 Subject: [PATCH 03/14] fix: use correct field name format for multipart file arrays --- src/postgrid/_qs.py | 8 ++----- src/postgrid/_types.py | 3 +++ src/postgrid/_utils/_utils.py | 42 ++++++++++++++++++++++++++++------- tests/test_extract_files.py | 28 ++++++++++++++++++----- tests/test_files.py | 2 +- 5 files changed, 63 insertions(+), 20 deletions(-) diff --git a/src/postgrid/_qs.py b/src/postgrid/_qs.py index de8c99b..4127c19 100644 --- a/src/postgrid/_qs.py +++ b/src/postgrid/_qs.py @@ -2,17 +2,13 @@ from typing import Any, List, Tuple, Union, Mapping, TypeVar from urllib.parse import parse_qs, urlencode -from typing_extensions import Literal, get_args +from typing_extensions import get_args -from ._types import NotGiven, not_given +from ._types import NotGiven, ArrayFormat, NestedFormat, not_given from ._utils import flatten _T = TypeVar("_T") - -ArrayFormat = Literal["comma", "repeat", "indices", "brackets"] -NestedFormat = Literal["dots", "brackets"] - PrimitiveData = Union[str, int, float, bool, None] # this should be Data = Union[PrimitiveData, "List[Data]", "Tuple[Data]", "Mapping[str, Data]"] # https://github.com/microsoft/pyright/issues/3555 diff --git a/src/postgrid/_types.py b/src/postgrid/_types.py index ce5c982..f7f9a7c 100644 --- a/src/postgrid/_types.py +++ b/src/postgrid/_types.py @@ -47,6 +47,9 @@ ModelT = TypeVar("ModelT", bound=pydantic.BaseModel) _T = TypeVar("_T") +ArrayFormat = Literal["comma", "repeat", "indices", "brackets"] +NestedFormat = Literal["dots", "brackets"] + # Approximates httpx internal ProxiesTypes and RequestFiles types # while adding support for `PathLike` instances diff --git a/src/postgrid/_utils/_utils.py b/src/postgrid/_utils/_utils.py index 771859f..199cd23 100644 --- a/src/postgrid/_utils/_utils.py +++ b/src/postgrid/_utils/_utils.py @@ -17,11 +17,11 @@ ) from pathlib import Path from datetime import date, datetime -from typing_extensions import TypeGuard +from typing_extensions import TypeGuard, get_args import sniffio -from .._types import Omit, NotGiven, FileTypes, HeadersLike +from .._types import Omit, NotGiven, FileTypes, ArrayFormat, HeadersLike _T = TypeVar("_T") _TupleT = TypeVar("_TupleT", bound=Tuple[object, ...]) @@ -40,25 +40,45 @@ def extract_files( query: Mapping[str, object], *, paths: Sequence[Sequence[str]], + array_format: ArrayFormat = "brackets", ) -> list[tuple[str, FileTypes]]: """Recursively extract files from the given dictionary based on specified paths. A path may look like this ['foo', 'files', '', 'data']. + ``array_format`` controls how ```` segments contribute to the emitted + field name. Supported values: ``"brackets"`` (``foo[]``), ``"repeat"`` and + ``"comma"`` (``foo``), ``"indices"`` (``foo[0]``, ``foo[1]``). + Note: this mutates the given dictionary. """ files: list[tuple[str, FileTypes]] = [] for path in paths: - files.extend(_extract_items(query, path, index=0, flattened_key=None)) + files.extend(_extract_items(query, path, index=0, flattened_key=None, array_format=array_format)) return files +def _array_suffix(array_format: ArrayFormat, array_index: int) -> str: + if array_format == "brackets": + return "[]" + if array_format == "indices": + return f"[{array_index}]" + if array_format == "repeat" or array_format == "comma": + # Both repeat the bare field name for each file part; there is no + # meaningful way to comma-join binary parts. + return "" + raise NotImplementedError( + f"Unknown array_format value: {array_format}, choose from {', '.join(get_args(ArrayFormat))}" + ) + + def _extract_items( obj: object, path: Sequence[str], *, index: int, flattened_key: str | None, + array_format: ArrayFormat, ) -> list[tuple[str, FileTypes]]: try: key = path[index] @@ -75,9 +95,11 @@ def _extract_items( if is_list(obj): files: list[tuple[str, FileTypes]] = [] - for entry in obj: - assert_is_file_content(entry, key=flattened_key + "[]" if flattened_key else "") - files.append((flattened_key + "[]", cast(FileTypes, entry))) + for array_index, entry in enumerate(obj): + suffix = _array_suffix(array_format, array_index) + emitted_key = (flattened_key + suffix) if flattened_key else suffix + assert_is_file_content(entry, key=emitted_key) + files.append((emitted_key, cast(FileTypes, entry))) return files assert_is_file_content(obj, key=flattened_key) @@ -106,6 +128,7 @@ def _extract_items( path, index=index, flattened_key=flattened_key, + array_format=array_format, ) elif is_list(obj): if key != "": @@ -117,9 +140,12 @@ def _extract_items( item, path, index=index, - flattened_key=flattened_key + "[]" if flattened_key is not None else "[]", + flattened_key=( + (flattened_key if flattened_key is not None else "") + _array_suffix(array_format, array_index) + ), + array_format=array_format, ) - for item in obj + for array_index, item in enumerate(obj) ] ) diff --git a/tests/test_extract_files.py b/tests/test_extract_files.py index 8e51d51..57328c7 100644 --- a/tests/test_extract_files.py +++ b/tests/test_extract_files.py @@ -4,7 +4,7 @@ import pytest -from postgrid._types import FileTypes +from postgrid._types import FileTypes, ArrayFormat from postgrid._utils import extract_files @@ -37,10 +37,7 @@ def test_multiple_files() -> None: def test_top_level_file_array() -> None: query = {"files": [b"file one", b"file two"], "title": "hello"} - assert extract_files(query, paths=[["files", ""]]) == [ - ("files[]", b"file one"), - ("files[]", b"file two"), - ] + assert extract_files(query, paths=[["files", ""]]) == [("files[]", b"file one"), ("files[]", b"file two")] assert query == {"title": "hello"} @@ -71,3 +68,24 @@ def test_ignores_incorrect_paths( expected: list[tuple[str, FileTypes]], ) -> None: assert extract_files(query, paths=paths) == expected + + +@pytest.mark.parametrize( + "array_format,expected_top_level,expected_nested", + [ + ("brackets", [("files[]", b"a"), ("files[]", b"b")], [("items[][file]", b"a"), ("items[][file]", b"b")]), + ("repeat", [("files", b"a"), ("files", b"b")], [("items[file]", b"a"), ("items[file]", b"b")]), + ("comma", [("files", b"a"), ("files", b"b")], [("items[file]", b"a"), ("items[file]", b"b")]), + ("indices", [("files[0]", b"a"), ("files[1]", b"b")], [("items[0][file]", b"a"), ("items[1][file]", b"b")]), + ], +) +def test_array_format_controls_file_field_names( + array_format: ArrayFormat, + expected_top_level: list[tuple[str, FileTypes]], + expected_nested: list[tuple[str, FileTypes]], +) -> None: + top_level = {"files": [b"a", b"b"]} + assert extract_files(top_level, paths=[["files", ""]], array_format=array_format) == expected_top_level + + nested = {"items": [{"file": b"a"}, {"file": b"b"}]} + assert extract_files(nested, paths=[["items", "", "file"]], array_format=array_format) == expected_nested diff --git a/tests/test_files.py b/tests/test_files.py index 5cfa36e..638d710 100644 --- a/tests/test_files.py +++ b/tests/test_files.py @@ -131,7 +131,7 @@ def test_extract_files_does_not_mutate_original_nested_array_path(self) -> None: copied = deepcopy_with_paths(original, [["items", "", "file"]]) extracted = extract_files(copied, paths=[["items", "", "file"]]) - assert extracted == [("items[][file]", file1), ("items[][file]", file2)] + assert [entry for _, entry in extracted] == [file1, file2] assert original == { "items": [ {"file": file1, "extra": 1}, From e690d3eea529e14db8ef172128b126e9c62a0bfa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 Apr 2026 22:27:17 +0000 Subject: [PATCH 04/14] feat: support setting headers via env --- src/postgrid/_client.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/postgrid/_client.py b/src/postgrid/_client.py index 7e49893..873c587 100644 --- a/src/postgrid/_client.py +++ b/src/postgrid/_client.py @@ -20,7 +20,11 @@ RequestOptions, not_given, ) -from ._utils import is_given, get_async_library +from ._utils import ( + is_given, + is_mapping_t, + get_async_library, +) from ._compat import cached_property from ._version import __version__ from ._streaming import Stream as Stream, AsyncStream as AsyncStream @@ -100,6 +104,15 @@ def __init__( if base_url is None: base_url = f"https://api.postgrid.com" + custom_headers_env = os.environ.get("POSTGRID_CUSTOM_HEADERS") + if custom_headers_env is not None: + parsed: dict[str, str] = {} + for line in custom_headers_env.split("\n"): + colon = line.find(":") + if colon >= 0: + parsed[line[:colon].strip()] = line[colon + 1 :].strip() + default_headers = {**parsed, **(default_headers if is_mapping_t(default_headers) else {})} + super().__init__( version=__version__, base_url=base_url, @@ -340,6 +353,15 @@ def __init__( if base_url is None: base_url = f"https://api.postgrid.com" + custom_headers_env = os.environ.get("POSTGRID_CUSTOM_HEADERS") + if custom_headers_env is not None: + parsed: dict[str, str] = {} + for line in custom_headers_env.split("\n"): + colon = line.find(":") + if colon >= 0: + parsed[line[:colon].strip()] = line[colon + 1 :].strip() + default_headers = {**parsed, **(default_headers if is_mapping_t(default_headers) else {})} + super().__init__( version=__version__, base_url=base_url, From 1fb66ac5c7d32f9f3626db2050fd2e03a20b0c0f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 29 Apr 2026 18:13:39 +0000 Subject: [PATCH 05/14] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a7354cb..0c1784b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 87 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/postgrid%2Fpostgrid-be6a47768faf3612d1dc9c8a108edb10a6c5a4e52b78cc7f4768e1d497e11e08.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/postgrid/postgrid-be6a47768faf3612d1dc9c8a108edb10a6c5a4e52b78cc7f4768e1d497e11e08.yml openapi_spec_hash: a3ed2b74031c834a724b67db9ab6b23d config_hash: 3e6912e5fb40d06f5dc19a10e7b4e703 From 0b6570a2c45576abbc91d15fcd4688fe7ad057b2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Apr 2026 16:20:17 +0000 Subject: [PATCH 06/14] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 0c1784b..8e2eeca 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 87 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/postgrid/postgrid-be6a47768faf3612d1dc9c8a108edb10a6c5a4e52b78cc7f4768e1d497e11e08.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/postgrid/postgrid-7b1eb4f037a241a6da36421efadc20366ecdc885ee4e753b64321ec53327ca87.yml openapi_spec_hash: a3ed2b74031c834a724b67db9ab6b23d config_hash: 3e6912e5fb40d06f5dc19a10e7b4e703 From 872adb3468462b205c3619f1de65cf163f982ad3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 30 Apr 2026 20:56:52 +0000 Subject: [PATCH 07/14] chore(internal): reformat pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6f075c9..f7f9f94 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -168,7 +168,7 @@ show_error_codes = true # # We also exclude our `tests` as mypy doesn't always infer # types correctly and Pyright will still catch any type errors. -exclude = ['src/postgrid/_files.py', '_dev/.*.py', 'tests/.*'] +exclude = ["src/postgrid/_files.py", "_dev/.*.py", "tests/.*"] strict_equality = true implicit_reexport = true From e077d42c1fa32be25d6b458d0095c4a94a008ad1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 1 May 2026 02:55:44 +0000 Subject: [PATCH 08/14] feat(api): Generate OpenAPI spec from master, Complete AV endpoints, Deprecate order profiles --- .stats.yml | 8 +- api.md | 113 +- .../resources/address_verification.py | 1276 +++++++++++++++-- .../resources/intl_address_verification.py | 611 +++++++- src/postgrid/resources/print_mail/__init__.py | 14 - .../resources/print_mail/campaigns.py | 158 +- .../print_mail/order_profiles/__init__.py | 75 - .../print_mail/order_profiles/cheques.py | 942 ------------ .../print_mail/order_profiles/letters.py | 947 ------------ .../order_profiles/order_profiles.py | 366 ----- .../print_mail/order_profiles/postcards.py | 847 ----------- .../print_mail/order_profiles/self_mailers.py | 853 ----------- .../resources/print_mail/postcards.py | 46 +- .../resources/print_mail/print_mail.py | 104 -- .../resources/print_mail/self_mailers.py | 18 +- .../resources/print_mail/sub_organizations.py | 26 - src/postgrid/types/__init__.py | 69 + ...ddress_verification_autocomplete_params.py | 45 + ...ress_verification_autocomplete_response.py | 440 ++++++ ..._verification_batch_verification_params.py | 65 + ...erification_batch_verification_response.py | 294 ++++ ...cation_get_autocomplete_previews_params.py | 31 + ...tion_get_autocomplete_previews_response.py | 48 + ...s_verification_get_lookup_info_response.py | 29 + ...or_state_from_postal_or_zip_code_params.py | 13 + ..._state_from_postal_or_zip_code_response.py | 44 + ...okup_zip_code_from_city_or_state_params.py | 20 + ...up_zip_code_from_city_or_state_response.py | 22 + ...ss_verification_parse_an_address_params.py | 12 + ..._verification_parse_an_address_response.py | 68 + ...s_verification_suggest_addresses_params.py | 64 + ...verification_suggest_addresses_response.py | 278 ++++ .../address_verification_verify_response.py | 9 + src/postgrid/types/errors.py | 3 + ...ddress_verification_autocomplete_params.py | 21 + ...ress_verification_autocomplete_response.py | 289 ++++ ..._verification_batch_verification_params.py | 74 + ...erification_batch_verification_response.py | 248 ++++ ...t_autocomplete_advanced_previews_params.py | 35 + ...autocomplete_advanced_previews_response.py | 52 + ...cation_get_autocomplete_previews_params.py | 35 + ...tion_get_autocomplete_previews_response.py | 52 + src/postgrid/types/print_mail/campaign.py | 403 +++++- .../print_mail/campaign_create_params.py | 424 +++++- .../print_mail/campaign_update_params.py | 422 +++++- .../print_mail/order_profiles/__init__.py | 32 - .../order_profiles/cheque_create_params.py | 97 -- .../order_profiles/cheque_delete_response.py | 17 - .../order_profiles/cheque_list_params.py | 22 - .../order_profiles/cheque_list_response.py | 102 -- .../order_profiles/cheque_profile.py | 106 -- .../order_profiles/cheque_retrieve_params.py | 14 - .../order_profiles/cheque_update_params.py | 97 -- .../order_profiles/currency_code.py | 7 - .../order_profiles/letter_create_params.py | 91 -- .../order_profiles/letter_delete_response.py | 17 - .../order_profiles/letter_list_params.py | 22 - .../order_profiles/letter_profile.py | 100 -- .../order_profiles/letter_retrieve_params.py | 14 - .../order_profiles/letter_update_params.py | 87 -- .../order_profiles/postcard_create_params.py | 77 - .../postcard_delete_response.py | 17 - .../order_profiles/postcard_list_params.py | 22 - .../order_profiles/postcard_profile.py | 86 -- .../postcard_retrieve_params.py | 14 - .../order_profiles/postcard_size.py | 7 - .../order_profiles/postcard_update_params.py | 73 - .../self_mailer_create_params.py | 74 - .../self_mailer_delete_response.py | 17 - .../order_profiles/self_mailer_list_params.py | 22 - .../order_profiles/self_mailer_profile.py | 85 -- .../self_mailer_retrieve_params.py | 14 - .../order_profiles/self_mailer_size.py | 7 - .../self_mailer_update_params.py | 74 - src/postgrid/types/print_mail/postcard.py | 9 +- .../print_mail/postcard_create_params.py | 25 +- src/postgrid/types/print_mail/self_mailer.py | 3 +- .../print_mail/self_mailer_create_params.py | 7 +- .../print_mail/order_profiles/__init__.py | 1 - .../print_mail/order_profiles/test_cheques.py | 547 ------- .../print_mail/order_profiles/test_letters.py | 542 ------- .../order_profiles/test_postcards.py | 506 ------- .../order_profiles/test_self_mailers.py | 516 ------- .../print_mail/test_campaigns.py | 288 +++- .../print_mail/test_postcards.py | 6 + .../test_address_verification.py | 908 +++++++++++- .../test_intl_address_verification.py | 520 ++++++- 87 files changed, 7262 insertions(+), 8043 deletions(-) delete mode 100644 src/postgrid/resources/print_mail/order_profiles/__init__.py delete mode 100644 src/postgrid/resources/print_mail/order_profiles/cheques.py delete mode 100644 src/postgrid/resources/print_mail/order_profiles/letters.py delete mode 100644 src/postgrid/resources/print_mail/order_profiles/order_profiles.py delete mode 100644 src/postgrid/resources/print_mail/order_profiles/postcards.py delete mode 100644 src/postgrid/resources/print_mail/order_profiles/self_mailers.py create mode 100644 src/postgrid/types/address_verification_autocomplete_params.py create mode 100644 src/postgrid/types/address_verification_autocomplete_response.py create mode 100644 src/postgrid/types/address_verification_batch_verification_params.py create mode 100644 src/postgrid/types/address_verification_batch_verification_response.py create mode 100644 src/postgrid/types/address_verification_get_autocomplete_previews_params.py create mode 100644 src/postgrid/types/address_verification_get_autocomplete_previews_response.py create mode 100644 src/postgrid/types/address_verification_get_lookup_info_response.py create mode 100644 src/postgrid/types/address_verification_lookup_city_or_state_from_postal_or_zip_code_params.py create mode 100644 src/postgrid/types/address_verification_lookup_city_or_state_from_postal_or_zip_code_response.py create mode 100644 src/postgrid/types/address_verification_lookup_zip_code_from_city_or_state_params.py create mode 100644 src/postgrid/types/address_verification_lookup_zip_code_from_city_or_state_response.py create mode 100644 src/postgrid/types/address_verification_parse_an_address_params.py create mode 100644 src/postgrid/types/address_verification_parse_an_address_response.py create mode 100644 src/postgrid/types/address_verification_suggest_addresses_params.py create mode 100644 src/postgrid/types/address_verification_suggest_addresses_response.py create mode 100644 src/postgrid/types/intl_address_verification_autocomplete_params.py create mode 100644 src/postgrid/types/intl_address_verification_autocomplete_response.py create mode 100644 src/postgrid/types/intl_address_verification_batch_verification_params.py create mode 100644 src/postgrid/types/intl_address_verification_batch_verification_response.py create mode 100644 src/postgrid/types/intl_address_verification_get_autocomplete_advanced_previews_params.py create mode 100644 src/postgrid/types/intl_address_verification_get_autocomplete_advanced_previews_response.py create mode 100644 src/postgrid/types/intl_address_verification_get_autocomplete_previews_params.py create mode 100644 src/postgrid/types/intl_address_verification_get_autocomplete_previews_response.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/__init__.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/cheque_create_params.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/cheque_delete_response.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/cheque_list_params.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/cheque_list_response.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/cheque_profile.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/cheque_retrieve_params.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/cheque_update_params.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/currency_code.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/letter_create_params.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/letter_delete_response.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/letter_list_params.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/letter_profile.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/letter_retrieve_params.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/letter_update_params.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/postcard_create_params.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/postcard_delete_response.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/postcard_list_params.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/postcard_profile.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/postcard_retrieve_params.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/postcard_size.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/postcard_update_params.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/self_mailer_create_params.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/self_mailer_delete_response.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/self_mailer_list_params.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/self_mailer_profile.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/self_mailer_retrieve_params.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/self_mailer_size.py delete mode 100644 src/postgrid/types/print_mail/order_profiles/self_mailer_update_params.py delete mode 100644 tests/api_resources/print_mail/order_profiles/__init__.py delete mode 100644 tests/api_resources/print_mail/order_profiles/test_cheques.py delete mode 100644 tests/api_resources/print_mail/order_profiles/test_letters.py delete mode 100644 tests/api_resources/print_mail/order_profiles/test_postcards.py delete mode 100644 tests/api_resources/print_mail/order_profiles/test_self_mailers.py diff --git a/.stats.yml b/.stats.yml index 8e2eeca..641e7c9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 87 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/postgrid/postgrid-7b1eb4f037a241a6da36421efadc20366ecdc885ee4e753b64321ec53327ca87.yml -openapi_spec_hash: a3ed2b74031c834a724b67db9ab6b23d -config_hash: 3e6912e5fb40d06f5dc19a10e7b4e703 +configured_endpoints: 78 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/postgrid/postgrid-65072e2fb134f32ca48c7c05c1a03e5f78a8622c084a8b56b91a0e10955e02a8.yml +openapi_spec_hash: 6dc0a877bf8ec7526d6557d4b232a332 +config_hash: 2916502bb96c402e0d3d8c8c6e804206 diff --git a/api.md b/api.md index b315b61..b9f1bb5 100644 --- a/api.md +++ b/api.md @@ -3,11 +3,31 @@ Types: ```python -from postgrid.types import Errors, Status, AddressVerificationVerifyResponse +from postgrid.types import ( + Errors, + Status, + AddressVerificationAutocompleteResponse, + AddressVerificationBatchVerificationResponse, + AddressVerificationGetAutocompletePreviewsResponse, + AddressVerificationGetLookupInfoResponse, + AddressVerificationLookupCityOrStateFromPostalOrZipCodeResponse, + AddressVerificationLookupZipCodeFromCityOrStateResponse, + AddressVerificationParseAnAddressResponse, + AddressVerificationSuggestAddressesResponse, + AddressVerificationVerifyResponse, +) ``` Methods: +- client.address_verification.autocomplete(\*\*params) -> AddressVerificationAutocompleteResponse +- client.address_verification.batch_verification(\*\*params) -> AddressVerificationBatchVerificationResponse +- client.address_verification.get_autocomplete_previews(\*\*params) -> AddressVerificationGetAutocompletePreviewsResponse +- client.address_verification.get_lookup_info() -> AddressVerificationGetLookupInfoResponse +- client.address_verification.lookup_city_or_state_from_postal_or_zip_code(\*\*params) -> AddressVerificationLookupCityOrStateFromPostalOrZipCodeResponse +- client.address_verification.lookup_zip_code_from_city_or_state(\*\*params) -> AddressVerificationLookupZipCodeFromCityOrStateResponse +- client.address_verification.parse_an_address(\*\*params) -> AddressVerificationParseAnAddressResponse +- client.address_verification.suggest_addresses(\*\*params) -> AddressVerificationSuggestAddressesResponse - client.address_verification.verify(\*\*params) -> AddressVerificationVerifyResponse # IntlAddressVerification @@ -15,11 +35,21 @@ Methods: Types: ```python -from postgrid.types import IntlAddressVerificationVerifyResponse +from postgrid.types import ( + IntlAddressVerificationAutocompleteResponse, + IntlAddressVerificationBatchVerificationResponse, + IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse, + IntlAddressVerificationGetAutocompletePreviewsResponse, + IntlAddressVerificationVerifyResponse, +) ``` Methods: +- client.intl_address_verification.autocomplete(\*\*params) -> IntlAddressVerificationAutocompleteResponse +- client.intl_address_verification.batch_verification(\*\*params) -> IntlAddressVerificationBatchVerificationResponse +- client.intl_address_verification.get_autocomplete_advanced_previews(\*\*params) -> IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse +- client.intl_address_verification.get_autocomplete_previews(\*\*params) -> IntlAddressVerificationGetAutocompletePreviewsResponse - client.intl_address_verification.verify(\*\*params) -> IntlAddressVerificationVerifyResponse # PrintMail @@ -155,85 +185,6 @@ Methods: - client.print_mail.mailing_lists.delete(id) -> MailingListDeleteResponse - client.print_mail.mailing_lists.jobs(id, \*\*params) -> MailingList -## OrderProfiles - -### Cheques - -Types: - -```python -from postgrid.types.print_mail.order_profiles import ( - ChequeProfile, - CurrencyCode, - ChequeListResponse, - ChequeDeleteResponse, -) -``` - -Methods: - -- client.print_mail.order_profiles.cheques.create(\*\*params) -> ChequeProfile -- client.print_mail.order_profiles.cheques.retrieve(id, \*\*params) -> ChequeProfile -- client.print_mail.order_profiles.cheques.update(id, \*\*params) -> ChequeProfile -- client.print_mail.order_profiles.cheques.list(\*\*params) -> SyncSkipLimit[ChequeListResponse] -- client.print_mail.order_profiles.cheques.delete(id) -> ChequeDeleteResponse - -### Letters - -Types: - -```python -from postgrid.types.print_mail.order_profiles import LetterProfile, LetterDeleteResponse -``` - -Methods: - -- client.print_mail.order_profiles.letters.create(\*\*params) -> LetterProfile -- client.print_mail.order_profiles.letters.retrieve(id, \*\*params) -> LetterProfile -- client.print_mail.order_profiles.letters.update(id, \*\*params) -> LetterProfile -- client.print_mail.order_profiles.letters.list(\*\*params) -> SyncSkipLimit[LetterProfile] -- client.print_mail.order_profiles.letters.delete(id) -> LetterDeleteResponse - -### Postcards - -Types: - -```python -from postgrid.types.print_mail.order_profiles import ( - PostcardProfile, - PostcardSize, - PostcardDeleteResponse, -) -``` - -Methods: - -- client.print_mail.order_profiles.postcards.create(\*\*params) -> PostcardProfile -- client.print_mail.order_profiles.postcards.retrieve(id, \*\*params) -> PostcardProfile -- client.print_mail.order_profiles.postcards.update(id, \*\*params) -> PostcardProfile -- client.print_mail.order_profiles.postcards.list(\*\*params) -> SyncSkipLimit[PostcardProfile] -- client.print_mail.order_profiles.postcards.delete(id) -> PostcardDeleteResponse - -### SelfMailers - -Types: - -```python -from postgrid.types.print_mail.order_profiles import ( - SelfMailerProfile, - SelfMailerSize, - SelfMailerDeleteResponse, -) -``` - -Methods: - -- client.print_mail.order_profiles.self_mailers.create(\*\*params) -> SelfMailerProfile -- client.print_mail.order_profiles.self_mailers.retrieve(id, \*\*params) -> SelfMailerProfile -- client.print_mail.order_profiles.self_mailers.update(id, \*\*params) -> SelfMailerProfile -- client.print_mail.order_profiles.self_mailers.list(\*\*params) -> SyncSkipLimit[SelfMailerProfile] -- client.print_mail.order_profiles.self_mailers.delete(id) -> SelfMailerDeleteResponse - ## Postcards Types: diff --git a/src/postgrid/resources/address_verification.py b/src/postgrid/resources/address_verification.py index 99217dd..6e35ea1 100644 --- a/src/postgrid/resources/address_verification.py +++ b/src/postgrid/resources/address_verification.py @@ -2,11 +2,21 @@ from __future__ import annotations +from typing import Iterable from typing_extensions import overload import httpx -from ..types import address_verification_verify_params +from ..types import ( + address_verification_verify_params, + address_verification_autocomplete_params, + address_verification_parse_an_address_params, + address_verification_suggest_addresses_params, + address_verification_batch_verification_params, + address_verification_get_autocomplete_previews_params, + address_verification_lookup_zip_code_from_city_or_state_params, + address_verification_lookup_city_or_state_from_postal_or_zip_code_params, +) from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from .._utils import required_args, maybe_transform, async_maybe_transform from .._compat import cached_property @@ -19,40 +29,1076 @@ ) from .._base_client import make_request_options from ..types.address_verification_verify_response import AddressVerificationVerifyResponse +from ..types.address_verification_autocomplete_response import AddressVerificationAutocompleteResponse +from ..types.address_verification_get_lookup_info_response import AddressVerificationGetLookupInfoResponse +from ..types.address_verification_parse_an_address_response import AddressVerificationParseAnAddressResponse +from ..types.address_verification_suggest_addresses_response import AddressVerificationSuggestAddressesResponse +from ..types.address_verification_batch_verification_response import AddressVerificationBatchVerificationResponse +from ..types.address_verification_get_autocomplete_previews_response import ( + AddressVerificationGetAutocompletePreviewsResponse, +) +from ..types.address_verification_lookup_zip_code_from_city_or_state_response import ( + AddressVerificationLookupZipCodeFromCityOrStateResponse, +) +from ..types.address_verification_lookup_city_or_state_from_postal_or_zip_code_response import ( + AddressVerificationLookupCityOrStateFromPostalOrZipCodeResponse, +) + +__all__ = ["AddressVerificationResource", "AsyncAddressVerificationResource"] + + +class AddressVerificationResource(SyncAPIResource): + """Standard Address Verification API. + + Provides endpoints to verify and standardize addresses across US and Canada, + supporting both structured and freeform inputs. + + Note that this uses a different set of lookups than our international API. + """ + + @cached_property + def with_raw_response(self) -> AddressVerificationResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + """ + return AddressVerificationResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AddressVerificationResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + """ + return AddressVerificationResourceWithStreamingResponse(self) + + def autocomplete( + self, + *, + partial_street: str, + filter_exact: bool | Omit = omit, + geocode: bool | Omit = omit, + include_details: bool | Omit = omit, + index: int | Omit = omit, + limit: int | Omit = omit, + proper_case: bool | Omit = omit, + query_verified_only: bool | Omit = omit, + verify: bool | Omit = omit, + city_filter: str | Omit = omit, + country_filter: str | Omit = omit, + pc_filter: str | Omit = omit, + state_filter: str | Omit = omit, + body_verified_only: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationAutocompleteResponse: + """ + Resolves a partial street address into a list of full address candidates, + optionally selecting a specific candidate by index and verifying it. + + **Basic usage** — omit `index`: returns an array of `CompletedAddressItem` + results for the given `partialStreet`. + + **With `index`** — specify `index` to resolve a single candidate. Returns a + single `CompletedAddressItem`. + + **With `index` + `verify=true`** — additionally runs the selected address + through the USPS/Canada Post verifier and returns a `StandardVerifiedAddress`. + + - Uses 1 lookup per call (plus 1 more if geocoding a result). + + Args: + partial_street: The partial street address to complete (e.g. `"22 Bay"`). + + city_filter: Filter results to a specific city. + + country_filter: Filter results to a specific country code. + + pc_filter: Filter results to a specific postal code prefix. + + state_filter: Filter results to a specific state or province abbreviation. + + body_verified_only: If true, only return addresses that passed USPS/Canada Post verification. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/v1/addver/completions", + body=maybe_transform( + { + "partial_street": partial_street, + "city_filter": city_filter, + "country_filter": country_filter, + "pc_filter": pc_filter, + "state_filter": state_filter, + "body_verified_only": body_verified_only, + }, + address_verification_autocomplete_params.AddressVerificationAutocompleteParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "filter_exact": filter_exact, + "geocode": geocode, + "include_details": include_details, + "index": index, + "limit": limit, + "proper_case": proper_case, + "query_verified_only": query_verified_only, + "verify": verify, + }, + address_verification_autocomplete_params.AddressVerificationAutocompleteParams, + ), + ), + cast_to=AddressVerificationAutocompleteResponse, + ) + + def batch_verification( + self, + *, + addresses: Iterable[address_verification_batch_verification_params.Address], + geocode: bool | Omit = omit, + include_details: bool | Omit = omit, + proper_case: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationBatchVerificationResponse: + """Verify a batch of US or Canadian addresses in a single request. + + Each address can + be freeform or structured, matching the same input formats accepted by the + single verification endpoint. + + - Uses 1 lookup per address (plus 1 more per address if geocoding). + - Requires a secret API key. + - Returns results in the same order as the input addresses. + - If an individual address fails, its result will contain an `error` field + rather than a `verifiedAddress`. + + Args: + addresses: Array of addresses to verify. Each item can be a freeform string or structured + address object. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/v1/addver/verifications/batch", + body=maybe_transform( + {"addresses": addresses}, + address_verification_batch_verification_params.AddressVerificationBatchVerificationParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "geocode": geocode, + "include_details": include_details, + "proper_case": proper_case, + }, + address_verification_batch_verification_params.AddressVerificationBatchVerificationParams, + ), + ), + cast_to=AddressVerificationBatchVerificationResponse, + ) + + def get_autocomplete_previews( + self, + *, + partial_street: str, + city_filter: str | Omit = omit, + country_filter: str | Omit = omit, + filter_exact: bool | Omit = omit, + limit: int | Omit = omit, + pc_filter: str | Omit = omit, + proper_case: bool | Omit = omit, + prov_instead_of_pc: bool | Omit = omit, + state_filter: str | Omit = omit, + verified_only: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationGetAutocompletePreviewsResponse: + """ + Returns address completion previews for a partial street address, suitable for + populating an autocomplete dropdown without consuming a lookup per keystroke. + + Each result contains a partial address preview (street, city, and — for non-US + addresses — only the first 3 digits of the postal code, to avoid revealing the + full code before a lookup is charged). + + - Does not consume a lookup. + - Use `POST /completions` to resolve a full address once the user selects a + result. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + "/v1/addver/completions", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "partial_street": partial_street, + "city_filter": city_filter, + "country_filter": country_filter, + "filter_exact": filter_exact, + "limit": limit, + "pc_filter": pc_filter, + "proper_case": proper_case, + "prov_instead_of_pc": prov_instead_of_pc, + "state_filter": state_filter, + "verified_only": verified_only, + }, + address_verification_get_autocomplete_previews_params.AddressVerificationGetAutocompletePreviewsParams, + ), + ), + cast_to=AddressVerificationGetAutocompletePreviewsResponse, + ) + + def get_lookup_info( + self, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationGetLookupInfoResponse: + """Returns your organization's current lookup usage and plan information. + + Useful + for checking how many lookups you have consumed and whether you are on a paid + plan. + """ + return self._get( + "/v1/addver/", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AddressVerificationGetLookupInfoResponse, + ) + + def lookup_city_or_state_from_postal_or_zip_code( + self, + *, + postal_or_zip: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationLookupCityOrStateFromPostalOrZipCodeResponse: + """ + Looks up city, county, and other location metadata for a given US or Canadian + postal code or ZIP code. + + A single postal code may map to multiple cities (e.g. a ZIP that spans several + towns), so the response is an array. + + - Uses 1 lookup. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/v1/addver/city_states", + body=maybe_transform( + {"postal_or_zip": postal_or_zip}, + address_verification_lookup_city_or_state_from_postal_or_zip_code_params.AddressVerificationLookupCityOrStateFromPostalOrZipCodeParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AddressVerificationLookupCityOrStateFromPostalOrZipCodeResponse, + ) + + def lookup_zip_code_from_city_or_state( + self, + *, + city: str, + country_code: str, + state: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationLookupZipCodeFromCityOrStateResponse: + """ + Looks up all ZIP codes that correspond to a given US city and state. + + - Currently only supported for US addresses (`countryCode: "US"`). + - Uses 1 lookup. + + Args: + city: The city name. + + country_code: The country code. Currently only `US` is supported. + + state: The state abbreviation (e.g. `NY`). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/v1/addver/zip_codes", + body=maybe_transform( + { + "city": city, + "country_code": country_code, + "state": state, + }, + address_verification_lookup_zip_code_from_city_or_state_params.AddressVerificationLookupZipCodeFromCityOrStateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AddressVerificationLookupZipCodeFromCityOrStateResponse, + ) + + def parse_an_address( + self, + *, + address: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationParseAnAddressResponse: + """ + Parses a freeform address string into its individual components (house number, + street name, city, state, postal code, etc.). + + Useful for extracting structured data from a single-line address without running + a full verification. + + - Uses 1 lookup. + + Args: + address: The address you want to verify, written on a single line. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/v1/addver/parses", + body=maybe_transform( + {"address": address}, + address_verification_parse_an_address_params.AddressVerificationParseAnAddressParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AddressVerificationParseAnAddressResponse, + ) + + @overload + def suggest_addresses( + self, + *, + address: str, + geocode: bool | Omit = omit, + include_details: bool | Omit = omit, + proper_case: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationSuggestAddressesResponse: + """ + Returns up to 3 verified address suggestions for a given input address. + + Useful as a fallback when `POST /verifications` returns a `failed` status — + suggestions represent the closest matches found and may help the user identify + the correct address. + + Accepts the same freeform or structured input formats as `POST /verifications`. + + - Uses 1 lookup per call (plus 1 more if geocoding). + + Args: + address: The address you want to verify, written on a single line. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def suggest_addresses( + self, + *, + address: address_verification_suggest_addresses_params.StandardStructuredAddressInputAddress, + geocode: bool | Omit = omit, + include_details: bool | Omit = omit, + proper_case: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationSuggestAddressesResponse: + """ + Returns up to 3 verified address suggestions for a given input address. + + Useful as a fallback when `POST /verifications` returns a `failed` status — + suggestions represent the closest matches found and may help the user identify + the correct address. + + Accepts the same freeform or structured input formats as `POST /verifications`. + + - Uses 1 lookup per call (plus 1 more if geocoding). + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args(["address"]) + def suggest_addresses( + self, + *, + address: str | address_verification_suggest_addresses_params.StandardStructuredAddressInputAddress, + geocode: bool | Omit = omit, + include_details: bool | Omit = omit, + proper_case: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationSuggestAddressesResponse: + return self._post( + "/v1/addver/suggestions", + body=maybe_transform( + {"address": address}, + address_verification_suggest_addresses_params.AddressVerificationSuggestAddressesParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "geocode": geocode, + "include_details": include_details, + "proper_case": proper_case, + }, + address_verification_suggest_addresses_params.AddressVerificationSuggestAddressesParams, + ), + ), + cast_to=AddressVerificationSuggestAddressesResponse, + ) + + @overload + def verify( + self, + *, + address: str, + geocode: bool | Omit = omit, + include_details: bool | Omit = omit, + proper_case: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationVerifyResponse: + """1. + + **Structured Address** — Verify and standardize a structured address (e.g., + with `line1`, `city`, etc.). + 2. **Freeform Address** — Verify and standardize a freeform address written on + one line. For best results, append the ISO 2-letter country code (e.g., `US`, + `CA`) to the end of the line. + + - Specifying `includeDetails=true` will provide additional output as documented + in the `Details` schema. + - Uses 1 lookup for verification, and 1 more if geocoding (unless your contract + says otherwise). + + Args: + address: The address you want to verify, written on a single line. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def verify( + self, + *, + address: address_verification_verify_params.StandardStructuredAddressInputAddress, + geocode: bool | Omit = omit, + include_details: bool | Omit = omit, + proper_case: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationVerifyResponse: + """1. + + **Structured Address** — Verify and standardize a structured address (e.g., + with `line1`, `city`, etc.). + 2. **Freeform Address** — Verify and standardize a freeform address written on + one line. For best results, append the ISO 2-letter country code (e.g., `US`, + `CA`) to the end of the line. + + - Specifying `includeDetails=true` will provide additional output as documented + in the `Details` schema. + - Uses 1 lookup for verification, and 1 more if geocoding (unless your contract + says otherwise). + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args(["address"]) + def verify( + self, + *, + address: str | address_verification_verify_params.StandardStructuredAddressInputAddress, + geocode: bool | Omit = omit, + include_details: bool | Omit = omit, + proper_case: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationVerifyResponse: + return self._post( + "/v1/addver/verifications", + body=maybe_transform( + {"address": address}, address_verification_verify_params.AddressVerificationVerifyParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "geocode": geocode, + "include_details": include_details, + "proper_case": proper_case, + }, + address_verification_verify_params.AddressVerificationVerifyParams, + ), + ), + cast_to=AddressVerificationVerifyResponse, + ) + + +class AsyncAddressVerificationResource(AsyncAPIResource): + """Standard Address Verification API. + + Provides endpoints to verify and standardize addresses across US and Canada, + supporting both structured and freeform inputs. + + Note that this uses a different set of lookups than our international API. + """ + + @cached_property + def with_raw_response(self) -> AsyncAddressVerificationResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + """ + return AsyncAddressVerificationResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAddressVerificationResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + """ + return AsyncAddressVerificationResourceWithStreamingResponse(self) + + async def autocomplete( + self, + *, + partial_street: str, + filter_exact: bool | Omit = omit, + geocode: bool | Omit = omit, + include_details: bool | Omit = omit, + index: int | Omit = omit, + limit: int | Omit = omit, + proper_case: bool | Omit = omit, + query_verified_only: bool | Omit = omit, + verify: bool | Omit = omit, + city_filter: str | Omit = omit, + country_filter: str | Omit = omit, + pc_filter: str | Omit = omit, + state_filter: str | Omit = omit, + body_verified_only: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationAutocompleteResponse: + """ + Resolves a partial street address into a list of full address candidates, + optionally selecting a specific candidate by index and verifying it. + + **Basic usage** — omit `index`: returns an array of `CompletedAddressItem` + results for the given `partialStreet`. + + **With `index`** — specify `index` to resolve a single candidate. Returns a + single `CompletedAddressItem`. + + **With `index` + `verify=true`** — additionally runs the selected address + through the USPS/Canada Post verifier and returns a `StandardVerifiedAddress`. + + - Uses 1 lookup per call (plus 1 more if geocoding a result). + + Args: + partial_street: The partial street address to complete (e.g. `"22 Bay"`). + + city_filter: Filter results to a specific city. + + country_filter: Filter results to a specific country code. + + pc_filter: Filter results to a specific postal code prefix. + + state_filter: Filter results to a specific state or province abbreviation. + + body_verified_only: If true, only return addresses that passed USPS/Canada Post verification. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/v1/addver/completions", + body=await async_maybe_transform( + { + "partial_street": partial_street, + "city_filter": city_filter, + "country_filter": country_filter, + "pc_filter": pc_filter, + "state_filter": state_filter, + "body_verified_only": body_verified_only, + }, + address_verification_autocomplete_params.AddressVerificationAutocompleteParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "filter_exact": filter_exact, + "geocode": geocode, + "include_details": include_details, + "index": index, + "limit": limit, + "proper_case": proper_case, + "query_verified_only": query_verified_only, + "verify": verify, + }, + address_verification_autocomplete_params.AddressVerificationAutocompleteParams, + ), + ), + cast_to=AddressVerificationAutocompleteResponse, + ) + + async def batch_verification( + self, + *, + addresses: Iterable[address_verification_batch_verification_params.Address], + geocode: bool | Omit = omit, + include_details: bool | Omit = omit, + proper_case: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationBatchVerificationResponse: + """Verify a batch of US or Canadian addresses in a single request. + + Each address can + be freeform or structured, matching the same input formats accepted by the + single verification endpoint. + + - Uses 1 lookup per address (plus 1 more per address if geocoding). + - Requires a secret API key. + - Returns results in the same order as the input addresses. + - If an individual address fails, its result will contain an `error` field + rather than a `verifiedAddress`. + + Args: + addresses: Array of addresses to verify. Each item can be a freeform string or structured + address object. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/v1/addver/verifications/batch", + body=await async_maybe_transform( + {"addresses": addresses}, + address_verification_batch_verification_params.AddressVerificationBatchVerificationParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "geocode": geocode, + "include_details": include_details, + "proper_case": proper_case, + }, + address_verification_batch_verification_params.AddressVerificationBatchVerificationParams, + ), + ), + cast_to=AddressVerificationBatchVerificationResponse, + ) -__all__ = ["AddressVerificationResource", "AsyncAddressVerificationResource"] + async def get_autocomplete_previews( + self, + *, + partial_street: str, + city_filter: str | Omit = omit, + country_filter: str | Omit = omit, + filter_exact: bool | Omit = omit, + limit: int | Omit = omit, + pc_filter: str | Omit = omit, + proper_case: bool | Omit = omit, + prov_instead_of_pc: bool | Omit = omit, + state_filter: str | Omit = omit, + verified_only: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationGetAutocompletePreviewsResponse: + """ + Returns address completion previews for a partial street address, suitable for + populating an autocomplete dropdown without consuming a lookup per keystroke. + Each result contains a partial address preview (street, city, and — for non-US + addresses — only the first 3 digits of the postal code, to avoid revealing the + full code before a lookup is charged). -class AddressVerificationResource(SyncAPIResource): - """Standard Address Verification API. + - Does not consume a lookup. + - Use `POST /completions` to resolve a full address once the user selects a + result. - Provides endpoints to verify and standardize addresses across US and Canada, - supporting both structured and freeform inputs. + Args: + extra_headers: Send extra headers - Note that this uses a different set of lookups than our international API. - """ + extra_query: Add additional query parameters to the request - @cached_property - def with_raw_response(self) -> AddressVerificationResourceWithRawResponse: + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. + return await self._get( + "/v1/addver/completions", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "partial_street": partial_street, + "city_filter": city_filter, + "country_filter": country_filter, + "filter_exact": filter_exact, + "limit": limit, + "pc_filter": pc_filter, + "proper_case": proper_case, + "prov_instead_of_pc": prov_instead_of_pc, + "state_filter": state_filter, + "verified_only": verified_only, + }, + address_verification_get_autocomplete_previews_params.AddressVerificationGetAutocompletePreviewsParams, + ), + ), + cast_to=AddressVerificationGetAutocompletePreviewsResponse, + ) - For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + async def get_lookup_info( + self, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationGetLookupInfoResponse: + """Returns your organization's current lookup usage and plan information. + + Useful + for checking how many lookups you have consumed and whether you are on a paid + plan. """ - return AddressVerificationResourceWithRawResponse(self) + return await self._get( + "/v1/addver/", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AddressVerificationGetLookupInfoResponse, + ) - @cached_property - def with_streaming_response(self) -> AddressVerificationResourceWithStreamingResponse: + async def lookup_city_or_state_from_postal_or_zip_code( + self, + *, + postal_or_zip: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationLookupCityOrStateFromPostalOrZipCodeResponse: """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. + Looks up city, county, and other location metadata for a given US or Canadian + postal code or ZIP code. - For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + A single postal code may map to multiple cities (e.g. a ZIP that spans several + towns), so the response is an array. + + - Uses 1 lookup. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds """ - return AddressVerificationResourceWithStreamingResponse(self) + return await self._post( + "/v1/addver/city_states", + body=await async_maybe_transform( + {"postal_or_zip": postal_or_zip}, + address_verification_lookup_city_or_state_from_postal_or_zip_code_params.AddressVerificationLookupCityOrStateFromPostalOrZipCodeParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AddressVerificationLookupCityOrStateFromPostalOrZipCodeResponse, + ) + + async def lookup_zip_code_from_city_or_state( + self, + *, + city: str, + country_code: str, + state: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationLookupZipCodeFromCityOrStateResponse: + """ + Looks up all ZIP codes that correspond to a given US city and state. + + - Currently only supported for US addresses (`countryCode: "US"`). + - Uses 1 lookup. + + Args: + city: The city name. + + country_code: The country code. Currently only `US` is supported. + + state: The state abbreviation (e.g. `NY`). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/v1/addver/zip_codes", + body=await async_maybe_transform( + { + "city": city, + "country_code": country_code, + "state": state, + }, + address_verification_lookup_zip_code_from_city_or_state_params.AddressVerificationLookupZipCodeFromCityOrStateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AddressVerificationLookupZipCodeFromCityOrStateResponse, + ) + + async def parse_an_address( + self, + *, + address: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AddressVerificationParseAnAddressResponse: + """ + Parses a freeform address string into its individual components (house number, + street name, city, state, postal code, etc.). + + Useful for extracting structured data from a single-line address without running + a full verification. + + - Uses 1 lookup. + + Args: + address: The address you want to verify, written on a single line. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/v1/addver/parses", + body=await async_maybe_transform( + {"address": address}, + address_verification_parse_an_address_params.AddressVerificationParseAnAddressParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AddressVerificationParseAnAddressResponse, + ) @overload - def verify( + async def suggest_addresses( self, *, address: str, @@ -65,19 +1111,17 @@ def verify( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AddressVerificationVerifyResponse: - """1. + ) -> AddressVerificationSuggestAddressesResponse: + """ + Returns up to 3 verified address suggestions for a given input address. - **Structured Address** — Verify and standardize a structured address (e.g., - with `line1`, `city`, etc.). - 2. **Freeform Address** — Verify and standardize a freeform address written on - one line. For best results, append the ISO 2-letter country code (e.g., `US`, - `CA`) to the end of the line. + Useful as a fallback when `POST /verifications` returns a `failed` status — + suggestions represent the closest matches found and may help the user identify + the correct address. - - Specifying `includeDetails=true` will provide additional output as documented - in the `Details` schema. - - Uses 1 lookup for verification, and 1 more if geocoding (unless your contract - says otherwise). + Accepts the same freeform or structured input formats as `POST /verifications`. + + - Uses 1 lookup per call (plus 1 more if geocoding). Args: address: The address you want to verify, written on a single line. @@ -93,10 +1137,10 @@ def verify( ... @overload - def verify( + async def suggest_addresses( self, *, - address: address_verification_verify_params.StandardStructuredAddressInputAddress, + address: address_verification_suggest_addresses_params.StandardStructuredAddressInputAddress, geocode: bool | Omit = omit, include_details: bool | Omit = omit, proper_case: bool | Omit = omit, @@ -106,19 +1150,17 @@ def verify( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AddressVerificationVerifyResponse: - """1. + ) -> AddressVerificationSuggestAddressesResponse: + """ + Returns up to 3 verified address suggestions for a given input address. - **Structured Address** — Verify and standardize a structured address (e.g., - with `line1`, `city`, etc.). - 2. **Freeform Address** — Verify and standardize a freeform address written on - one line. For best results, append the ISO 2-letter country code (e.g., `US`, - `CA`) to the end of the line. + Useful as a fallback when `POST /verifications` returns a `failed` status — + suggestions represent the closest matches found and may help the user identify + the correct address. - - Specifying `includeDetails=true` will provide additional output as documented - in the `Details` schema. - - Uses 1 lookup for verification, and 1 more if geocoding (unless your contract - says otherwise). + Accepts the same freeform or structured input formats as `POST /verifications`. + + - Uses 1 lookup per call (plus 1 more if geocoding). Args: extra_headers: Send extra headers @@ -132,10 +1174,10 @@ def verify( ... @required_args(["address"]) - def verify( + async def suggest_addresses( self, *, - address: str | address_verification_verify_params.StandardStructuredAddressInputAddress, + address: str | address_verification_suggest_addresses_params.StandardStructuredAddressInputAddress, geocode: bool | Omit = omit, include_details: bool | Omit = omit, proper_case: bool | Omit = omit, @@ -145,58 +1187,30 @@ def verify( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AddressVerificationVerifyResponse: - return self._post( - "/v1/addver/verifications", - body=maybe_transform( - {"address": address}, address_verification_verify_params.AddressVerificationVerifyParams + ) -> AddressVerificationSuggestAddressesResponse: + return await self._post( + "/v1/addver/suggestions", + body=await async_maybe_transform( + {"address": address}, + address_verification_suggest_addresses_params.AddressVerificationSuggestAddressesParams, ), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - query=maybe_transform( + query=await async_maybe_transform( { "geocode": geocode, "include_details": include_details, "proper_case": proper_case, }, - address_verification_verify_params.AddressVerificationVerifyParams, + address_verification_suggest_addresses_params.AddressVerificationSuggestAddressesParams, ), ), - cast_to=AddressVerificationVerifyResponse, + cast_to=AddressVerificationSuggestAddressesResponse, ) - -class AsyncAddressVerificationResource(AsyncAPIResource): - """Standard Address Verification API. - - Provides endpoints to verify and standardize addresses across US and Canada, - supporting both structured and freeform inputs. - - Note that this uses a different set of lookups than our international API. - """ - - @cached_property - def with_raw_response(self) -> AsyncAddressVerificationResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers - """ - return AsyncAddressVerificationResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncAddressVerificationResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response - """ - return AsyncAddressVerificationResourceWithStreamingResponse(self) - @overload async def verify( self, @@ -319,6 +1333,30 @@ class AddressVerificationResourceWithRawResponse: def __init__(self, address_verification: AddressVerificationResource) -> None: self._address_verification = address_verification + self.autocomplete = to_raw_response_wrapper( + address_verification.autocomplete, + ) + self.batch_verification = to_raw_response_wrapper( + address_verification.batch_verification, + ) + self.get_autocomplete_previews = to_raw_response_wrapper( + address_verification.get_autocomplete_previews, + ) + self.get_lookup_info = to_raw_response_wrapper( + address_verification.get_lookup_info, + ) + self.lookup_city_or_state_from_postal_or_zip_code = to_raw_response_wrapper( + address_verification.lookup_city_or_state_from_postal_or_zip_code, + ) + self.lookup_zip_code_from_city_or_state = to_raw_response_wrapper( + address_verification.lookup_zip_code_from_city_or_state, + ) + self.parse_an_address = to_raw_response_wrapper( + address_verification.parse_an_address, + ) + self.suggest_addresses = to_raw_response_wrapper( + address_verification.suggest_addresses, + ) self.verify = to_raw_response_wrapper( address_verification.verify, ) @@ -328,6 +1366,30 @@ class AsyncAddressVerificationResourceWithRawResponse: def __init__(self, address_verification: AsyncAddressVerificationResource) -> None: self._address_verification = address_verification + self.autocomplete = async_to_raw_response_wrapper( + address_verification.autocomplete, + ) + self.batch_verification = async_to_raw_response_wrapper( + address_verification.batch_verification, + ) + self.get_autocomplete_previews = async_to_raw_response_wrapper( + address_verification.get_autocomplete_previews, + ) + self.get_lookup_info = async_to_raw_response_wrapper( + address_verification.get_lookup_info, + ) + self.lookup_city_or_state_from_postal_or_zip_code = async_to_raw_response_wrapper( + address_verification.lookup_city_or_state_from_postal_or_zip_code, + ) + self.lookup_zip_code_from_city_or_state = async_to_raw_response_wrapper( + address_verification.lookup_zip_code_from_city_or_state, + ) + self.parse_an_address = async_to_raw_response_wrapper( + address_verification.parse_an_address, + ) + self.suggest_addresses = async_to_raw_response_wrapper( + address_verification.suggest_addresses, + ) self.verify = async_to_raw_response_wrapper( address_verification.verify, ) @@ -337,6 +1399,30 @@ class AddressVerificationResourceWithStreamingResponse: def __init__(self, address_verification: AddressVerificationResource) -> None: self._address_verification = address_verification + self.autocomplete = to_streamed_response_wrapper( + address_verification.autocomplete, + ) + self.batch_verification = to_streamed_response_wrapper( + address_verification.batch_verification, + ) + self.get_autocomplete_previews = to_streamed_response_wrapper( + address_verification.get_autocomplete_previews, + ) + self.get_lookup_info = to_streamed_response_wrapper( + address_verification.get_lookup_info, + ) + self.lookup_city_or_state_from_postal_or_zip_code = to_streamed_response_wrapper( + address_verification.lookup_city_or_state_from_postal_or_zip_code, + ) + self.lookup_zip_code_from_city_or_state = to_streamed_response_wrapper( + address_verification.lookup_zip_code_from_city_or_state, + ) + self.parse_an_address = to_streamed_response_wrapper( + address_verification.parse_an_address, + ) + self.suggest_addresses = to_streamed_response_wrapper( + address_verification.suggest_addresses, + ) self.verify = to_streamed_response_wrapper( address_verification.verify, ) @@ -346,6 +1432,30 @@ class AsyncAddressVerificationResourceWithStreamingResponse: def __init__(self, address_verification: AsyncAddressVerificationResource) -> None: self._address_verification = address_verification + self.autocomplete = async_to_streamed_response_wrapper( + address_verification.autocomplete, + ) + self.batch_verification = async_to_streamed_response_wrapper( + address_verification.batch_verification, + ) + self.get_autocomplete_previews = async_to_streamed_response_wrapper( + address_verification.get_autocomplete_previews, + ) + self.get_lookup_info = async_to_streamed_response_wrapper( + address_verification.get_lookup_info, + ) + self.lookup_city_or_state_from_postal_or_zip_code = async_to_streamed_response_wrapper( + address_verification.lookup_city_or_state_from_postal_or_zip_code, + ) + self.lookup_zip_code_from_city_or_state = async_to_streamed_response_wrapper( + address_verification.lookup_zip_code_from_city_or_state, + ) + self.parse_an_address = async_to_streamed_response_wrapper( + address_verification.parse_an_address, + ) + self.suggest_addresses = async_to_streamed_response_wrapper( + address_verification.suggest_addresses, + ) self.verify = async_to_streamed_response_wrapper( address_verification.verify, ) diff --git a/src/postgrid/resources/intl_address_verification.py b/src/postgrid/resources/intl_address_verification.py index bc42a84..2777590 100644 --- a/src/postgrid/resources/intl_address_verification.py +++ b/src/postgrid/resources/intl_address_verification.py @@ -2,11 +2,18 @@ from __future__ import annotations +from typing import Iterable from typing_extensions import overload import httpx -from ..types import intl_address_verification_verify_params +from ..types import ( + intl_address_verification_verify_params, + intl_address_verification_autocomplete_params, + intl_address_verification_batch_verification_params, + intl_address_verification_get_autocomplete_previews_params, + intl_address_verification_get_autocomplete_advanced_previews_params, +) from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given from .._utils import required_args, maybe_transform, async_maybe_transform from .._compat import cached_property @@ -19,6 +26,16 @@ ) from .._base_client import make_request_options from ..types.intl_address_verification_verify_response import IntlAddressVerificationVerifyResponse +from ..types.intl_address_verification_autocomplete_response import IntlAddressVerificationAutocompleteResponse +from ..types.intl_address_verification_batch_verification_response import ( + IntlAddressVerificationBatchVerificationResponse, +) +from ..types.intl_address_verification_get_autocomplete_previews_response import ( + IntlAddressVerificationGetAutocompletePreviewsResponse, +) +from ..types.intl_address_verification_get_autocomplete_advanced_previews_response import ( + IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse, +) __all__ = ["IntlAddressVerificationResource", "AsyncIntlAddressVerificationResource"] @@ -49,6 +66,278 @@ def with_streaming_response(self) -> IntlAddressVerificationResourceWithStreamin """ return IntlAddressVerificationResourceWithStreamingResponse(self) + def autocomplete( + self, + *, + id: str, + include_details: bool | Omit = omit, + proper_case: bool | Omit = omit, + use_enhanced_china_dataset: bool | Omit = omit, + verify: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> IntlAddressVerificationAutocompleteResponse: + """ + Resolves an address preview `id` (from `GET /completions`) into a full address. + + Optionally verifies the resolved address through the standard US/CA verifier + when `verify=true` is supplied and the address is in the US or Canada. + + - Uses 1 lookup per call. + - When `verify=true` resolves a US or CA address, the response will be a + `VerifiedAddress` instead of an `IntlAddressCompletion`. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/v1/intl_addver/completions", + body=maybe_transform( + {"id": id}, intl_address_verification_autocomplete_params.IntlAddressVerificationAutocompleteParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "include_details": include_details, + "proper_case": proper_case, + "use_enhanced_china_dataset": use_enhanced_china_dataset, + "verify": verify, + }, + intl_address_verification_autocomplete_params.IntlAddressVerificationAutocompleteParams, + ), + ), + cast_to=IntlAddressVerificationAutocompleteResponse, + ) + + def batch_verification( + self, + *, + addresses: Iterable[intl_address_verification_batch_verification_params.Address], + geo_data: bool | Omit = omit, + include_details: bool | Omit = omit, + proper_case: bool | Omit = omit, + use_enhanced_china_dataset: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> IntlAddressVerificationBatchVerificationResponse: + """Verify a batch of international addresses in a single request. + + Each address can + be freeform or structured, matching the same input formats accepted by the + single verification endpoint. + + - Uses 1 lookup per address. + - Requires a secret API key. + - Returns results in the same order as the input addresses. + - If an individual address fails, its result will contain an `error` field + rather than a `verifiedAddress`. + + Args: + addresses: Array of addresses to verify. Each item can be a freeform string or a structured + address object. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/v1/intl_addver/verifications/batch", + body=maybe_transform( + {"addresses": addresses}, + intl_address_verification_batch_verification_params.IntlAddressVerificationBatchVerificationParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "geo_data": geo_data, + "include_details": include_details, + "proper_case": proper_case, + "use_enhanced_china_dataset": use_enhanced_china_dataset, + }, + intl_address_verification_batch_verification_params.IntlAddressVerificationBatchVerificationParams, + ), + ), + cast_to=IntlAddressVerificationBatchVerificationResponse, + ) + + def get_autocomplete_advanced_previews( + self, + *, + advanced: bool | Omit = omit, + city_filter: str | Omit = omit, + container: str | Omit = omit, + countries_filter: str | Omit = omit, + disable_ip_biasing: bool | Omit = omit, + language: str | Omit = omit, + limit: int | Omit = omit, + partial_street: str | Omit = omit, + postal_or_zip_filter: str | Omit = omit, + standard_fallback: bool | Omit = omit, + street_filter: str | Omit = omit, + use_enhanced_china_dataset: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse: + """ + Returns address completion previews for a partial address string, suitable for + populating an autocomplete dropdown. + + **Regular mode** — supply `partialStreet` to search by partial street address. + Results may include `Address` types (resolvable directly) and `Container` types + (buildings/complexes that require a follow-up call). + + **Advanced mode** — supply `advanced=true` and a `container` ID (from a previous + regular call) to drill into a building or complex and retrieve individual unit + addresses. + + Results with `type: "Address"` can be fully resolved by passing their `id` to + `POST /completions`. + + - Does not consume a lookup. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + "/v1/intl_addver/completions", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "advanced": advanced, + "city_filter": city_filter, + "container": container, + "countries_filter": countries_filter, + "disable_ip_biasing": disable_ip_biasing, + "language": language, + "limit": limit, + "partial_street": partial_street, + "postal_or_zip_filter": postal_or_zip_filter, + "standard_fallback": standard_fallback, + "street_filter": street_filter, + "use_enhanced_china_dataset": use_enhanced_china_dataset, + }, + intl_address_verification_get_autocomplete_advanced_previews_params.IntlAddressVerificationGetAutocompleteAdvancedPreviewsParams, + ), + ), + cast_to=IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse, + ) + + def get_autocomplete_previews( + self, + *, + advanced: bool | Omit = omit, + city_filter: str | Omit = omit, + container: str | Omit = omit, + countries_filter: str | Omit = omit, + disable_ip_biasing: bool | Omit = omit, + language: str | Omit = omit, + limit: int | Omit = omit, + partial_street: str | Omit = omit, + postal_or_zip_filter: str | Omit = omit, + standard_fallback: bool | Omit = omit, + street_filter: str | Omit = omit, + use_enhanced_china_dataset: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> IntlAddressVerificationGetAutocompletePreviewsResponse: + """ + Returns address completion previews for a partial address string, suitable for + populating an autocomplete dropdown. + + **Regular mode** — supply `partialStreet` to search by partial street address. + Results may include `Address` types (resolvable directly) and `Container` types + (buildings/complexes that require a follow-up call). + + **Advanced mode** — supply `advanced=true` and a `container` ID (from a previous + regular call) to drill into a building or complex and retrieve individual unit + addresses. + + Results with `type: "Address"` can be fully resolved by passing their `id` to + `POST /completions`. + + - Does not consume a lookup. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + "/v1/intl_addver/completions", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "advanced": advanced, + "city_filter": city_filter, + "container": container, + "countries_filter": countries_filter, + "disable_ip_biasing": disable_ip_biasing, + "language": language, + "limit": limit, + "partial_street": partial_street, + "postal_or_zip_filter": postal_or_zip_filter, + "standard_fallback": standard_fallback, + "street_filter": street_filter, + "use_enhanced_china_dataset": use_enhanced_china_dataset, + }, + intl_address_verification_get_autocomplete_previews_params.IntlAddressVerificationGetAutocompletePreviewsParams, + ), + ), + cast_to=IntlAddressVerificationGetAutocompletePreviewsResponse, + ) + @overload def verify( self, @@ -183,6 +472,278 @@ def with_streaming_response(self) -> AsyncIntlAddressVerificationResourceWithStr """ return AsyncIntlAddressVerificationResourceWithStreamingResponse(self) + async def autocomplete( + self, + *, + id: str, + include_details: bool | Omit = omit, + proper_case: bool | Omit = omit, + use_enhanced_china_dataset: bool | Omit = omit, + verify: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> IntlAddressVerificationAutocompleteResponse: + """ + Resolves an address preview `id` (from `GET /completions`) into a full address. + + Optionally verifies the resolved address through the standard US/CA verifier + when `verify=true` is supplied and the address is in the US or Canada. + + - Uses 1 lookup per call. + - When `verify=true` resolves a US or CA address, the response will be a + `VerifiedAddress` instead of an `IntlAddressCompletion`. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/v1/intl_addver/completions", + body=await async_maybe_transform( + {"id": id}, intl_address_verification_autocomplete_params.IntlAddressVerificationAutocompleteParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "include_details": include_details, + "proper_case": proper_case, + "use_enhanced_china_dataset": use_enhanced_china_dataset, + "verify": verify, + }, + intl_address_verification_autocomplete_params.IntlAddressVerificationAutocompleteParams, + ), + ), + cast_to=IntlAddressVerificationAutocompleteResponse, + ) + + async def batch_verification( + self, + *, + addresses: Iterable[intl_address_verification_batch_verification_params.Address], + geo_data: bool | Omit = omit, + include_details: bool | Omit = omit, + proper_case: bool | Omit = omit, + use_enhanced_china_dataset: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> IntlAddressVerificationBatchVerificationResponse: + """Verify a batch of international addresses in a single request. + + Each address can + be freeform or structured, matching the same input formats accepted by the + single verification endpoint. + + - Uses 1 lookup per address. + - Requires a secret API key. + - Returns results in the same order as the input addresses. + - If an individual address fails, its result will contain an `error` field + rather than a `verifiedAddress`. + + Args: + addresses: Array of addresses to verify. Each item can be a freeform string or a structured + address object. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/v1/intl_addver/verifications/batch", + body=await async_maybe_transform( + {"addresses": addresses}, + intl_address_verification_batch_verification_params.IntlAddressVerificationBatchVerificationParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "geo_data": geo_data, + "include_details": include_details, + "proper_case": proper_case, + "use_enhanced_china_dataset": use_enhanced_china_dataset, + }, + intl_address_verification_batch_verification_params.IntlAddressVerificationBatchVerificationParams, + ), + ), + cast_to=IntlAddressVerificationBatchVerificationResponse, + ) + + async def get_autocomplete_advanced_previews( + self, + *, + advanced: bool | Omit = omit, + city_filter: str | Omit = omit, + container: str | Omit = omit, + countries_filter: str | Omit = omit, + disable_ip_biasing: bool | Omit = omit, + language: str | Omit = omit, + limit: int | Omit = omit, + partial_street: str | Omit = omit, + postal_or_zip_filter: str | Omit = omit, + standard_fallback: bool | Omit = omit, + street_filter: str | Omit = omit, + use_enhanced_china_dataset: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse: + """ + Returns address completion previews for a partial address string, suitable for + populating an autocomplete dropdown. + + **Regular mode** — supply `partialStreet` to search by partial street address. + Results may include `Address` types (resolvable directly) and `Container` types + (buildings/complexes that require a follow-up call). + + **Advanced mode** — supply `advanced=true` and a `container` ID (from a previous + regular call) to drill into a building or complex and retrieve individual unit + addresses. + + Results with `type: "Address"` can be fully resolved by passing their `id` to + `POST /completions`. + + - Does not consume a lookup. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + "/v1/intl_addver/completions", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "advanced": advanced, + "city_filter": city_filter, + "container": container, + "countries_filter": countries_filter, + "disable_ip_biasing": disable_ip_biasing, + "language": language, + "limit": limit, + "partial_street": partial_street, + "postal_or_zip_filter": postal_or_zip_filter, + "standard_fallback": standard_fallback, + "street_filter": street_filter, + "use_enhanced_china_dataset": use_enhanced_china_dataset, + }, + intl_address_verification_get_autocomplete_advanced_previews_params.IntlAddressVerificationGetAutocompleteAdvancedPreviewsParams, + ), + ), + cast_to=IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse, + ) + + async def get_autocomplete_previews( + self, + *, + advanced: bool | Omit = omit, + city_filter: str | Omit = omit, + container: str | Omit = omit, + countries_filter: str | Omit = omit, + disable_ip_biasing: bool | Omit = omit, + language: str | Omit = omit, + limit: int | Omit = omit, + partial_street: str | Omit = omit, + postal_or_zip_filter: str | Omit = omit, + standard_fallback: bool | Omit = omit, + street_filter: str | Omit = omit, + use_enhanced_china_dataset: bool | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> IntlAddressVerificationGetAutocompletePreviewsResponse: + """ + Returns address completion previews for a partial address string, suitable for + populating an autocomplete dropdown. + + **Regular mode** — supply `partialStreet` to search by partial street address. + Results may include `Address` types (resolvable directly) and `Container` types + (buildings/complexes that require a follow-up call). + + **Advanced mode** — supply `advanced=true` and a `container` ID (from a previous + regular call) to drill into a building or complex and retrieve individual unit + addresses. + + Results with `type: "Address"` can be fully resolved by passing their `id` to + `POST /completions`. + + - Does not consume a lookup. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + "/v1/intl_addver/completions", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "advanced": advanced, + "city_filter": city_filter, + "container": container, + "countries_filter": countries_filter, + "disable_ip_biasing": disable_ip_biasing, + "language": language, + "limit": limit, + "partial_street": partial_street, + "postal_or_zip_filter": postal_or_zip_filter, + "standard_fallback": standard_fallback, + "street_filter": street_filter, + "use_enhanced_china_dataset": use_enhanced_china_dataset, + }, + intl_address_verification_get_autocomplete_previews_params.IntlAddressVerificationGetAutocompletePreviewsParams, + ), + ), + cast_to=IntlAddressVerificationGetAutocompletePreviewsResponse, + ) + @overload async def verify( self, @@ -295,6 +856,18 @@ class IntlAddressVerificationResourceWithRawResponse: def __init__(self, intl_address_verification: IntlAddressVerificationResource) -> None: self._intl_address_verification = intl_address_verification + self.autocomplete = to_raw_response_wrapper( + intl_address_verification.autocomplete, + ) + self.batch_verification = to_raw_response_wrapper( + intl_address_verification.batch_verification, + ) + self.get_autocomplete_advanced_previews = to_raw_response_wrapper( + intl_address_verification.get_autocomplete_advanced_previews, + ) + self.get_autocomplete_previews = to_raw_response_wrapper( + intl_address_verification.get_autocomplete_previews, + ) self.verify = to_raw_response_wrapper( intl_address_verification.verify, ) @@ -304,6 +877,18 @@ class AsyncIntlAddressVerificationResourceWithRawResponse: def __init__(self, intl_address_verification: AsyncIntlAddressVerificationResource) -> None: self._intl_address_verification = intl_address_verification + self.autocomplete = async_to_raw_response_wrapper( + intl_address_verification.autocomplete, + ) + self.batch_verification = async_to_raw_response_wrapper( + intl_address_verification.batch_verification, + ) + self.get_autocomplete_advanced_previews = async_to_raw_response_wrapper( + intl_address_verification.get_autocomplete_advanced_previews, + ) + self.get_autocomplete_previews = async_to_raw_response_wrapper( + intl_address_verification.get_autocomplete_previews, + ) self.verify = async_to_raw_response_wrapper( intl_address_verification.verify, ) @@ -313,6 +898,18 @@ class IntlAddressVerificationResourceWithStreamingResponse: def __init__(self, intl_address_verification: IntlAddressVerificationResource) -> None: self._intl_address_verification = intl_address_verification + self.autocomplete = to_streamed_response_wrapper( + intl_address_verification.autocomplete, + ) + self.batch_verification = to_streamed_response_wrapper( + intl_address_verification.batch_verification, + ) + self.get_autocomplete_advanced_previews = to_streamed_response_wrapper( + intl_address_verification.get_autocomplete_advanced_previews, + ) + self.get_autocomplete_previews = to_streamed_response_wrapper( + intl_address_verification.get_autocomplete_previews, + ) self.verify = to_streamed_response_wrapper( intl_address_verification.verify, ) @@ -322,6 +919,18 @@ class AsyncIntlAddressVerificationResourceWithStreamingResponse: def __init__(self, intl_address_verification: AsyncIntlAddressVerificationResource) -> None: self._intl_address_verification = intl_address_verification + self.autocomplete = async_to_streamed_response_wrapper( + intl_address_verification.autocomplete, + ) + self.batch_verification = async_to_streamed_response_wrapper( + intl_address_verification.batch_verification, + ) + self.get_autocomplete_advanced_previews = async_to_streamed_response_wrapper( + intl_address_verification.get_autocomplete_advanced_previews, + ) + self.get_autocomplete_previews = async_to_streamed_response_wrapper( + intl_address_verification.get_autocomplete_previews, + ) self.verify = async_to_streamed_response_wrapper( intl_address_verification.verify, ) diff --git a/src/postgrid/resources/print_mail/__init__.py b/src/postgrid/resources/print_mail/__init__.py index 2f87a66..cb21176 100644 --- a/src/postgrid/resources/print_mail/__init__.py +++ b/src/postgrid/resources/print_mail/__init__.py @@ -88,14 +88,6 @@ MailingListsResourceWithStreamingResponse, AsyncMailingListsResourceWithStreamingResponse, ) -from .order_profiles import ( - OrderProfilesResource, - AsyncOrderProfilesResource, - OrderProfilesResourceWithRawResponse, - AsyncOrderProfilesResourceWithRawResponse, - OrderProfilesResourceWithStreamingResponse, - AsyncOrderProfilesResourceWithStreamingResponse, -) from .sub_organizations import ( SubOrganizationsResource, AsyncSubOrganizationsResource, @@ -156,12 +148,6 @@ "AsyncMailingListsResourceWithRawResponse", "MailingListsResourceWithStreamingResponse", "AsyncMailingListsResourceWithStreamingResponse", - "OrderProfilesResource", - "AsyncOrderProfilesResource", - "OrderProfilesResourceWithRawResponse", - "AsyncOrderProfilesResourceWithRawResponse", - "OrderProfilesResourceWithStreamingResponse", - "AsyncOrderProfilesResourceWithStreamingResponse", "PostcardsResource", "AsyncPostcardsResource", "PostcardsResourceWithRawResponse", diff --git a/src/postgrid/resources/print_mail/campaigns.py b/src/postgrid/resources/print_mail/campaigns.py index e275832..f7f7a69 100644 --- a/src/postgrid/resources/print_mail/campaigns.py +++ b/src/postgrid/resources/print_mail/campaigns.py @@ -60,14 +60,15 @@ def create( self, *, mailing_list: str, - cheque_profile: str | Omit = omit, + cheque: campaign_create_params.Cheque | Omit = omit, default_sender_contact: str | Omit = omit, description: str | Omit = omit, - letter_profile: str | Omit = omit, + letter: campaign_create_params.Letter | Omit = omit, metadata: Dict[str, object] | Omit = omit, - postcard_profile: str | Omit = omit, - self_mailer_profile: str | Omit = omit, + postcard: campaign_create_params.Postcard | Omit = omit, + self_mailer: campaign_create_params.SelfMailer | Omit = omit, send_date: Union[str, datetime] | Omit = omit, + snap_pack: campaign_create_params.SnapPack | Omit = omit, idempotency_key: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -79,14 +80,18 @@ def create( """ Create a new campaign. - A campaign links a mailing list with a specific mail piece profile (letter, - postcard, cheque, or self-mailer) to send bulk mail. Upon creation, the campaign - enters the `drafting` status while assets are validated. + A campaign links a mailing list with a specific mail piece configuration + (letter, postcard, cheque, self-mailer, or snap pack) to send bulk mail. Only + one collateral type can be set per campaign. + + Upon creation, the campaign enters the `drafting` status while assets are + validated. Args: mailing_list: The ID of the mailing list associated with this campaign. - cheque_profile: The ID of the cheque profile used for this campaign, if applicable. + cheque: Inline cheque configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. default_sender_contact: The ID of the default sender contact to use for orders if not specified per recipient. @@ -94,16 +99,22 @@ def create( description: An optional string describing this resource. Will be visible in the API and the dashboard. - letter_profile: The ID of the letter profile used for this campaign, if applicable. + letter: Inline letter configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. metadata: See the section on Metadata. - postcard_profile: The ID of the postcard profile used for this campaign, if applicable. + postcard: Inline postcard configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. - self_mailer_profile: The ID of the self-mailer profile used for this campaign, if applicable. + self_mailer: Inline self-mailer configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. send_date: The scheduled date and time for the campaign to be sent. + snap_pack: Inline snap pack configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -118,14 +129,15 @@ def create( body=maybe_transform( { "mailing_list": mailing_list, - "cheque_profile": cheque_profile, + "cheque": cheque, "default_sender_contact": default_sender_contact, "description": description, - "letter_profile": letter_profile, + "letter": letter, "metadata": metadata, - "postcard_profile": postcard_profile, - "self_mailer_profile": self_mailer_profile, + "postcard": postcard, + "self_mailer": self_mailer, "send_date": send_date, + "snap_pack": snap_pack, }, campaign_create_params.CampaignCreateParams, ), @@ -172,14 +184,15 @@ def update( self, id: str, *, - cheque_profile: Optional[str] | Omit = omit, + cheque: Optional[campaign_update_params.Cheque] | Omit = omit, default_sender_contact: Optional[str] | Omit = omit, description: Optional[str] | Omit = omit, - letter_profile: Optional[str] | Omit = omit, + letter: Optional[campaign_update_params.Letter] | Omit = omit, mailing_list: str | Omit = omit, metadata: Optional[Dict[str, str]] | Omit = omit, - postcard_profile: Optional[str] | Omit = omit, - self_mailer_profile: Optional[str] | Omit = omit, + postcard: Optional[campaign_update_params.Postcard] | Omit = omit, + self_mailer: Optional[campaign_update_params.SelfMailer] | Omit = omit, + snap_pack: Optional[campaign_update_params.SnapPack] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -195,27 +208,30 @@ def update( `drafting`. Args: - cheque_profile: The ID of the cheque profile to use. Setting this will remove other profile - types. Set to `null` to remove. + cheque: Inline cheque configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. default_sender_contact: The ID of the default sender contact. Set to `null` to remove. description: An optional description for the campaign. Set to `null` to remove the existing description. - letter_profile: The ID of the letter profile to use. Setting this will remove other profile - types. Set to `null` to remove. + letter: Inline letter configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. mailing_list: The ID of the mailing list to associate with this campaign. metadata: Optional key-value data associated with the campaign. Set to `null` to remove existing metadata. - postcard_profile: The ID of the postcard profile to use. Setting this will remove other profile - types. Set to `null` to remove. + postcard: Inline postcard configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. + + self_mailer: Inline self-mailer configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. - self_mailer_profile: The ID of the self-mailer profile to use. Setting this will remove other profile - types. Set to `null` to remove. + snap_pack: Inline snap pack configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. extra_headers: Send extra headers @@ -231,14 +247,15 @@ def update( path_template("/print-mail/v1/campaigns/{id}", id=id), body=maybe_transform( { - "cheque_profile": cheque_profile, + "cheque": cheque, "default_sender_contact": default_sender_contact, "description": description, - "letter_profile": letter_profile, + "letter": letter, "mailing_list": mailing_list, "metadata": metadata, - "postcard_profile": postcard_profile, - "self_mailer_profile": self_mailer_profile, + "postcard": postcard, + "self_mailer": self_mailer, + "snap_pack": snap_pack, }, campaign_update_params.CampaignUpdateParams, ), @@ -411,14 +428,15 @@ async def create( self, *, mailing_list: str, - cheque_profile: str | Omit = omit, + cheque: campaign_create_params.Cheque | Omit = omit, default_sender_contact: str | Omit = omit, description: str | Omit = omit, - letter_profile: str | Omit = omit, + letter: campaign_create_params.Letter | Omit = omit, metadata: Dict[str, object] | Omit = omit, - postcard_profile: str | Omit = omit, - self_mailer_profile: str | Omit = omit, + postcard: campaign_create_params.Postcard | Omit = omit, + self_mailer: campaign_create_params.SelfMailer | Omit = omit, send_date: Union[str, datetime] | Omit = omit, + snap_pack: campaign_create_params.SnapPack | Omit = omit, idempotency_key: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -430,14 +448,18 @@ async def create( """ Create a new campaign. - A campaign links a mailing list with a specific mail piece profile (letter, - postcard, cheque, or self-mailer) to send bulk mail. Upon creation, the campaign - enters the `drafting` status while assets are validated. + A campaign links a mailing list with a specific mail piece configuration + (letter, postcard, cheque, self-mailer, or snap pack) to send bulk mail. Only + one collateral type can be set per campaign. + + Upon creation, the campaign enters the `drafting` status while assets are + validated. Args: mailing_list: The ID of the mailing list associated with this campaign. - cheque_profile: The ID of the cheque profile used for this campaign, if applicable. + cheque: Inline cheque configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. default_sender_contact: The ID of the default sender contact to use for orders if not specified per recipient. @@ -445,16 +467,22 @@ async def create( description: An optional string describing this resource. Will be visible in the API and the dashboard. - letter_profile: The ID of the letter profile used for this campaign, if applicable. + letter: Inline letter configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. metadata: See the section on Metadata. - postcard_profile: The ID of the postcard profile used for this campaign, if applicable. + postcard: Inline postcard configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. - self_mailer_profile: The ID of the self-mailer profile used for this campaign, if applicable. + self_mailer: Inline self-mailer configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. send_date: The scheduled date and time for the campaign to be sent. + snap_pack: Inline snap pack configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -469,14 +497,15 @@ async def create( body=await async_maybe_transform( { "mailing_list": mailing_list, - "cheque_profile": cheque_profile, + "cheque": cheque, "default_sender_contact": default_sender_contact, "description": description, - "letter_profile": letter_profile, + "letter": letter, "metadata": metadata, - "postcard_profile": postcard_profile, - "self_mailer_profile": self_mailer_profile, + "postcard": postcard, + "self_mailer": self_mailer, "send_date": send_date, + "snap_pack": snap_pack, }, campaign_create_params.CampaignCreateParams, ), @@ -523,14 +552,15 @@ async def update( self, id: str, *, - cheque_profile: Optional[str] | Omit = omit, + cheque: Optional[campaign_update_params.Cheque] | Omit = omit, default_sender_contact: Optional[str] | Omit = omit, description: Optional[str] | Omit = omit, - letter_profile: Optional[str] | Omit = omit, + letter: Optional[campaign_update_params.Letter] | Omit = omit, mailing_list: str | Omit = omit, metadata: Optional[Dict[str, str]] | Omit = omit, - postcard_profile: Optional[str] | Omit = omit, - self_mailer_profile: Optional[str] | Omit = omit, + postcard: Optional[campaign_update_params.Postcard] | Omit = omit, + self_mailer: Optional[campaign_update_params.SelfMailer] | Omit = omit, + snap_pack: Optional[campaign_update_params.SnapPack] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -546,27 +576,30 @@ async def update( `drafting`. Args: - cheque_profile: The ID of the cheque profile to use. Setting this will remove other profile - types. Set to `null` to remove. + cheque: Inline cheque configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. default_sender_contact: The ID of the default sender contact. Set to `null` to remove. description: An optional description for the campaign. Set to `null` to remove the existing description. - letter_profile: The ID of the letter profile to use. Setting this will remove other profile - types. Set to `null` to remove. + letter: Inline letter configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. mailing_list: The ID of the mailing list to associate with this campaign. metadata: Optional key-value data associated with the campaign. Set to `null` to remove existing metadata. - postcard_profile: The ID of the postcard profile to use. Setting this will remove other profile - types. Set to `null` to remove. + postcard: Inline postcard configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. + + self_mailer: Inline self-mailer configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. - self_mailer_profile: The ID of the self-mailer profile to use. Setting this will remove other profile - types. Set to `null` to remove. + snap_pack: Inline snap pack configuration for a campaign. All fields are optional since + campaigns may be in a partial state during drafting. extra_headers: Send extra headers @@ -582,14 +615,15 @@ async def update( path_template("/print-mail/v1/campaigns/{id}", id=id), body=await async_maybe_transform( { - "cheque_profile": cheque_profile, + "cheque": cheque, "default_sender_contact": default_sender_contact, "description": description, - "letter_profile": letter_profile, + "letter": letter, "mailing_list": mailing_list, "metadata": metadata, - "postcard_profile": postcard_profile, - "self_mailer_profile": self_mailer_profile, + "postcard": postcard, + "self_mailer": self_mailer, + "snap_pack": snap_pack, }, campaign_update_params.CampaignUpdateParams, ), diff --git a/src/postgrid/resources/print_mail/order_profiles/__init__.py b/src/postgrid/resources/print_mail/order_profiles/__init__.py deleted file mode 100644 index 6f7e6b7..0000000 --- a/src/postgrid/resources/print_mail/order_profiles/__init__.py +++ /dev/null @@ -1,75 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from .cheques import ( - ChequesResource, - AsyncChequesResource, - ChequesResourceWithRawResponse, - AsyncChequesResourceWithRawResponse, - ChequesResourceWithStreamingResponse, - AsyncChequesResourceWithStreamingResponse, -) -from .letters import ( - LettersResource, - AsyncLettersResource, - LettersResourceWithRawResponse, - AsyncLettersResourceWithRawResponse, - LettersResourceWithStreamingResponse, - AsyncLettersResourceWithStreamingResponse, -) -from .postcards import ( - PostcardsResource, - AsyncPostcardsResource, - PostcardsResourceWithRawResponse, - AsyncPostcardsResourceWithRawResponse, - PostcardsResourceWithStreamingResponse, - AsyncPostcardsResourceWithStreamingResponse, -) -from .self_mailers import ( - SelfMailersResource, - AsyncSelfMailersResource, - SelfMailersResourceWithRawResponse, - AsyncSelfMailersResourceWithRawResponse, - SelfMailersResourceWithStreamingResponse, - AsyncSelfMailersResourceWithStreamingResponse, -) -from .order_profiles import ( - OrderProfilesResource, - AsyncOrderProfilesResource, - OrderProfilesResourceWithRawResponse, - AsyncOrderProfilesResourceWithRawResponse, - OrderProfilesResourceWithStreamingResponse, - AsyncOrderProfilesResourceWithStreamingResponse, -) - -__all__ = [ - "ChequesResource", - "AsyncChequesResource", - "ChequesResourceWithRawResponse", - "AsyncChequesResourceWithRawResponse", - "ChequesResourceWithStreamingResponse", - "AsyncChequesResourceWithStreamingResponse", - "LettersResource", - "AsyncLettersResource", - "LettersResourceWithRawResponse", - "AsyncLettersResourceWithRawResponse", - "LettersResourceWithStreamingResponse", - "AsyncLettersResourceWithStreamingResponse", - "PostcardsResource", - "AsyncPostcardsResource", - "PostcardsResourceWithRawResponse", - "AsyncPostcardsResourceWithRawResponse", - "PostcardsResourceWithStreamingResponse", - "AsyncPostcardsResourceWithStreamingResponse", - "SelfMailersResource", - "AsyncSelfMailersResource", - "SelfMailersResourceWithRawResponse", - "AsyncSelfMailersResourceWithRawResponse", - "SelfMailersResourceWithStreamingResponse", - "AsyncSelfMailersResourceWithStreamingResponse", - "OrderProfilesResource", - "AsyncOrderProfilesResource", - "OrderProfilesResourceWithRawResponse", - "AsyncOrderProfilesResourceWithRawResponse", - "OrderProfilesResourceWithStreamingResponse", - "AsyncOrderProfilesResourceWithStreamingResponse", -] diff --git a/src/postgrid/resources/print_mail/order_profiles/cheques.py b/src/postgrid/resources/print_mail/order_profiles/cheques.py deleted file mode 100644 index ef08d92..0000000 --- a/src/postgrid/resources/print_mail/order_profiles/cheques.py +++ /dev/null @@ -1,942 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Dict, Union, Optional -from typing_extensions import Literal - -import httpx - -from ...._types import ( - Body, - Omit, - Query, - Headers, - NotGiven, - SequenceNotStr, - Base64FileInput, - omit, - not_given, -) -from ...._utils import path_template, maybe_transform, async_maybe_transform -from ...._compat import cached_property -from ...._resource import SyncAPIResource, AsyncAPIResource -from ...._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ....pagination import SyncSkipLimit, AsyncSkipLimit -from ...._base_client import AsyncPaginator, make_request_options -from ....types.print_mail import ChequeSize -from ....types.print_mail.cheque_size import ChequeSize -from ....types.print_mail.order_profiles import ( - CurrencyCode, - cheque_list_params, - cheque_create_params, - cheque_update_params, - cheque_retrieve_params, -) -from ....types.print_mail.order_profiles.currency_code import CurrencyCode -from ....types.print_mail.order_profiles.cheque_profile import ChequeProfile -from ....types.print_mail.order_profiles.cheque_list_response import ChequeListResponse -from ....types.print_mail.order_profiles.cheque_delete_response import ChequeDeleteResponse - -__all__ = ["ChequesResource", "AsyncChequesResource"] - - -class ChequesResource(SyncAPIResource): - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - - @cached_property - def with_raw_response(self) -> ChequesResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers - """ - return ChequesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> ChequesResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response - """ - return ChequesResourceWithStreamingResponse(self) - - def create( - self, - *, - bank_account: str, - size: ChequeSize, - expand: SequenceNotStr[str] | Omit = omit, - currency_code: CurrencyCode | Omit = omit, - description: Optional[str] | Omit = omit, - letter_pdf: Union[str, Base64FileInput] | Omit = omit, - letter_template: str | Omit = omit, - logo: Optional[str] | Omit = omit, - mailing_class: Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - | Omit = omit, - memo: Optional[str] | Omit = omit, - merge_variables: Optional[Dict[str, object]] | Omit = omit, - message: Optional[str] | Omit = omit, - metadata: Optional[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. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> ChequeProfile: - """Creates a new Cheque Profile. - - Requires a `bankAccount` ID. Can optionally - include an attached letter via `letterHTML`, `letterTemplate`, or `letterPDF`. - If providing `letterPDF` or `logo` (if logo needs upload, though schema suggests - URL), use `multipart/form-data`. - - Args: - bank_account: ID of the bank account to use for the cheque. Required for creation. - - size: Enum representing the supported cheque sizes. - - expand: Optional list of related resources to expand in the response. - - currency_code: Enum representing the supported currency codes. - - description: An optional description for the profile. Set to `null` to remove during update. - - letter_pdf: PDF file for an optional attached letter. Cannot be used with `letterHTML` or - `letterTemplate`. Input only. - - letter_template: ID of a template for an optional attached letter. Cannot be used with - `letterHTML` or `letterPDF`. - - logo: A publicly accessible URL for the logo to print on the cheque. Set to `null` to - remove during update. - - mailing_class: Mailing class. Generally must be first class (or equivalent for destination - country) for cheques. - - memo: Memo line text for the cheque. Set to `null` to remove during update. - - merge_variables: Default merge variables for orders created using this profile. - - message: Message included on the cheque stub. Set to `null` to remove during update. - - metadata: Optional key-value metadata. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._post( - "/print-mail/v1/order_profiles/cheques", - body=maybe_transform( - { - "bank_account": bank_account, - "size": size, - "currency_code": currency_code, - "description": description, - "letter_pdf": letter_pdf, - "letter_template": letter_template, - "logo": logo, - "mailing_class": mailing_class, - "memo": memo, - "merge_variables": merge_variables, - "message": message, - "metadata": metadata, - }, - cheque_create_params.ChequeCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform({"expand": expand}, cheque_create_params.ChequeCreateParams), - ), - cast_to=ChequeProfile, - ) - - def retrieve( - self, - id: str, - *, - expand: SequenceNotStr[str] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> ChequeProfile: - """ - Retrieves the details of a specific Cheque Profile. - - Args: - expand: Optional list of related resources to expand in the response. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._get( - path_template("/print-mail/v1/order_profiles/cheques/{id}", id=id), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform({"expand": expand}, cheque_retrieve_params.ChequeRetrieveParams), - ), - cast_to=ChequeProfile, - ) - - def update( - self, - id: str, - *, - bank_account: str, - size: ChequeSize, - expand: SequenceNotStr[str] | Omit = omit, - currency_code: CurrencyCode | Omit = omit, - description: Optional[str] | Omit = omit, - letter_pdf: Union[str, Base64FileInput] | Omit = omit, - letter_template: str | Omit = omit, - logo: Optional[str] | Omit = omit, - mailing_class: Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - | Omit = omit, - memo: Optional[str] | Omit = omit, - merge_variables: Optional[Dict[str, object]] | Omit = omit, - message: Optional[str] | Omit = omit, - metadata: Optional[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. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> ChequeProfile: - """Updates specific fields of an existing Cheque Profile. - - If providing `letterPDF` - or `logo`, use `multipart/form-data`. - - Args: - bank_account: ID of the bank account to use for the cheque. Required for creation. - - size: Enum representing the supported cheque sizes. - - expand: Optional list of related resources to expand in the response. - - currency_code: Enum representing the supported currency codes. - - description: An optional description for the profile. Set to `null` to remove during update. - - letter_pdf: PDF file for an optional attached letter. Cannot be used with `letterHTML` or - `letterTemplate`. Input only. - - letter_template: ID of a template for an optional attached letter. Cannot be used with - `letterHTML` or `letterPDF`. - - logo: A publicly accessible URL for the logo to print on the cheque. Set to `null` to - remove during update. - - mailing_class: Mailing class. Generally must be first class (or equivalent for destination - country) for cheques. - - memo: Memo line text for the cheque. Set to `null` to remove during update. - - merge_variables: Default merge variables for orders created using this profile. - - message: Message included on the cheque stub. Set to `null` to remove during update. - - metadata: Optional key-value metadata. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._post( - path_template("/print-mail/v1/order_profiles/cheques/{id}", id=id), - body=maybe_transform( - { - "bank_account": bank_account, - "size": size, - "currency_code": currency_code, - "description": description, - "letter_pdf": letter_pdf, - "letter_template": letter_template, - "logo": logo, - "mailing_class": mailing_class, - "memo": memo, - "merge_variables": merge_variables, - "message": message, - "metadata": metadata, - }, - cheque_update_params.ChequeUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform({"expand": expand}, cheque_update_params.ChequeUpdateParams), - ), - cast_to=ChequeProfile, - ) - - def list( - self, - *, - limit: int | Omit = omit, - search: str | Omit = omit, - skip: int | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SyncSkipLimit[ChequeListResponse]: - """ - Retrieves a list of Cheque Profiles. - - Args: - search: You can supply any string to help narrow down the list of resources. For - example, if you pass `"New York"` (quoted), it will return resources that have - that string present somewhere in their response. Alternatively, you can supply a - structured search query. See the documentation on `StructuredSearchQuery` for - more details. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get_api_list( - "/print-mail/v1/order_profiles/cheques", - page=SyncSkipLimit[ChequeListResponse], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "limit": limit, - "search": search, - "skip": skip, - }, - cheque_list_params.ChequeListParams, - ), - ), - model=ChequeListResponse, - ) - - def delete( - self, - id: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> ChequeDeleteResponse: - """ - Deletes a Cheque Profile. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._delete( - path_template("/print-mail/v1/order_profiles/cheques/{id}", id=id), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=ChequeDeleteResponse, - ) - - -class AsyncChequesResource(AsyncAPIResource): - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - - @cached_property - def with_raw_response(self) -> AsyncChequesResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers - """ - return AsyncChequesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncChequesResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response - """ - return AsyncChequesResourceWithStreamingResponse(self) - - async def create( - self, - *, - bank_account: str, - size: ChequeSize, - expand: SequenceNotStr[str] | Omit = omit, - currency_code: CurrencyCode | Omit = omit, - description: Optional[str] | Omit = omit, - letter_pdf: Union[str, Base64FileInput] | Omit = omit, - letter_template: str | Omit = omit, - logo: Optional[str] | Omit = omit, - mailing_class: Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - | Omit = omit, - memo: Optional[str] | Omit = omit, - merge_variables: Optional[Dict[str, object]] | Omit = omit, - message: Optional[str] | Omit = omit, - metadata: Optional[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. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> ChequeProfile: - """Creates a new Cheque Profile. - - Requires a `bankAccount` ID. Can optionally - include an attached letter via `letterHTML`, `letterTemplate`, or `letterPDF`. - If providing `letterPDF` or `logo` (if logo needs upload, though schema suggests - URL), use `multipart/form-data`. - - Args: - bank_account: ID of the bank account to use for the cheque. Required for creation. - - size: Enum representing the supported cheque sizes. - - expand: Optional list of related resources to expand in the response. - - currency_code: Enum representing the supported currency codes. - - description: An optional description for the profile. Set to `null` to remove during update. - - letter_pdf: PDF file for an optional attached letter. Cannot be used with `letterHTML` or - `letterTemplate`. Input only. - - letter_template: ID of a template for an optional attached letter. Cannot be used with - `letterHTML` or `letterPDF`. - - logo: A publicly accessible URL for the logo to print on the cheque. Set to `null` to - remove during update. - - mailing_class: Mailing class. Generally must be first class (or equivalent for destination - country) for cheques. - - memo: Memo line text for the cheque. Set to `null` to remove during update. - - merge_variables: Default merge variables for orders created using this profile. - - message: Message included on the cheque stub. Set to `null` to remove during update. - - metadata: Optional key-value metadata. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._post( - "/print-mail/v1/order_profiles/cheques", - body=await async_maybe_transform( - { - "bank_account": bank_account, - "size": size, - "currency_code": currency_code, - "description": description, - "letter_pdf": letter_pdf, - "letter_template": letter_template, - "logo": logo, - "mailing_class": mailing_class, - "memo": memo, - "merge_variables": merge_variables, - "message": message, - "metadata": metadata, - }, - cheque_create_params.ChequeCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform({"expand": expand}, cheque_create_params.ChequeCreateParams), - ), - cast_to=ChequeProfile, - ) - - async def retrieve( - self, - id: str, - *, - expand: SequenceNotStr[str] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> ChequeProfile: - """ - Retrieves the details of a specific Cheque Profile. - - Args: - expand: Optional list of related resources to expand in the response. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return await self._get( - path_template("/print-mail/v1/order_profiles/cheques/{id}", id=id), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform({"expand": expand}, cheque_retrieve_params.ChequeRetrieveParams), - ), - cast_to=ChequeProfile, - ) - - async def update( - self, - id: str, - *, - bank_account: str, - size: ChequeSize, - expand: SequenceNotStr[str] | Omit = omit, - currency_code: CurrencyCode | Omit = omit, - description: Optional[str] | Omit = omit, - letter_pdf: Union[str, Base64FileInput] | Omit = omit, - letter_template: str | Omit = omit, - logo: Optional[str] | Omit = omit, - mailing_class: Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - | Omit = omit, - memo: Optional[str] | Omit = omit, - merge_variables: Optional[Dict[str, object]] | Omit = omit, - message: Optional[str] | Omit = omit, - metadata: Optional[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. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> ChequeProfile: - """Updates specific fields of an existing Cheque Profile. - - If providing `letterPDF` - or `logo`, use `multipart/form-data`. - - Args: - bank_account: ID of the bank account to use for the cheque. Required for creation. - - size: Enum representing the supported cheque sizes. - - expand: Optional list of related resources to expand in the response. - - currency_code: Enum representing the supported currency codes. - - description: An optional description for the profile. Set to `null` to remove during update. - - letter_pdf: PDF file for an optional attached letter. Cannot be used with `letterHTML` or - `letterTemplate`. Input only. - - letter_template: ID of a template for an optional attached letter. Cannot be used with - `letterHTML` or `letterPDF`. - - logo: A publicly accessible URL for the logo to print on the cheque. Set to `null` to - remove during update. - - mailing_class: Mailing class. Generally must be first class (or equivalent for destination - country) for cheques. - - memo: Memo line text for the cheque. Set to `null` to remove during update. - - merge_variables: Default merge variables for orders created using this profile. - - message: Message included on the cheque stub. Set to `null` to remove during update. - - metadata: Optional key-value metadata. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return await self._post( - path_template("/print-mail/v1/order_profiles/cheques/{id}", id=id), - body=await async_maybe_transform( - { - "bank_account": bank_account, - "size": size, - "currency_code": currency_code, - "description": description, - "letter_pdf": letter_pdf, - "letter_template": letter_template, - "logo": logo, - "mailing_class": mailing_class, - "memo": memo, - "merge_variables": merge_variables, - "message": message, - "metadata": metadata, - }, - cheque_update_params.ChequeUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform({"expand": expand}, cheque_update_params.ChequeUpdateParams), - ), - cast_to=ChequeProfile, - ) - - def list( - self, - *, - limit: int | Omit = omit, - search: str | Omit = omit, - skip: int | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AsyncPaginator[ChequeListResponse, AsyncSkipLimit[ChequeListResponse]]: - """ - Retrieves a list of Cheque Profiles. - - Args: - search: You can supply any string to help narrow down the list of resources. For - example, if you pass `"New York"` (quoted), it will return resources that have - that string present somewhere in their response. Alternatively, you can supply a - structured search query. See the documentation on `StructuredSearchQuery` for - more details. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get_api_list( - "/print-mail/v1/order_profiles/cheques", - page=AsyncSkipLimit[ChequeListResponse], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "limit": limit, - "search": search, - "skip": skip, - }, - cheque_list_params.ChequeListParams, - ), - ), - model=ChequeListResponse, - ) - - async def delete( - self, - id: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> ChequeDeleteResponse: - """ - Deletes a Cheque Profile. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return await self._delete( - path_template("/print-mail/v1/order_profiles/cheques/{id}", id=id), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=ChequeDeleteResponse, - ) - - -class ChequesResourceWithRawResponse: - def __init__(self, cheques: ChequesResource) -> None: - self._cheques = cheques - - self.create = to_raw_response_wrapper( - cheques.create, - ) - self.retrieve = to_raw_response_wrapper( - cheques.retrieve, - ) - self.update = to_raw_response_wrapper( - cheques.update, - ) - self.list = to_raw_response_wrapper( - cheques.list, - ) - self.delete = to_raw_response_wrapper( - cheques.delete, - ) - - -class AsyncChequesResourceWithRawResponse: - def __init__(self, cheques: AsyncChequesResource) -> None: - self._cheques = cheques - - self.create = async_to_raw_response_wrapper( - cheques.create, - ) - self.retrieve = async_to_raw_response_wrapper( - cheques.retrieve, - ) - self.update = async_to_raw_response_wrapper( - cheques.update, - ) - self.list = async_to_raw_response_wrapper( - cheques.list, - ) - self.delete = async_to_raw_response_wrapper( - cheques.delete, - ) - - -class ChequesResourceWithStreamingResponse: - def __init__(self, cheques: ChequesResource) -> None: - self._cheques = cheques - - self.create = to_streamed_response_wrapper( - cheques.create, - ) - self.retrieve = to_streamed_response_wrapper( - cheques.retrieve, - ) - self.update = to_streamed_response_wrapper( - cheques.update, - ) - self.list = to_streamed_response_wrapper( - cheques.list, - ) - self.delete = to_streamed_response_wrapper( - cheques.delete, - ) - - -class AsyncChequesResourceWithStreamingResponse: - def __init__(self, cheques: AsyncChequesResource) -> None: - self._cheques = cheques - - self.create = async_to_streamed_response_wrapper( - cheques.create, - ) - self.retrieve = async_to_streamed_response_wrapper( - cheques.retrieve, - ) - self.update = async_to_streamed_response_wrapper( - cheques.update, - ) - self.list = async_to_streamed_response_wrapper( - cheques.list, - ) - self.delete = async_to_streamed_response_wrapper( - cheques.delete, - ) diff --git a/src/postgrid/resources/print_mail/order_profiles/letters.py b/src/postgrid/resources/print_mail/order_profiles/letters.py deleted file mode 100644 index 53303e6..0000000 --- a/src/postgrid/resources/print_mail/order_profiles/letters.py +++ /dev/null @@ -1,947 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Dict, Optional -from typing_extensions import Literal - -import httpx - -from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import path_template, maybe_transform, async_maybe_transform -from ...._compat import cached_property -from ...._resource import SyncAPIResource, AsyncAPIResource -from ...._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ....pagination import SyncSkipLimit, AsyncSkipLimit -from ...._base_client import AsyncPaginator, make_request_options -from ....types.print_mail import LetterSize, AddressPlacement -from ....types.print_mail.letter_size import LetterSize -from ....types.print_mail.order_profiles import ( - letter_list_params, - letter_create_params, - letter_update_params, - letter_retrieve_params, -) -from ....types.print_mail.address_placement import AddressPlacement -from ....types.print_mail.attached_pdf_param import AttachedPdfParam -from ....types.print_mail.order_profiles.letter_profile import LetterProfile -from ....types.print_mail.order_profiles.letter_delete_response import LetterDeleteResponse - -__all__ = ["LettersResource", "AsyncLettersResource"] - - -class LettersResource(SyncAPIResource): - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - - @cached_property - def with_raw_response(self) -> LettersResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers - """ - return LettersResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> LettersResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response - """ - return LettersResourceWithStreamingResponse(self) - - def create( - self, - *, - size: LetterSize, - expand: SequenceNotStr[str] | Omit = omit, - address_placement: AddressPlacement | Omit = omit, - attached_pdf: AttachedPdfParam | Omit = omit, - color: bool | Omit = omit, - description: Optional[str] | Omit = omit, - double_sided: bool | Omit = omit, - envelope: str | Omit = omit, - mailing_class: Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - | Omit = omit, - merge_variables: Optional[Dict[str, object]] | Omit = omit, - metadata: Optional[Dict[str, str]] | Omit = omit, - pdf: str | Omit = omit, - perforated_page: Literal[1] | Omit = omit, - return_envelope: str | Omit = omit, - template: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> LetterProfile: - """Creates a new Letter Profile. - - You must provide either a `template` ID or upload - a `pdf` file for the content. If providing PDF files (`pdf` or - `attachedPDFFile`), the request `Content-Type` must be `multipart/form-data`. - - Args: - size: Enum representing the supported letter sizes. - - expand: Optional list of related resources to expand in the response. - - address_placement: Enum representing the placement of the address on the letter. - - attached_pdf: Model representing an attached PDF. - - color: Specifies whether to print in color (true) or black and white (false). - - description: An optional description for the profile. Set to `null` to remove during update. - - double_sided: Specifies whether to print on both sides of the paper. - - envelope: ID of a custom envelope to use. - - mailing_class: Mailing class. - - merge_variables: Default merge variables for orders created using this profile. - - metadata: Optional key-value metadata. - - pdf: A PDF file containing the letter content. Cannot be used with `template`. - - perforated_page: Specifies which page number should be perforated (if any). - - return_envelope: ID of a return envelope to include. - - template: ID of a template to use for the letter content. Cannot be used with `pdf`. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._post( - "/print-mail/v1/order_profiles/letters", - body=maybe_transform( - { - "size": size, - "address_placement": address_placement, - "attached_pdf": attached_pdf, - "color": color, - "description": description, - "double_sided": double_sided, - "envelope": envelope, - "mailing_class": mailing_class, - "merge_variables": merge_variables, - "metadata": metadata, - "pdf": pdf, - "perforated_page": perforated_page, - "return_envelope": return_envelope, - "template": template, - }, - letter_create_params.LetterCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform({"expand": expand}, letter_create_params.LetterCreateParams), - ), - cast_to=LetterProfile, - ) - - def retrieve( - self, - id: str, - *, - expand: SequenceNotStr[str] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> LetterProfile: - """ - Retrieves the details of a specific Letter Profile by its ID. - - Args: - expand: Optional list of related resources to expand in the response. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._get( - path_template("/print-mail/v1/order_profiles/letters/{id}", id=id), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform({"expand": expand}, letter_retrieve_params.LetterRetrieveParams), - ), - cast_to=LetterProfile, - ) - - def update( - self, - id: str, - *, - expand: SequenceNotStr[str] | Omit = omit, - address_placement: AddressPlacement | Omit = omit, - attached_pdf: AttachedPdfParam | Omit = omit, - color: bool | Omit = omit, - description: Optional[str] | Omit = omit, - double_sided: bool | Omit = omit, - envelope: str | Omit = omit, - mailing_class: Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - | Omit = omit, - merge_variables: Optional[Dict[str, object]] | Omit = omit, - metadata: Optional[Dict[str, str]] | Omit = omit, - pdf: str | Omit = omit, - perforated_page: Literal[1] | Omit = omit, - return_envelope: str | Omit = omit, - template: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> LetterProfile: - """Updates specific fields of an existing Letter Profile. - - Only the fields provided - in the request body will be updated. If providing PDF files (`pdf` or - `attachedPDFFile`), the request `Content-Type` must be `multipart/form-data`. - - Args: - expand: Optional list of related resources to expand in the response. - - address_placement: Enum representing the placement of the address on the letter. - - attached_pdf: Model representing an attached PDF. - - color: Specifies whether to print in color (true) or black and white (false). - - description: An optional description for the profile. Set to `null` to remove during update. - - double_sided: Specifies whether to print on both sides of the paper. - - envelope: ID of a custom envelope to use. - - mailing_class: Mailing class. - - merge_variables: Default merge variables for orders created using this profile. - - metadata: Optional key-value metadata. - - pdf: A PDF file containing the letter content. Cannot be used with `template`. - - perforated_page: Specifies which page number should be perforated (if any). - - return_envelope: ID of a return envelope to include. - - template: ID of a template to use for the letter content. Cannot be used with `pdf`. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._post( - path_template("/print-mail/v1/order_profiles/letters/{id}", id=id), - body=maybe_transform( - { - "address_placement": address_placement, - "attached_pdf": attached_pdf, - "color": color, - "description": description, - "double_sided": double_sided, - "envelope": envelope, - "mailing_class": mailing_class, - "merge_variables": merge_variables, - "metadata": metadata, - "pdf": pdf, - "perforated_page": perforated_page, - "return_envelope": return_envelope, - "template": template, - }, - letter_update_params.LetterUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform({"expand": expand}, letter_update_params.LetterUpdateParams), - ), - cast_to=LetterProfile, - ) - - def list( - self, - *, - limit: int | Omit = omit, - search: str | Omit = omit, - skip: int | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SyncSkipLimit[LetterProfile]: - """Retrieves a list of Letter Profiles. - - The profiles are returned sorted by - creation date, with the most recent appearing first. - - Args: - search: You can supply any string to help narrow down the list of resources. For - example, if you pass `"New York"` (quoted), it will return resources that have - that string present somewhere in their response. Alternatively, you can supply a - structured search query. See the documentation on `StructuredSearchQuery` for - more details. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get_api_list( - "/print-mail/v1/order_profiles/letters", - page=SyncSkipLimit[LetterProfile], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "limit": limit, - "search": search, - "skip": skip, - }, - letter_list_params.LetterListParams, - ), - ), - model=LetterProfile, - ) - - def delete( - self, - id: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> LetterDeleteResponse: - """Deletes a Letter Profile. - - This action cannot be undone. Orders previously - created using this profile are not affected. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._delete( - path_template("/print-mail/v1/order_profiles/letters/{id}", id=id), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=LetterDeleteResponse, - ) - - -class AsyncLettersResource(AsyncAPIResource): - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - - @cached_property - def with_raw_response(self) -> AsyncLettersResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers - """ - return AsyncLettersResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncLettersResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response - """ - return AsyncLettersResourceWithStreamingResponse(self) - - async def create( - self, - *, - size: LetterSize, - expand: SequenceNotStr[str] | Omit = omit, - address_placement: AddressPlacement | Omit = omit, - attached_pdf: AttachedPdfParam | Omit = omit, - color: bool | Omit = omit, - description: Optional[str] | Omit = omit, - double_sided: bool | Omit = omit, - envelope: str | Omit = omit, - mailing_class: Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - | Omit = omit, - merge_variables: Optional[Dict[str, object]] | Omit = omit, - metadata: Optional[Dict[str, str]] | Omit = omit, - pdf: str | Omit = omit, - perforated_page: Literal[1] | Omit = omit, - return_envelope: str | Omit = omit, - template: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> LetterProfile: - """Creates a new Letter Profile. - - You must provide either a `template` ID or upload - a `pdf` file for the content. If providing PDF files (`pdf` or - `attachedPDFFile`), the request `Content-Type` must be `multipart/form-data`. - - Args: - size: Enum representing the supported letter sizes. - - expand: Optional list of related resources to expand in the response. - - address_placement: Enum representing the placement of the address on the letter. - - attached_pdf: Model representing an attached PDF. - - color: Specifies whether to print in color (true) or black and white (false). - - description: An optional description for the profile. Set to `null` to remove during update. - - double_sided: Specifies whether to print on both sides of the paper. - - envelope: ID of a custom envelope to use. - - mailing_class: Mailing class. - - merge_variables: Default merge variables for orders created using this profile. - - metadata: Optional key-value metadata. - - pdf: A PDF file containing the letter content. Cannot be used with `template`. - - perforated_page: Specifies which page number should be perforated (if any). - - return_envelope: ID of a return envelope to include. - - template: ID of a template to use for the letter content. Cannot be used with `pdf`. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._post( - "/print-mail/v1/order_profiles/letters", - body=await async_maybe_transform( - { - "size": size, - "address_placement": address_placement, - "attached_pdf": attached_pdf, - "color": color, - "description": description, - "double_sided": double_sided, - "envelope": envelope, - "mailing_class": mailing_class, - "merge_variables": merge_variables, - "metadata": metadata, - "pdf": pdf, - "perforated_page": perforated_page, - "return_envelope": return_envelope, - "template": template, - }, - letter_create_params.LetterCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform({"expand": expand}, letter_create_params.LetterCreateParams), - ), - cast_to=LetterProfile, - ) - - async def retrieve( - self, - id: str, - *, - expand: SequenceNotStr[str] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> LetterProfile: - """ - Retrieves the details of a specific Letter Profile by its ID. - - Args: - expand: Optional list of related resources to expand in the response. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return await self._get( - path_template("/print-mail/v1/order_profiles/letters/{id}", id=id), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform({"expand": expand}, letter_retrieve_params.LetterRetrieveParams), - ), - cast_to=LetterProfile, - ) - - async def update( - self, - id: str, - *, - expand: SequenceNotStr[str] | Omit = omit, - address_placement: AddressPlacement | Omit = omit, - attached_pdf: AttachedPdfParam | Omit = omit, - color: bool | Omit = omit, - description: Optional[str] | Omit = omit, - double_sided: bool | Omit = omit, - envelope: str | Omit = omit, - mailing_class: Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - | Omit = omit, - merge_variables: Optional[Dict[str, object]] | Omit = omit, - metadata: Optional[Dict[str, str]] | Omit = omit, - pdf: str | Omit = omit, - perforated_page: Literal[1] | Omit = omit, - return_envelope: str | Omit = omit, - template: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> LetterProfile: - """Updates specific fields of an existing Letter Profile. - - Only the fields provided - in the request body will be updated. If providing PDF files (`pdf` or - `attachedPDFFile`), the request `Content-Type` must be `multipart/form-data`. - - Args: - expand: Optional list of related resources to expand in the response. - - address_placement: Enum representing the placement of the address on the letter. - - attached_pdf: Model representing an attached PDF. - - color: Specifies whether to print in color (true) or black and white (false). - - description: An optional description for the profile. Set to `null` to remove during update. - - double_sided: Specifies whether to print on both sides of the paper. - - envelope: ID of a custom envelope to use. - - mailing_class: Mailing class. - - merge_variables: Default merge variables for orders created using this profile. - - metadata: Optional key-value metadata. - - pdf: A PDF file containing the letter content. Cannot be used with `template`. - - perforated_page: Specifies which page number should be perforated (if any). - - return_envelope: ID of a return envelope to include. - - template: ID of a template to use for the letter content. Cannot be used with `pdf`. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return await self._post( - path_template("/print-mail/v1/order_profiles/letters/{id}", id=id), - body=await async_maybe_transform( - { - "address_placement": address_placement, - "attached_pdf": attached_pdf, - "color": color, - "description": description, - "double_sided": double_sided, - "envelope": envelope, - "mailing_class": mailing_class, - "merge_variables": merge_variables, - "metadata": metadata, - "pdf": pdf, - "perforated_page": perforated_page, - "return_envelope": return_envelope, - "template": template, - }, - letter_update_params.LetterUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform({"expand": expand}, letter_update_params.LetterUpdateParams), - ), - cast_to=LetterProfile, - ) - - def list( - self, - *, - limit: int | Omit = omit, - search: str | Omit = omit, - skip: int | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AsyncPaginator[LetterProfile, AsyncSkipLimit[LetterProfile]]: - """Retrieves a list of Letter Profiles. - - The profiles are returned sorted by - creation date, with the most recent appearing first. - - Args: - search: You can supply any string to help narrow down the list of resources. For - example, if you pass `"New York"` (quoted), it will return resources that have - that string present somewhere in their response. Alternatively, you can supply a - structured search query. See the documentation on `StructuredSearchQuery` for - more details. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get_api_list( - "/print-mail/v1/order_profiles/letters", - page=AsyncSkipLimit[LetterProfile], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "limit": limit, - "search": search, - "skip": skip, - }, - letter_list_params.LetterListParams, - ), - ), - model=LetterProfile, - ) - - async def delete( - self, - id: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> LetterDeleteResponse: - """Deletes a Letter Profile. - - This action cannot be undone. Orders previously - created using this profile are not affected. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return await self._delete( - path_template("/print-mail/v1/order_profiles/letters/{id}", id=id), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=LetterDeleteResponse, - ) - - -class LettersResourceWithRawResponse: - def __init__(self, letters: LettersResource) -> None: - self._letters = letters - - self.create = to_raw_response_wrapper( - letters.create, - ) - self.retrieve = to_raw_response_wrapper( - letters.retrieve, - ) - self.update = to_raw_response_wrapper( - letters.update, - ) - self.list = to_raw_response_wrapper( - letters.list, - ) - self.delete = to_raw_response_wrapper( - letters.delete, - ) - - -class AsyncLettersResourceWithRawResponse: - def __init__(self, letters: AsyncLettersResource) -> None: - self._letters = letters - - self.create = async_to_raw_response_wrapper( - letters.create, - ) - self.retrieve = async_to_raw_response_wrapper( - letters.retrieve, - ) - self.update = async_to_raw_response_wrapper( - letters.update, - ) - self.list = async_to_raw_response_wrapper( - letters.list, - ) - self.delete = async_to_raw_response_wrapper( - letters.delete, - ) - - -class LettersResourceWithStreamingResponse: - def __init__(self, letters: LettersResource) -> None: - self._letters = letters - - self.create = to_streamed_response_wrapper( - letters.create, - ) - self.retrieve = to_streamed_response_wrapper( - letters.retrieve, - ) - self.update = to_streamed_response_wrapper( - letters.update, - ) - self.list = to_streamed_response_wrapper( - letters.list, - ) - self.delete = to_streamed_response_wrapper( - letters.delete, - ) - - -class AsyncLettersResourceWithStreamingResponse: - def __init__(self, letters: AsyncLettersResource) -> None: - self._letters = letters - - self.create = async_to_streamed_response_wrapper( - letters.create, - ) - self.retrieve = async_to_streamed_response_wrapper( - letters.retrieve, - ) - self.update = async_to_streamed_response_wrapper( - letters.update, - ) - self.list = async_to_streamed_response_wrapper( - letters.list, - ) - self.delete = async_to_streamed_response_wrapper( - letters.delete, - ) diff --git a/src/postgrid/resources/print_mail/order_profiles/order_profiles.py b/src/postgrid/resources/print_mail/order_profiles/order_profiles.py deleted file mode 100644 index cebb2b8..0000000 --- a/src/postgrid/resources/print_mail/order_profiles/order_profiles.py +++ /dev/null @@ -1,366 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from .cheques import ( - ChequesResource, - AsyncChequesResource, - ChequesResourceWithRawResponse, - AsyncChequesResourceWithRawResponse, - ChequesResourceWithStreamingResponse, - AsyncChequesResourceWithStreamingResponse, -) -from .letters import ( - LettersResource, - AsyncLettersResource, - LettersResourceWithRawResponse, - AsyncLettersResourceWithRawResponse, - LettersResourceWithStreamingResponse, - AsyncLettersResourceWithStreamingResponse, -) -from .postcards import ( - PostcardsResource, - AsyncPostcardsResource, - PostcardsResourceWithRawResponse, - AsyncPostcardsResourceWithRawResponse, - PostcardsResourceWithStreamingResponse, - AsyncPostcardsResourceWithStreamingResponse, -) -from ...._compat import cached_property -from ...._resource import SyncAPIResource, AsyncAPIResource -from .self_mailers import ( - SelfMailersResource, - AsyncSelfMailersResource, - SelfMailersResourceWithRawResponse, - AsyncSelfMailersResourceWithRawResponse, - SelfMailersResourceWithStreamingResponse, - AsyncSelfMailersResourceWithStreamingResponse, -) - -__all__ = ["OrderProfilesResource", "AsyncOrderProfilesResource"] - - -class OrderProfilesResource(SyncAPIResource): - @cached_property - def cheques(self) -> ChequesResource: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return ChequesResource(self._client) - - @cached_property - def letters(self) -> LettersResource: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return LettersResource(self._client) - - @cached_property - def postcards(self) -> PostcardsResource: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return PostcardsResource(self._client) - - @cached_property - def self_mailers(self) -> SelfMailersResource: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return SelfMailersResource(self._client) - - @cached_property - def with_raw_response(self) -> OrderProfilesResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers - """ - return OrderProfilesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> OrderProfilesResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response - """ - return OrderProfilesResourceWithStreamingResponse(self) - - -class AsyncOrderProfilesResource(AsyncAPIResource): - @cached_property - def cheques(self) -> AsyncChequesResource: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return AsyncChequesResource(self._client) - - @cached_property - def letters(self) -> AsyncLettersResource: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return AsyncLettersResource(self._client) - - @cached_property - def postcards(self) -> AsyncPostcardsResource: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return AsyncPostcardsResource(self._client) - - @cached_property - def self_mailers(self) -> AsyncSelfMailersResource: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return AsyncSelfMailersResource(self._client) - - @cached_property - def with_raw_response(self) -> AsyncOrderProfilesResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers - """ - return AsyncOrderProfilesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncOrderProfilesResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response - """ - return AsyncOrderProfilesResourceWithStreamingResponse(self) - - -class OrderProfilesResourceWithRawResponse: - def __init__(self, order_profiles: OrderProfilesResource) -> None: - self._order_profiles = order_profiles - - @cached_property - def cheques(self) -> ChequesResourceWithRawResponse: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return ChequesResourceWithRawResponse(self._order_profiles.cheques) - - @cached_property - def letters(self) -> LettersResourceWithRawResponse: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return LettersResourceWithRawResponse(self._order_profiles.letters) - - @cached_property - def postcards(self) -> PostcardsResourceWithRawResponse: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return PostcardsResourceWithRawResponse(self._order_profiles.postcards) - - @cached_property - def self_mailers(self) -> SelfMailersResourceWithRawResponse: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return SelfMailersResourceWithRawResponse(self._order_profiles.self_mailers) - - -class AsyncOrderProfilesResourceWithRawResponse: - def __init__(self, order_profiles: AsyncOrderProfilesResource) -> None: - self._order_profiles = order_profiles - - @cached_property - def cheques(self) -> AsyncChequesResourceWithRawResponse: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return AsyncChequesResourceWithRawResponse(self._order_profiles.cheques) - - @cached_property - def letters(self) -> AsyncLettersResourceWithRawResponse: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return AsyncLettersResourceWithRawResponse(self._order_profiles.letters) - - @cached_property - def postcards(self) -> AsyncPostcardsResourceWithRawResponse: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return AsyncPostcardsResourceWithRawResponse(self._order_profiles.postcards) - - @cached_property - def self_mailers(self) -> AsyncSelfMailersResourceWithRawResponse: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return AsyncSelfMailersResourceWithRawResponse(self._order_profiles.self_mailers) - - -class OrderProfilesResourceWithStreamingResponse: - def __init__(self, order_profiles: OrderProfilesResource) -> None: - self._order_profiles = order_profiles - - @cached_property - def cheques(self) -> ChequesResourceWithStreamingResponse: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return ChequesResourceWithStreamingResponse(self._order_profiles.cheques) - - @cached_property - def letters(self) -> LettersResourceWithStreamingResponse: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return LettersResourceWithStreamingResponse(self._order_profiles.letters) - - @cached_property - def postcards(self) -> PostcardsResourceWithStreamingResponse: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return PostcardsResourceWithStreamingResponse(self._order_profiles.postcards) - - @cached_property - def self_mailers(self) -> SelfMailersResourceWithStreamingResponse: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return SelfMailersResourceWithStreamingResponse(self._order_profiles.self_mailers) - - -class AsyncOrderProfilesResourceWithStreamingResponse: - def __init__(self, order_profiles: AsyncOrderProfilesResource) -> None: - self._order_profiles = order_profiles - - @cached_property - def cheques(self) -> AsyncChequesResourceWithStreamingResponse: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return AsyncChequesResourceWithStreamingResponse(self._order_profiles.cheques) - - @cached_property - def letters(self) -> AsyncLettersResourceWithStreamingResponse: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return AsyncLettersResourceWithStreamingResponse(self._order_profiles.letters) - - @cached_property - def postcards(self) -> AsyncPostcardsResourceWithStreamingResponse: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return AsyncPostcardsResourceWithStreamingResponse(self._order_profiles.postcards) - - @cached_property - def self_mailers(self) -> AsyncSelfMailersResourceWithStreamingResponse: - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - return AsyncSelfMailersResourceWithStreamingResponse(self._order_profiles.self_mailers) diff --git a/src/postgrid/resources/print_mail/order_profiles/postcards.py b/src/postgrid/resources/print_mail/order_profiles/postcards.py deleted file mode 100644 index 059a1e3..0000000 --- a/src/postgrid/resources/print_mail/order_profiles/postcards.py +++ /dev/null @@ -1,847 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Dict, Optional -from typing_extensions import Literal - -import httpx - -from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import path_template, maybe_transform, async_maybe_transform -from ...._compat import cached_property -from ...._resource import SyncAPIResource, AsyncAPIResource -from ...._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ....pagination import SyncSkipLimit, AsyncSkipLimit -from ...._base_client import AsyncPaginator, make_request_options -from ....types.print_mail.order_profiles import ( - PostcardSize, - postcard_list_params, - postcard_create_params, - postcard_update_params, - postcard_retrieve_params, -) -from ....types.print_mail.order_profiles.postcard_size import PostcardSize -from ....types.print_mail.order_profiles.postcard_profile import PostcardProfile -from ....types.print_mail.order_profiles.postcard_delete_response import PostcardDeleteResponse - -__all__ = ["PostcardsResource", "AsyncPostcardsResource"] - - -class PostcardsResource(SyncAPIResource): - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - - @cached_property - def with_raw_response(self) -> PostcardsResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers - """ - return PostcardsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> PostcardsResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response - """ - return PostcardsResourceWithStreamingResponse(self) - - def create( - self, - *, - size: PostcardSize, - expand: SequenceNotStr[str] | Omit = omit, - back_template: str | Omit = omit, - description: Optional[str] | Omit = omit, - front_template: str | Omit = omit, - mailing_class: Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - | Omit = omit, - merge_variables: Optional[Dict[str, object]] | Omit = omit, - metadata: Optional[Dict[str, str]] | Omit = omit, - pdf: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> PostcardProfile: - """Creates a new Postcard Profile. - - Provide either `frontTemplate` and - `backTemplate` IDs, or upload a 2-page `pdf`. If providing a `pdf`, the request - `Content-Type` must be `multipart/form-data`. - - Args: - size: Enum representing the supported postcard sizes. - - expand: Optional list of related resources to expand in the response. - - back_template: ID of the template for the back side. Required unless `pdf` is provided. - - description: An optional description for the profile. Set to `null` to remove during update. - - front_template: ID of the template for the front side. Required unless `pdf` is provided. - - mailing_class: Mailing class (cannot include extra services like `certified` or `registered` - for postcards, though). - - merge_variables: Default merge variables for orders created using this profile. - - metadata: Optional key-value metadata. - - pdf: A 2-page PDF file containing the postcard content (front and back). Cannot be - used with `frontTemplate`/`backTemplate`. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._post( - "/print-mail/v1/order_profiles/postcards", - body=maybe_transform( - { - "size": size, - "back_template": back_template, - "description": description, - "front_template": front_template, - "mailing_class": mailing_class, - "merge_variables": merge_variables, - "metadata": metadata, - "pdf": pdf, - }, - postcard_create_params.PostcardCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform({"expand": expand}, postcard_create_params.PostcardCreateParams), - ), - cast_to=PostcardProfile, - ) - - def retrieve( - self, - id: str, - *, - expand: SequenceNotStr[str] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> PostcardProfile: - """ - Retrieves the details of a specific Postcard Profile. - - Args: - expand: Optional list of related resources to expand in the response. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._get( - path_template("/print-mail/v1/order_profiles/postcards/{id}", id=id), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform({"expand": expand}, postcard_retrieve_params.PostcardRetrieveParams), - ), - cast_to=PostcardProfile, - ) - - def update( - self, - id: str, - *, - expand: SequenceNotStr[str] | Omit = omit, - back_template: str | Omit = omit, - description: Optional[str] | Omit = omit, - front_template: str | Omit = omit, - mailing_class: Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - | Omit = omit, - merge_variables: Optional[Dict[str, object]] | Omit = omit, - metadata: Optional[Dict[str, str]] | Omit = omit, - pdf: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> PostcardProfile: - """Updates specific fields of an existing Postcard Profile. - - If providing a `pdf`, - the request `Content-Type` must be `multipart/form-data`. - - Args: - expand: Optional list of related resources to expand in the response. - - back_template: ID of the template for the back side. Required unless `pdf` is provided. - - description: An optional description for the profile. Set to `null` to remove during update. - - front_template: ID of the template for the front side. Required unless `pdf` is provided. - - mailing_class: Mailing class (cannot include extra services like `certified` or `registered` - for postcards, though). - - merge_variables: Default merge variables for orders created using this profile. - - metadata: Optional key-value metadata. - - pdf: A 2-page PDF file containing the postcard content (front and back). Cannot be - used with `frontTemplate`/`backTemplate`. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._post( - path_template("/print-mail/v1/order_profiles/postcards/{id}", id=id), - body=maybe_transform( - { - "back_template": back_template, - "description": description, - "front_template": front_template, - "mailing_class": mailing_class, - "merge_variables": merge_variables, - "metadata": metadata, - "pdf": pdf, - }, - postcard_update_params.PostcardUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform({"expand": expand}, postcard_update_params.PostcardUpdateParams), - ), - cast_to=PostcardProfile, - ) - - def list( - self, - *, - limit: int | Omit = omit, - search: str | Omit = omit, - skip: int | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SyncSkipLimit[PostcardProfile]: - """ - Retrieves a list of Postcard Profiles. - - Args: - search: You can supply any string to help narrow down the list of resources. For - example, if you pass `"New York"` (quoted), it will return resources that have - that string present somewhere in their response. Alternatively, you can supply a - structured search query. See the documentation on `StructuredSearchQuery` for - more details. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get_api_list( - "/print-mail/v1/order_profiles/postcards", - page=SyncSkipLimit[PostcardProfile], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "limit": limit, - "search": search, - "skip": skip, - }, - postcard_list_params.PostcardListParams, - ), - ), - model=PostcardProfile, - ) - - def delete( - self, - id: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> PostcardDeleteResponse: - """ - Deletes a Postcard Profile. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._delete( - path_template("/print-mail/v1/order_profiles/postcards/{id}", id=id), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=PostcardDeleteResponse, - ) - - -class AsyncPostcardsResource(AsyncAPIResource): - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - - @cached_property - def with_raw_response(self) -> AsyncPostcardsResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers - """ - return AsyncPostcardsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncPostcardsResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response - """ - return AsyncPostcardsResourceWithStreamingResponse(self) - - async def create( - self, - *, - size: PostcardSize, - expand: SequenceNotStr[str] | Omit = omit, - back_template: str | Omit = omit, - description: Optional[str] | Omit = omit, - front_template: str | Omit = omit, - mailing_class: Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - | Omit = omit, - merge_variables: Optional[Dict[str, object]] | Omit = omit, - metadata: Optional[Dict[str, str]] | Omit = omit, - pdf: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> PostcardProfile: - """Creates a new Postcard Profile. - - Provide either `frontTemplate` and - `backTemplate` IDs, or upload a 2-page `pdf`. If providing a `pdf`, the request - `Content-Type` must be `multipart/form-data`. - - Args: - size: Enum representing the supported postcard sizes. - - expand: Optional list of related resources to expand in the response. - - back_template: ID of the template for the back side. Required unless `pdf` is provided. - - description: An optional description for the profile. Set to `null` to remove during update. - - front_template: ID of the template for the front side. Required unless `pdf` is provided. - - mailing_class: Mailing class (cannot include extra services like `certified` or `registered` - for postcards, though). - - merge_variables: Default merge variables for orders created using this profile. - - metadata: Optional key-value metadata. - - pdf: A 2-page PDF file containing the postcard content (front and back). Cannot be - used with `frontTemplate`/`backTemplate`. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._post( - "/print-mail/v1/order_profiles/postcards", - body=await async_maybe_transform( - { - "size": size, - "back_template": back_template, - "description": description, - "front_template": front_template, - "mailing_class": mailing_class, - "merge_variables": merge_variables, - "metadata": metadata, - "pdf": pdf, - }, - postcard_create_params.PostcardCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform({"expand": expand}, postcard_create_params.PostcardCreateParams), - ), - cast_to=PostcardProfile, - ) - - async def retrieve( - self, - id: str, - *, - expand: SequenceNotStr[str] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> PostcardProfile: - """ - Retrieves the details of a specific Postcard Profile. - - Args: - expand: Optional list of related resources to expand in the response. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return await self._get( - path_template("/print-mail/v1/order_profiles/postcards/{id}", id=id), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform({"expand": expand}, postcard_retrieve_params.PostcardRetrieveParams), - ), - cast_to=PostcardProfile, - ) - - async def update( - self, - id: str, - *, - expand: SequenceNotStr[str] | Omit = omit, - back_template: str | Omit = omit, - description: Optional[str] | Omit = omit, - front_template: str | Omit = omit, - mailing_class: Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - | Omit = omit, - merge_variables: Optional[Dict[str, object]] | Omit = omit, - metadata: Optional[Dict[str, str]] | Omit = omit, - pdf: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> PostcardProfile: - """Updates specific fields of an existing Postcard Profile. - - If providing a `pdf`, - the request `Content-Type` must be `multipart/form-data`. - - Args: - expand: Optional list of related resources to expand in the response. - - back_template: ID of the template for the back side. Required unless `pdf` is provided. - - description: An optional description for the profile. Set to `null` to remove during update. - - front_template: ID of the template for the front side. Required unless `pdf` is provided. - - mailing_class: Mailing class (cannot include extra services like `certified` or `registered` - for postcards, though). - - merge_variables: Default merge variables for orders created using this profile. - - metadata: Optional key-value metadata. - - pdf: A 2-page PDF file containing the postcard content (front and back). Cannot be - used with `frontTemplate`/`backTemplate`. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return await self._post( - path_template("/print-mail/v1/order_profiles/postcards/{id}", id=id), - body=await async_maybe_transform( - { - "back_template": back_template, - "description": description, - "front_template": front_template, - "mailing_class": mailing_class, - "merge_variables": merge_variables, - "metadata": metadata, - "pdf": pdf, - }, - postcard_update_params.PostcardUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform({"expand": expand}, postcard_update_params.PostcardUpdateParams), - ), - cast_to=PostcardProfile, - ) - - def list( - self, - *, - limit: int | Omit = omit, - search: str | Omit = omit, - skip: int | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AsyncPaginator[PostcardProfile, AsyncSkipLimit[PostcardProfile]]: - """ - Retrieves a list of Postcard Profiles. - - Args: - search: You can supply any string to help narrow down the list of resources. For - example, if you pass `"New York"` (quoted), it will return resources that have - that string present somewhere in their response. Alternatively, you can supply a - structured search query. See the documentation on `StructuredSearchQuery` for - more details. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get_api_list( - "/print-mail/v1/order_profiles/postcards", - page=AsyncSkipLimit[PostcardProfile], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "limit": limit, - "search": search, - "skip": skip, - }, - postcard_list_params.PostcardListParams, - ), - ), - model=PostcardProfile, - ) - - async def delete( - self, - id: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> PostcardDeleteResponse: - """ - Deletes a Postcard Profile. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return await self._delete( - path_template("/print-mail/v1/order_profiles/postcards/{id}", id=id), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=PostcardDeleteResponse, - ) - - -class PostcardsResourceWithRawResponse: - def __init__(self, postcards: PostcardsResource) -> None: - self._postcards = postcards - - self.create = to_raw_response_wrapper( - postcards.create, - ) - self.retrieve = to_raw_response_wrapper( - postcards.retrieve, - ) - self.update = to_raw_response_wrapper( - postcards.update, - ) - self.list = to_raw_response_wrapper( - postcards.list, - ) - self.delete = to_raw_response_wrapper( - postcards.delete, - ) - - -class AsyncPostcardsResourceWithRawResponse: - def __init__(self, postcards: AsyncPostcardsResource) -> None: - self._postcards = postcards - - self.create = async_to_raw_response_wrapper( - postcards.create, - ) - self.retrieve = async_to_raw_response_wrapper( - postcards.retrieve, - ) - self.update = async_to_raw_response_wrapper( - postcards.update, - ) - self.list = async_to_raw_response_wrapper( - postcards.list, - ) - self.delete = async_to_raw_response_wrapper( - postcards.delete, - ) - - -class PostcardsResourceWithStreamingResponse: - def __init__(self, postcards: PostcardsResource) -> None: - self._postcards = postcards - - self.create = to_streamed_response_wrapper( - postcards.create, - ) - self.retrieve = to_streamed_response_wrapper( - postcards.retrieve, - ) - self.update = to_streamed_response_wrapper( - postcards.update, - ) - self.list = to_streamed_response_wrapper( - postcards.list, - ) - self.delete = to_streamed_response_wrapper( - postcards.delete, - ) - - -class AsyncPostcardsResourceWithStreamingResponse: - def __init__(self, postcards: AsyncPostcardsResource) -> None: - self._postcards = postcards - - self.create = async_to_streamed_response_wrapper( - postcards.create, - ) - self.retrieve = async_to_streamed_response_wrapper( - postcards.retrieve, - ) - self.update = async_to_streamed_response_wrapper( - postcards.update, - ) - self.list = async_to_streamed_response_wrapper( - postcards.list, - ) - self.delete = async_to_streamed_response_wrapper( - postcards.delete, - ) diff --git a/src/postgrid/resources/print_mail/order_profiles/self_mailers.py b/src/postgrid/resources/print_mail/order_profiles/self_mailers.py deleted file mode 100644 index 161c8f6..0000000 --- a/src/postgrid/resources/print_mail/order_profiles/self_mailers.py +++ /dev/null @@ -1,853 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Dict, Optional -from typing_extensions import Literal - -import httpx - -from ...._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given -from ...._utils import path_template, maybe_transform, async_maybe_transform -from ...._compat import cached_property -from ...._resource import SyncAPIResource, AsyncAPIResource -from ...._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ....pagination import SyncSkipLimit, AsyncSkipLimit -from ...._base_client import AsyncPaginator, make_request_options -from ....types.print_mail.order_profiles import ( - SelfMailerSize, - self_mailer_list_params, - self_mailer_create_params, - self_mailer_update_params, - self_mailer_retrieve_params, -) -from ....types.print_mail.order_profiles.self_mailer_size import SelfMailerSize -from ....types.print_mail.order_profiles.self_mailer_profile import SelfMailerProfile -from ....types.print_mail.order_profiles.self_mailer_delete_response import SelfMailerDeleteResponse - -__all__ = ["SelfMailersResource", "AsyncSelfMailersResource"] - - -class SelfMailersResource(SyncAPIResource): - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - - @cached_property - def with_raw_response(self) -> SelfMailersResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers - """ - return SelfMailersResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> SelfMailersResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response - """ - return SelfMailersResourceWithStreamingResponse(self) - - def create( - self, - *, - size: SelfMailerSize, - expand: SequenceNotStr[str] | Omit = omit, - description: Optional[str] | Omit = omit, - inside_template: str | Omit = omit, - mailing_class: Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - | Omit = omit, - merge_variables: Optional[Dict[str, object]] | Omit = omit, - metadata: Optional[Dict[str, str]] | Omit = omit, - outside_template: str | Omit = omit, - pdf: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SelfMailerProfile: - """Creates a new Self-Mailer Profile. - - Provide either `insideTemplate` and - `outsideTemplate` IDs, or upload a 2-page `pdf`. If providing a `pdf`, the - request `Content-Type` must be `multipart/form-data`. - - Args: - size: Enum representing the supported self-mailer sizes. - - expand: Optional list of related resources to expand in the response. - - description: An optional description for the profile. Set to `null` to remove during update. - - inside_template: ID of the template for the inside. Required unless `pdf` is provided. - - mailing_class: Mailing class (cannot include extra services for self-mailers). - - merge_variables: Default merge variables for orders created using this profile. - - metadata: Optional key-value metadata. - - outside_template: ID of the template for the outside. Required unless `pdf` is provided. - - pdf: A 2-page PDF file containing the self-mailer content (inside and outside). - Cannot be used with `insideTemplate`/`outsideTemplate`. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._post( - "/print-mail/v1/order_profiles/self_mailers", - body=maybe_transform( - { - "size": size, - "description": description, - "inside_template": inside_template, - "mailing_class": mailing_class, - "merge_variables": merge_variables, - "metadata": metadata, - "outside_template": outside_template, - "pdf": pdf, - }, - self_mailer_create_params.SelfMailerCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform({"expand": expand}, self_mailer_create_params.SelfMailerCreateParams), - ), - cast_to=SelfMailerProfile, - ) - - def retrieve( - self, - id: str, - *, - expand: SequenceNotStr[str] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SelfMailerProfile: - """ - Retrieves the details of a specific Self-Mailer Profile. - - Args: - expand: Optional list of related resources to expand in the response. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._get( - path_template("/print-mail/v1/order_profiles/self_mailers/{id}", id=id), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform({"expand": expand}, self_mailer_retrieve_params.SelfMailerRetrieveParams), - ), - cast_to=SelfMailerProfile, - ) - - def update( - self, - id: str, - *, - size: SelfMailerSize, - expand: SequenceNotStr[str] | Omit = omit, - description: Optional[str] | Omit = omit, - inside_template: str | Omit = omit, - mailing_class: Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - | Omit = omit, - merge_variables: Optional[Dict[str, object]] | Omit = omit, - metadata: Optional[Dict[str, str]] | Omit = omit, - outside_template: str | Omit = omit, - pdf: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SelfMailerProfile: - """Updates specific fields of an existing Self-Mailer Profile. - - If providing a - `pdf`, the request `Content-Type` must be `multipart/form-data`. - - Args: - size: Enum representing the supported self-mailer sizes. - - expand: Optional list of related resources to expand in the response. - - description: An optional description for the profile. Set to `null` to remove during update. - - inside_template: ID of the template for the inside. Required unless `pdf` is provided. - - mailing_class: Mailing class (cannot include extra services for self-mailers). - - merge_variables: Default merge variables for orders created using this profile. - - metadata: Optional key-value metadata. - - outside_template: ID of the template for the outside. Required unless `pdf` is provided. - - pdf: A 2-page PDF file containing the self-mailer content (inside and outside). - Cannot be used with `insideTemplate`/`outsideTemplate`. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._post( - path_template("/print-mail/v1/order_profiles/self_mailers/{id}", id=id), - body=maybe_transform( - { - "size": size, - "description": description, - "inside_template": inside_template, - "mailing_class": mailing_class, - "merge_variables": merge_variables, - "metadata": metadata, - "outside_template": outside_template, - "pdf": pdf, - }, - self_mailer_update_params.SelfMailerUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform({"expand": expand}, self_mailer_update_params.SelfMailerUpdateParams), - ), - cast_to=SelfMailerProfile, - ) - - def list( - self, - *, - limit: int | Omit = omit, - search: str | Omit = omit, - skip: int | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SyncSkipLimit[SelfMailerProfile]: - """ - Retrieves a list of Self-Mailer Profiles. - - Args: - search: You can supply any string to help narrow down the list of resources. For - example, if you pass `"New York"` (quoted), it will return resources that have - that string present somewhere in their response. Alternatively, you can supply a - structured search query. See the documentation on `StructuredSearchQuery` for - more details. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get_api_list( - "/print-mail/v1/order_profiles/self_mailers", - page=SyncSkipLimit[SelfMailerProfile], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "limit": limit, - "search": search, - "skip": skip, - }, - self_mailer_list_params.SelfMailerListParams, - ), - ), - model=SelfMailerProfile, - ) - - def delete( - self, - id: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SelfMailerDeleteResponse: - """ - Deletes a Self-Mailer Profile. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._delete( - path_template("/print-mail/v1/order_profiles/self_mailers/{id}", id=id), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=SelfMailerDeleteResponse, - ) - - -class AsyncSelfMailersResource(AsyncAPIResource): - """ - Order Profiles are reusable blueprints for creating print and mail orders (Letters, Postcards, Cheques, Self-Mailers). - They define common properties like size, content (via templates or uploaded PDFs), mailing class, and metadata. - Using profiles simplifies order creation, especially for recurring mailings or campaigns, by pre-filling many parameters. - - Profiles are environment-specific (live vs. test). - """ - - @cached_property - def with_raw_response(self) -> AsyncSelfMailersResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers - """ - return AsyncSelfMailersResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncSelfMailersResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response - """ - return AsyncSelfMailersResourceWithStreamingResponse(self) - - async def create( - self, - *, - size: SelfMailerSize, - expand: SequenceNotStr[str] | Omit = omit, - description: Optional[str] | Omit = omit, - inside_template: str | Omit = omit, - mailing_class: Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - | Omit = omit, - merge_variables: Optional[Dict[str, object]] | Omit = omit, - metadata: Optional[Dict[str, str]] | Omit = omit, - outside_template: str | Omit = omit, - pdf: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SelfMailerProfile: - """Creates a new Self-Mailer Profile. - - Provide either `insideTemplate` and - `outsideTemplate` IDs, or upload a 2-page `pdf`. If providing a `pdf`, the - request `Content-Type` must be `multipart/form-data`. - - Args: - size: Enum representing the supported self-mailer sizes. - - expand: Optional list of related resources to expand in the response. - - description: An optional description for the profile. Set to `null` to remove during update. - - inside_template: ID of the template for the inside. Required unless `pdf` is provided. - - mailing_class: Mailing class (cannot include extra services for self-mailers). - - merge_variables: Default merge variables for orders created using this profile. - - metadata: Optional key-value metadata. - - outside_template: ID of the template for the outside. Required unless `pdf` is provided. - - pdf: A 2-page PDF file containing the self-mailer content (inside and outside). - Cannot be used with `insideTemplate`/`outsideTemplate`. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return await self._post( - "/print-mail/v1/order_profiles/self_mailers", - body=await async_maybe_transform( - { - "size": size, - "description": description, - "inside_template": inside_template, - "mailing_class": mailing_class, - "merge_variables": merge_variables, - "metadata": metadata, - "outside_template": outside_template, - "pdf": pdf, - }, - self_mailer_create_params.SelfMailerCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform({"expand": expand}, self_mailer_create_params.SelfMailerCreateParams), - ), - cast_to=SelfMailerProfile, - ) - - async def retrieve( - self, - id: str, - *, - expand: SequenceNotStr[str] | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SelfMailerProfile: - """ - Retrieves the details of a specific Self-Mailer Profile. - - Args: - expand: Optional list of related resources to expand in the response. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return await self._get( - path_template("/print-mail/v1/order_profiles/self_mailers/{id}", id=id), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform( - {"expand": expand}, self_mailer_retrieve_params.SelfMailerRetrieveParams - ), - ), - cast_to=SelfMailerProfile, - ) - - async def update( - self, - id: str, - *, - size: SelfMailerSize, - expand: SequenceNotStr[str] | Omit = omit, - description: Optional[str] | Omit = omit, - inside_template: str | Omit = omit, - mailing_class: Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - | Omit = omit, - merge_variables: Optional[Dict[str, object]] | Omit = omit, - metadata: Optional[Dict[str, str]] | Omit = omit, - outside_template: str | Omit = omit, - pdf: str | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SelfMailerProfile: - """Updates specific fields of an existing Self-Mailer Profile. - - If providing a - `pdf`, the request `Content-Type` must be `multipart/form-data`. - - Args: - size: Enum representing the supported self-mailer sizes. - - expand: Optional list of related resources to expand in the response. - - description: An optional description for the profile. Set to `null` to remove during update. - - inside_template: ID of the template for the inside. Required unless `pdf` is provided. - - mailing_class: Mailing class (cannot include extra services for self-mailers). - - merge_variables: Default merge variables for orders created using this profile. - - metadata: Optional key-value metadata. - - outside_template: ID of the template for the outside. Required unless `pdf` is provided. - - pdf: A 2-page PDF file containing the self-mailer content (inside and outside). - Cannot be used with `insideTemplate`/`outsideTemplate`. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return await self._post( - path_template("/print-mail/v1/order_profiles/self_mailers/{id}", id=id), - body=await async_maybe_transform( - { - "size": size, - "description": description, - "inside_template": inside_template, - "mailing_class": mailing_class, - "merge_variables": merge_variables, - "metadata": metadata, - "outside_template": outside_template, - "pdf": pdf, - }, - self_mailer_update_params.SelfMailerUpdateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=await async_maybe_transform({"expand": expand}, self_mailer_update_params.SelfMailerUpdateParams), - ), - cast_to=SelfMailerProfile, - ) - - def list( - self, - *, - limit: int | Omit = omit, - search: str | Omit = omit, - skip: int | Omit = omit, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> AsyncPaginator[SelfMailerProfile, AsyncSkipLimit[SelfMailerProfile]]: - """ - Retrieves a list of Self-Mailer Profiles. - - Args: - search: You can supply any string to help narrow down the list of resources. For - example, if you pass `"New York"` (quoted), it will return resources that have - that string present somewhere in their response. Alternatively, you can supply a - structured search query. See the documentation on `StructuredSearchQuery` for - more details. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - return self._get_api_list( - "/print-mail/v1/order_profiles/self_mailers", - page=AsyncSkipLimit[SelfMailerProfile], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "limit": limit, - "search": search, - "skip": skip, - }, - self_mailer_list_params.SelfMailerListParams, - ), - ), - model=SelfMailerProfile, - ) - - async def delete( - self, - id: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SelfMailerDeleteResponse: - """ - Deletes a Self-Mailer Profile. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return await self._delete( - path_template("/print-mail/v1/order_profiles/self_mailers/{id}", id=id), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=SelfMailerDeleteResponse, - ) - - -class SelfMailersResourceWithRawResponse: - def __init__(self, self_mailers: SelfMailersResource) -> None: - self._self_mailers = self_mailers - - self.create = to_raw_response_wrapper( - self_mailers.create, - ) - self.retrieve = to_raw_response_wrapper( - self_mailers.retrieve, - ) - self.update = to_raw_response_wrapper( - self_mailers.update, - ) - self.list = to_raw_response_wrapper( - self_mailers.list, - ) - self.delete = to_raw_response_wrapper( - self_mailers.delete, - ) - - -class AsyncSelfMailersResourceWithRawResponse: - def __init__(self, self_mailers: AsyncSelfMailersResource) -> None: - self._self_mailers = self_mailers - - self.create = async_to_raw_response_wrapper( - self_mailers.create, - ) - self.retrieve = async_to_raw_response_wrapper( - self_mailers.retrieve, - ) - self.update = async_to_raw_response_wrapper( - self_mailers.update, - ) - self.list = async_to_raw_response_wrapper( - self_mailers.list, - ) - self.delete = async_to_raw_response_wrapper( - self_mailers.delete, - ) - - -class SelfMailersResourceWithStreamingResponse: - def __init__(self, self_mailers: SelfMailersResource) -> None: - self._self_mailers = self_mailers - - self.create = to_streamed_response_wrapper( - self_mailers.create, - ) - self.retrieve = to_streamed_response_wrapper( - self_mailers.retrieve, - ) - self.update = to_streamed_response_wrapper( - self_mailers.update, - ) - self.list = to_streamed_response_wrapper( - self_mailers.list, - ) - self.delete = to_streamed_response_wrapper( - self_mailers.delete, - ) - - -class AsyncSelfMailersResourceWithStreamingResponse: - def __init__(self, self_mailers: AsyncSelfMailersResource) -> None: - self._self_mailers = self_mailers - - self.create = async_to_streamed_response_wrapper( - self_mailers.create, - ) - self.retrieve = async_to_streamed_response_wrapper( - self_mailers.retrieve, - ) - self.update = async_to_streamed_response_wrapper( - self_mailers.update, - ) - self.list = async_to_streamed_response_wrapper( - self_mailers.list, - ) - self.delete = async_to_streamed_response_wrapper( - self_mailers.delete, - ) diff --git a/src/postgrid/resources/print_mail/postcards.py b/src/postgrid/resources/print_mail/postcards.py index 49bf5ae..746ac36 100644 --- a/src/postgrid/resources/print_mail/postcards.py +++ b/src/postgrid/resources/print_mail/postcards.py @@ -22,8 +22,6 @@ from ..._base_client import AsyncPaginator, make_request_options from ...types.print_mail import postcard_list_params, postcard_create_params from ...types.print_mail.postcard import Postcard -from ...types.print_mail.order_profiles import PostcardSize -from ...types.print_mail.order_profiles.postcard_size import PostcardSize from ...types.print_mail.postcard_retrieve_url_response import PostcardRetrieveURLResponse __all__ = ["PostcardsResource", "AsyncPostcardsResource"] @@ -55,7 +53,7 @@ def create( *, back_html: str, front_html: str, - size: PostcardSize, + size: Literal["6x4", "9x6", "11x6"], to: postcard_create_params.PostcardCreateWithHTMLTo, description: str | Omit = omit, from_: postcard_create_params.PostcardCreateWithHTMLFrom | Omit = omit, @@ -90,6 +88,7 @@ def create( | Omit = omit, merge_variables: Dict[str, object] | Omit = omit, metadata: Dict[str, object] | Omit = omit, + paper: str | Omit = omit, send_date: Union[str, datetime] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -139,6 +138,9 @@ def create( metadata: See the section on Metadata. + paper: Premium paper identifier. Use "standard" for regular stock or a premium*paper*\\** + ID. + send_date: This order will transition from `ready` to `printing` on the day after this date. You can use this parameter to schedule orders for a future date. @@ -197,7 +199,7 @@ def create( self, *, pdf: str, - size: PostcardSize, + size: Literal["6x4", "9x6", "11x6"], to: postcard_create_params.PostcardCreateWithPdfurlTo, description: str | Omit = omit, from_: postcard_create_params.PostcardCreateWithPdfurlFrom | Omit = omit, @@ -232,6 +234,7 @@ def create( | Omit = omit, merge_variables: Dict[str, object] | Omit = omit, metadata: Dict[str, object] | Omit = omit, + paper: str | Omit = omit, send_date: Union[str, datetime] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -278,6 +281,9 @@ def create( metadata: See the section on Metadata. + paper: Premium paper identifier. Use "standard" for regular stock or a premium*paper*\\** + ID. + send_date: This order will transition from `ready` to `printing` on the day after this date. You can use this parameter to schedule orders for a future date. @@ -296,7 +302,7 @@ def create( self, *, pdf: Union[str, Base64FileInput], - size: PostcardSize, + size: Literal["6x4", "9x6", "11x6"], to: postcard_create_params.PostcardCreateWithPdfFileTo, description: str | Omit = omit, from_: postcard_create_params.PostcardCreateWithPdfFileFrom | Omit = omit, @@ -331,6 +337,7 @@ def create( | Omit = omit, merge_variables: Dict[str, object] | Omit = omit, metadata: Dict[str, object] | Omit = omit, + paper: str | Omit = omit, send_date: Union[str, datetime] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -377,6 +384,9 @@ def create( metadata: See the section on Metadata. + paper: Premium paper identifier. Use "standard" for regular stock or a premium*paper*\\** + ID. + send_date: This order will transition from `ready` to `printing` on the day after this date. You can use this parameter to schedule orders for a future date. @@ -398,7 +408,7 @@ def create( *, back_html: str | Omit = omit, front_html: str | Omit = omit, - size: PostcardSize | Omit = omit, + size: Literal["6x4", "9x6", "11x6"] | Omit = omit, to: postcard_create_params.PostcardCreateWithHTMLTo | postcard_create_params.PostcardCreateWithPdfurlTo | postcard_create_params.PostcardCreateWithPdfFileTo @@ -439,6 +449,7 @@ def create( | Omit = omit, merge_variables: Dict[str, object] | Omit = omit, metadata: Dict[str, object] | Omit = omit, + paper: str | Omit = omit, send_date: Union[str, datetime] | Omit = omit, back_template: str | Omit = omit, front_template: str | Omit = omit, @@ -463,6 +474,7 @@ def create( "mailing_class": mailing_class, "merge_variables": merge_variables, "metadata": metadata, + "paper": paper, "send_date": send_date, "back_template": back_template, "front_template": front_template, @@ -659,7 +671,7 @@ async def create( *, back_html: str, front_html: str, - size: PostcardSize, + size: Literal["6x4", "9x6", "11x6"], to: postcard_create_params.PostcardCreateWithHTMLTo, description: str | Omit = omit, from_: postcard_create_params.PostcardCreateWithHTMLFrom | Omit = omit, @@ -694,6 +706,7 @@ async def create( | Omit = omit, merge_variables: Dict[str, object] | Omit = omit, metadata: Dict[str, object] | Omit = omit, + paper: str | Omit = omit, send_date: Union[str, datetime] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -743,6 +756,9 @@ async def create( metadata: See the section on Metadata. + paper: Premium paper identifier. Use "standard" for regular stock or a premium*paper*\\** + ID. + send_date: This order will transition from `ready` to `printing` on the day after this date. You can use this parameter to schedule orders for a future date. @@ -801,7 +817,7 @@ async def create( self, *, pdf: str, - size: PostcardSize, + size: Literal["6x4", "9x6", "11x6"], to: postcard_create_params.PostcardCreateWithPdfurlTo, description: str | Omit = omit, from_: postcard_create_params.PostcardCreateWithPdfurlFrom | Omit = omit, @@ -836,6 +852,7 @@ async def create( | Omit = omit, merge_variables: Dict[str, object] | Omit = omit, metadata: Dict[str, object] | Omit = omit, + paper: str | Omit = omit, send_date: Union[str, datetime] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -882,6 +899,9 @@ async def create( metadata: See the section on Metadata. + paper: Premium paper identifier. Use "standard" for regular stock or a premium*paper*\\** + ID. + send_date: This order will transition from `ready` to `printing` on the day after this date. You can use this parameter to schedule orders for a future date. @@ -900,7 +920,7 @@ async def create( self, *, pdf: Union[str, Base64FileInput], - size: PostcardSize, + size: Literal["6x4", "9x6", "11x6"], to: postcard_create_params.PostcardCreateWithPdfFileTo, description: str | Omit = omit, from_: postcard_create_params.PostcardCreateWithPdfFileFrom | Omit = omit, @@ -935,6 +955,7 @@ async def create( | Omit = omit, merge_variables: Dict[str, object] | Omit = omit, metadata: Dict[str, object] | Omit = omit, + paper: str | Omit = omit, send_date: Union[str, datetime] | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -981,6 +1002,9 @@ async def create( metadata: See the section on Metadata. + paper: Premium paper identifier. Use "standard" for regular stock or a premium*paper*\\** + ID. + send_date: This order will transition from `ready` to `printing` on the day after this date. You can use this parameter to schedule orders for a future date. @@ -1002,7 +1026,7 @@ async def create( *, back_html: str | Omit = omit, front_html: str | Omit = omit, - size: PostcardSize | Omit = omit, + size: Literal["6x4", "9x6", "11x6"] | Omit = omit, to: postcard_create_params.PostcardCreateWithHTMLTo | postcard_create_params.PostcardCreateWithPdfurlTo | postcard_create_params.PostcardCreateWithPdfFileTo @@ -1043,6 +1067,7 @@ async def create( | Omit = omit, merge_variables: Dict[str, object] | Omit = omit, metadata: Dict[str, object] | Omit = omit, + paper: str | Omit = omit, send_date: Union[str, datetime] | Omit = omit, back_template: str | Omit = omit, front_template: str | Omit = omit, @@ -1067,6 +1092,7 @@ async def create( "mailing_class": mailing_class, "merge_variables": merge_variables, "metadata": metadata, + "paper": paper, "send_date": send_date, "back_template": back_template, "front_template": front_template, diff --git a/src/postgrid/resources/print_mail/print_mail.py b/src/postgrid/resources/print_mail/print_mail.py index 2b919c4..6681005 100644 --- a/src/postgrid/resources/print_mail/print_mail.py +++ b/src/postgrid/resources/print_mail/print_mail.py @@ -100,14 +100,6 @@ MailingListImportsResourceWithStreamingResponse, AsyncMailingListImportsResourceWithStreamingResponse, ) -from .order_profiles.order_profiles import ( - OrderProfilesResource, - AsyncOrderProfilesResource, - OrderProfilesResourceWithRawResponse, - AsyncOrderProfilesResourceWithRawResponse, - OrderProfilesResourceWithStreamingResponse, - AsyncOrderProfilesResourceWithStreamingResponse, -) __all__ = ["PrintMailResource", "AsyncPrintMailResource"] @@ -149,10 +141,6 @@ def mailing_list_imports(self) -> MailingListImportsResource: def mailing_lists(self) -> MailingListsResource: return MailingListsResource(self._client) - @cached_property - def order_profiles(self) -> OrderProfilesResource: - return OrderProfilesResource(self._client) - @cached_property def postcards(self) -> PostcardsResource: return PostcardsResource(self._client) @@ -174,18 +162,6 @@ def self_mailers(self) -> SelfMailersResource: @cached_property def sub_organizations(self) -> SubOrganizationsResource: - """ - Sub-organizations enable you to create isolated PostGrid accounts - ("sub-organizations") under your PostGrid account (the "parent organization"). - Each sub-organization has fully isolated resources - and users, and can act independently. - - This allows you to isolate different departments or even re-sell PostGrid - entirely. - - You can request access to this feature by reaching out to - support@postgrid.com - """ return SubOrganizationsResource(self._client) @cached_property @@ -249,10 +225,6 @@ def mailing_list_imports(self) -> AsyncMailingListImportsResource: def mailing_lists(self) -> AsyncMailingListsResource: return AsyncMailingListsResource(self._client) - @cached_property - def order_profiles(self) -> AsyncOrderProfilesResource: - return AsyncOrderProfilesResource(self._client) - @cached_property def postcards(self) -> AsyncPostcardsResource: return AsyncPostcardsResource(self._client) @@ -274,18 +246,6 @@ def self_mailers(self) -> AsyncSelfMailersResource: @cached_property def sub_organizations(self) -> AsyncSubOrganizationsResource: - """ - Sub-organizations enable you to create isolated PostGrid accounts - ("sub-organizations") under your PostGrid account (the "parent organization"). - Each sub-organization has fully isolated resources - and users, and can act independently. - - This allows you to isolate different departments or even re-sell PostGrid - entirely. - - You can request access to this feature by reaching out to - support@postgrid.com - """ return AsyncSubOrganizationsResource(self._client) @cached_property @@ -352,10 +312,6 @@ def mailing_list_imports(self) -> MailingListImportsResourceWithRawResponse: def mailing_lists(self) -> MailingListsResourceWithRawResponse: return MailingListsResourceWithRawResponse(self._print_mail.mailing_lists) - @cached_property - def order_profiles(self) -> OrderProfilesResourceWithRawResponse: - return OrderProfilesResourceWithRawResponse(self._print_mail.order_profiles) - @cached_property def postcards(self) -> PostcardsResourceWithRawResponse: return PostcardsResourceWithRawResponse(self._print_mail.postcards) @@ -377,18 +333,6 @@ def self_mailers(self) -> SelfMailersResourceWithRawResponse: @cached_property def sub_organizations(self) -> SubOrganizationsResourceWithRawResponse: - """ - Sub-organizations enable you to create isolated PostGrid accounts - ("sub-organizations") under your PostGrid account (the "parent organization"). - Each sub-organization has fully isolated resources - and users, and can act independently. - - This allows you to isolate different departments or even re-sell PostGrid - entirely. - - You can request access to this feature by reaching out to - support@postgrid.com - """ return SubOrganizationsResourceWithRawResponse(self._print_mail.sub_organizations) @cached_property @@ -436,10 +380,6 @@ def mailing_list_imports(self) -> AsyncMailingListImportsResourceWithRawResponse def mailing_lists(self) -> AsyncMailingListsResourceWithRawResponse: return AsyncMailingListsResourceWithRawResponse(self._print_mail.mailing_lists) - @cached_property - def order_profiles(self) -> AsyncOrderProfilesResourceWithRawResponse: - return AsyncOrderProfilesResourceWithRawResponse(self._print_mail.order_profiles) - @cached_property def postcards(self) -> AsyncPostcardsResourceWithRawResponse: return AsyncPostcardsResourceWithRawResponse(self._print_mail.postcards) @@ -461,18 +401,6 @@ def self_mailers(self) -> AsyncSelfMailersResourceWithRawResponse: @cached_property def sub_organizations(self) -> AsyncSubOrganizationsResourceWithRawResponse: - """ - Sub-organizations enable you to create isolated PostGrid accounts - ("sub-organizations") under your PostGrid account (the "parent organization"). - Each sub-organization has fully isolated resources - and users, and can act independently. - - This allows you to isolate different departments or even re-sell PostGrid - entirely. - - You can request access to this feature by reaching out to - support@postgrid.com - """ return AsyncSubOrganizationsResourceWithRawResponse(self._print_mail.sub_organizations) @cached_property @@ -520,10 +448,6 @@ def mailing_list_imports(self) -> MailingListImportsResourceWithStreamingRespons def mailing_lists(self) -> MailingListsResourceWithStreamingResponse: return MailingListsResourceWithStreamingResponse(self._print_mail.mailing_lists) - @cached_property - def order_profiles(self) -> OrderProfilesResourceWithStreamingResponse: - return OrderProfilesResourceWithStreamingResponse(self._print_mail.order_profiles) - @cached_property def postcards(self) -> PostcardsResourceWithStreamingResponse: return PostcardsResourceWithStreamingResponse(self._print_mail.postcards) @@ -545,18 +469,6 @@ def self_mailers(self) -> SelfMailersResourceWithStreamingResponse: @cached_property def sub_organizations(self) -> SubOrganizationsResourceWithStreamingResponse: - """ - Sub-organizations enable you to create isolated PostGrid accounts - ("sub-organizations") under your PostGrid account (the "parent organization"). - Each sub-organization has fully isolated resources - and users, and can act independently. - - This allows you to isolate different departments or even re-sell PostGrid - entirely. - - You can request access to this feature by reaching out to - support@postgrid.com - """ return SubOrganizationsResourceWithStreamingResponse(self._print_mail.sub_organizations) @cached_property @@ -604,10 +516,6 @@ def mailing_list_imports(self) -> AsyncMailingListImportsResourceWithStreamingRe def mailing_lists(self) -> AsyncMailingListsResourceWithStreamingResponse: return AsyncMailingListsResourceWithStreamingResponse(self._print_mail.mailing_lists) - @cached_property - def order_profiles(self) -> AsyncOrderProfilesResourceWithStreamingResponse: - return AsyncOrderProfilesResourceWithStreamingResponse(self._print_mail.order_profiles) - @cached_property def postcards(self) -> AsyncPostcardsResourceWithStreamingResponse: return AsyncPostcardsResourceWithStreamingResponse(self._print_mail.postcards) @@ -629,18 +537,6 @@ def self_mailers(self) -> AsyncSelfMailersResourceWithStreamingResponse: @cached_property def sub_organizations(self) -> AsyncSubOrganizationsResourceWithStreamingResponse: - """ - Sub-organizations enable you to create isolated PostGrid accounts - ("sub-organizations") under your PostGrid account (the "parent organization"). - Each sub-organization has fully isolated resources - and users, and can act independently. - - This allows you to isolate different departments or even re-sell PostGrid - entirely. - - You can request access to this feature by reaching out to - support@postgrid.com - """ return AsyncSubOrganizationsResourceWithStreamingResponse(self._print_mail.sub_organizations) @cached_property diff --git a/src/postgrid/resources/print_mail/self_mailers.py b/src/postgrid/resources/print_mail/self_mailers.py index b86b862..1b63dda 100644 --- a/src/postgrid/resources/print_mail/self_mailers.py +++ b/src/postgrid/resources/print_mail/self_mailers.py @@ -22,8 +22,6 @@ from ..._base_client import AsyncPaginator, make_request_options from ...types.print_mail import self_mailer_list_params, self_mailer_create_params from ...types.print_mail.self_mailer import SelfMailer -from ...types.print_mail.order_profiles import SelfMailerSize -from ...types.print_mail.order_profiles.self_mailer_size import SelfMailerSize from ...types.print_mail.self_mailer_retrieve_url_response import SelfMailerRetrieveURLResponse __all__ = ["SelfMailersResource", "AsyncSelfMailersResource"] @@ -56,7 +54,7 @@ def create( from_: self_mailer_create_params.SelfMailerCreateWithHTMLFrom, inside_html: str, outside_html: str, - size: SelfMailerSize, + size: Literal["8.5x11_bifold", "8.5x11_trifold", "9.5x16_trifold"], to: self_mailer_create_params.SelfMailerCreateWithHTMLTo, description: str | Omit = omit, mailing_class: Literal[ @@ -197,7 +195,7 @@ def create( *, from_: self_mailer_create_params.SelfMailerCreateWithPdfurlFrom, pdf: str, - size: SelfMailerSize, + size: Literal["8.5x11_bifold", "8.5x11_trifold", "9.5x16_trifold"], to: self_mailer_create_params.SelfMailerCreateWithPdfurlTo, description: str | Omit = omit, mailing_class: Literal[ @@ -296,7 +294,7 @@ def create( *, from_: self_mailer_create_params.SelfMailerCreateWithPdfFileFrom, pdf: Union[str, Base64FileInput], - size: SelfMailerSize, + size: Literal["8.5x11_bifold", "8.5x11_trifold", "9.5x16_trifold"], to: self_mailer_create_params.SelfMailerCreateWithPdfFileTo, description: str | Omit = omit, mailing_class: Literal[ @@ -402,7 +400,7 @@ def create( | Omit = omit, inside_html: str | Omit = omit, outside_html: str | Omit = omit, - size: SelfMailerSize | Omit = omit, + size: Literal["8.5x11_bifold", "8.5x11_trifold", "9.5x16_trifold"] | Omit = omit, to: self_mailer_create_params.SelfMailerCreateWithHTMLTo | self_mailer_create_params.SelfMailerCreateWithPdfurlTo | self_mailer_create_params.SelfMailerCreateWithPdfFileTo @@ -660,7 +658,7 @@ async def create( from_: self_mailer_create_params.SelfMailerCreateWithHTMLFrom, inside_html: str, outside_html: str, - size: SelfMailerSize, + size: Literal["8.5x11_bifold", "8.5x11_trifold", "9.5x16_trifold"], to: self_mailer_create_params.SelfMailerCreateWithHTMLTo, description: str | Omit = omit, mailing_class: Literal[ @@ -801,7 +799,7 @@ async def create( *, from_: self_mailer_create_params.SelfMailerCreateWithPdfurlFrom, pdf: str, - size: SelfMailerSize, + size: Literal["8.5x11_bifold", "8.5x11_trifold", "9.5x16_trifold"], to: self_mailer_create_params.SelfMailerCreateWithPdfurlTo, description: str | Omit = omit, mailing_class: Literal[ @@ -900,7 +898,7 @@ async def create( *, from_: self_mailer_create_params.SelfMailerCreateWithPdfFileFrom, pdf: Union[str, Base64FileInput], - size: SelfMailerSize, + size: Literal["8.5x11_bifold", "8.5x11_trifold", "9.5x16_trifold"], to: self_mailer_create_params.SelfMailerCreateWithPdfFileTo, description: str | Omit = omit, mailing_class: Literal[ @@ -1006,7 +1004,7 @@ async def create( | Omit = omit, inside_html: str | Omit = omit, outside_html: str | Omit = omit, - size: SelfMailerSize | Omit = omit, + size: Literal["8.5x11_bifold", "8.5x11_trifold", "9.5x16_trifold"] | Omit = omit, to: self_mailer_create_params.SelfMailerCreateWithHTMLTo | self_mailer_create_params.SelfMailerCreateWithPdfurlTo | self_mailer_create_params.SelfMailerCreateWithPdfFileTo diff --git a/src/postgrid/resources/print_mail/sub_organizations.py b/src/postgrid/resources/print_mail/sub_organizations.py index 9ac0561..0499a50 100644 --- a/src/postgrid/resources/print_mail/sub_organizations.py +++ b/src/postgrid/resources/print_mail/sub_organizations.py @@ -29,19 +29,6 @@ class SubOrganizationsResource(SyncAPIResource): - """ - Sub-organizations enable you to create isolated PostGrid accounts - ("sub-organizations") under your PostGrid account (the "parent organization"). - Each sub-organization has fully isolated resources - and users, and can act independently. - - This allows you to isolate different departments or even re-sell PostGrid - entirely. - - You can request access to this feature by reaching out to - support@postgrid.com - """ - @cached_property def with_raw_response(self) -> SubOrganizationsResourceWithRawResponse: """ @@ -261,19 +248,6 @@ def retrieve_users( class AsyncSubOrganizationsResource(AsyncAPIResource): - """ - Sub-organizations enable you to create isolated PostGrid accounts - ("sub-organizations") under your PostGrid account (the "parent organization"). - Each sub-organization has fully isolated resources - and users, and can act independently. - - This allows you to isolate different departments or even re-sell PostGrid - entirely. - - You can request access to this feature by reaching out to - support@postgrid.com - """ - @cached_property def with_raw_response(self) -> AsyncSubOrganizationsResourceWithRawResponse: """ diff --git a/src/postgrid/types/__init__.py b/src/postgrid/types/__init__.py index a35a1a9..9246b3b 100644 --- a/src/postgrid/types/__init__.py +++ b/src/postgrid/types/__init__.py @@ -13,6 +13,75 @@ from .intl_address_verification_verify_params import ( IntlAddressVerificationVerifyParams as IntlAddressVerificationVerifyParams, ) +from .address_verification_autocomplete_params import ( + AddressVerificationAutocompleteParams as AddressVerificationAutocompleteParams, +) from .intl_address_verification_verify_response import ( IntlAddressVerificationVerifyResponse as IntlAddressVerificationVerifyResponse, ) +from .address_verification_autocomplete_response import ( + AddressVerificationAutocompleteResponse as AddressVerificationAutocompleteResponse, +) +from .address_verification_parse_an_address_params import ( + AddressVerificationParseAnAddressParams as AddressVerificationParseAnAddressParams, +) +from .address_verification_get_lookup_info_response import ( + AddressVerificationGetLookupInfoResponse as AddressVerificationGetLookupInfoResponse, +) +from .address_verification_suggest_addresses_params import ( + AddressVerificationSuggestAddressesParams as AddressVerificationSuggestAddressesParams, +) +from .intl_address_verification_autocomplete_params import ( + IntlAddressVerificationAutocompleteParams as IntlAddressVerificationAutocompleteParams, +) +from .address_verification_batch_verification_params import ( + AddressVerificationBatchVerificationParams as AddressVerificationBatchVerificationParams, +) +from .address_verification_parse_an_address_response import ( + AddressVerificationParseAnAddressResponse as AddressVerificationParseAnAddressResponse, +) +from .address_verification_suggest_addresses_response import ( + AddressVerificationSuggestAddressesResponse as AddressVerificationSuggestAddressesResponse, +) +from .intl_address_verification_autocomplete_response import ( + IntlAddressVerificationAutocompleteResponse as IntlAddressVerificationAutocompleteResponse, +) +from .address_verification_batch_verification_response import ( + AddressVerificationBatchVerificationResponse as AddressVerificationBatchVerificationResponse, +) +from .intl_address_verification_batch_verification_params import ( + IntlAddressVerificationBatchVerificationParams as IntlAddressVerificationBatchVerificationParams, +) +from .address_verification_get_autocomplete_previews_params import ( + AddressVerificationGetAutocompletePreviewsParams as AddressVerificationGetAutocompletePreviewsParams, +) +from .intl_address_verification_batch_verification_response import ( + IntlAddressVerificationBatchVerificationResponse as IntlAddressVerificationBatchVerificationResponse, +) +from .address_verification_get_autocomplete_previews_response import ( + AddressVerificationGetAutocompletePreviewsResponse as AddressVerificationGetAutocompletePreviewsResponse, +) +from .intl_address_verification_get_autocomplete_previews_params import ( + IntlAddressVerificationGetAutocompletePreviewsParams as IntlAddressVerificationGetAutocompletePreviewsParams, +) +from .intl_address_verification_get_autocomplete_previews_response import ( + IntlAddressVerificationGetAutocompletePreviewsResponse as IntlAddressVerificationGetAutocompletePreviewsResponse, +) +from .address_verification_lookup_zip_code_from_city_or_state_params import ( + AddressVerificationLookupZipCodeFromCityOrStateParams as AddressVerificationLookupZipCodeFromCityOrStateParams, +) +from .address_verification_lookup_zip_code_from_city_or_state_response import ( + AddressVerificationLookupZipCodeFromCityOrStateResponse as AddressVerificationLookupZipCodeFromCityOrStateResponse, +) +from .intl_address_verification_get_autocomplete_advanced_previews_params import ( + IntlAddressVerificationGetAutocompleteAdvancedPreviewsParams as IntlAddressVerificationGetAutocompleteAdvancedPreviewsParams, +) +from .intl_address_verification_get_autocomplete_advanced_previews_response import ( + IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse as IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse, +) +from .address_verification_lookup_city_or_state_from_postal_or_zip_code_params import ( + AddressVerificationLookupCityOrStateFromPostalOrZipCodeParams as AddressVerificationLookupCityOrStateFromPostalOrZipCodeParams, +) +from .address_verification_lookup_city_or_state_from_postal_or_zip_code_response import ( + AddressVerificationLookupCityOrStateFromPostalOrZipCodeResponse as AddressVerificationLookupCityOrStateFromPostalOrZipCodeResponse, +) diff --git a/src/postgrid/types/address_verification_autocomplete_params.py b/src/postgrid/types/address_verification_autocomplete_params.py new file mode 100644 index 0000000..7334256 --- /dev/null +++ b/src/postgrid/types/address_verification_autocomplete_params.py @@ -0,0 +1,45 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, Annotated, TypedDict + +from .._utils import PropertyInfo + +__all__ = ["AddressVerificationAutocompleteParams"] + + +class AddressVerificationAutocompleteParams(TypedDict, total=False): + partial_street: Required[Annotated[str, PropertyInfo(alias="partialStreet")]] + """The partial street address to complete (e.g. `"22 Bay"`).""" + + filter_exact: Annotated[bool, PropertyInfo(alias="filterExact")] + + geocode: bool + + include_details: Annotated[bool, PropertyInfo(alias="includeDetails")] + + index: int + + limit: int + + proper_case: Annotated[bool, PropertyInfo(alias="properCase")] + + query_verified_only: Annotated[bool, PropertyInfo(alias="verifiedOnly")] + + verify: bool + + city_filter: Annotated[str, PropertyInfo(alias="cityFilter")] + """Filter results to a specific city.""" + + country_filter: Annotated[str, PropertyInfo(alias="countryFilter")] + """Filter results to a specific country code.""" + + pc_filter: Annotated[str, PropertyInfo(alias="pcFilter")] + """Filter results to a specific postal code prefix.""" + + state_filter: Annotated[str, PropertyInfo(alias="stateFilter")] + """Filter results to a specific state or province abbreviation.""" + + body_verified_only: Annotated[bool, PropertyInfo(alias="verifiedOnly")] + """If true, only return addresses that passed USPS/Canada Post verification.""" diff --git a/src/postgrid/types/address_verification_autocomplete_response.py b/src/postgrid/types/address_verification_autocomplete_response.py new file mode 100644 index 0000000..fd696cf --- /dev/null +++ b/src/postgrid/types/address_verification_autocomplete_response.py @@ -0,0 +1,440 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from typing_extensions import Literal, TypeAlias + +from pydantic import Field as FieldInfo + +from .errors import Errors +from .status import Status +from .._models import BaseModel + +__all__ = [ + "AddressVerificationAutocompleteResponse", + "Data", + "DataCompletedAddressItem", + "DataCompletedAddressItemAddress", + "DataCompletedAddressItemGeocodeResult", + "DataCompletedAddressItemGeocodeResultLocation", + "DataUnionMember1", + "DataUnionMember1Address", + "DataUnionMember1GeocodeResult", + "DataUnionMember1GeocodeResultLocation", + "DataStandardVerifiedAddress", + "DataStandardVerifiedAddressDetails", + "DataStandardVerifiedAddressGeocodeResult", + "DataStandardVerifiedAddressGeocodeResultLocation", +] + + +class DataCompletedAddressItemAddress(BaseModel): + """The resolved address components.""" + + address: str + """The first line of the address.""" + + address2: Optional[str] = None + """The second line of the address.""" + + city: Optional[str] = None + """The city.""" + + country: Optional[str] = None + """The ISO 2-letter country code.""" + + pc: Optional[str] = None + """The postal code.""" + + prov: Optional[str] = None + """The province or state abbreviation.""" + + +class DataCompletedAddressItemGeocodeResultLocation(BaseModel): + """Object that contains `lat`, `lng` properties with number values""" + + lat: float + + lng: float + + +class DataCompletedAddressItemGeocodeResult(BaseModel): + """Geocoding result. + + Only present when `geocode=true` is supplied and an `index` is specified. + """ + + accuracy: float + """ + A real number from 0.00 to 1.00 which represents an + [accuracy score](https://avdocs.postgrid.com/#accuracy-score) + """ + + accuracy_type: Literal[ + "rooftop", + "point", + "range_interpolation", + "nearest_rooftop_match", + "intersection", + "street_center", + "place", + "state", + ] = FieldInfo(alias="accuracyType") + """ + A string representing the + [accuracy type](https://avdocs.postgrid.com/#accuracy-type) + """ + + location: DataCompletedAddressItemGeocodeResultLocation + """Object that contains `lat`, `lng` properties with number values""" + + +class DataCompletedAddressItem(BaseModel): + address: DataCompletedAddressItemAddress + """The resolved address components.""" + + errors: Optional[Errors] = None + """Errors encountered during address verification.""" + + geocode_result: Optional[DataCompletedAddressItemGeocodeResult] = FieldInfo(alias="geocodeResult", default=None) + """Geocoding result. + + Only present when `geocode=true` is supplied and an `index` is specified. + """ + + +class DataUnionMember1Address(BaseModel): + """The resolved address components.""" + + address: str + """The first line of the address.""" + + address2: Optional[str] = None + """The second line of the address.""" + + city: Optional[str] = None + """The city.""" + + country: Optional[str] = None + """The ISO 2-letter country code.""" + + pc: Optional[str] = None + """The postal code.""" + + prov: Optional[str] = None + """The province or state abbreviation.""" + + +class DataUnionMember1GeocodeResultLocation(BaseModel): + """Object that contains `lat`, `lng` properties with number values""" + + lat: float + + lng: float + + +class DataUnionMember1GeocodeResult(BaseModel): + """Geocoding result. + + Only present when `geocode=true` is supplied and an `index` is specified. + """ + + accuracy: float + """ + A real number from 0.00 to 1.00 which represents an + [accuracy score](https://avdocs.postgrid.com/#accuracy-score) + """ + + accuracy_type: Literal[ + "rooftop", + "point", + "range_interpolation", + "nearest_rooftop_match", + "intersection", + "street_center", + "place", + "state", + ] = FieldInfo(alias="accuracyType") + """ + A string representing the + [accuracy type](https://avdocs.postgrid.com/#accuracy-type) + """ + + location: DataUnionMember1GeocodeResultLocation + """Object that contains `lat`, `lng` properties with number values""" + + +class DataUnionMember1(BaseModel): + address: DataUnionMember1Address + """The resolved address components.""" + + errors: Optional[Errors] = None + """Errors encountered during address verification.""" + + geocode_result: Optional[DataUnionMember1GeocodeResult] = FieldInfo(alias="geocodeResult", default=None) + """Geocoding result. + + Only present when `geocode=true` is supplied and an `index` is specified. + """ + + +class DataStandardVerifiedAddressDetails(BaseModel): + """ + If you supply `includeDetails=true` as a query parameter, we will also populate an additional `details` field that follows the [Address Details](https://avdocs.postgrid.com/#address-details) schema. + """ + + box_id: Optional[str] = FieldInfo(alias="boxID", default=None) + """PO Box ID""" + + county: Optional[str] = None + """County in the United States (US address only)""" + + county_num: Optional[str] = FieldInfo(alias="countyNum", default=None) + """FIPS code for county (US address only)""" + + delivery_installation_area_name: Optional[str] = FieldInfo(alias="deliveryInstallationAreaName", default=None) + """Delivery installation area name""" + + delivery_installation_qualifier: Optional[str] = FieldInfo(alias="deliveryInstallationQualifier", default=None) + """Delivery installation qualifier""" + + delivery_installation_type: Optional[str] = FieldInfo(alias="deliveryInstallationType", default=None) + """Delivery installation type""" + + extra_info: Optional[str] = FieldInfo(alias="extraInfo", default=None) + """Any extra information relevant to the address""" + + post_direction: Optional[str] = FieldInfo(alias="postDirection", default=None) + """The post-direction of the street (after the street name, US addresses only)""" + + pre_direction: Optional[str] = FieldInfo(alias="preDirection", default=None) + """The pre-direction of the street (before the street name, US addresses only)""" + + residential: Optional[bool] = None + """Indicates that the address is residential (US address only)""" + + rural_route_number: Optional[str] = FieldInfo(alias="ruralRouteNumber", default=None) + """Rural route number""" + + rural_route_type: Optional[str] = FieldInfo(alias="ruralRouteType", default=None) + """Rural route type""" + + street_direction: Optional[str] = FieldInfo(alias="streetDirection", default=None) + """The direction of the street (N, S, E, W, etc)""" + + street_name: Optional[str] = FieldInfo(alias="streetName", default=None) + """Name of the street where the address is located""" + + street_number: Optional[str] = FieldInfo(alias="streetNumber", default=None) + """Street number (e.g. the 20 in 20 Bay St)""" + + street_type: Optional[str] = FieldInfo(alias="streetType", default=None) + """Type of the street (DR, ST, BLVD, etc)""" + + suite_id: Optional[str] = FieldInfo(alias="suiteID", default=None) + """The unit number/name""" + + suite_key: Optional[str] = FieldInfo(alias="suiteKey", default=None) + """The suite key""" + + us_census_block_number: Optional[str] = FieldInfo(alias="usCensusBlockNumber", default=None) + """US Census block number""" + + us_census_cmsa: Optional[str] = FieldInfo(alias="usCensusCMSA", default=None) + """US Census consolidated metropolitan statistical area""" + + us_census_fips: Optional[str] = FieldInfo(alias="usCensusFIPS", default=None) + """US Census FIPS code (US address only)""" + + us_census_ma: Optional[str] = FieldInfo(alias="usCensusMA", default=None) + """US Census metropolitan area""" + + us_census_msa: Optional[str] = FieldInfo(alias="usCensusMSA", default=None) + """US Census metropolitan statistical area""" + + us_census_pmsa: Optional[str] = FieldInfo(alias="usCensusPMSA", default=None) + """US Census primary metropolitan statistical area""" + + us_census_tract_number: Optional[str] = FieldInfo(alias="usCensusTractNumber", default=None) + """US Census tract number""" + + us_congressional_district_number: Optional[str] = FieldInfo(alias="usCongressionalDistrictNumber", default=None) + """US congressional district number""" + + us_has_daylight_savings: Optional[bool] = FieldInfo(alias="usHasDaylightSavings", default=None) + """True if address location recognizes DST""" + + us_mailing_check_digit: Optional[str] = FieldInfo(alias="usMailingCheckDigit", default=None) + """PostNet barcode digit""" + + us_mailings_carrier_route: Optional[str] = FieldInfo(alias="usMailingsCarrierRoute", default=None) + """4-character code assigned to mail delivery route within a 5 digit zip code""" + + us_mailings_default_flag: Optional[bool] = FieldInfo(alias="usMailingsDefaultFlag", default=None) + """ + True if US address matches a high-rise default or rural route default in the + USPS data + """ + + us_mailings_delivery_point: Optional[str] = FieldInfo(alias="usMailingsDeliveryPoint", default=None) + """Unique USPS identifier for the delivery point""" + + us_mailings_dpv_confirmation_indicator: Optional[str] = FieldInfo( + alias="usMailingsDpvConfirmationIndicator", default=None + ) + """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + + us_mailings_dpv_crma_indicator: Optional[str] = FieldInfo(alias="usMailingsDpvCrmaIndicator", default=None) + """Y if this is a commercial mail receiving agency, N otherwise""" + + us_mailings_dpv_footnote1: Optional[str] = FieldInfo(alias="usMailingsDpvFootnote1", default=None) + """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + + us_mailings_dpv_footnote2: Optional[str] = FieldInfo(alias="usMailingsDpvFootnote2", default=None) + """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + + us_mailings_dpv_footnote3: Optional[str] = FieldInfo(alias="usMailingsDpvFootnote3", default=None) + """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + + us_mailings_elot_asc_desc: Optional[str] = FieldInfo(alias="usMailingsElotAscDesc", default=None) + """A for ascending, D for descending""" + + us_mailings_elot_sequence_number: Optional[str] = FieldInfo(alias="usMailingsElotSequenceNumber", default=None) + """eLOT sequence number""" + + us_mailings_ews_flag: Optional[str] = FieldInfo(alias="usMailingsEWSFlag", default=None) + """Y if address is in early warning system database""" + + us_mailings_lacs_flag: Optional[str] = FieldInfo(alias="usMailingsLACSFlag", default=None) + """Y if address converted by LACS""" + + us_mailings_lacs_return_code: Optional[str] = FieldInfo(alias="usMailingsLACSReturnCode", default=None) + """Corresponds to USPS LACSLink return code""" + + us_mailings_record_type_code: Optional[str] = FieldInfo(alias="usMailingsRecordTypeCode", default=None) + """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + + us_mailings_suite_link_return_code: Optional[str] = FieldInfo(alias="usMailingsSuiteLinkReturnCode", default=None) + """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + + us_postnet_barcode: Optional[str] = FieldInfo(alias="usPostnetBarcode", default=None) + """PostNet barcode for the address (US address only)""" + + us_state_legislative_lower: Optional[str] = FieldInfo(alias="usStateLegislativeLower", default=None) + """Lower legislative district for the US address""" + + us_state_legislative_upper: Optional[str] = FieldInfo(alias="usStateLegislativeUpper", default=None) + """Upper legislative district for the US address""" + + us_time_zone: Optional[str] = FieldInfo(alias="usTimeZone", default=None) + """Time zone for the US address area""" + + vacant: Optional[bool] = None + """Indicates that the address is vacant according to the USPS (US address only)""" + + +class DataStandardVerifiedAddressGeocodeResultLocation(BaseModel): + """Object that contains `lat`, `lng` properties with number values""" + + lat: float + + lng: float + + +class DataStandardVerifiedAddressGeocodeResult(BaseModel): + """ + If the `geocode=true` query parameter is supplied, the response will include a geocodeResult + which follows the [Geocoding](https://avdocs.postgrid.com/#geocoding) schema. You can request + this feature be enabled by emailing `support@postgrid.com`. This includes our verification, batch + verification, suggestions, and POST /completions endpoint. Note that you must supply country when + geocoding to get the result successfully. + """ + + accuracy: float + """ + A real number from 0.00 to 1.00 which represents an + [accuracy score](https://avdocs.postgrid.com/#accuracy-score) + """ + + accuracy_type: Literal[ + "rooftop", + "point", + "range_interpolation", + "nearest_rooftop_match", + "intersection", + "street_center", + "place", + "state", + ] = FieldInfo(alias="accuracyType") + """ + A string representing the + [accuracy type](https://avdocs.postgrid.com/#accuracy-type) + """ + + location: DataStandardVerifiedAddressGeocodeResultLocation + """Object that contains `lat`, `lng` properties with number values""" + + +class DataStandardVerifiedAddress(BaseModel): + city: str + """The city name of the address.""" + + country: str + """The country code of the address.""" + + line1: str + """The first line of the address.""" + + postal_or_zip: str = FieldInfo(alias="postalOrZip") + """The postal code or ZIP code of the address.""" + + province_or_state: str = FieldInfo(alias="provinceOrState") + """The province or state of the address.""" + + country_name: Optional[str] = FieldInfo(alias="countryName", default=None) + """The country name of the address.""" + + details: Optional[DataStandardVerifiedAddressDetails] = None + """ + If you supply `includeDetails=true` as a query parameter, we will also populate + an additional `details` field that follows the + [Address Details](https://avdocs.postgrid.com/#address-details) schema. + """ + + errors: Optional[Errors] = None + """Errors encountered during address verification.""" + + firm_name: Optional[str] = FieldInfo(alias="firmName", default=None) + """The firm name of the address.""" + + geocode_result: Optional[DataStandardVerifiedAddressGeocodeResult] = FieldInfo(alias="geocodeResult", default=None) + """ + If the `geocode=true` query parameter is supplied, the response will include a + geocodeResult which follows the + [Geocoding](https://avdocs.postgrid.com/#geocoding) schema. You can request this + feature be enabled by emailing `support@postgrid.com`. This includes our + verification, batch verification, suggestions, and POST /completions endpoint. + Note that you must supply country when geocoding to get the result successfully. + """ + + line2: Optional[str] = None + """The second line of the address.""" + + province_or_state_name: Optional[str] = FieldInfo(alias="provinceOrStateName", default=None) + """The full name of the province or state.""" + + status: Optional[Status] = None + """The verification status of an address.""" + + zip_plus4: Optional[str] = FieldInfo(alias="zipPlus4", default=None) + """The zip plus 4 code of the address.""" + + +Data: TypeAlias = Union[DataCompletedAddressItem, List[DataUnionMember1], DataStandardVerifiedAddress] + + +class AddressVerificationAutocompleteResponse(BaseModel): + data: Data + + message: str + + status: Literal["success", "error"] diff --git a/src/postgrid/types/address_verification_batch_verification_params.py b/src/postgrid/types/address_verification_batch_verification_params.py new file mode 100644 index 0000000..8f7396a --- /dev/null +++ b/src/postgrid/types/address_verification_batch_verification_params.py @@ -0,0 +1,65 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union, Iterable +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict + +from .._utils import PropertyInfo + +__all__ = [ + "AddressVerificationBatchVerificationParams", + "Address", + "AddressStandardFreeformAddressInput", + "AddressStandardStructuredAddressInput", + "AddressStandardStructuredAddressInputAddress", +] + + +class AddressVerificationBatchVerificationParams(TypedDict, total=False): + addresses: Required[Iterable[Address]] + """Array of addresses to verify. + + Each item can be a freeform string or structured address object. + """ + + geocode: bool + + include_details: Annotated[bool, PropertyInfo(alias="includeDetails")] + + proper_case: Annotated[bool, PropertyInfo(alias="properCase")] + + +class AddressStandardFreeformAddressInput(TypedDict, total=False): + address: Required[str] + """The address you want to verify, written on a single line.""" + + +class AddressStandardStructuredAddressInputAddress(TypedDict, total=False): + city: Required[str] + """The city of the address.""" + + country: Required[Literal["ca", "us"]] + """The country of your address, one of `ca` or `us`.""" + + line1: Required[str] + """The first line of the address.""" + + postal_or_zip: Required[Annotated[str, PropertyInfo(alias="postalOrZip")]] + """The postal code or ZIP code of the address.""" + + province_or_state: Required[Annotated[str, PropertyInfo(alias="provinceOrState")]] + """The province or state of the address.""" + + line2: str + """The second line of the address.""" + + recipient: str + """The optional firm/recipient name.""" + + +class AddressStandardStructuredAddressInput(TypedDict, total=False): + address: Required[AddressStandardStructuredAddressInputAddress] + + +Address: TypeAlias = Union[AddressStandardFreeformAddressInput, AddressStandardStructuredAddressInput] diff --git a/src/postgrid/types/address_verification_batch_verification_response.py b/src/postgrid/types/address_verification_batch_verification_response.py new file mode 100644 index 0000000..10207de --- /dev/null +++ b/src/postgrid/types/address_verification_batch_verification_response.py @@ -0,0 +1,294 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .errors import Errors +from .status import Status +from .._models import BaseModel + +__all__ = [ + "AddressVerificationBatchVerificationResponse", + "Data", + "DataResult", + "DataResultVerifiedAddress", + "DataResultVerifiedAddressDetails", + "DataResultVerifiedAddressGeocodeResult", + "DataResultVerifiedAddressGeocodeResultLocation", +] + + +class DataResultVerifiedAddressDetails(BaseModel): + """ + If you supply `includeDetails=true` as a query parameter, we will also populate an additional `details` field that follows the [Address Details](https://avdocs.postgrid.com/#address-details) schema. + """ + + box_id: Optional[str] = FieldInfo(alias="boxID", default=None) + """PO Box ID""" + + county: Optional[str] = None + """County in the United States (US address only)""" + + county_num: Optional[str] = FieldInfo(alias="countyNum", default=None) + """FIPS code for county (US address only)""" + + delivery_installation_area_name: Optional[str] = FieldInfo(alias="deliveryInstallationAreaName", default=None) + """Delivery installation area name""" + + delivery_installation_qualifier: Optional[str] = FieldInfo(alias="deliveryInstallationQualifier", default=None) + """Delivery installation qualifier""" + + delivery_installation_type: Optional[str] = FieldInfo(alias="deliveryInstallationType", default=None) + """Delivery installation type""" + + extra_info: Optional[str] = FieldInfo(alias="extraInfo", default=None) + """Any extra information relevant to the address""" + + post_direction: Optional[str] = FieldInfo(alias="postDirection", default=None) + """The post-direction of the street (after the street name, US addresses only)""" + + pre_direction: Optional[str] = FieldInfo(alias="preDirection", default=None) + """The pre-direction of the street (before the street name, US addresses only)""" + + residential: Optional[bool] = None + """Indicates that the address is residential (US address only)""" + + rural_route_number: Optional[str] = FieldInfo(alias="ruralRouteNumber", default=None) + """Rural route number""" + + rural_route_type: Optional[str] = FieldInfo(alias="ruralRouteType", default=None) + """Rural route type""" + + street_direction: Optional[str] = FieldInfo(alias="streetDirection", default=None) + """The direction of the street (N, S, E, W, etc)""" + + street_name: Optional[str] = FieldInfo(alias="streetName", default=None) + """Name of the street where the address is located""" + + street_number: Optional[str] = FieldInfo(alias="streetNumber", default=None) + """Street number (e.g. the 20 in 20 Bay St)""" + + street_type: Optional[str] = FieldInfo(alias="streetType", default=None) + """Type of the street (DR, ST, BLVD, etc)""" + + suite_id: Optional[str] = FieldInfo(alias="suiteID", default=None) + """The unit number/name""" + + suite_key: Optional[str] = FieldInfo(alias="suiteKey", default=None) + """The suite key""" + + us_census_block_number: Optional[str] = FieldInfo(alias="usCensusBlockNumber", default=None) + """US Census block number""" + + us_census_cmsa: Optional[str] = FieldInfo(alias="usCensusCMSA", default=None) + """US Census consolidated metropolitan statistical area""" + + us_census_fips: Optional[str] = FieldInfo(alias="usCensusFIPS", default=None) + """US Census FIPS code (US address only)""" + + us_census_ma: Optional[str] = FieldInfo(alias="usCensusMA", default=None) + """US Census metropolitan area""" + + us_census_msa: Optional[str] = FieldInfo(alias="usCensusMSA", default=None) + """US Census metropolitan statistical area""" + + us_census_pmsa: Optional[str] = FieldInfo(alias="usCensusPMSA", default=None) + """US Census primary metropolitan statistical area""" + + us_census_tract_number: Optional[str] = FieldInfo(alias="usCensusTractNumber", default=None) + """US Census tract number""" + + us_congressional_district_number: Optional[str] = FieldInfo(alias="usCongressionalDistrictNumber", default=None) + """US congressional district number""" + + us_has_daylight_savings: Optional[bool] = FieldInfo(alias="usHasDaylightSavings", default=None) + """True if address location recognizes DST""" + + us_mailing_check_digit: Optional[str] = FieldInfo(alias="usMailingCheckDigit", default=None) + """PostNet barcode digit""" + + us_mailings_carrier_route: Optional[str] = FieldInfo(alias="usMailingsCarrierRoute", default=None) + """4-character code assigned to mail delivery route within a 5 digit zip code""" + + us_mailings_default_flag: Optional[bool] = FieldInfo(alias="usMailingsDefaultFlag", default=None) + """ + True if US address matches a high-rise default or rural route default in the + USPS data + """ + + us_mailings_delivery_point: Optional[str] = FieldInfo(alias="usMailingsDeliveryPoint", default=None) + """Unique USPS identifier for the delivery point""" + + us_mailings_dpv_confirmation_indicator: Optional[str] = FieldInfo( + alias="usMailingsDpvConfirmationIndicator", default=None + ) + """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + + us_mailings_dpv_crma_indicator: Optional[str] = FieldInfo(alias="usMailingsDpvCrmaIndicator", default=None) + """Y if this is a commercial mail receiving agency, N otherwise""" + + us_mailings_dpv_footnote1: Optional[str] = FieldInfo(alias="usMailingsDpvFootnote1", default=None) + """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + + us_mailings_dpv_footnote2: Optional[str] = FieldInfo(alias="usMailingsDpvFootnote2", default=None) + """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + + us_mailings_dpv_footnote3: Optional[str] = FieldInfo(alias="usMailingsDpvFootnote3", default=None) + """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + + us_mailings_elot_asc_desc: Optional[str] = FieldInfo(alias="usMailingsElotAscDesc", default=None) + """A for ascending, D for descending""" + + us_mailings_elot_sequence_number: Optional[str] = FieldInfo(alias="usMailingsElotSequenceNumber", default=None) + """eLOT sequence number""" + + us_mailings_ews_flag: Optional[str] = FieldInfo(alias="usMailingsEWSFlag", default=None) + """Y if address is in early warning system database""" + + us_mailings_lacs_flag: Optional[str] = FieldInfo(alias="usMailingsLACSFlag", default=None) + """Y if address converted by LACS""" + + us_mailings_lacs_return_code: Optional[str] = FieldInfo(alias="usMailingsLACSReturnCode", default=None) + """Corresponds to USPS LACSLink return code""" + + us_mailings_record_type_code: Optional[str] = FieldInfo(alias="usMailingsRecordTypeCode", default=None) + """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + + us_mailings_suite_link_return_code: Optional[str] = FieldInfo(alias="usMailingsSuiteLinkReturnCode", default=None) + """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + + us_postnet_barcode: Optional[str] = FieldInfo(alias="usPostnetBarcode", default=None) + """PostNet barcode for the address (US address only)""" + + us_state_legislative_lower: Optional[str] = FieldInfo(alias="usStateLegislativeLower", default=None) + """Lower legislative district for the US address""" + + us_state_legislative_upper: Optional[str] = FieldInfo(alias="usStateLegislativeUpper", default=None) + """Upper legislative district for the US address""" + + us_time_zone: Optional[str] = FieldInfo(alias="usTimeZone", default=None) + """Time zone for the US address area""" + + vacant: Optional[bool] = None + """Indicates that the address is vacant according to the USPS (US address only)""" + + +class DataResultVerifiedAddressGeocodeResultLocation(BaseModel): + """Object that contains `lat`, `lng` properties with number values""" + + lat: float + + lng: float + + +class DataResultVerifiedAddressGeocodeResult(BaseModel): + """ + If the `geocode=true` query parameter is supplied, the response will include a geocodeResult + which follows the [Geocoding](https://avdocs.postgrid.com/#geocoding) schema. You can request + this feature be enabled by emailing `support@postgrid.com`. This includes our verification, batch + verification, suggestions, and POST /completions endpoint. Note that you must supply country when + geocoding to get the result successfully. + """ + + accuracy: float + """ + A real number from 0.00 to 1.00 which represents an + [accuracy score](https://avdocs.postgrid.com/#accuracy-score) + """ + + accuracy_type: Literal[ + "rooftop", + "point", + "range_interpolation", + "nearest_rooftop_match", + "intersection", + "street_center", + "place", + "state", + ] = FieldInfo(alias="accuracyType") + """ + A string representing the + [accuracy type](https://avdocs.postgrid.com/#accuracy-type) + """ + + location: DataResultVerifiedAddressGeocodeResultLocation + """Object that contains `lat`, `lng` properties with number values""" + + +class DataResultVerifiedAddress(BaseModel): + """The verified address result. Present when verification succeeded.""" + + city: str + """The city name of the address.""" + + country: str + """The country code of the address.""" + + line1: str + """The first line of the address.""" + + postal_or_zip: str = FieldInfo(alias="postalOrZip") + """The postal code or ZIP code of the address.""" + + province_or_state: str = FieldInfo(alias="provinceOrState") + """The province or state of the address.""" + + country_name: Optional[str] = FieldInfo(alias="countryName", default=None) + """The country name of the address.""" + + details: Optional[DataResultVerifiedAddressDetails] = None + """ + If you supply `includeDetails=true` as a query parameter, we will also populate + an additional `details` field that follows the + [Address Details](https://avdocs.postgrid.com/#address-details) schema. + """ + + errors: Optional[Errors] = None + """Errors encountered during address verification.""" + + firm_name: Optional[str] = FieldInfo(alias="firmName", default=None) + """The firm name of the address.""" + + geocode_result: Optional[DataResultVerifiedAddressGeocodeResult] = FieldInfo(alias="geocodeResult", default=None) + """ + If the `geocode=true` query parameter is supplied, the response will include a + geocodeResult which follows the + [Geocoding](https://avdocs.postgrid.com/#geocoding) schema. You can request this + feature be enabled by emailing `support@postgrid.com`. This includes our + verification, batch verification, suggestions, and POST /completions endpoint. + Note that you must supply country when geocoding to get the result successfully. + """ + + line2: Optional[str] = None + """The second line of the address.""" + + province_or_state_name: Optional[str] = FieldInfo(alias="provinceOrStateName", default=None) + """The full name of the province or state.""" + + status: Optional[Status] = None + """The verification status of an address.""" + + zip_plus4: Optional[str] = FieldInfo(alias="zipPlus4", default=None) + """The zip plus 4 code of the address.""" + + +class DataResult(BaseModel): + error: Optional[str] = None + """An error message for this address. Present when verification failed.""" + + verified_address: Optional[DataResultVerifiedAddress] = FieldInfo(alias="verifiedAddress", default=None) + """The verified address result. Present when verification succeeded.""" + + +class Data(BaseModel): + results: List[DataResult] + + +class AddressVerificationBatchVerificationResponse(BaseModel): + data: Data + + message: str + + status: Literal["success", "error"] diff --git a/src/postgrid/types/address_verification_get_autocomplete_previews_params.py b/src/postgrid/types/address_verification_get_autocomplete_previews_params.py new file mode 100644 index 0000000..60b8c63 --- /dev/null +++ b/src/postgrid/types/address_verification_get_autocomplete_previews_params.py @@ -0,0 +1,31 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, Annotated, TypedDict + +from .._utils import PropertyInfo + +__all__ = ["AddressVerificationGetAutocompletePreviewsParams"] + + +class AddressVerificationGetAutocompletePreviewsParams(TypedDict, total=False): + partial_street: Required[Annotated[str, PropertyInfo(alias="partialStreet")]] + + city_filter: Annotated[str, PropertyInfo(alias="cityFilter")] + + country_filter: Annotated[str, PropertyInfo(alias="countryFilter")] + + filter_exact: Annotated[bool, PropertyInfo(alias="filterExact")] + + limit: int + + pc_filter: Annotated[str, PropertyInfo(alias="pcFilter")] + + proper_case: Annotated[bool, PropertyInfo(alias="properCase")] + + prov_instead_of_pc: Annotated[bool, PropertyInfo(alias="provInsteadOfPC")] + + state_filter: Annotated[str, PropertyInfo(alias="stateFilter")] + + verified_only: Annotated[bool, PropertyInfo(alias="verifiedOnly")] diff --git a/src/postgrid/types/address_verification_get_autocomplete_previews_response.py b/src/postgrid/types/address_verification_get_autocomplete_previews_response.py new file mode 100644 index 0000000..f68aacb --- /dev/null +++ b/src/postgrid/types/address_verification_get_autocomplete_previews_response.py @@ -0,0 +1,48 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["AddressVerificationGetAutocompletePreviewsResponse", "Data", "DataPreview"] + + +class DataPreview(BaseModel): + """ + A partial view of the address, suitable for display in an autocomplete dropdown. + """ + + address: str + """The street address line.""" + + city: Optional[str] = None + """The city.""" + + pc: Optional[str] = None + """For US addresses, the full postal code. + + For non-US addresses, only the first 3 digits are returned to avoid consuming a + lookup. + """ + + prov: Optional[str] = None + """The province or state abbreviation. + + Returned instead of `pc` when `provInsteadOfPC=true`. + """ + + +class Data(BaseModel): + preview: DataPreview + """ + A partial view of the address, suitable for display in an autocomplete dropdown. + """ + + +class AddressVerificationGetAutocompletePreviewsResponse(BaseModel): + data: List[Data] + + message: str + + status: Literal["success", "error"] diff --git a/src/postgrid/types/address_verification_get_lookup_info_response.py b/src/postgrid/types/address_verification_get_lookup_info_response.py new file mode 100644 index 0000000..9948741 --- /dev/null +++ b/src/postgrid/types/address_verification_get_lookup_info_response.py @@ -0,0 +1,29 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .._models import BaseModel + +__all__ = ["AddressVerificationGetLookupInfoResponse", "Data"] + + +class Data(BaseModel): + free_limit: Optional[int] = FieldInfo(alias="freeLimit", default=None) + """ + The maximum number of lookups allowed in the current billing period. `null` + indicates an unlimited plan. + """ + + used: int + """The number of lookups consumed in the current billing period.""" + + +class AddressVerificationGetLookupInfoResponse(BaseModel): + data: Data + + message: str + + status: Literal["success", "error"] diff --git a/src/postgrid/types/address_verification_lookup_city_or_state_from_postal_or_zip_code_params.py b/src/postgrid/types/address_verification_lookup_city_or_state_from_postal_or_zip_code_params.py new file mode 100644 index 0000000..9fa30d3 --- /dev/null +++ b/src/postgrid/types/address_verification_lookup_city_or_state_from_postal_or_zip_code_params.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, Annotated, TypedDict + +from .._utils import PropertyInfo + +__all__ = ["AddressVerificationLookupCityOrStateFromPostalOrZipCodeParams"] + + +class AddressVerificationLookupCityOrStateFromPostalOrZipCodeParams(TypedDict, total=False): + postal_or_zip: Required[Annotated[str, PropertyInfo(alias="postalOrZip")]] diff --git a/src/postgrid/types/address_verification_lookup_city_or_state_from_postal_or_zip_code_response.py b/src/postgrid/types/address_verification_lookup_city_or_state_from_postal_or_zip_code_response.py new file mode 100644 index 0000000..5ab0079 --- /dev/null +++ b/src/postgrid/types/address_verification_lookup_city_or_state_from_postal_or_zip_code_response.py @@ -0,0 +1,44 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .._models import BaseModel + +__all__ = ["AddressVerificationLookupCityOrStateFromPostalOrZipCodeResponse", "Data"] + + +class Data(BaseModel): + city: str + """The city name.""" + + country: str + """The ISO 2-letter country code.""" + + province_or_state: str = FieldInfo(alias="provinceOrState") + """The province or state abbreviation.""" + + county: Optional[str] = None + """The county name (US addresses only).""" + + county_fips: Optional[str] = FieldInfo(alias="countyFIPS", default=None) + """The FIPS code for the county (US addresses only).""" + + mailable: Optional[bool] = None + """Whether the location is mailable.""" + + preferred_city: Optional[str] = FieldInfo(alias="preferredCity", default=None) + """The USPS preferred city name for this postal code.""" + + zip_class: Optional[str] = FieldInfo(alias="zipClass", default=None) + """The USPS ZIP code class (e.g. `S` for standard, `P` for PO Box only).""" + + +class AddressVerificationLookupCityOrStateFromPostalOrZipCodeResponse(BaseModel): + data: List[Data] + + message: str + + status: Literal["success", "error"] diff --git a/src/postgrid/types/address_verification_lookup_zip_code_from_city_or_state_params.py b/src/postgrid/types/address_verification_lookup_zip_code_from_city_or_state_params.py new file mode 100644 index 0000000..7bd2f78 --- /dev/null +++ b/src/postgrid/types/address_verification_lookup_zip_code_from_city_or_state_params.py @@ -0,0 +1,20 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, Annotated, TypedDict + +from .._utils import PropertyInfo + +__all__ = ["AddressVerificationLookupZipCodeFromCityOrStateParams"] + + +class AddressVerificationLookupZipCodeFromCityOrStateParams(TypedDict, total=False): + city: Required[str] + """The city name.""" + + country_code: Required[Annotated[str, PropertyInfo(alias="countryCode")]] + """The country code. Currently only `US` is supported.""" + + state: Required[str] + """The state abbreviation (e.g. `NY`).""" diff --git a/src/postgrid/types/address_verification_lookup_zip_code_from_city_or_state_response.py b/src/postgrid/types/address_verification_lookup_zip_code_from_city_or_state_response.py new file mode 100644 index 0000000..6fb0488 --- /dev/null +++ b/src/postgrid/types/address_verification_lookup_zip_code_from_city_or_state_response.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .._models import BaseModel + +__all__ = ["AddressVerificationLookupZipCodeFromCityOrStateResponse", "Data"] + + +class Data(BaseModel): + zip_codes: List[str] = FieldInfo(alias="zipCodes") + + +class AddressVerificationLookupZipCodeFromCityOrStateResponse(BaseModel): + data: Data + + message: str + + status: Literal["success", "error"] diff --git a/src/postgrid/types/address_verification_parse_an_address_params.py b/src/postgrid/types/address_verification_parse_an_address_params.py new file mode 100644 index 0000000..ffc2629 --- /dev/null +++ b/src/postgrid/types/address_verification_parse_an_address_params.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["AddressVerificationParseAnAddressParams"] + + +class AddressVerificationParseAnAddressParams(TypedDict, total=False): + address: Required[str] + """The address you want to verify, written on a single line.""" diff --git a/src/postgrid/types/address_verification_parse_an_address_response.py b/src/postgrid/types/address_verification_parse_an_address_response.py new file mode 100644 index 0000000..f7dbc53 --- /dev/null +++ b/src/postgrid/types/address_verification_parse_an_address_response.py @@ -0,0 +1,68 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .._models import BaseModel + +__all__ = ["AddressVerificationParseAnAddressResponse", "Data"] + + +class Data(BaseModel): + category: Optional[str] = None + """The category of the location (e.g. restaurant).""" + + city: Optional[str] = None + """The city name.""" + + city_district: Optional[str] = FieldInfo(alias="cityDistrict", default=None) + """The borough within a city.""" + + country: Optional[str] = None + """The country.""" + + house: Optional[str] = None + """The name of the location.""" + + house_number: Optional[str] = FieldInfo(alias="houseNumber", default=None) + """The house or street number.""" + + island: Optional[str] = None + """The name of the island.""" + + level: Optional[str] = None + """The floor.""" + + near: Optional[str] = None + """Populated if the input query contains a near/in qualifier.""" + + po_box: Optional[str] = FieldInfo(alias="poBox", default=None) + """The postal office box.""" + + postcode: Optional[str] = None + """The postal or ZIP code.""" + + road: Optional[str] = None + """The street name.""" + + state: Optional[str] = None + """The state or province.""" + + state_district: Optional[str] = FieldInfo(alias="stateDistrict", default=None) + """The county.""" + + suburb: Optional[str] = None + """The unofficial neighborhood name.""" + + unit: Optional[str] = None + """The apartment, unit, office, lot, or other secondary unit designator.""" + + +class AddressVerificationParseAnAddressResponse(BaseModel): + data: Data + + message: str + + status: Literal["success", "error"] diff --git a/src/postgrid/types/address_verification_suggest_addresses_params.py b/src/postgrid/types/address_verification_suggest_addresses_params.py new file mode 100644 index 0000000..2731f74 --- /dev/null +++ b/src/postgrid/types/address_verification_suggest_addresses_params.py @@ -0,0 +1,64 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict + +from .._utils import PropertyInfo + +__all__ = [ + "AddressVerificationSuggestAddressesParams", + "StandardFreeformAddressInput", + "StandardStructuredAddressInput", + "StandardStructuredAddressInputAddress", +] + + +class StandardFreeformAddressInput(TypedDict, total=False): + address: Required[str] + """The address you want to verify, written on a single line.""" + + geocode: bool + + include_details: Annotated[bool, PropertyInfo(alias="includeDetails")] + + proper_case: Annotated[bool, PropertyInfo(alias="properCase")] + + +class StandardStructuredAddressInput(TypedDict, total=False): + address: Required[StandardStructuredAddressInputAddress] + + geocode: bool + + include_details: Annotated[bool, PropertyInfo(alias="includeDetails")] + + proper_case: Annotated[bool, PropertyInfo(alias="properCase")] + + +class StandardStructuredAddressInputAddress(TypedDict, total=False): + city: Required[str] + """The city of the address.""" + + country: Required[Literal["ca", "us"]] + """The country of your address, one of `ca` or `us`.""" + + line1: Required[str] + """The first line of the address.""" + + postal_or_zip: Required[Annotated[str, PropertyInfo(alias="postalOrZip")]] + """The postal code or ZIP code of the address.""" + + province_or_state: Required[Annotated[str, PropertyInfo(alias="provinceOrState")]] + """The province or state of the address.""" + + line2: str + """The second line of the address.""" + + recipient: str + """The optional firm/recipient name.""" + + +AddressVerificationSuggestAddressesParams: TypeAlias = Union[ + StandardFreeformAddressInput, StandardStructuredAddressInput +] diff --git a/src/postgrid/types/address_verification_suggest_addresses_response.py b/src/postgrid/types/address_verification_suggest_addresses_response.py new file mode 100644 index 0000000..88ae582 --- /dev/null +++ b/src/postgrid/types/address_verification_suggest_addresses_response.py @@ -0,0 +1,278 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .errors import Errors +from .status import Status +from .._models import BaseModel + +__all__ = [ + "AddressVerificationSuggestAddressesResponse", + "Data", + "DataDetails", + "DataGeocodeResult", + "DataGeocodeResultLocation", +] + + +class DataDetails(BaseModel): + """ + If you supply `includeDetails=true` as a query parameter, we will also populate an additional `details` field that follows the [Address Details](https://avdocs.postgrid.com/#address-details) schema. + """ + + box_id: Optional[str] = FieldInfo(alias="boxID", default=None) + """PO Box ID""" + + county: Optional[str] = None + """County in the United States (US address only)""" + + county_num: Optional[str] = FieldInfo(alias="countyNum", default=None) + """FIPS code for county (US address only)""" + + delivery_installation_area_name: Optional[str] = FieldInfo(alias="deliveryInstallationAreaName", default=None) + """Delivery installation area name""" + + delivery_installation_qualifier: Optional[str] = FieldInfo(alias="deliveryInstallationQualifier", default=None) + """Delivery installation qualifier""" + + delivery_installation_type: Optional[str] = FieldInfo(alias="deliveryInstallationType", default=None) + """Delivery installation type""" + + extra_info: Optional[str] = FieldInfo(alias="extraInfo", default=None) + """Any extra information relevant to the address""" + + post_direction: Optional[str] = FieldInfo(alias="postDirection", default=None) + """The post-direction of the street (after the street name, US addresses only)""" + + pre_direction: Optional[str] = FieldInfo(alias="preDirection", default=None) + """The pre-direction of the street (before the street name, US addresses only)""" + + residential: Optional[bool] = None + """Indicates that the address is residential (US address only)""" + + rural_route_number: Optional[str] = FieldInfo(alias="ruralRouteNumber", default=None) + """Rural route number""" + + rural_route_type: Optional[str] = FieldInfo(alias="ruralRouteType", default=None) + """Rural route type""" + + street_direction: Optional[str] = FieldInfo(alias="streetDirection", default=None) + """The direction of the street (N, S, E, W, etc)""" + + street_name: Optional[str] = FieldInfo(alias="streetName", default=None) + """Name of the street where the address is located""" + + street_number: Optional[str] = FieldInfo(alias="streetNumber", default=None) + """Street number (e.g. the 20 in 20 Bay St)""" + + street_type: Optional[str] = FieldInfo(alias="streetType", default=None) + """Type of the street (DR, ST, BLVD, etc)""" + + suite_id: Optional[str] = FieldInfo(alias="suiteID", default=None) + """The unit number/name""" + + suite_key: Optional[str] = FieldInfo(alias="suiteKey", default=None) + """The suite key""" + + us_census_block_number: Optional[str] = FieldInfo(alias="usCensusBlockNumber", default=None) + """US Census block number""" + + us_census_cmsa: Optional[str] = FieldInfo(alias="usCensusCMSA", default=None) + """US Census consolidated metropolitan statistical area""" + + us_census_fips: Optional[str] = FieldInfo(alias="usCensusFIPS", default=None) + """US Census FIPS code (US address only)""" + + us_census_ma: Optional[str] = FieldInfo(alias="usCensusMA", default=None) + """US Census metropolitan area""" + + us_census_msa: Optional[str] = FieldInfo(alias="usCensusMSA", default=None) + """US Census metropolitan statistical area""" + + us_census_pmsa: Optional[str] = FieldInfo(alias="usCensusPMSA", default=None) + """US Census primary metropolitan statistical area""" + + us_census_tract_number: Optional[str] = FieldInfo(alias="usCensusTractNumber", default=None) + """US Census tract number""" + + us_congressional_district_number: Optional[str] = FieldInfo(alias="usCongressionalDistrictNumber", default=None) + """US congressional district number""" + + us_has_daylight_savings: Optional[bool] = FieldInfo(alias="usHasDaylightSavings", default=None) + """True if address location recognizes DST""" + + us_mailing_check_digit: Optional[str] = FieldInfo(alias="usMailingCheckDigit", default=None) + """PostNet barcode digit""" + + us_mailings_carrier_route: Optional[str] = FieldInfo(alias="usMailingsCarrierRoute", default=None) + """4-character code assigned to mail delivery route within a 5 digit zip code""" + + us_mailings_default_flag: Optional[bool] = FieldInfo(alias="usMailingsDefaultFlag", default=None) + """ + True if US address matches a high-rise default or rural route default in the + USPS data + """ + + us_mailings_delivery_point: Optional[str] = FieldInfo(alias="usMailingsDeliveryPoint", default=None) + """Unique USPS identifier for the delivery point""" + + us_mailings_dpv_confirmation_indicator: Optional[str] = FieldInfo( + alias="usMailingsDpvConfirmationIndicator", default=None + ) + """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + + us_mailings_dpv_crma_indicator: Optional[str] = FieldInfo(alias="usMailingsDpvCrmaIndicator", default=None) + """Y if this is a commercial mail receiving agency, N otherwise""" + + us_mailings_dpv_footnote1: Optional[str] = FieldInfo(alias="usMailingsDpvFootnote1", default=None) + """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + + us_mailings_dpv_footnote2: Optional[str] = FieldInfo(alias="usMailingsDpvFootnote2", default=None) + """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + + us_mailings_dpv_footnote3: Optional[str] = FieldInfo(alias="usMailingsDpvFootnote3", default=None) + """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + + us_mailings_elot_asc_desc: Optional[str] = FieldInfo(alias="usMailingsElotAscDesc", default=None) + """A for ascending, D for descending""" + + us_mailings_elot_sequence_number: Optional[str] = FieldInfo(alias="usMailingsElotSequenceNumber", default=None) + """eLOT sequence number""" + + us_mailings_ews_flag: Optional[str] = FieldInfo(alias="usMailingsEWSFlag", default=None) + """Y if address is in early warning system database""" + + us_mailings_lacs_flag: Optional[str] = FieldInfo(alias="usMailingsLACSFlag", default=None) + """Y if address converted by LACS""" + + us_mailings_lacs_return_code: Optional[str] = FieldInfo(alias="usMailingsLACSReturnCode", default=None) + """Corresponds to USPS LACSLink return code""" + + us_mailings_record_type_code: Optional[str] = FieldInfo(alias="usMailingsRecordTypeCode", default=None) + """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + + us_mailings_suite_link_return_code: Optional[str] = FieldInfo(alias="usMailingsSuiteLinkReturnCode", default=None) + """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + + us_postnet_barcode: Optional[str] = FieldInfo(alias="usPostnetBarcode", default=None) + """PostNet barcode for the address (US address only)""" + + us_state_legislative_lower: Optional[str] = FieldInfo(alias="usStateLegislativeLower", default=None) + """Lower legislative district for the US address""" + + us_state_legislative_upper: Optional[str] = FieldInfo(alias="usStateLegislativeUpper", default=None) + """Upper legislative district for the US address""" + + us_time_zone: Optional[str] = FieldInfo(alias="usTimeZone", default=None) + """Time zone for the US address area""" + + vacant: Optional[bool] = None + """Indicates that the address is vacant according to the USPS (US address only)""" + + +class DataGeocodeResultLocation(BaseModel): + """Object that contains `lat`, `lng` properties with number values""" + + lat: float + + lng: float + + +class DataGeocodeResult(BaseModel): + """ + If the `geocode=true` query parameter is supplied, the response will include a geocodeResult + which follows the [Geocoding](https://avdocs.postgrid.com/#geocoding) schema. You can request + this feature be enabled by emailing `support@postgrid.com`. This includes our verification, batch + verification, suggestions, and POST /completions endpoint. Note that you must supply country when + geocoding to get the result successfully. + """ + + accuracy: float + """ + A real number from 0.00 to 1.00 which represents an + [accuracy score](https://avdocs.postgrid.com/#accuracy-score) + """ + + accuracy_type: Literal[ + "rooftop", + "point", + "range_interpolation", + "nearest_rooftop_match", + "intersection", + "street_center", + "place", + "state", + ] = FieldInfo(alias="accuracyType") + """ + A string representing the + [accuracy type](https://avdocs.postgrid.com/#accuracy-type) + """ + + location: DataGeocodeResultLocation + """Object that contains `lat`, `lng` properties with number values""" + + +class Data(BaseModel): + city: str + """The city name of the address.""" + + country: str + """The country code of the address.""" + + line1: str + """The first line of the address.""" + + postal_or_zip: str = FieldInfo(alias="postalOrZip") + """The postal code or ZIP code of the address.""" + + province_or_state: str = FieldInfo(alias="provinceOrState") + """The province or state of the address.""" + + country_name: Optional[str] = FieldInfo(alias="countryName", default=None) + """The country name of the address.""" + + details: Optional[DataDetails] = None + """ + If you supply `includeDetails=true` as a query parameter, we will also populate + an additional `details` field that follows the + [Address Details](https://avdocs.postgrid.com/#address-details) schema. + """ + + errors: Optional[Errors] = None + """Errors encountered during address verification.""" + + firm_name: Optional[str] = FieldInfo(alias="firmName", default=None) + """The firm name of the address.""" + + geocode_result: Optional[DataGeocodeResult] = FieldInfo(alias="geocodeResult", default=None) + """ + If the `geocode=true` query parameter is supplied, the response will include a + geocodeResult which follows the + [Geocoding](https://avdocs.postgrid.com/#geocoding) schema. You can request this + feature be enabled by emailing `support@postgrid.com`. This includes our + verification, batch verification, suggestions, and POST /completions endpoint. + Note that you must supply country when geocoding to get the result successfully. + """ + + line2: Optional[str] = None + """The second line of the address.""" + + province_or_state_name: Optional[str] = FieldInfo(alias="provinceOrStateName", default=None) + """The full name of the province or state.""" + + status: Optional[Status] = None + """The verification status of an address.""" + + zip_plus4: Optional[str] = FieldInfo(alias="zipPlus4", default=None) + """The zip plus 4 code of the address.""" + + +class AddressVerificationSuggestAddressesResponse(BaseModel): + data: List[Data] + + message: str + + status: Literal["success", "error"] diff --git a/src/postgrid/types/address_verification_verify_response.py b/src/postgrid/types/address_verification_verify_response.py index f7dfd5a..f714b4e 100644 --- a/src/postgrid/types/address_verification_verify_response.py +++ b/src/postgrid/types/address_verification_verify_response.py @@ -77,6 +77,9 @@ class DataDetails(BaseModel): us_census_cmsa: Optional[str] = FieldInfo(alias="usCensusCMSA", default=None) """US Census consolidated metropolitan statistical area""" + us_census_fips: Optional[str] = FieldInfo(alias="usCensusFIPS", default=None) + """US Census FIPS code (US address only)""" + us_census_ma: Optional[str] = FieldInfo(alias="usCensusMA", default=None) """US Census metropolitan area""" @@ -148,6 +151,9 @@ class DataDetails(BaseModel): us_mailings_suite_link_return_code: Optional[str] = FieldInfo(alias="usMailingsSuiteLinkReturnCode", default=None) """See [USPS DPV](https://avdocs.postgrid.com/#usps-dpv)""" + us_postnet_barcode: Optional[str] = FieldInfo(alias="usPostnetBarcode", default=None) + """PostNet barcode for the address (US address only)""" + us_state_legislative_lower: Optional[str] = FieldInfo(alias="usStateLegislativeLower", default=None) """Lower legislative district for the US address""" @@ -248,6 +254,9 @@ class Data(BaseModel): line2: Optional[str] = None """The second line of the address.""" + province_or_state_name: Optional[str] = FieldInfo(alias="provinceOrStateName", default=None) + """The full name of the province or state.""" + status: Optional[Status] = None """The verification status of an address.""" diff --git a/src/postgrid/types/errors.py b/src/postgrid/types/errors.py index 0eb9921..f3f9475 100644 --- a/src/postgrid/types/errors.py +++ b/src/postgrid/types/errors.py @@ -24,5 +24,8 @@ class Errors(BaseModel): line2: Optional[List[str]] = None """Errors related to the second address line.""" + postal_or_zip: Optional[List[str]] = FieldInfo(alias="postalOrZip", default=None) + """Errors related to the postal or ZIP code.""" + province_or_state: Optional[List[str]] = FieldInfo(alias="provinceOrState", default=None) """Errors related to the province or state.""" diff --git a/src/postgrid/types/intl_address_verification_autocomplete_params.py b/src/postgrid/types/intl_address_verification_autocomplete_params.py new file mode 100644 index 0000000..20219d7 --- /dev/null +++ b/src/postgrid/types/intl_address_verification_autocomplete_params.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, Annotated, TypedDict + +from .._utils import PropertyInfo + +__all__ = ["IntlAddressVerificationAutocompleteParams"] + + +class IntlAddressVerificationAutocompleteParams(TypedDict, total=False): + id: Required[str] + + include_details: Annotated[bool, PropertyInfo(alias="includeDetails")] + + proper_case: Annotated[bool, PropertyInfo(alias="properCase")] + + use_enhanced_china_dataset: Annotated[bool, PropertyInfo(alias="useEnhancedChinaDataset")] + + verify: bool diff --git a/src/postgrid/types/intl_address_verification_autocomplete_response.py b/src/postgrid/types/intl_address_verification_autocomplete_response.py new file mode 100644 index 0000000..0644bd5 --- /dev/null +++ b/src/postgrid/types/intl_address_verification_autocomplete_response.py @@ -0,0 +1,289 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union, Optional +from typing_extensions import Literal, TypeAlias + +from pydantic import Field as FieldInfo + +from .errors import Errors +from .status import Status +from .._models import BaseModel + +__all__ = [ + "IntlAddressVerificationAutocompleteResponse", + "Data", + "DataIntlAddressCompletion", + "DataVerifiedAddress", + "DataVerifiedAddressDetails", + "DataVerifiedAddressGeoData", + "DataVerifiedAddressSummary", +] + + +class DataIntlAddressCompletion(BaseModel): + """A fully resolved international address returned by `POST /completions`.""" + + building: Optional[str] = None + """The building name, if applicable.""" + + city: Optional[str] = None + """The city or locality.""" + + company: Optional[str] = None + """The company or organization name, if applicable.""" + + country: Optional[str] = None + """The country name.""" + + country_code: Optional[str] = FieldInfo(alias="countryCode", default=None) + """The ISO 2-letter country code.""" + + department: Optional[str] = None + """The department or floor, if applicable.""" + + error: Optional[str] = None + """An error message if resolution failed.""" + + formatted_address: Optional[str] = FieldInfo(alias="formattedAddress", default=None) + """The full formatted address string.""" + + line1: Optional[str] = None + """The first address line.""" + + line2: Optional[str] = None + """The second address line.""" + + line3: Optional[str] = None + """The third address line.""" + + line4: Optional[str] = None + """The fourth address line.""" + + postal_or_zip: Optional[str] = FieldInfo(alias="postalOrZip", default=None) + """The postal or ZIP code.""" + + province_code: Optional[str] = FieldInfo(alias="provinceCode", default=None) + """The province or state code.""" + + province_or_state: Optional[str] = FieldInfo(alias="provinceOrState", default=None) + """The province or state name.""" + + +class DataVerifiedAddressDetails(BaseModel): + """ + Additional details about the verified address, such as premise, thoroughfare, and locality. + """ + + building: Optional[str] = None + """The building name or number.""" + + building_type: Optional[str] = FieldInfo(alias="buildingType", default=None) + """The type of building (e.g., apartment, office).""" + + city_name: Optional[str] = FieldInfo(alias="cityName", default=None) + """The full city name.""" + + city_secondary: Optional[str] = FieldInfo(alias="citySecondary", default=None) + """Secondary city information.""" + + city_type: Optional[str] = FieldInfo(alias="cityType", default=None) + """The type of city (e.g., city, town, village).""" + + delivery_address: Optional[str] = FieldInfo(alias="deliveryAddress", default=None) + """The full delivery address.""" + + dependent_locality: Optional[str] = FieldInfo(alias="dependentLocality", default=None) + """The dependent locality (UK addresses).""" + + double_dependent_locality: Optional[str] = FieldInfo(alias="doubleDependentLocality", default=None) + """The double dependent locality (UK addresses).""" + + organization: Optional[str] = None + """The organization or company name.""" + + postal_or_zip_primary: Optional[str] = FieldInfo(alias="postalOrZipPrimary", default=None) + """The primary part of the postal or ZIP code.""" + + postal_or_zip_secondary: Optional[str] = FieldInfo(alias="postalOrZipSecondary", default=None) + """The secondary part of the postal or ZIP code.""" + + post_box: Optional[str] = FieldInfo(alias="postBox", default=None) + """The post box number.""" + + premise: Optional[str] = None + """The premise name or number.""" + + premise_number: Optional[str] = FieldInfo(alias="premiseNumber", default=None) + """The premise number.""" + + premise_secondary: Optional[str] = FieldInfo(alias="premiseSecondary", default=None) + """Secondary premise information.""" + + premise_type: Optional[str] = FieldInfo(alias="premiseType", default=None) + """The type of premise (e.g., house, flat).""" + + province_or_state_name: Optional[str] = FieldInfo(alias="provinceOrStateName", default=None) + """The full name of the province or state.""" + + province_or_state_type: Optional[str] = FieldInfo(alias="provinceOrStateType", default=None) + """The type of province or state (e.g., province, state, region).""" + + street: Optional[str] = None + """The street name.""" + + street_post_direction: Optional[str] = FieldInfo(alias="streetPostDirection", default=None) + """The directional suffix for the street (e.g., N, S, E, W).""" + + street_pre_direction: Optional[str] = FieldInfo(alias="streetPreDirection", default=None) + """The directional prefix for the street (e.g., N, S, E, W).""" + + street_type: Optional[str] = FieldInfo(alias="streetType", default=None) + """The type of street (e.g., St, Ave, Blvd).""" + + sub_administrative_area: Optional[str] = FieldInfo(alias="subAdministrativeArea", default=None) + """The sub-administrative area.""" + + sub_building: Optional[str] = FieldInfo(alias="subBuilding", default=None) + """The sub-building name or number (e.g., unit, suite).""" + + sub_building_floor: Optional[str] = FieldInfo(alias="SubBuildingFloor", default=None) + """The floor of the sub-building.""" + + sub_building_number: Optional[str] = FieldInfo(alias="subBuildingNumber", default=None) + """The sub-building number.""" + + sub_building_type: Optional[str] = FieldInfo(alias="subBuildingType", default=None) + """The type of sub-building (e.g., floor, wing).""" + + sub_street: Optional[str] = FieldInfo(alias="subStreet", default=None) + """The sub-street name.""" + + sub_street_post_direction: Optional[str] = FieldInfo(alias="subStreetPostDirection", default=None) + """The directional suffix for the sub-street.""" + + sub_street_pre_direction: Optional[str] = FieldInfo(alias="subStreetPreDirection", default=None) + """The directional prefix for the sub-street.""" + + sub_street_type: Optional[str] = FieldInfo(alias="subStreetType", default=None) + """The type of sub-street.""" + + super_administrative_area: Optional[str] = FieldInfo(alias="superAdministrativeArea", default=None) + """The super-administrative area.""" + + telephone: Optional[str] = None + """The telephone number associated with the address.""" + + +class DataVerifiedAddressGeoData(BaseModel): + """Geocoding result for the verified address.""" + + geo_accuracy: Optional[str] = FieldInfo(alias="geoAccuracy", default=None) + """The geocode accuracy.""" + + latitude: Optional[str] = None + """The latitude of the address.""" + + longitude: Optional[str] = None + """The longitude of the address.""" + + +class DataVerifiedAddressSummary(BaseModel): + """A summary of the verification process and match levels.""" + + context_identification_match_level: Optional[str] = FieldInfo(alias="contextIdentificationMatchLevel", default=None) + """Context identification match level.""" + + lexicon_identification_match_level: Optional[str] = FieldInfo(alias="lexiconIdentificationMatchLevel", default=None) + """Lexicon identification match level.""" + + match_score: Optional[float] = FieldInfo(alias="matchScore", default=None) + """The match score (0-100).""" + + message: Optional[str] = None + """Additional message about the verification.""" + + parsing_status: Optional[str] = FieldInfo(alias="parsingStatus", default=None) + """The parsing status of the address.""" + + post_code_status: Optional[str] = FieldInfo(alias="postCodeStatus", default=None) + """The status of the postal code.""" + + post_processed_verification_match_level: Optional[str] = FieldInfo( + alias="postProcessedVerificationMatchLevel", default=None + ) + """The match level after post-processing.""" + + pre_processed_verification_match_level: Optional[str] = FieldInfo( + alias="preProcessedVerificationMatchLevel", default=None + ) + """The match level before post-processing.""" + + verification_status: Optional[str] = FieldInfo(alias="verificationStatus", default=None) + """The overall verification status.""" + + +class DataVerifiedAddress(BaseModel): + """The result of a verified international address.""" + + city: str + """The city or locality.""" + + country: str + """The country code (ISO 3166-1 alpha-2).""" + + line1: str + """The first address line.""" + + postal_or_zip: str = FieldInfo(alias="postalOrZip") + """The postal or ZIP code.""" + + province_or_state: str = FieldInfo(alias="provinceOrState") + """The province or state.""" + + country_name: Optional[str] = FieldInfo(alias="countryName", default=None) + """The full country name.""" + + details: Optional[DataVerifiedAddressDetails] = None + """ + Additional details about the verified address, such as premise, thoroughfare, + and locality. + """ + + errors: Optional[Errors] = None + """Errors encountered during address verification.""" + + firm_name: Optional[str] = FieldInfo(alias="firmName", default=None) + """The firm or company name, if available.""" + + formatted_address: Optional[str] = FieldInfo(alias="formattedAddress", default=None) + """The formatted address string.""" + + geo_data: Optional[DataVerifiedAddressGeoData] = FieldInfo(alias="geoData", default=None) + """Geocoding result for the verified address.""" + + line2: Optional[str] = None + """The second address line.""" + + line3: Optional[str] = None + """The third address line, if available.""" + + status: Optional[Status] = None + """The verification status of an address.""" + + summary: Optional[DataVerifiedAddressSummary] = None + """A summary of the verification process and match levels.""" + + zip_plus4: Optional[str] = FieldInfo(alias="zipPlus4", default=None) + """The ZIP+4 code (for US addresses).""" + + +Data: TypeAlias = Union[DataIntlAddressCompletion, DataVerifiedAddress] + + +class IntlAddressVerificationAutocompleteResponse(BaseModel): + data: Data + """A fully resolved international address returned by `POST /completions`.""" + + message: str + + status: Literal["success", "error"] diff --git a/src/postgrid/types/intl_address_verification_batch_verification_params.py b/src/postgrid/types/intl_address_verification_batch_verification_params.py new file mode 100644 index 0000000..f252cbf --- /dev/null +++ b/src/postgrid/types/intl_address_verification_batch_verification_params.py @@ -0,0 +1,74 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union, Iterable +from typing_extensions import Required, Annotated, TypeAlias, TypedDict + +from .._utils import PropertyInfo + +__all__ = [ + "IntlAddressVerificationBatchVerificationParams", + "Address", + "AddressStructuredAddressInput", + "AddressStructuredAddressInputAddress", + "AddressFreeformAddressInput", +] + + +class IntlAddressVerificationBatchVerificationParams(TypedDict, total=False): + addresses: Required[Iterable[Address]] + """Array of addresses to verify. + + Each item can be a freeform string or a structured address object. + """ + + geo_data: Annotated[bool, PropertyInfo(alias="geoData")] + + include_details: Annotated[bool, PropertyInfo(alias="includeDetails")] + + proper_case: Annotated[bool, PropertyInfo(alias="properCase")] + + use_enhanced_china_dataset: Annotated[bool, PropertyInfo(alias="useEnhancedChinaDataset")] + + +class AddressStructuredAddressInputAddress(TypedDict, total=False): + country: Required[str] + """The country code (ISO 3166-1 alpha-2 or alpha-3).""" + + line1: Required[str] + """The first line of the address (e.g., street address, building, etc.).""" + + postal_or_zip: Required[Annotated[str, PropertyInfo(alias="postalOrZip")]] + """The postal or ZIP code.""" + + province_or_state: Required[Annotated[str, PropertyInfo(alias="provinceOrState")]] + """The administrative area (e.g., state, province, region).""" + + city: str + """The city, town, or locality of the address.""" + + line2: str + """The second line of the address (e.g., apartment, suite, etc.).""" + + line3: str + """The third line of the address (e.g., additional locality or delivery info).""" + + line4: str + """The fourth line of the address (e.g., further address details).""" + + +class AddressStructuredAddressInput(TypedDict, total=False): + """Input model for structured international address verification.""" + + address: Required[AddressStructuredAddressInputAddress] + + +class AddressFreeformAddressInput(TypedDict, total=False): + """Input model for freeform international address verification.""" + + address: Required[str] + """The full address as a single string.""" + + +Address: TypeAlias = Union[AddressStructuredAddressInput, AddressFreeformAddressInput] diff --git a/src/postgrid/types/intl_address_verification_batch_verification_response.py b/src/postgrid/types/intl_address_verification_batch_verification_response.py new file mode 100644 index 0000000..159ef63 --- /dev/null +++ b/src/postgrid/types/intl_address_verification_batch_verification_response.py @@ -0,0 +1,248 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .errors import Errors +from .status import Status +from .._models import BaseModel + +__all__ = [ + "IntlAddressVerificationBatchVerificationResponse", + "Data", + "DataResult", + "DataResultVerifiedAddress", + "DataResultVerifiedAddressDetails", + "DataResultVerifiedAddressGeoData", + "DataResultVerifiedAddressSummary", +] + + +class DataResultVerifiedAddressDetails(BaseModel): + """ + Additional details about the verified address, such as premise, thoroughfare, and locality. + """ + + building: Optional[str] = None + """The building name or number.""" + + building_type: Optional[str] = FieldInfo(alias="buildingType", default=None) + """The type of building (e.g., apartment, office).""" + + city_name: Optional[str] = FieldInfo(alias="cityName", default=None) + """The full city name.""" + + city_secondary: Optional[str] = FieldInfo(alias="citySecondary", default=None) + """Secondary city information.""" + + city_type: Optional[str] = FieldInfo(alias="cityType", default=None) + """The type of city (e.g., city, town, village).""" + + delivery_address: Optional[str] = FieldInfo(alias="deliveryAddress", default=None) + """The full delivery address.""" + + dependent_locality: Optional[str] = FieldInfo(alias="dependentLocality", default=None) + """The dependent locality (UK addresses).""" + + double_dependent_locality: Optional[str] = FieldInfo(alias="doubleDependentLocality", default=None) + """The double dependent locality (UK addresses).""" + + organization: Optional[str] = None + """The organization or company name.""" + + postal_or_zip_primary: Optional[str] = FieldInfo(alias="postalOrZipPrimary", default=None) + """The primary part of the postal or ZIP code.""" + + postal_or_zip_secondary: Optional[str] = FieldInfo(alias="postalOrZipSecondary", default=None) + """The secondary part of the postal or ZIP code.""" + + post_box: Optional[str] = FieldInfo(alias="postBox", default=None) + """The post box number.""" + + premise: Optional[str] = None + """The premise name or number.""" + + premise_number: Optional[str] = FieldInfo(alias="premiseNumber", default=None) + """The premise number.""" + + premise_secondary: Optional[str] = FieldInfo(alias="premiseSecondary", default=None) + """Secondary premise information.""" + + premise_type: Optional[str] = FieldInfo(alias="premiseType", default=None) + """The type of premise (e.g., house, flat).""" + + province_or_state_name: Optional[str] = FieldInfo(alias="provinceOrStateName", default=None) + """The full name of the province or state.""" + + province_or_state_type: Optional[str] = FieldInfo(alias="provinceOrStateType", default=None) + """The type of province or state (e.g., province, state, region).""" + + street: Optional[str] = None + """The street name.""" + + street_post_direction: Optional[str] = FieldInfo(alias="streetPostDirection", default=None) + """The directional suffix for the street (e.g., N, S, E, W).""" + + street_pre_direction: Optional[str] = FieldInfo(alias="streetPreDirection", default=None) + """The directional prefix for the street (e.g., N, S, E, W).""" + + street_type: Optional[str] = FieldInfo(alias="streetType", default=None) + """The type of street (e.g., St, Ave, Blvd).""" + + sub_administrative_area: Optional[str] = FieldInfo(alias="subAdministrativeArea", default=None) + """The sub-administrative area.""" + + sub_building: Optional[str] = FieldInfo(alias="subBuilding", default=None) + """The sub-building name or number (e.g., unit, suite).""" + + sub_building_floor: Optional[str] = FieldInfo(alias="SubBuildingFloor", default=None) + """The floor of the sub-building.""" + + sub_building_number: Optional[str] = FieldInfo(alias="subBuildingNumber", default=None) + """The sub-building number.""" + + sub_building_type: Optional[str] = FieldInfo(alias="subBuildingType", default=None) + """The type of sub-building (e.g., floor, wing).""" + + sub_street: Optional[str] = FieldInfo(alias="subStreet", default=None) + """The sub-street name.""" + + sub_street_post_direction: Optional[str] = FieldInfo(alias="subStreetPostDirection", default=None) + """The directional suffix for the sub-street.""" + + sub_street_pre_direction: Optional[str] = FieldInfo(alias="subStreetPreDirection", default=None) + """The directional prefix for the sub-street.""" + + sub_street_type: Optional[str] = FieldInfo(alias="subStreetType", default=None) + """The type of sub-street.""" + + super_administrative_area: Optional[str] = FieldInfo(alias="superAdministrativeArea", default=None) + """The super-administrative area.""" + + telephone: Optional[str] = None + """The telephone number associated with the address.""" + + +class DataResultVerifiedAddressGeoData(BaseModel): + """Geocoding result for the verified address.""" + + geo_accuracy: Optional[str] = FieldInfo(alias="geoAccuracy", default=None) + """The geocode accuracy.""" + + latitude: Optional[str] = None + """The latitude of the address.""" + + longitude: Optional[str] = None + """The longitude of the address.""" + + +class DataResultVerifiedAddressSummary(BaseModel): + """A summary of the verification process and match levels.""" + + context_identification_match_level: Optional[str] = FieldInfo(alias="contextIdentificationMatchLevel", default=None) + """Context identification match level.""" + + lexicon_identification_match_level: Optional[str] = FieldInfo(alias="lexiconIdentificationMatchLevel", default=None) + """Lexicon identification match level.""" + + match_score: Optional[float] = FieldInfo(alias="matchScore", default=None) + """The match score (0-100).""" + + message: Optional[str] = None + """Additional message about the verification.""" + + parsing_status: Optional[str] = FieldInfo(alias="parsingStatus", default=None) + """The parsing status of the address.""" + + post_code_status: Optional[str] = FieldInfo(alias="postCodeStatus", default=None) + """The status of the postal code.""" + + post_processed_verification_match_level: Optional[str] = FieldInfo( + alias="postProcessedVerificationMatchLevel", default=None + ) + """The match level after post-processing.""" + + pre_processed_verification_match_level: Optional[str] = FieldInfo( + alias="preProcessedVerificationMatchLevel", default=None + ) + """The match level before post-processing.""" + + verification_status: Optional[str] = FieldInfo(alias="verificationStatus", default=None) + """The overall verification status.""" + + +class DataResultVerifiedAddress(BaseModel): + """The result of a verified international address.""" + + city: str + """The city or locality.""" + + country: str + """The country code (ISO 3166-1 alpha-2).""" + + line1: str + """The first address line.""" + + postal_or_zip: str = FieldInfo(alias="postalOrZip") + """The postal or ZIP code.""" + + province_or_state: str = FieldInfo(alias="provinceOrState") + """The province or state.""" + + country_name: Optional[str] = FieldInfo(alias="countryName", default=None) + """The full country name.""" + + details: Optional[DataResultVerifiedAddressDetails] = None + """ + Additional details about the verified address, such as premise, thoroughfare, + and locality. + """ + + errors: Optional[Errors] = None + """Errors encountered during address verification.""" + + firm_name: Optional[str] = FieldInfo(alias="firmName", default=None) + """The firm or company name, if available.""" + + formatted_address: Optional[str] = FieldInfo(alias="formattedAddress", default=None) + """The formatted address string.""" + + geo_data: Optional[DataResultVerifiedAddressGeoData] = FieldInfo(alias="geoData", default=None) + """Geocoding result for the verified address.""" + + line2: Optional[str] = None + """The second address line.""" + + line3: Optional[str] = None + """The third address line, if available.""" + + status: Optional[Status] = None + """The verification status of an address.""" + + summary: Optional[DataResultVerifiedAddressSummary] = None + """A summary of the verification process and match levels.""" + + zip_plus4: Optional[str] = FieldInfo(alias="zipPlus4", default=None) + """The ZIP+4 code (for US addresses).""" + + +class DataResult(BaseModel): + error: Optional[str] = None + """An error message for this address. Present when verification failed.""" + + verified_address: Optional[DataResultVerifiedAddress] = FieldInfo(alias="verifiedAddress", default=None) + """The result of a verified international address.""" + + +class Data(BaseModel): + results: List[DataResult] + + +class IntlAddressVerificationBatchVerificationResponse(BaseModel): + data: Data + + message: str + + status: Literal["success", "error"] diff --git a/src/postgrid/types/intl_address_verification_get_autocomplete_advanced_previews_params.py b/src/postgrid/types/intl_address_verification_get_autocomplete_advanced_previews_params.py new file mode 100644 index 0000000..212f0b0 --- /dev/null +++ b/src/postgrid/types/intl_address_verification_get_autocomplete_advanced_previews_params.py @@ -0,0 +1,35 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Annotated, TypedDict + +from .._utils import PropertyInfo + +__all__ = ["IntlAddressVerificationGetAutocompleteAdvancedPreviewsParams"] + + +class IntlAddressVerificationGetAutocompleteAdvancedPreviewsParams(TypedDict, total=False): + advanced: bool + + city_filter: Annotated[str, PropertyInfo(alias="cityFilter")] + + container: str + + countries_filter: Annotated[str, PropertyInfo(alias="countriesFilter")] + + disable_ip_biasing: Annotated[bool, PropertyInfo(alias="disableIPBiasing")] + + language: str + + limit: int + + partial_street: Annotated[str, PropertyInfo(alias="partialStreet")] + + postal_or_zip_filter: Annotated[str, PropertyInfo(alias="postalOrZipFilter")] + + standard_fallback: Annotated[bool, PropertyInfo(alias="standardFallback")] + + street_filter: Annotated[str, PropertyInfo(alias="streetFilter")] + + use_enhanced_china_dataset: Annotated[bool, PropertyInfo(alias="useEnhancedChinaDataset")] diff --git a/src/postgrid/types/intl_address_verification_get_autocomplete_advanced_previews_response.py b/src/postgrid/types/intl_address_verification_get_autocomplete_advanced_previews_response.py new file mode 100644 index 0000000..bc43848 --- /dev/null +++ b/src/postgrid/types/intl_address_verification_get_autocomplete_advanced_previews_response.py @@ -0,0 +1,52 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse", "Data"] + + +class Data(BaseModel): + """ + A single address suggestion returned by `GET /completions`. + Use the `id` field to retrieve the full address via `POST /completions`. + """ + + id: Optional[str] = None + """The unique identifier for this result. + + Pass this to `POST /completions` to retrieve the full address. If the `type` is + `Container`, pass it as the `container` parameter to `GET /completions` to drill + down further. + """ + + description: Optional[str] = None + """A secondary description of the result (e.g. city and country).""" + + error: Optional[str] = None + """An error message if the lookup failed for this result.""" + + highlight: Optional[str] = None + """Character ranges within `text` that match the search input, for bolding in UI.""" + + text: Optional[str] = None + """The human-readable address suggestion text.""" + + type: Optional[str] = None + """The type of result. + + `Address` means this can be resolved directly via `POST /completions`. + `Container` means the result represents a building or complex — perform another + `GET /completions` with this `id` as `container` to get individual unit + addresses. + """ + + +class IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse(BaseModel): + data: List[Data] + + message: str + + status: Literal["success", "error"] diff --git a/src/postgrid/types/intl_address_verification_get_autocomplete_previews_params.py b/src/postgrid/types/intl_address_verification_get_autocomplete_previews_params.py new file mode 100644 index 0000000..d703dc0 --- /dev/null +++ b/src/postgrid/types/intl_address_verification_get_autocomplete_previews_params.py @@ -0,0 +1,35 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Annotated, TypedDict + +from .._utils import PropertyInfo + +__all__ = ["IntlAddressVerificationGetAutocompletePreviewsParams"] + + +class IntlAddressVerificationGetAutocompletePreviewsParams(TypedDict, total=False): + advanced: bool + + city_filter: Annotated[str, PropertyInfo(alias="cityFilter")] + + container: str + + countries_filter: Annotated[str, PropertyInfo(alias="countriesFilter")] + + disable_ip_biasing: Annotated[bool, PropertyInfo(alias="disableIPBiasing")] + + language: str + + limit: int + + partial_street: Annotated[str, PropertyInfo(alias="partialStreet")] + + postal_or_zip_filter: Annotated[str, PropertyInfo(alias="postalOrZipFilter")] + + standard_fallback: Annotated[bool, PropertyInfo(alias="standardFallback")] + + street_filter: Annotated[str, PropertyInfo(alias="streetFilter")] + + use_enhanced_china_dataset: Annotated[bool, PropertyInfo(alias="useEnhancedChinaDataset")] diff --git a/src/postgrid/types/intl_address_verification_get_autocomplete_previews_response.py b/src/postgrid/types/intl_address_verification_get_autocomplete_previews_response.py new file mode 100644 index 0000000..b3c4b4d --- /dev/null +++ b/src/postgrid/types/intl_address_verification_get_autocomplete_previews_response.py @@ -0,0 +1,52 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["IntlAddressVerificationGetAutocompletePreviewsResponse", "Data"] + + +class Data(BaseModel): + """ + A single address suggestion returned by `GET /completions`. + Use the `id` field to retrieve the full address via `POST /completions`. + """ + + id: Optional[str] = None + """The unique identifier for this result. + + Pass this to `POST /completions` to retrieve the full address. If the `type` is + `Container`, pass it as the `container` parameter to `GET /completions` to drill + down further. + """ + + description: Optional[str] = None + """A secondary description of the result (e.g. city and country).""" + + error: Optional[str] = None + """An error message if the lookup failed for this result.""" + + highlight: Optional[str] = None + """Character ranges within `text` that match the search input, for bolding in UI.""" + + text: Optional[str] = None + """The human-readable address suggestion text.""" + + type: Optional[str] = None + """The type of result. + + `Address` means this can be resolved directly via `POST /completions`. + `Container` means the result represents a building or complex — perform another + `GET /completions` with this `id` as `container` to get individual unit + addresses. + """ + + +class IntlAddressVerificationGetAutocompletePreviewsResponse(BaseModel): + data: List[Data] + + message: str + + status: Literal["success", "error"] diff --git a/src/postgrid/types/print_mail/campaign.py b/src/postgrid/types/print_mail/campaign.py index 6d3cf92..aa84dd2 100644 --- a/src/postgrid/types/print_mail/campaign.py +++ b/src/postgrid/types/print_mail/campaign.py @@ -7,8 +7,103 @@ from pydantic import Field as FieldInfo from ..._models import BaseModel +from .cheque_size import ChequeSize +from .letter_size import LetterSize +from .attached_pdf import AttachedPdf +from .address_placement import AddressPlacement -__all__ = ["Campaign", "Error"] +__all__ = ["Campaign", "Cheque", "ChequeLetterSettings", "Error", "Letter", "Postcard", "SelfMailer", "SnapPack"] + + +class ChequeLetterSettings(BaseModel): + """Settings for the attached letter (e.g., color printing).""" + + color: Optional[bool] = None + """Whether to print the attached letter in color.""" + + +class Cheque(BaseModel): + """Inline cheque configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during drafting. + """ + + bank_account: Optional[str] = FieldInfo(alias="bankAccount", default=None) + """ID of the bank account to use for the cheque.""" + + currency_code: Optional[Literal["CAD", "USD"]] = FieldInfo(alias="currencyCode", default=None) + """Enum representing the supported currency codes.""" + + description: Optional[str] = None + """An optional description.""" + + envelope: Optional[str] = None + """The custom envelope ID or `"standard"`.""" + + letter_settings: Optional[ChequeLetterSettings] = FieldInfo(alias="letterSettings", default=None) + """Settings for the attached letter (e.g., color printing).""" + + letter_template: Optional[str] = FieldInfo(alias="letterTemplate", default=None) + """ID of a template for an optional attached letter. + + Cannot be used with `letterPDF`. + """ + + letter_uploaded_pdf: Optional[str] = FieldInfo(alias="letterUploadedPDF", default=None) + """A signed URL to the attached letter PDF, if any.""" + + logo: Optional[str] = None + """A publicly accessible URL for the logo to print on the cheque.""" + + mailing_class: Optional[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] + ] = FieldInfo(alias="mailingClass", default=None) + """Mailing class for the cheque.""" + + memo: Optional[str] = None + """Memo line text for the cheque.""" + + merge_variables: Optional[Dict[str, object]] = FieldInfo(alias="mergeVariables", default=None) + """Default merge variables for the cheque.""" + + message: Optional[str] = None + """Message included on the cheque stub.""" + + metadata: Optional[Dict[str, str]] = None + """Optional key-value metadata.""" + + return_envelope: Optional[str] = FieldInfo(alias="returnEnvelope", default=None) + """ID of a return envelope to include.""" + + size: Optional[ChequeSize] = None + """Enum representing the supported cheque sizes.""" class Error(BaseModel): @@ -21,6 +116,273 @@ class Error(BaseModel): """Type of error encountered during campaign processing.""" +class Letter(BaseModel): + """Inline letter configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during drafting. + """ + + address_placement: Optional[AddressPlacement] = FieldInfo(alias="addressPlacement", default=None) + """Enum representing the placement of the address on the letter.""" + + attached_pdf: Optional[AttachedPdf] = FieldInfo(alias="attachedPDF", default=None) + """Model representing an attached PDF.""" + + color: Optional[bool] = None + """Whether to print in color.""" + + description: Optional[str] = None + """An optional description.""" + + double_sided: Optional[bool] = FieldInfo(alias="doubleSided", default=None) + """Whether to print on both sides of the paper.""" + + envelope: Optional[str] = None + """The custom envelope ID or `"standard"`.""" + + envelope_type: Optional[Literal["standard_double_window", "flat"]] = FieldInfo(alias="envelopeType", default=None) + """The type of envelope used for the letter.""" + + mailing_class: Optional[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] + ] = FieldInfo(alias="mailingClass", default=None) + """Mailing class for the letter.""" + + merge_variables: Optional[Dict[str, object]] = FieldInfo(alias="mergeVariables", default=None) + """Default merge variables for the letter.""" + + metadata: Optional[Dict[str, str]] = None + """Optional key-value metadata.""" + + perforated_page: Optional[Literal[1]] = FieldInfo(alias="perforatedPage", default=None) + """Which page number should be perforated (if any).""" + + return_envelope: Optional[str] = FieldInfo(alias="returnEnvelope", default=None) + """ID of a return envelope to include.""" + + size: Optional[LetterSize] = None + """Enum representing the supported letter sizes.""" + + template: Optional[str] = None + """ID of a template for the letter content. Cannot be used with `pdf`.""" + + uploaded_pdf: Optional[str] = FieldInfo(alias="uploadedPDF", default=None) + """A signed URL to the uploaded PDF, if any.""" + + +class Postcard(BaseModel): + """Inline postcard configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during drafting. + """ + + back_template: Optional[str] = FieldInfo(alias="backTemplate", default=None) + """ID of the template for the back side. Cannot be used with `pdf`.""" + + description: Optional[str] = None + """An optional description.""" + + front_template: Optional[str] = FieldInfo(alias="frontTemplate", default=None) + """ID of the template for the front side. Cannot be used with `pdf`.""" + + mailing_class: Optional[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] + ] = FieldInfo(alias="mailingClass", default=None) + """Mailing class for the postcard.""" + + merge_variables: Optional[Dict[str, object]] = FieldInfo(alias="mergeVariables", default=None) + """Default merge variables for the postcard.""" + + metadata: Optional[Dict[str, str]] = None + """Optional key-value metadata.""" + + paper: Optional[str] = None + """Premium paper identifier. + + Use "standard" for regular stock or a premium*paper*\\** ID. + """ + + size: Optional[Literal["6x4", "9x6", "11x6"]] = None + """Enum representing the supported postcard sizes.""" + + uploaded_pdf: Optional[str] = FieldInfo(alias="uploadedPDF", default=None) + """A signed URL to the uploaded PDF, if any.""" + + +class SelfMailer(BaseModel): + """Inline self-mailer configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during drafting. + """ + + description: Optional[str] = None + """An optional description.""" + + inside_template: Optional[str] = FieldInfo(alias="insideTemplate", default=None) + """ID of the template for the inside. Cannot be used with `pdf`.""" + + mailing_class: Optional[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] + ] = FieldInfo(alias="mailingClass", default=None) + """Mailing class for the self-mailer.""" + + merge_variables: Optional[Dict[str, object]] = FieldInfo(alias="mergeVariables", default=None) + """Default merge variables for the self-mailer.""" + + metadata: Optional[Dict[str, str]] = None + """Optional key-value metadata.""" + + outside_template: Optional[str] = FieldInfo(alias="outsideTemplate", default=None) + """ID of the template for the outside. Cannot be used with `pdf`.""" + + size: Optional[Literal["8.5x11_bifold", "8.5x11_trifold", "9.5x16_trifold"]] = None + """Enum representing the supported self-mailer sizes.""" + + uploaded_pdf: Optional[str] = FieldInfo(alias="uploadedPDF", default=None) + """A signed URL to the uploaded PDF, if any.""" + + +class SnapPack(BaseModel): + """Inline snap pack configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during drafting. + """ + + description: Optional[str] = None + """An optional description.""" + + inside_template: Optional[str] = FieldInfo(alias="insideTemplate", default=None) + """ID of the template for the inside. Cannot be used with `pdf`.""" + + mailing_class: Optional[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] + ] = FieldInfo(alias="mailingClass", default=None) + """Mailing class for the snap pack.""" + + merge_variables: Optional[Dict[str, object]] = FieldInfo(alias="mergeVariables", default=None) + """Default merge variables for the snap pack.""" + + metadata: Optional[Dict[str, str]] = None + """Optional key-value metadata.""" + + outside_template: Optional[str] = FieldInfo(alias="outsideTemplate", default=None) + """ID of the template for the outside. Cannot be used with `pdf`.""" + + size: Optional[Literal["8.5x11_bifold_v"]] = None + """Enum representing the supported snap pack sizes.""" + + uploaded_pdf: Optional[str] = FieldInfo(alias="uploadedPDF", default=None) + """A signed URL to the uploaded PDF, if any.""" + + class Campaign(BaseModel): """Represents a bulk mail campaign.""" @@ -47,8 +409,12 @@ class Campaign(BaseModel): updated_at: datetime = FieldInfo(alias="updatedAt") """The UTC time at which this resource was last updated.""" - cheque_profile: Optional[str] = FieldInfo(alias="chequeProfile", default=None) - """The ID of the cheque profile used for this campaign, if applicable.""" + cheque: Optional[Cheque] = None + """Inline cheque configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during + drafting. + """ default_sender_contact: Optional[str] = FieldInfo(alias="defaultSenderContact", default=None) """ @@ -68,8 +434,12 @@ class Campaign(BaseModel): Present when status is 'changes_required'. """ - letter_profile: Optional[str] = FieldInfo(alias="letterProfile", default=None) - """The ID of the letter profile used for this campaign, if applicable.""" + letter: Optional[Letter] = None + """Inline letter configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during + drafting. + """ metadata: Optional[Dict[str, object]] = None """See the section on Metadata.""" @@ -80,8 +450,12 @@ class Campaign(BaseModel): status is 'draft' or later. """ - postcard_profile: Optional[str] = FieldInfo(alias="postcardProfile", default=None) - """The ID of the postcard profile used for this campaign, if applicable.""" + postcard: Optional[Postcard] = None + """Inline postcard configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during + drafting. + """ report_url: Optional[str] = FieldInfo(alias="reportURL", default=None) """ @@ -89,8 +463,19 @@ class Campaign(BaseModel): is in the `ready` status. """ - self_mailer_profile: Optional[str] = FieldInfo(alias="selfMailerProfile", default=None) - """The ID of the self-mailer profile used for this campaign, if applicable.""" + self_mailer: Optional[SelfMailer] = FieldInfo(alias="selfMailer", default=None) + """Inline self-mailer configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during + drafting. + """ send_date: Optional[datetime] = FieldInfo(alias="sendDate", default=None) """The scheduled date and time for the campaign to be sent.""" + + snap_pack: Optional[SnapPack] = FieldInfo(alias="snapPack", default=None) + """Inline snap pack configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during + drafting. + """ diff --git a/src/postgrid/types/print_mail/campaign_create_params.py b/src/postgrid/types/print_mail/campaign_create_params.py index e34bfc3..50de448 100644 --- a/src/postgrid/types/print_mail/campaign_create_params.py +++ b/src/postgrid/types/print_mail/campaign_create_params.py @@ -4,19 +4,29 @@ from typing import Dict, Union from datetime import datetime -from typing_extensions import Required, Annotated, TypedDict +from typing_extensions import Literal, Required, Annotated, TypedDict +from ..._types import Base64FileInput from ..._utils import PropertyInfo +from ..._models import set_pydantic_config +from .cheque_size import ChequeSize +from .letter_size import LetterSize +from .address_placement import AddressPlacement +from .attached_pdf_param import AttachedPdfParam -__all__ = ["CampaignCreateParams"] +__all__ = ["CampaignCreateParams", "Cheque", "ChequeLetterSettings", "Letter", "Postcard", "SelfMailer", "SnapPack"] class CampaignCreateParams(TypedDict, total=False): mailing_list: Required[Annotated[str, PropertyInfo(alias="mailingList")]] """The ID of the mailing list associated with this campaign.""" - cheque_profile: Annotated[str, PropertyInfo(alias="chequeProfile")] - """The ID of the cheque profile used for this campaign, if applicable.""" + cheque: Cheque + """Inline cheque configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during + drafting. + """ default_sender_contact: Annotated[str, PropertyInfo(alias="defaultSenderContact")] """ @@ -30,19 +40,413 @@ class CampaignCreateParams(TypedDict, total=False): Will be visible in the API and the dashboard. """ - letter_profile: Annotated[str, PropertyInfo(alias="letterProfile")] - """The ID of the letter profile used for this campaign, if applicable.""" + letter: Letter + """Inline letter configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during + drafting. + """ metadata: Dict[str, object] """See the section on Metadata.""" - postcard_profile: Annotated[str, PropertyInfo(alias="postcardProfile")] - """The ID of the postcard profile used for this campaign, if applicable.""" + postcard: Postcard + """Inline postcard configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during + drafting. + """ + + self_mailer: Annotated[SelfMailer, PropertyInfo(alias="selfMailer")] + """Inline self-mailer configuration for a campaign. - self_mailer_profile: Annotated[str, PropertyInfo(alias="selfMailerProfile")] - """The ID of the self-mailer profile used for this campaign, if applicable.""" + All fields are optional since campaigns may be in a partial state during + drafting. + """ send_date: Annotated[Union[str, datetime], PropertyInfo(alias="sendDate", format="iso8601")] """The scheduled date and time for the campaign to be sent.""" + snap_pack: Annotated[SnapPack, PropertyInfo(alias="snapPack")] + """Inline snap pack configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during + drafting. + """ + idempotency_key: Annotated[str, PropertyInfo(alias="idempotency-key")] + + +class ChequeLetterSettings(TypedDict, total=False): + """Settings for the attached letter (e.g., color printing).""" + + color: bool + """Whether to print the attached letter in color.""" + + +class Cheque(TypedDict, total=False): + """Inline cheque configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during drafting. + """ + + bank_account: Annotated[str, PropertyInfo(alias="bankAccount")] + """ID of the bank account to use for the cheque.""" + + currency_code: Annotated[Literal["CAD", "USD"], PropertyInfo(alias="currencyCode")] + """Enum representing the supported currency codes.""" + + description: str + """An optional description.""" + + envelope: str + """The custom envelope ID or `"standard"`.""" + + letter_pdf: Annotated[Union[str, Base64FileInput], PropertyInfo(alias="letterPDF", format="base64")] + """PDF file for an optional attached letter. Cannot be used with `letterTemplate`.""" + + letter_settings: Annotated[ChequeLetterSettings, PropertyInfo(alias="letterSettings")] + """Settings for the attached letter (e.g., color printing).""" + + letter_template: Annotated[str, PropertyInfo(alias="letterTemplate")] + """ID of a template for an optional attached letter. + + Cannot be used with `letterPDF`. + """ + + logo: str + """A publicly accessible URL for the logo to print on the cheque.""" + + mailing_class: Annotated[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ], + PropertyInfo(alias="mailingClass"), + ] + """Mailing class for the cheque.""" + + memo: str + """Memo line text for the cheque.""" + + merge_variables: Annotated[Dict[str, object], PropertyInfo(alias="mergeVariables")] + """Default merge variables for the cheque.""" + + message: str + """Message included on the cheque stub.""" + + metadata: Dict[str, str] + """Optional key-value metadata.""" + + return_envelope: Annotated[str, PropertyInfo(alias="returnEnvelope")] + """ID of a return envelope to include.""" + + size: ChequeSize + """Enum representing the supported cheque sizes.""" + + +set_pydantic_config(Cheque, {"arbitrary_types_allowed": True}) + + +class Letter(TypedDict, total=False): + """Inline letter configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during drafting. + """ + + address_placement: Annotated[AddressPlacement, PropertyInfo(alias="addressPlacement")] + """Enum representing the placement of the address on the letter.""" + + attached_pdf: Annotated[AttachedPdfParam, PropertyInfo(alias="attachedPDF")] + """Model representing an attached PDF.""" + + color: bool + """Whether to print in color.""" + + description: str + """An optional description.""" + + double_sided: Annotated[bool, PropertyInfo(alias="doubleSided")] + """Whether to print on both sides of the paper.""" + + envelope: str + """The custom envelope ID or `"standard"`.""" + + envelope_type: Annotated[Literal["standard_double_window", "flat"], PropertyInfo(alias="envelopeType")] + """The type of envelope used for the letter.""" + + mailing_class: Annotated[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ], + PropertyInfo(alias="mailingClass"), + ] + """Mailing class for the letter.""" + + merge_variables: Annotated[Dict[str, object], PropertyInfo(alias="mergeVariables")] + """Default merge variables for the letter.""" + + metadata: Dict[str, str] + """Optional key-value metadata.""" + + pdf: str + """A PDF file or URL for the letter content. Cannot be used with `template`.""" + + perforated_page: Annotated[Literal[1], PropertyInfo(alias="perforatedPage")] + """Which page number should be perforated (if any).""" + + return_envelope: Annotated[str, PropertyInfo(alias="returnEnvelope")] + """ID of a return envelope to include.""" + + size: LetterSize + """Enum representing the supported letter sizes.""" + + template: str + """ID of a template for the letter content. Cannot be used with `pdf`.""" + + +class Postcard(TypedDict, total=False): + """Inline postcard configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during drafting. + """ + + back_template: Annotated[str, PropertyInfo(alias="backTemplate")] + """ID of the template for the back side. Cannot be used with `pdf`.""" + + description: str + """An optional description.""" + + front_template: Annotated[str, PropertyInfo(alias="frontTemplate")] + """ID of the template for the front side. Cannot be used with `pdf`.""" + + mailing_class: Annotated[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ], + PropertyInfo(alias="mailingClass"), + ] + """Mailing class for the postcard.""" + + merge_variables: Annotated[Dict[str, object], PropertyInfo(alias="mergeVariables")] + """Default merge variables for the postcard.""" + + metadata: Dict[str, str] + """Optional key-value metadata.""" + + paper: str + """Premium paper identifier. + + Use "standard" for regular stock or a premium*paper*\\** ID. + """ + + pdf: str + """A 2-page PDF file for the postcard content (front and back). + + Cannot be used with `frontTemplate`/`backTemplate`. + """ + + size: Literal["6x4", "9x6", "11x6"] + """Enum representing the supported postcard sizes.""" + + +class SelfMailer(TypedDict, total=False): + """Inline self-mailer configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during drafting. + """ + + description: str + """An optional description.""" + + inside_template: Annotated[str, PropertyInfo(alias="insideTemplate")] + """ID of the template for the inside. Cannot be used with `pdf`.""" + + mailing_class: Annotated[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ], + PropertyInfo(alias="mailingClass"), + ] + """Mailing class for the self-mailer.""" + + merge_variables: Annotated[Dict[str, object], PropertyInfo(alias="mergeVariables")] + """Default merge variables for the self-mailer.""" + + metadata: Dict[str, str] + """Optional key-value metadata.""" + + outside_template: Annotated[str, PropertyInfo(alias="outsideTemplate")] + """ID of the template for the outside. Cannot be used with `pdf`.""" + + pdf: str + """A 2-page PDF file for the self-mailer content. + + Cannot be used with `insideTemplate`/`outsideTemplate`. + """ + + size: Literal["8.5x11_bifold", "8.5x11_trifold", "9.5x16_trifold"] + """Enum representing the supported self-mailer sizes.""" + + +class SnapPack(TypedDict, total=False): + """Inline snap pack configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during drafting. + """ + + description: str + """An optional description.""" + + inside_template: Annotated[str, PropertyInfo(alias="insideTemplate")] + """ID of the template for the inside. Cannot be used with `pdf`.""" + + mailing_class: Annotated[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ], + PropertyInfo(alias="mailingClass"), + ] + """Mailing class for the snap pack.""" + + merge_variables: Annotated[Dict[str, object], PropertyInfo(alias="mergeVariables")] + """Default merge variables for the snap pack.""" + + metadata: Dict[str, str] + """Optional key-value metadata.""" + + outside_template: Annotated[str, PropertyInfo(alias="outsideTemplate")] + """ID of the template for the outside. Cannot be used with `pdf`.""" + + pdf: str + """A 2-page PDF file for the snap pack content. + + Cannot be used with `insideTemplate`/`outsideTemplate`. + """ + + size: Literal["8.5x11_bifold_v"] + """Enum representing the supported snap pack sizes.""" diff --git a/src/postgrid/types/print_mail/campaign_update_params.py b/src/postgrid/types/print_mail/campaign_update_params.py index 829f066..406779c 100644 --- a/src/postgrid/types/print_mail/campaign_update_params.py +++ b/src/postgrid/types/print_mail/campaign_update_params.py @@ -2,19 +2,26 @@ from __future__ import annotations -from typing import Dict, Optional -from typing_extensions import Annotated, TypedDict +from typing import Dict, Union, Optional +from typing_extensions import Literal, Annotated, TypedDict +from ..._types import Base64FileInput from ..._utils import PropertyInfo +from ..._models import set_pydantic_config +from .cheque_size import ChequeSize +from .letter_size import LetterSize +from .address_placement import AddressPlacement +from .attached_pdf_param import AttachedPdfParam -__all__ = ["CampaignUpdateParams"] +__all__ = ["CampaignUpdateParams", "Cheque", "ChequeLetterSettings", "Letter", "Postcard", "SelfMailer", "SnapPack"] class CampaignUpdateParams(TypedDict, total=False): - cheque_profile: Annotated[Optional[str], PropertyInfo(alias="chequeProfile")] - """The ID of the cheque profile to use. + cheque: Optional[Cheque] + """Inline cheque configuration for a campaign. - Setting this will remove other profile types. Set to `null` to remove. + All fields are optional since campaigns may be in a partial state during + drafting. """ default_sender_contact: Annotated[Optional[str], PropertyInfo(alias="defaultSenderContact")] @@ -26,10 +33,11 @@ class CampaignUpdateParams(TypedDict, total=False): Set to `null` to remove the existing description. """ - letter_profile: Annotated[Optional[str], PropertyInfo(alias="letterProfile")] - """The ID of the letter profile to use. + letter: Optional[Letter] + """Inline letter configuration for a campaign. - Setting this will remove other profile types. Set to `null` to remove. + All fields are optional since campaigns may be in a partial state during + drafting. """ mailing_list: Annotated[str, PropertyInfo(alias="mailingList")] @@ -41,14 +49,398 @@ class CampaignUpdateParams(TypedDict, total=False): Set to `null` to remove existing metadata. """ - postcard_profile: Annotated[Optional[str], PropertyInfo(alias="postcardProfile")] - """The ID of the postcard profile to use. + postcard: Optional[Postcard] + """Inline postcard configuration for a campaign. - Setting this will remove other profile types. Set to `null` to remove. + All fields are optional since campaigns may be in a partial state during + drafting. """ - self_mailer_profile: Annotated[Optional[str], PropertyInfo(alias="selfMailerProfile")] - """The ID of the self-mailer profile to use. + self_mailer: Annotated[Optional[SelfMailer], PropertyInfo(alias="selfMailer")] + """Inline self-mailer configuration for a campaign. - Setting this will remove other profile types. Set to `null` to remove. + All fields are optional since campaigns may be in a partial state during + drafting. """ + + snap_pack: Annotated[Optional[SnapPack], PropertyInfo(alias="snapPack")] + """Inline snap pack configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during + drafting. + """ + + +class ChequeLetterSettings(TypedDict, total=False): + """Settings for the attached letter (e.g., color printing).""" + + color: bool + """Whether to print the attached letter in color.""" + + +class Cheque(TypedDict, total=False): + """Inline cheque configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during drafting. + """ + + bank_account: Annotated[str, PropertyInfo(alias="bankAccount")] + """ID of the bank account to use for the cheque.""" + + currency_code: Annotated[Literal["CAD", "USD"], PropertyInfo(alias="currencyCode")] + """Enum representing the supported currency codes.""" + + description: str + """An optional description.""" + + envelope: str + """The custom envelope ID or `"standard"`.""" + + letter_pdf: Annotated[Union[str, Base64FileInput], PropertyInfo(alias="letterPDF", format="base64")] + """PDF file for an optional attached letter. Cannot be used with `letterTemplate`.""" + + letter_settings: Annotated[ChequeLetterSettings, PropertyInfo(alias="letterSettings")] + """Settings for the attached letter (e.g., color printing).""" + + letter_template: Annotated[str, PropertyInfo(alias="letterTemplate")] + """ID of a template for an optional attached letter. + + Cannot be used with `letterPDF`. + """ + + logo: str + """A publicly accessible URL for the logo to print on the cheque.""" + + mailing_class: Annotated[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ], + PropertyInfo(alias="mailingClass"), + ] + """Mailing class for the cheque.""" + + memo: str + """Memo line text for the cheque.""" + + merge_variables: Annotated[Dict[str, object], PropertyInfo(alias="mergeVariables")] + """Default merge variables for the cheque.""" + + message: str + """Message included on the cheque stub.""" + + metadata: Dict[str, str] + """Optional key-value metadata.""" + + return_envelope: Annotated[str, PropertyInfo(alias="returnEnvelope")] + """ID of a return envelope to include.""" + + size: ChequeSize + """Enum representing the supported cheque sizes.""" + + +set_pydantic_config(Cheque, {"arbitrary_types_allowed": True}) + + +class Letter(TypedDict, total=False): + """Inline letter configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during drafting. + """ + + address_placement: Annotated[AddressPlacement, PropertyInfo(alias="addressPlacement")] + """Enum representing the placement of the address on the letter.""" + + attached_pdf: Annotated[AttachedPdfParam, PropertyInfo(alias="attachedPDF")] + """Model representing an attached PDF.""" + + color: bool + """Whether to print in color.""" + + description: str + """An optional description.""" + + double_sided: Annotated[bool, PropertyInfo(alias="doubleSided")] + """Whether to print on both sides of the paper.""" + + envelope: str + """The custom envelope ID or `"standard"`.""" + + envelope_type: Annotated[Literal["standard_double_window", "flat"], PropertyInfo(alias="envelopeType")] + """The type of envelope used for the letter.""" + + mailing_class: Annotated[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ], + PropertyInfo(alias="mailingClass"), + ] + """Mailing class for the letter.""" + + merge_variables: Annotated[Dict[str, object], PropertyInfo(alias="mergeVariables")] + """Default merge variables for the letter.""" + + metadata: Dict[str, str] + """Optional key-value metadata.""" + + pdf: str + """A PDF file or URL for the letter content. Cannot be used with `template`.""" + + perforated_page: Annotated[Literal[1], PropertyInfo(alias="perforatedPage")] + """Which page number should be perforated (if any).""" + + return_envelope: Annotated[str, PropertyInfo(alias="returnEnvelope")] + """ID of a return envelope to include.""" + + size: LetterSize + """Enum representing the supported letter sizes.""" + + template: str + """ID of a template for the letter content. Cannot be used with `pdf`.""" + + +class Postcard(TypedDict, total=False): + """Inline postcard configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during drafting. + """ + + back_template: Annotated[str, PropertyInfo(alias="backTemplate")] + """ID of the template for the back side. Cannot be used with `pdf`.""" + + description: str + """An optional description.""" + + front_template: Annotated[str, PropertyInfo(alias="frontTemplate")] + """ID of the template for the front side. Cannot be used with `pdf`.""" + + mailing_class: Annotated[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ], + PropertyInfo(alias="mailingClass"), + ] + """Mailing class for the postcard.""" + + merge_variables: Annotated[Dict[str, object], PropertyInfo(alias="mergeVariables")] + """Default merge variables for the postcard.""" + + metadata: Dict[str, str] + """Optional key-value metadata.""" + + paper: str + """Premium paper identifier. + + Use "standard" for regular stock or a premium*paper*\\** ID. + """ + + pdf: str + """A 2-page PDF file for the postcard content (front and back). + + Cannot be used with `frontTemplate`/`backTemplate`. + """ + + size: Literal["6x4", "9x6", "11x6"] + """Enum representing the supported postcard sizes.""" + + +class SelfMailer(TypedDict, total=False): + """Inline self-mailer configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during drafting. + """ + + description: str + """An optional description.""" + + inside_template: Annotated[str, PropertyInfo(alias="insideTemplate")] + """ID of the template for the inside. Cannot be used with `pdf`.""" + + mailing_class: Annotated[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ], + PropertyInfo(alias="mailingClass"), + ] + """Mailing class for the self-mailer.""" + + merge_variables: Annotated[Dict[str, object], PropertyInfo(alias="mergeVariables")] + """Default merge variables for the self-mailer.""" + + metadata: Dict[str, str] + """Optional key-value metadata.""" + + outside_template: Annotated[str, PropertyInfo(alias="outsideTemplate")] + """ID of the template for the outside. Cannot be used with `pdf`.""" + + pdf: str + """A 2-page PDF file for the self-mailer content. + + Cannot be used with `insideTemplate`/`outsideTemplate`. + """ + + size: Literal["8.5x11_bifold", "8.5x11_trifold", "9.5x16_trifold"] + """Enum representing the supported self-mailer sizes.""" + + +class SnapPack(TypedDict, total=False): + """Inline snap pack configuration for a campaign. + + All fields are optional since campaigns may be in a partial state during drafting. + """ + + description: str + """An optional description.""" + + inside_template: Annotated[str, PropertyInfo(alias="insideTemplate")] + """ID of the template for the inside. Cannot be used with `pdf`.""" + + mailing_class: Annotated[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ], + PropertyInfo(alias="mailingClass"), + ] + """Mailing class for the snap pack.""" + + merge_variables: Annotated[Dict[str, object], PropertyInfo(alias="mergeVariables")] + """Default merge variables for the snap pack.""" + + metadata: Dict[str, str] + """Optional key-value metadata.""" + + outside_template: Annotated[str, PropertyInfo(alias="outsideTemplate")] + """ID of the template for the outside. Cannot be used with `pdf`.""" + + pdf: str + """A 2-page PDF file for the snap pack content. + + Cannot be used with `insideTemplate`/`outsideTemplate`. + """ + + size: Literal["8.5x11_bifold_v"] + """Enum representing the supported snap pack sizes.""" diff --git a/src/postgrid/types/print_mail/order_profiles/__init__.py b/src/postgrid/types/print_mail/order_profiles/__init__.py deleted file mode 100644 index afd8d01..0000000 --- a/src/postgrid/types/print_mail/order_profiles/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from .currency_code import CurrencyCode as CurrencyCode -from .postcard_size import PostcardSize as PostcardSize -from .cheque_profile import ChequeProfile as ChequeProfile -from .letter_profile import LetterProfile as LetterProfile -from .postcard_profile import PostcardProfile as PostcardProfile -from .self_mailer_size import SelfMailerSize as SelfMailerSize -from .cheque_list_params import ChequeListParams as ChequeListParams -from .letter_list_params import LetterListParams as LetterListParams -from .self_mailer_profile import SelfMailerProfile as SelfMailerProfile -from .cheque_create_params import ChequeCreateParams as ChequeCreateParams -from .cheque_list_response import ChequeListResponse as ChequeListResponse -from .cheque_update_params import ChequeUpdateParams as ChequeUpdateParams -from .letter_create_params import LetterCreateParams as LetterCreateParams -from .letter_update_params import LetterUpdateParams as LetterUpdateParams -from .postcard_list_params import PostcardListParams as PostcardListParams -from .cheque_delete_response import ChequeDeleteResponse as ChequeDeleteResponse -from .cheque_retrieve_params import ChequeRetrieveParams as ChequeRetrieveParams -from .letter_delete_response import LetterDeleteResponse as LetterDeleteResponse -from .letter_retrieve_params import LetterRetrieveParams as LetterRetrieveParams -from .postcard_create_params import PostcardCreateParams as PostcardCreateParams -from .postcard_update_params import PostcardUpdateParams as PostcardUpdateParams -from .self_mailer_list_params import SelfMailerListParams as SelfMailerListParams -from .postcard_delete_response import PostcardDeleteResponse as PostcardDeleteResponse -from .postcard_retrieve_params import PostcardRetrieveParams as PostcardRetrieveParams -from .self_mailer_create_params import SelfMailerCreateParams as SelfMailerCreateParams -from .self_mailer_update_params import SelfMailerUpdateParams as SelfMailerUpdateParams -from .self_mailer_delete_response import SelfMailerDeleteResponse as SelfMailerDeleteResponse -from .self_mailer_retrieve_params import SelfMailerRetrieveParams as SelfMailerRetrieveParams diff --git a/src/postgrid/types/print_mail/order_profiles/cheque_create_params.py b/src/postgrid/types/print_mail/order_profiles/cheque_create_params.py deleted file mode 100644 index 294abf7..0000000 --- a/src/postgrid/types/print_mail/order_profiles/cheque_create_params.py +++ /dev/null @@ -1,97 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Dict, Union, Optional -from typing_extensions import Literal, Required, Annotated, TypedDict - -from ...._types import SequenceNotStr, Base64FileInput -from ...._utils import PropertyInfo -from ..cheque_size import ChequeSize -from .currency_code import CurrencyCode - -__all__ = ["ChequeCreateParams"] - - -class ChequeCreateParams(TypedDict, total=False): - bank_account: Required[Annotated[str, PropertyInfo(alias="bankAccount")]] - """ID of the bank account to use for the cheque. Required for creation.""" - - size: Required[ChequeSize] - """Enum representing the supported cheque sizes.""" - - expand: SequenceNotStr[str] - """Optional list of related resources to expand in the response.""" - - currency_code: Annotated[CurrencyCode, PropertyInfo(alias="currencyCode")] - """Enum representing the supported currency codes.""" - - description: Optional[str] - """An optional description for the profile. Set to `null` to remove during update.""" - - letter_pdf: Annotated[Union[str, Base64FileInput], PropertyInfo(alias="letterPDF", format="base64")] - """PDF file for an optional attached letter. - - Cannot be used with `letterHTML` or `letterTemplate`. Input only. - """ - - letter_template: Annotated[str, PropertyInfo(alias="letterTemplate")] - """ID of a template for an optional attached letter. - - Cannot be used with `letterHTML` or `letterPDF`. - """ - - logo: Optional[str] - """A publicly accessible URL for the logo to print on the cheque. - - Set to `null` to remove during update. - """ - - mailing_class: Annotated[ - Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ], - PropertyInfo(alias="mailingClass"), - ] - """Mailing class. - - Generally must be first class (or equivalent for destination country) for - cheques. - """ - - memo: Optional[str] - """Memo line text for the cheque. Set to `null` to remove during update.""" - - merge_variables: Annotated[Optional[Dict[str, object]], PropertyInfo(alias="mergeVariables")] - """Default merge variables for orders created using this profile.""" - - message: Optional[str] - """Message included on the cheque stub. Set to `null` to remove during update.""" - - metadata: Optional[Dict[str, str]] - """Optional key-value metadata.""" diff --git a/src/postgrid/types/print_mail/order_profiles/cheque_delete_response.py b/src/postgrid/types/print_mail/order_profiles/cheque_delete_response.py deleted file mode 100644 index 0b7f724..0000000 --- a/src/postgrid/types/print_mail/order_profiles/cheque_delete_response.py +++ /dev/null @@ -1,17 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing_extensions import Literal - -from ...._models import BaseModel - -__all__ = ["ChequeDeleteResponse"] - - -class ChequeDeleteResponse(BaseModel): - id: str - """Unique identifier for the order profile.""" - - deleted: Literal[True] - - object: Literal["cheque_profile"] - """Always `cheque_profile`.""" diff --git a/src/postgrid/types/print_mail/order_profiles/cheque_list_params.py b/src/postgrid/types/print_mail/order_profiles/cheque_list_params.py deleted file mode 100644 index 394ef15..0000000 --- a/src/postgrid/types/print_mail/order_profiles/cheque_list_params.py +++ /dev/null @@ -1,22 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import TypedDict - -__all__ = ["ChequeListParams"] - - -class ChequeListParams(TypedDict, total=False): - limit: int - - search: str - """You can supply any string to help narrow down the list of resources. - - For example, if you pass `"New York"` (quoted), it will return resources that - have that string present somewhere in their response. Alternatively, you can - supply a structured search query. See the documentation on - `StructuredSearchQuery` for more details. - """ - - skip: int diff --git a/src/postgrid/types/print_mail/order_profiles/cheque_list_response.py b/src/postgrid/types/print_mail/order_profiles/cheque_list_response.py deleted file mode 100644 index 9da8ec1..0000000 --- a/src/postgrid/types/print_mail/order_profiles/cheque_list_response.py +++ /dev/null @@ -1,102 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import builtins -from typing import Dict, Optional -from datetime import datetime -from typing_extensions import Literal - -from pydantic import Field as FieldInfo - -from ...._models import BaseModel -from ..cheque_size import ChequeSize - -__all__ = ["ChequeListResponse"] - - -class ChequeListResponse(BaseModel): - id: str - """Unique identifier for the order profile.""" - - bank_account: str = FieldInfo(alias="bankAccount") - """ID of the bank account to use for the cheque. Required for creation.""" - - created_at: datetime = FieldInfo(alias="createdAt") - """Timestamp when the profile was created.""" - - live: bool - """Indicates if the profile is associated with the live or test environment.""" - - object: Literal["cheque_profile"] - """Always `cheque_profile`.""" - - size: ChequeSize - """Enum representing the supported cheque sizes.""" - - updated_at: datetime = FieldInfo(alias="updatedAt") - """Timestamp when the profile was last updated.""" - - description: Optional[str] = None - """An optional description for the profile. Set to `null` to remove during update.""" - - letter_template: Optional[str] = FieldInfo(alias="letterTemplate", default=None) - """ID of a template for an optional attached letter. - - Cannot be used with `letterHTML` or `letterPDF`. - """ - - letter_uploaded_pdf: Optional[str] = FieldInfo(alias="letterUploadedPDF", default=None) - """A temporary, signed URL to view the attached letter PDF, if any. Output only.""" - - logo: Optional[str] = None - """A publicly accessible URL for the logo to print on the cheque. - - Set to `null` to remove during update. - """ - - mailing_class: Optional[ - Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - ] = FieldInfo(alias="mailingClass", default=None) - """Mailing class. - - Generally must be first class (or equivalent for destination country) for - cheques. - """ - - memo: Optional[str] = None - """Memo line text for the cheque. Set to `null` to remove during update.""" - - merge_variables: Optional[Dict[str, builtins.object]] = FieldInfo(alias="mergeVariables", default=None) - """Default merge variables for orders created using this profile.""" - - message: Optional[str] = None - """Message included on the cheque stub. Set to `null` to remove during update.""" - - metadata: Optional[Dict[str, str]] = None - """Optional key-value metadata.""" diff --git a/src/postgrid/types/print_mail/order_profiles/cheque_profile.py b/src/postgrid/types/print_mail/order_profiles/cheque_profile.py deleted file mode 100644 index b354056..0000000 --- a/src/postgrid/types/print_mail/order_profiles/cheque_profile.py +++ /dev/null @@ -1,106 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import builtins -from typing import Dict, Optional -from datetime import datetime -from typing_extensions import Literal - -from pydantic import Field as FieldInfo - -from ...._models import BaseModel -from ..cheque_size import ChequeSize -from .currency_code import CurrencyCode - -__all__ = ["ChequeProfile"] - - -class ChequeProfile(BaseModel): - id: str - """Unique identifier for the order profile.""" - - bank_account: str = FieldInfo(alias="bankAccount") - """ID of the bank account to use for the cheque. Required for creation.""" - - created_at: datetime = FieldInfo(alias="createdAt") - """Timestamp when the profile was created.""" - - currency_code: CurrencyCode = FieldInfo(alias="currencyCode") - """Enum representing the supported currency codes.""" - - live: bool - """Indicates if the profile is associated with the live or test environment.""" - - object: Literal["cheque_profile"] - """Always `cheque_profile`.""" - - size: ChequeSize - """Enum representing the supported cheque sizes.""" - - updated_at: datetime = FieldInfo(alias="updatedAt") - """Timestamp when the profile was last updated.""" - - description: Optional[str] = None - """An optional description for the profile. Set to `null` to remove during update.""" - - letter_template: Optional[str] = FieldInfo(alias="letterTemplate", default=None) - """ID of a template for an optional attached letter. - - Cannot be used with `letterHTML` or `letterPDF`. - """ - - letter_uploaded_pdf: Optional[str] = FieldInfo(alias="letterUploadedPDF", default=None) - """A temporary, signed URL to view the attached letter PDF, if any. Output only.""" - - logo: Optional[str] = None - """A publicly accessible URL for the logo to print on the cheque. - - Set to `null` to remove during update. - """ - - mailing_class: Optional[ - Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - ] = FieldInfo(alias="mailingClass", default=None) - """Mailing class. - - Generally must be first class (or equivalent for destination country) for - cheques. - """ - - memo: Optional[str] = None - """Memo line text for the cheque. Set to `null` to remove during update.""" - - merge_variables: Optional[Dict[str, builtins.object]] = FieldInfo(alias="mergeVariables", default=None) - """Default merge variables for orders created using this profile.""" - - message: Optional[str] = None - """Message included on the cheque stub. Set to `null` to remove during update.""" - - metadata: Optional[Dict[str, str]] = None - """Optional key-value metadata.""" diff --git a/src/postgrid/types/print_mail/order_profiles/cheque_retrieve_params.py b/src/postgrid/types/print_mail/order_profiles/cheque_retrieve_params.py deleted file mode 100644 index d877634..0000000 --- a/src/postgrid/types/print_mail/order_profiles/cheque_retrieve_params.py +++ /dev/null @@ -1,14 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import TypedDict - -from ...._types import SequenceNotStr - -__all__ = ["ChequeRetrieveParams"] - - -class ChequeRetrieveParams(TypedDict, total=False): - expand: SequenceNotStr[str] - """Optional list of related resources to expand in the response.""" diff --git a/src/postgrid/types/print_mail/order_profiles/cheque_update_params.py b/src/postgrid/types/print_mail/order_profiles/cheque_update_params.py deleted file mode 100644 index 8c3aeaf..0000000 --- a/src/postgrid/types/print_mail/order_profiles/cheque_update_params.py +++ /dev/null @@ -1,97 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Dict, Union, Optional -from typing_extensions import Literal, Required, Annotated, TypedDict - -from ...._types import SequenceNotStr, Base64FileInput -from ...._utils import PropertyInfo -from ..cheque_size import ChequeSize -from .currency_code import CurrencyCode - -__all__ = ["ChequeUpdateParams"] - - -class ChequeUpdateParams(TypedDict, total=False): - bank_account: Required[Annotated[str, PropertyInfo(alias="bankAccount")]] - """ID of the bank account to use for the cheque. Required for creation.""" - - size: Required[ChequeSize] - """Enum representing the supported cheque sizes.""" - - expand: SequenceNotStr[str] - """Optional list of related resources to expand in the response.""" - - currency_code: Annotated[CurrencyCode, PropertyInfo(alias="currencyCode")] - """Enum representing the supported currency codes.""" - - description: Optional[str] - """An optional description for the profile. Set to `null` to remove during update.""" - - letter_pdf: Annotated[Union[str, Base64FileInput], PropertyInfo(alias="letterPDF", format="base64")] - """PDF file for an optional attached letter. - - Cannot be used with `letterHTML` or `letterTemplate`. Input only. - """ - - letter_template: Annotated[str, PropertyInfo(alias="letterTemplate")] - """ID of a template for an optional attached letter. - - Cannot be used with `letterHTML` or `letterPDF`. - """ - - logo: Optional[str] - """A publicly accessible URL for the logo to print on the cheque. - - Set to `null` to remove during update. - """ - - mailing_class: Annotated[ - Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ], - PropertyInfo(alias="mailingClass"), - ] - """Mailing class. - - Generally must be first class (or equivalent for destination country) for - cheques. - """ - - memo: Optional[str] - """Memo line text for the cheque. Set to `null` to remove during update.""" - - merge_variables: Annotated[Optional[Dict[str, object]], PropertyInfo(alias="mergeVariables")] - """Default merge variables for orders created using this profile.""" - - message: Optional[str] - """Message included on the cheque stub. Set to `null` to remove during update.""" - - metadata: Optional[Dict[str, str]] - """Optional key-value metadata.""" diff --git a/src/postgrid/types/print_mail/order_profiles/currency_code.py b/src/postgrid/types/print_mail/order_profiles/currency_code.py deleted file mode 100644 index 56b2a59..0000000 --- a/src/postgrid/types/print_mail/order_profiles/currency_code.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing_extensions import Literal, TypeAlias - -__all__ = ["CurrencyCode"] - -CurrencyCode: TypeAlias = Literal["CAD", "USD"] diff --git a/src/postgrid/types/print_mail/order_profiles/letter_create_params.py b/src/postgrid/types/print_mail/order_profiles/letter_create_params.py deleted file mode 100644 index 0ccffab..0000000 --- a/src/postgrid/types/print_mail/order_profiles/letter_create_params.py +++ /dev/null @@ -1,91 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Dict, Optional -from typing_extensions import Literal, Required, Annotated, TypedDict - -from ...._types import SequenceNotStr -from ...._utils import PropertyInfo -from ..letter_size import LetterSize -from ..address_placement import AddressPlacement -from ..attached_pdf_param import AttachedPdfParam - -__all__ = ["LetterCreateParams"] - - -class LetterCreateParams(TypedDict, total=False): - size: Required[LetterSize] - """Enum representing the supported letter sizes.""" - - expand: SequenceNotStr[str] - """Optional list of related resources to expand in the response.""" - - address_placement: Annotated[AddressPlacement, PropertyInfo(alias="addressPlacement")] - """Enum representing the placement of the address on the letter.""" - - attached_pdf: Annotated[AttachedPdfParam, PropertyInfo(alias="attachedPDF")] - """Model representing an attached PDF.""" - - color: bool - """Specifies whether to print in color (true) or black and white (false).""" - - description: Optional[str] - """An optional description for the profile. Set to `null` to remove during update.""" - - double_sided: Annotated[bool, PropertyInfo(alias="doubleSided")] - """Specifies whether to print on both sides of the paper.""" - - envelope: str - """ID of a custom envelope to use.""" - - mailing_class: Annotated[ - Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ], - PropertyInfo(alias="mailingClass"), - ] - """Mailing class.""" - - merge_variables: Annotated[Optional[Dict[str, object]], PropertyInfo(alias="mergeVariables")] - """Default merge variables for orders created using this profile.""" - - metadata: Optional[Dict[str, str]] - """Optional key-value metadata.""" - - pdf: str - """A PDF file containing the letter content. Cannot be used with `template`.""" - - perforated_page: Annotated[Literal[1], PropertyInfo(alias="perforatedPage")] - """Specifies which page number should be perforated (if any).""" - - return_envelope: Annotated[str, PropertyInfo(alias="returnEnvelope")] - """ID of a return envelope to include.""" - - template: str - """ID of a template to use for the letter content. Cannot be used with `pdf`.""" diff --git a/src/postgrid/types/print_mail/order_profiles/letter_delete_response.py b/src/postgrid/types/print_mail/order_profiles/letter_delete_response.py deleted file mode 100644 index d62d8b3..0000000 --- a/src/postgrid/types/print_mail/order_profiles/letter_delete_response.py +++ /dev/null @@ -1,17 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing_extensions import Literal - -from ...._models import BaseModel - -__all__ = ["LetterDeleteResponse"] - - -class LetterDeleteResponse(BaseModel): - id: str - """Unique identifier for the order profile.""" - - deleted: Literal[True] - - object: Literal["letter_profile"] - """Always `letter_profile`.""" diff --git a/src/postgrid/types/print_mail/order_profiles/letter_list_params.py b/src/postgrid/types/print_mail/order_profiles/letter_list_params.py deleted file mode 100644 index 38fcb03..0000000 --- a/src/postgrid/types/print_mail/order_profiles/letter_list_params.py +++ /dev/null @@ -1,22 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import TypedDict - -__all__ = ["LetterListParams"] - - -class LetterListParams(TypedDict, total=False): - limit: int - - search: str - """You can supply any string to help narrow down the list of resources. - - For example, if you pass `"New York"` (quoted), it will return resources that - have that string present somewhere in their response. Alternatively, you can - supply a structured search query. See the documentation on - `StructuredSearchQuery` for more details. - """ - - skip: int diff --git a/src/postgrid/types/print_mail/order_profiles/letter_profile.py b/src/postgrid/types/print_mail/order_profiles/letter_profile.py deleted file mode 100644 index fd9d80e..0000000 --- a/src/postgrid/types/print_mail/order_profiles/letter_profile.py +++ /dev/null @@ -1,100 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import builtins -from typing import Dict, Optional -from datetime import datetime -from typing_extensions import Literal - -from pydantic import Field as FieldInfo - -from ...._models import BaseModel -from ..letter_size import LetterSize -from ..attached_pdf import AttachedPdf -from ..address_placement import AddressPlacement - -__all__ = ["LetterProfile"] - - -class LetterProfile(BaseModel): - id: str - """Unique identifier for the order profile.""" - - created_at: datetime = FieldInfo(alias="createdAt") - """Timestamp when the profile was created.""" - - live: bool - """Indicates if the profile is associated with the live or test environment.""" - - object: Literal["letter_profile"] - """Always `letter_profile`.""" - - size: LetterSize - """Enum representing the supported letter sizes.""" - - updated_at: datetime = FieldInfo(alias="updatedAt") - """Timestamp when the profile was last updated.""" - - address_placement: Optional[AddressPlacement] = FieldInfo(alias="addressPlacement", default=None) - """Enum representing the placement of the address on the letter.""" - - attached_pdf: Optional[AttachedPdf] = FieldInfo(alias="attachedPDF", default=None) - """Model representing an attached PDF.""" - - color: Optional[bool] = None - """Specifies whether to print in color (true) or black and white (false).""" - - description: Optional[str] = None - """An optional description for the profile. Set to `null` to remove during update.""" - - double_sided: Optional[bool] = FieldInfo(alias="doubleSided", default=None) - """Specifies whether to print on both sides of the paper.""" - - envelope: Optional[str] = None - """ID of a custom envelope to use.""" - - mailing_class: Optional[ - Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - ] = FieldInfo(alias="mailingClass", default=None) - """Mailing class.""" - - merge_variables: Optional[Dict[str, builtins.object]] = FieldInfo(alias="mergeVariables", default=None) - """Default merge variables for orders created using this profile.""" - - metadata: Optional[Dict[str, str]] = None - """Optional key-value metadata.""" - - perforated_page: Optional[Literal[1]] = FieldInfo(alias="perforatedPage", default=None) - """Specifies which page number should be perforated (if any).""" - - template: Optional[str] = None - """ID of a template to use for the letter content. Cannot be used with `pdf`.""" - - uploaded_pdf: Optional[str] = FieldInfo(alias="uploadedPDF", default=None) - """A temporary, signed URL to view the uploaded PDF, if any.""" diff --git a/src/postgrid/types/print_mail/order_profiles/letter_retrieve_params.py b/src/postgrid/types/print_mail/order_profiles/letter_retrieve_params.py deleted file mode 100644 index b972d23..0000000 --- a/src/postgrid/types/print_mail/order_profiles/letter_retrieve_params.py +++ /dev/null @@ -1,14 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import TypedDict - -from ...._types import SequenceNotStr - -__all__ = ["LetterRetrieveParams"] - - -class LetterRetrieveParams(TypedDict, total=False): - expand: SequenceNotStr[str] - """Optional list of related resources to expand in the response.""" diff --git a/src/postgrid/types/print_mail/order_profiles/letter_update_params.py b/src/postgrid/types/print_mail/order_profiles/letter_update_params.py deleted file mode 100644 index 84eb61c..0000000 --- a/src/postgrid/types/print_mail/order_profiles/letter_update_params.py +++ /dev/null @@ -1,87 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Dict, Optional -from typing_extensions import Literal, Annotated, TypedDict - -from ...._types import SequenceNotStr -from ...._utils import PropertyInfo -from ..address_placement import AddressPlacement -from ..attached_pdf_param import AttachedPdfParam - -__all__ = ["LetterUpdateParams"] - - -class LetterUpdateParams(TypedDict, total=False): - expand: SequenceNotStr[str] - """Optional list of related resources to expand in the response.""" - - address_placement: Annotated[AddressPlacement, PropertyInfo(alias="addressPlacement")] - """Enum representing the placement of the address on the letter.""" - - attached_pdf: Annotated[AttachedPdfParam, PropertyInfo(alias="attachedPDF")] - """Model representing an attached PDF.""" - - color: bool - """Specifies whether to print in color (true) or black and white (false).""" - - description: Optional[str] - """An optional description for the profile. Set to `null` to remove during update.""" - - double_sided: Annotated[bool, PropertyInfo(alias="doubleSided")] - """Specifies whether to print on both sides of the paper.""" - - envelope: str - """ID of a custom envelope to use.""" - - mailing_class: Annotated[ - Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ], - PropertyInfo(alias="mailingClass"), - ] - """Mailing class.""" - - merge_variables: Annotated[Optional[Dict[str, object]], PropertyInfo(alias="mergeVariables")] - """Default merge variables for orders created using this profile.""" - - metadata: Optional[Dict[str, str]] - """Optional key-value metadata.""" - - pdf: str - """A PDF file containing the letter content. Cannot be used with `template`.""" - - perforated_page: Annotated[Literal[1], PropertyInfo(alias="perforatedPage")] - """Specifies which page number should be perforated (if any).""" - - return_envelope: Annotated[str, PropertyInfo(alias="returnEnvelope")] - """ID of a return envelope to include.""" - - template: str - """ID of a template to use for the letter content. Cannot be used with `pdf`.""" diff --git a/src/postgrid/types/print_mail/order_profiles/postcard_create_params.py b/src/postgrid/types/print_mail/order_profiles/postcard_create_params.py deleted file mode 100644 index 37359d0..0000000 --- a/src/postgrid/types/print_mail/order_profiles/postcard_create_params.py +++ /dev/null @@ -1,77 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Dict, Optional -from typing_extensions import Literal, Required, Annotated, TypedDict - -from ...._types import SequenceNotStr -from ...._utils import PropertyInfo -from .postcard_size import PostcardSize - -__all__ = ["PostcardCreateParams"] - - -class PostcardCreateParams(TypedDict, total=False): - size: Required[PostcardSize] - """Enum representing the supported postcard sizes.""" - - expand: SequenceNotStr[str] - """Optional list of related resources to expand in the response.""" - - back_template: Annotated[str, PropertyInfo(alias="backTemplate")] - """ID of the template for the back side. Required unless `pdf` is provided.""" - - description: Optional[str] - """An optional description for the profile. Set to `null` to remove during update.""" - - front_template: Annotated[str, PropertyInfo(alias="frontTemplate")] - """ID of the template for the front side. Required unless `pdf` is provided.""" - - mailing_class: Annotated[ - Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ], - PropertyInfo(alias="mailingClass"), - ] - """ - Mailing class (cannot include extra services like `certified` or `registered` - for postcards, though). - """ - - merge_variables: Annotated[Optional[Dict[str, object]], PropertyInfo(alias="mergeVariables")] - """Default merge variables for orders created using this profile.""" - - metadata: Optional[Dict[str, str]] - """Optional key-value metadata.""" - - pdf: str - """A 2-page PDF file containing the postcard content (front and back). - - Cannot be used with `frontTemplate`/`backTemplate`. - """ diff --git a/src/postgrid/types/print_mail/order_profiles/postcard_delete_response.py b/src/postgrid/types/print_mail/order_profiles/postcard_delete_response.py deleted file mode 100644 index 42d9932..0000000 --- a/src/postgrid/types/print_mail/order_profiles/postcard_delete_response.py +++ /dev/null @@ -1,17 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing_extensions import Literal - -from ...._models import BaseModel - -__all__ = ["PostcardDeleteResponse"] - - -class PostcardDeleteResponse(BaseModel): - id: str - """Unique identifier for the order profile.""" - - deleted: Literal[True] - - object: Literal["postcard_profile"] - """Always `postcard_profile`.""" diff --git a/src/postgrid/types/print_mail/order_profiles/postcard_list_params.py b/src/postgrid/types/print_mail/order_profiles/postcard_list_params.py deleted file mode 100644 index 03b3e16..0000000 --- a/src/postgrid/types/print_mail/order_profiles/postcard_list_params.py +++ /dev/null @@ -1,22 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import TypedDict - -__all__ = ["PostcardListParams"] - - -class PostcardListParams(TypedDict, total=False): - limit: int - - search: str - """You can supply any string to help narrow down the list of resources. - - For example, if you pass `"New York"` (quoted), it will return resources that - have that string present somewhere in their response. Alternatively, you can - supply a structured search query. See the documentation on - `StructuredSearchQuery` for more details. - """ - - skip: int diff --git a/src/postgrid/types/print_mail/order_profiles/postcard_profile.py b/src/postgrid/types/print_mail/order_profiles/postcard_profile.py deleted file mode 100644 index 9c25e57..0000000 --- a/src/postgrid/types/print_mail/order_profiles/postcard_profile.py +++ /dev/null @@ -1,86 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import builtins -from typing import Dict, Optional -from datetime import datetime -from typing_extensions import Literal - -from pydantic import Field as FieldInfo - -from ...._models import BaseModel -from .postcard_size import PostcardSize - -__all__ = ["PostcardProfile"] - - -class PostcardProfile(BaseModel): - id: str - """Unique identifier for the order profile.""" - - created_at: datetime = FieldInfo(alias="createdAt") - """Timestamp when the profile was created.""" - - live: bool - """Indicates if the profile is associated with the live or test environment.""" - - object: Literal["postcard_profile"] - """Always `postcard_profile`.""" - - size: PostcardSize - """Enum representing the supported postcard sizes.""" - - updated_at: datetime = FieldInfo(alias="updatedAt") - """Timestamp when the profile was last updated.""" - - back_template: Optional[str] = FieldInfo(alias="backTemplate", default=None) - """ID of the template for the back side. Required unless `pdf` is provided.""" - - description: Optional[str] = None - """An optional description for the profile. Set to `null` to remove during update.""" - - front_template: Optional[str] = FieldInfo(alias="frontTemplate", default=None) - """ID of the template for the front side. Required unless `pdf` is provided.""" - - mailing_class: Optional[ - Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - ] = FieldInfo(alias="mailingClass", default=None) - """ - Mailing class (cannot include extra services like `certified` or `registered` - for postcards, though). - """ - - merge_variables: Optional[Dict[str, builtins.object]] = FieldInfo(alias="mergeVariables", default=None) - """Default merge variables for orders created using this profile.""" - - metadata: Optional[Dict[str, str]] = None - """Optional key-value metadata.""" - - uploaded_pdf: Optional[str] = FieldInfo(alias="uploadedPDF", default=None) - """A temporary, signed URL to view the uploaded PDF content, if any.""" diff --git a/src/postgrid/types/print_mail/order_profiles/postcard_retrieve_params.py b/src/postgrid/types/print_mail/order_profiles/postcard_retrieve_params.py deleted file mode 100644 index fd63330..0000000 --- a/src/postgrid/types/print_mail/order_profiles/postcard_retrieve_params.py +++ /dev/null @@ -1,14 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import TypedDict - -from ...._types import SequenceNotStr - -__all__ = ["PostcardRetrieveParams"] - - -class PostcardRetrieveParams(TypedDict, total=False): - expand: SequenceNotStr[str] - """Optional list of related resources to expand in the response.""" diff --git a/src/postgrid/types/print_mail/order_profiles/postcard_size.py b/src/postgrid/types/print_mail/order_profiles/postcard_size.py deleted file mode 100644 index e059962..0000000 --- a/src/postgrid/types/print_mail/order_profiles/postcard_size.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing_extensions import Literal, TypeAlias - -__all__ = ["PostcardSize"] - -PostcardSize: TypeAlias = Literal["6x4", "9x6", "11x6"] diff --git a/src/postgrid/types/print_mail/order_profiles/postcard_update_params.py b/src/postgrid/types/print_mail/order_profiles/postcard_update_params.py deleted file mode 100644 index cf58687..0000000 --- a/src/postgrid/types/print_mail/order_profiles/postcard_update_params.py +++ /dev/null @@ -1,73 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Dict, Optional -from typing_extensions import Literal, Annotated, TypedDict - -from ...._types import SequenceNotStr -from ...._utils import PropertyInfo - -__all__ = ["PostcardUpdateParams"] - - -class PostcardUpdateParams(TypedDict, total=False): - expand: SequenceNotStr[str] - """Optional list of related resources to expand in the response.""" - - back_template: Annotated[str, PropertyInfo(alias="backTemplate")] - """ID of the template for the back side. Required unless `pdf` is provided.""" - - description: Optional[str] - """An optional description for the profile. Set to `null` to remove during update.""" - - front_template: Annotated[str, PropertyInfo(alias="frontTemplate")] - """ID of the template for the front side. Required unless `pdf` is provided.""" - - mailing_class: Annotated[ - Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ], - PropertyInfo(alias="mailingClass"), - ] - """ - Mailing class (cannot include extra services like `certified` or `registered` - for postcards, though). - """ - - merge_variables: Annotated[Optional[Dict[str, object]], PropertyInfo(alias="mergeVariables")] - """Default merge variables for orders created using this profile.""" - - metadata: Optional[Dict[str, str]] - """Optional key-value metadata.""" - - pdf: str - """A 2-page PDF file containing the postcard content (front and back). - - Cannot be used with `frontTemplate`/`backTemplate`. - """ diff --git a/src/postgrid/types/print_mail/order_profiles/self_mailer_create_params.py b/src/postgrid/types/print_mail/order_profiles/self_mailer_create_params.py deleted file mode 100644 index 37984be..0000000 --- a/src/postgrid/types/print_mail/order_profiles/self_mailer_create_params.py +++ /dev/null @@ -1,74 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Dict, Optional -from typing_extensions import Literal, Required, Annotated, TypedDict - -from ...._types import SequenceNotStr -from ...._utils import PropertyInfo -from .self_mailer_size import SelfMailerSize - -__all__ = ["SelfMailerCreateParams"] - - -class SelfMailerCreateParams(TypedDict, total=False): - size: Required[SelfMailerSize] - """Enum representing the supported self-mailer sizes.""" - - expand: SequenceNotStr[str] - """Optional list of related resources to expand in the response.""" - - description: Optional[str] - """An optional description for the profile. Set to `null` to remove during update.""" - - inside_template: Annotated[str, PropertyInfo(alias="insideTemplate")] - """ID of the template for the inside. Required unless `pdf` is provided.""" - - mailing_class: Annotated[ - Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ], - PropertyInfo(alias="mailingClass"), - ] - """Mailing class (cannot include extra services for self-mailers).""" - - merge_variables: Annotated[Optional[Dict[str, object]], PropertyInfo(alias="mergeVariables")] - """Default merge variables for orders created using this profile.""" - - metadata: Optional[Dict[str, str]] - """Optional key-value metadata.""" - - outside_template: Annotated[str, PropertyInfo(alias="outsideTemplate")] - """ID of the template for the outside. Required unless `pdf` is provided.""" - - pdf: str - """A 2-page PDF file containing the self-mailer content (inside and outside). - - Cannot be used with `insideTemplate`/`outsideTemplate`. - """ diff --git a/src/postgrid/types/print_mail/order_profiles/self_mailer_delete_response.py b/src/postgrid/types/print_mail/order_profiles/self_mailer_delete_response.py deleted file mode 100644 index 2f0b52a..0000000 --- a/src/postgrid/types/print_mail/order_profiles/self_mailer_delete_response.py +++ /dev/null @@ -1,17 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing_extensions import Literal - -from ...._models import BaseModel - -__all__ = ["SelfMailerDeleteResponse"] - - -class SelfMailerDeleteResponse(BaseModel): - id: str - """Unique identifier for the order profile.""" - - deleted: Literal[True] - - object: Literal["self_mailer_profile"] - """Always `self_mailer_profile`.""" diff --git a/src/postgrid/types/print_mail/order_profiles/self_mailer_list_params.py b/src/postgrid/types/print_mail/order_profiles/self_mailer_list_params.py deleted file mode 100644 index 8afdca9..0000000 --- a/src/postgrid/types/print_mail/order_profiles/self_mailer_list_params.py +++ /dev/null @@ -1,22 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import TypedDict - -__all__ = ["SelfMailerListParams"] - - -class SelfMailerListParams(TypedDict, total=False): - limit: int - - search: str - """You can supply any string to help narrow down the list of resources. - - For example, if you pass `"New York"` (quoted), it will return resources that - have that string present somewhere in their response. Alternatively, you can - supply a structured search query. See the documentation on - `StructuredSearchQuery` for more details. - """ - - skip: int diff --git a/src/postgrid/types/print_mail/order_profiles/self_mailer_profile.py b/src/postgrid/types/print_mail/order_profiles/self_mailer_profile.py deleted file mode 100644 index ea6810c..0000000 --- a/src/postgrid/types/print_mail/order_profiles/self_mailer_profile.py +++ /dev/null @@ -1,85 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import builtins -from typing import Dict, Optional -from datetime import datetime -from typing_extensions import Literal - -from pydantic import Field as FieldInfo - -from ...._models import BaseModel -from .self_mailer_size import SelfMailerSize - -__all__ = ["SelfMailerProfile"] - - -class SelfMailerProfile(BaseModel): - """Represents a Self-Mailer Profile resource.""" - - id: str - """Unique identifier for the order profile.""" - - created_at: datetime = FieldInfo(alias="createdAt") - """Timestamp when the profile was created.""" - - live: bool - """Indicates if the profile is associated with the live or test environment.""" - - object: Literal["self_mailer_profile"] - """Always `self_mailer_profile`.""" - - size: SelfMailerSize - """Enum representing the supported self-mailer sizes.""" - - updated_at: datetime = FieldInfo(alias="updatedAt") - """Timestamp when the profile was last updated.""" - - description: Optional[str] = None - """An optional description for the profile. Set to `null` to remove during update.""" - - inside_template: Optional[str] = FieldInfo(alias="insideTemplate", default=None) - """ID of the template for the inside. Required unless `pdf` is provided.""" - - mailing_class: Optional[ - Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ] - ] = FieldInfo(alias="mailingClass", default=None) - """Mailing class (cannot include extra services for self-mailers).""" - - merge_variables: Optional[Dict[str, builtins.object]] = FieldInfo(alias="mergeVariables", default=None) - """Default merge variables for orders created using this profile.""" - - metadata: Optional[Dict[str, str]] = None - """Optional key-value metadata.""" - - outside_template: Optional[str] = FieldInfo(alias="outsideTemplate", default=None) - """ID of the template for the outside. Required unless `pdf` is provided.""" - - uploaded_pdf: Optional[str] = FieldInfo(alias="uploadedPDF", default=None) - """A temporary, signed URL to view the uploaded PDF, if any.""" diff --git a/src/postgrid/types/print_mail/order_profiles/self_mailer_retrieve_params.py b/src/postgrid/types/print_mail/order_profiles/self_mailer_retrieve_params.py deleted file mode 100644 index 9f45b38..0000000 --- a/src/postgrid/types/print_mail/order_profiles/self_mailer_retrieve_params.py +++ /dev/null @@ -1,14 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import TypedDict - -from ...._types import SequenceNotStr - -__all__ = ["SelfMailerRetrieveParams"] - - -class SelfMailerRetrieveParams(TypedDict, total=False): - expand: SequenceNotStr[str] - """Optional list of related resources to expand in the response.""" diff --git a/src/postgrid/types/print_mail/order_profiles/self_mailer_size.py b/src/postgrid/types/print_mail/order_profiles/self_mailer_size.py deleted file mode 100644 index 99ff836..0000000 --- a/src/postgrid/types/print_mail/order_profiles/self_mailer_size.py +++ /dev/null @@ -1,7 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing_extensions import Literal, TypeAlias - -__all__ = ["SelfMailerSize"] - -SelfMailerSize: TypeAlias = Literal["8.5x11_bifold", "8.5x11_trifold", "9.5x16_trifold"] diff --git a/src/postgrid/types/print_mail/order_profiles/self_mailer_update_params.py b/src/postgrid/types/print_mail/order_profiles/self_mailer_update_params.py deleted file mode 100644 index b51045e..0000000 --- a/src/postgrid/types/print_mail/order_profiles/self_mailer_update_params.py +++ /dev/null @@ -1,74 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Dict, Optional -from typing_extensions import Literal, Required, Annotated, TypedDict - -from ...._types import SequenceNotStr -from ...._utils import PropertyInfo -from .self_mailer_size import SelfMailerSize - -__all__ = ["SelfMailerUpdateParams"] - - -class SelfMailerUpdateParams(TypedDict, total=False): - size: Required[SelfMailerSize] - """Enum representing the supported self-mailer sizes.""" - - expand: SequenceNotStr[str] - """Optional list of related resources to expand in the response.""" - - description: Optional[str] - """An optional description for the profile. Set to `null` to remove during update.""" - - inside_template: Annotated[str, PropertyInfo(alias="insideTemplate")] - """ID of the template for the inside. Required unless `pdf` is provided.""" - - mailing_class: Annotated[ - Literal[ - "first_class", - "standard_class", - "express", - "certified", - "certified_return_receipt", - "registered", - "usps_first_class", - "usps_standard_class", - "usps_eddm", - "usps_express_2_day", - "usps_express_3_day", - "usps_first_class_certified", - "usps_first_class_certified_return_receipt", - "usps_first_class_registered", - "usps_express_3_day_signature_confirmation", - "usps_express_3_day_certified", - "usps_express_3_day_certified_return_receipt", - "ca_post_lettermail", - "ca_post_personalized", - "ca_post_neighbourhood_mail", - "ups_express_overnight", - "ups_express_2_day", - "ups_express_3_day", - "royal_mail_first_class", - "royal_mail_second_class", - "au_post_second_class", - ], - PropertyInfo(alias="mailingClass"), - ] - """Mailing class (cannot include extra services for self-mailers).""" - - merge_variables: Annotated[Optional[Dict[str, object]], PropertyInfo(alias="mergeVariables")] - """Default merge variables for orders created using this profile.""" - - metadata: Optional[Dict[str, str]] - """Optional key-value metadata.""" - - outside_template: Annotated[str, PropertyInfo(alias="outsideTemplate")] - """ID of the template for the outside. Required unless `pdf` is provided.""" - - pdf: str - """A 2-page PDF file containing the self-mailer content (inside and outside). - - Cannot be used with `insideTemplate`/`outsideTemplate`. - """ diff --git a/src/postgrid/types/print_mail/postcard.py b/src/postgrid/types/print_mail/postcard.py index b624534..e692605 100644 --- a/src/postgrid/types/print_mail/postcard.py +++ b/src/postgrid/types/print_mail/postcard.py @@ -9,7 +9,6 @@ from .contact import Contact from ..._models import BaseModel -from .order_profiles.postcard_size import PostcardSize __all__ = ["Postcard", "Cancellation"] @@ -85,7 +84,7 @@ class Postcard(BaseModel): `printing` on Wednesday at midnight eastern time. """ - size: PostcardSize + size: Literal["6x4", "9x6", "11x6"] """Enum representing the supported postcard sizes.""" status: Literal["ready", "printing", "processed_for_delivery", "completed", "cancelled"] @@ -147,6 +146,12 @@ class Postcard(BaseModel): metadata: Optional[Dict[str, builtins.object]] = None """See the section on Metadata.""" + paper: Optional[str] = None + """Premium paper identifier. + + Use "standard" for regular stock or a premium*paper*\\** ID. + """ + tracking_number: Optional[str] = FieldInfo(alias="trackingNumber", default=None) """The tracking number of this order. diff --git a/src/postgrid/types/print_mail/postcard_create_params.py b/src/postgrid/types/print_mail/postcard_create_params.py index 7c8f1b9..5323a59 100644 --- a/src/postgrid/types/print_mail/postcard_create_params.py +++ b/src/postgrid/types/print_mail/postcard_create_params.py @@ -8,7 +8,6 @@ from ..._types import Base64FileInput from ..._utils import PropertyInfo -from .order_profiles.postcard_size import PostcardSize from ..contact_create_with_first_name_param import ContactCreateWithFirstNameParam from ..contact_create_with_company_name_param import ContactCreateWithCompanyNameParam @@ -40,7 +39,7 @@ class PostcardCreateWithHTML(TypedDict, total=False): You can supply _either_ this or `frontTemplate` but not both. """ - size: Required[PostcardSize] + size: Required[Literal["6x4", "9x6", "11x6"]] """Enum representing the supported postcard sizes.""" to: Required[PostcardCreateWithHTMLTo] @@ -111,6 +110,12 @@ class PostcardCreateWithHTML(TypedDict, total=False): metadata: Dict[str, object] """See the section on Metadata.""" + paper: str + """Premium paper identifier. + + Use "standard" for regular stock or a premium*paper*\\** ID. + """ + send_date: Annotated[Union[str, datetime], PropertyInfo(alias="sendDate", format="iso8601")] """This order will transition from `ready` to `printing` on the day after this date. @@ -146,7 +151,7 @@ class PostcardCreateWithPdfurl(TypedDict, total=False): (where the address will be stamped on). """ - size: Required[PostcardSize] + size: Required[Literal["6x4", "9x6", "11x6"]] """Enum representing the supported postcard sizes.""" to: Required[PostcardCreateWithPdfurlTo] @@ -217,6 +222,12 @@ class PostcardCreateWithPdfurl(TypedDict, total=False): metadata: Dict[str, object] """See the section on Metadata.""" + paper: str + """Premium paper identifier. + + Use "standard" for regular stock or a premium*paper*\\** ID. + """ + send_date: Annotated[Union[str, datetime], PropertyInfo(alias="sendDate", format="iso8601")] """This order will transition from `ready` to `printing` on the day after this date. @@ -238,7 +249,7 @@ class PostcardCreateWithPdfFile(TypedDict, total=False): (where the address will be stamped on). """ - size: Required[PostcardSize] + size: Required[Literal["6x4", "9x6", "11x6"]] """Enum representing the supported postcard sizes.""" to: Required[PostcardCreateWithPdfFileTo] @@ -309,6 +320,12 @@ class PostcardCreateWithPdfFile(TypedDict, total=False): metadata: Dict[str, object] """See the section on Metadata.""" + paper: str + """Premium paper identifier. + + Use "standard" for regular stock or a premium*paper*\\** ID. + """ + send_date: Annotated[Union[str, datetime], PropertyInfo(alias="sendDate", format="iso8601")] """This order will transition from `ready` to `printing` on the day after this date. diff --git a/src/postgrid/types/print_mail/self_mailer.py b/src/postgrid/types/print_mail/self_mailer.py index 47fd82e..ee0116c 100644 --- a/src/postgrid/types/print_mail/self_mailer.py +++ b/src/postgrid/types/print_mail/self_mailer.py @@ -9,7 +9,6 @@ from .contact import Contact from ..._models import BaseModel -from .order_profiles.self_mailer_size import SelfMailerSize __all__ = ["SelfMailer", "Cancellation"] @@ -88,7 +87,7 @@ class SelfMailer(BaseModel): `printing` on Wednesday at midnight eastern time. """ - size: SelfMailerSize + size: Literal["8.5x11_bifold", "8.5x11_trifold", "9.5x16_trifold"] """Enum representing the supported self-mailer sizes.""" status: Literal["ready", "printing", "processed_for_delivery", "completed", "cancelled"] diff --git a/src/postgrid/types/print_mail/self_mailer_create_params.py b/src/postgrid/types/print_mail/self_mailer_create_params.py index f9f6ca8..3b8ba8c 100644 --- a/src/postgrid/types/print_mail/self_mailer_create_params.py +++ b/src/postgrid/types/print_mail/self_mailer_create_params.py @@ -8,7 +8,6 @@ from ..._types import Base64FileInput from ..._utils import PropertyInfo -from .order_profiles.self_mailer_size import SelfMailerSize from ..contact_create_with_first_name_param import ContactCreateWithFirstNameParam from ..contact_create_with_company_name_param import ContactCreateWithCompanyNameParam @@ -46,7 +45,7 @@ class SelfMailerCreateWithHTML(TypedDict, total=False): You can supply _either_ this or `outsideTemplate` but not both. """ - size: Required[SelfMailerSize] + size: Required[Literal["8.5x11_bifold", "8.5x11_trifold", "9.5x16_trifold"]] """Enum representing the supported self-mailer sizes.""" to: Required[SelfMailerCreateWithHTMLTo] @@ -151,7 +150,7 @@ class SelfMailerCreateWithPdfurl(TypedDict, total=False): outside (where the address will be stamped on). """ - size: Required[SelfMailerSize] + size: Required[Literal["8.5x11_bifold", "8.5x11_trifold", "9.5x16_trifold"]] """Enum representing the supported self-mailer sizes.""" to: Required[SelfMailerCreateWithPdfurlTo] @@ -244,7 +243,7 @@ class SelfMailerCreateWithPdfFile(TypedDict, total=False): outside (where the address will be stamped on). """ - size: Required[SelfMailerSize] + size: Required[Literal["8.5x11_bifold", "8.5x11_trifold", "9.5x16_trifold"]] """Enum representing the supported self-mailer sizes.""" to: Required[SelfMailerCreateWithPdfFileTo] diff --git a/tests/api_resources/print_mail/order_profiles/__init__.py b/tests/api_resources/print_mail/order_profiles/__init__.py deleted file mode 100644 index fd8019a..0000000 --- a/tests/api_resources/print_mail/order_profiles/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/print_mail/order_profiles/test_cheques.py b/tests/api_resources/print_mail/order_profiles/test_cheques.py deleted file mode 100644 index 5faf74b..0000000 --- a/tests/api_resources/print_mail/order_profiles/test_cheques.py +++ /dev/null @@ -1,547 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from postgrid import PostGrid, AsyncPostGrid -from tests.utils import assert_matches_type -from postgrid.pagination import SyncSkipLimit, AsyncSkipLimit -from postgrid.types.print_mail.order_profiles import ( - ChequeProfile, - ChequeListResponse, - ChequeDeleteResponse, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestCheques: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_create(self, client: PostGrid) -> None: - cheque = client.print_mail.order_profiles.cheques.create( - bank_account="bankAccount", - size="us_letter", - ) - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_create_with_all_params(self, client: PostGrid) -> None: - cheque = client.print_mail.order_profiles.cheques.create( - bank_account="bankAccount", - size="us_letter", - expand=["string"], - currency_code="CAD", - description="description", - letter_pdf="U3RhaW5sZXNzIHJvY2tz", - letter_template="letterTemplate", - logo="https://example.com", - mailing_class="first_class", - memo="memo", - merge_variables={"foo": "bar"}, - message="message", - metadata={"foo": "string"}, - ) - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_create(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.cheques.with_raw_response.create( - bank_account="bankAccount", - size="us_letter", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - cheque = response.parse() - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_create(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.cheques.with_streaming_response.create( - bank_account="bankAccount", - size="us_letter", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - cheque = response.parse() - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_retrieve(self, client: PostGrid) -> None: - cheque = client.print_mail.order_profiles.cheques.retrieve( - id="id", - ) - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_retrieve_with_all_params(self, client: PostGrid) -> None: - cheque = client.print_mail.order_profiles.cheques.retrieve( - id="id", - expand=["string"], - ) - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_retrieve(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.cheques.with_raw_response.retrieve( - id="id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - cheque = response.parse() - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_retrieve(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.cheques.with_streaming_response.retrieve( - id="id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - cheque = response.parse() - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_retrieve(self, client: PostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.print_mail.order_profiles.cheques.with_raw_response.retrieve( - id="", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_update(self, client: PostGrid) -> None: - cheque = client.print_mail.order_profiles.cheques.update( - id="id", - bank_account="bankAccount", - size="us_letter", - ) - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_update_with_all_params(self, client: PostGrid) -> None: - cheque = client.print_mail.order_profiles.cheques.update( - id="id", - bank_account="bankAccount", - size="us_letter", - expand=["string"], - currency_code="CAD", - description="description", - letter_pdf="U3RhaW5sZXNzIHJvY2tz", - letter_template="letterTemplate", - logo="https://example.com", - mailing_class="first_class", - memo="memo", - merge_variables={"foo": "bar"}, - message="message", - metadata={"foo": "string"}, - ) - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_update(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.cheques.with_raw_response.update( - id="id", - bank_account="bankAccount", - size="us_letter", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - cheque = response.parse() - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_update(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.cheques.with_streaming_response.update( - id="id", - bank_account="bankAccount", - size="us_letter", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - cheque = response.parse() - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_update(self, client: PostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.print_mail.order_profiles.cheques.with_raw_response.update( - id="", - bank_account="bankAccount", - size="us_letter", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_list(self, client: PostGrid) -> None: - cheque = client.print_mail.order_profiles.cheques.list() - assert_matches_type(SyncSkipLimit[ChequeListResponse], cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_list_with_all_params(self, client: PostGrid) -> None: - cheque = client.print_mail.order_profiles.cheques.list( - limit=0, - search="search", - skip=0, - ) - assert_matches_type(SyncSkipLimit[ChequeListResponse], cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_list(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.cheques.with_raw_response.list() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - cheque = response.parse() - assert_matches_type(SyncSkipLimit[ChequeListResponse], cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_list(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.cheques.with_streaming_response.list() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - cheque = response.parse() - assert_matches_type(SyncSkipLimit[ChequeListResponse], cheque, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_delete(self, client: PostGrid) -> None: - cheque = client.print_mail.order_profiles.cheques.delete( - "id", - ) - assert_matches_type(ChequeDeleteResponse, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_delete(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.cheques.with_raw_response.delete( - "id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - cheque = response.parse() - assert_matches_type(ChequeDeleteResponse, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_delete(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.cheques.with_streaming_response.delete( - "id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - cheque = response.parse() - assert_matches_type(ChequeDeleteResponse, cheque, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_delete(self, client: PostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.print_mail.order_profiles.cheques.with_raw_response.delete( - "", - ) - - -class TestAsyncCheques: - parametrize = pytest.mark.parametrize( - "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_create(self, async_client: AsyncPostGrid) -> None: - cheque = await async_client.print_mail.order_profiles.cheques.create( - bank_account="bankAccount", - size="us_letter", - ) - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncPostGrid) -> None: - cheque = await async_client.print_mail.order_profiles.cheques.create( - bank_account="bankAccount", - size="us_letter", - expand=["string"], - currency_code="CAD", - description="description", - letter_pdf="U3RhaW5sZXNzIHJvY2tz", - letter_template="letterTemplate", - logo="https://example.com", - mailing_class="first_class", - memo="memo", - merge_variables={"foo": "bar"}, - message="message", - metadata={"foo": "string"}, - ) - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_create(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.cheques.with_raw_response.create( - bank_account="bankAccount", - size="us_letter", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - cheque = await response.parse() - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_create(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.cheques.with_streaming_response.create( - bank_account="bankAccount", - size="us_letter", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - cheque = await response.parse() - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_retrieve(self, async_client: AsyncPostGrid) -> None: - cheque = await async_client.print_mail.order_profiles.cheques.retrieve( - id="id", - ) - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_retrieve_with_all_params(self, async_client: AsyncPostGrid) -> None: - cheque = await async_client.print_mail.order_profiles.cheques.retrieve( - id="id", - expand=["string"], - ) - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_retrieve(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.cheques.with_raw_response.retrieve( - id="id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - cheque = await response.parse() - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_retrieve(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.cheques.with_streaming_response.retrieve( - id="id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - cheque = await response.parse() - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_retrieve(self, async_client: AsyncPostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.print_mail.order_profiles.cheques.with_raw_response.retrieve( - id="", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_update(self, async_client: AsyncPostGrid) -> None: - cheque = await async_client.print_mail.order_profiles.cheques.update( - id="id", - bank_account="bankAccount", - size="us_letter", - ) - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncPostGrid) -> None: - cheque = await async_client.print_mail.order_profiles.cheques.update( - id="id", - bank_account="bankAccount", - size="us_letter", - expand=["string"], - currency_code="CAD", - description="description", - letter_pdf="U3RhaW5sZXNzIHJvY2tz", - letter_template="letterTemplate", - logo="https://example.com", - mailing_class="first_class", - memo="memo", - merge_variables={"foo": "bar"}, - message="message", - metadata={"foo": "string"}, - ) - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_update(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.cheques.with_raw_response.update( - id="id", - bank_account="bankAccount", - size="us_letter", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - cheque = await response.parse() - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_update(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.cheques.with_streaming_response.update( - id="id", - bank_account="bankAccount", - size="us_letter", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - cheque = await response.parse() - assert_matches_type(ChequeProfile, cheque, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_update(self, async_client: AsyncPostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.print_mail.order_profiles.cheques.with_raw_response.update( - id="", - bank_account="bankAccount", - size="us_letter", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_list(self, async_client: AsyncPostGrid) -> None: - cheque = await async_client.print_mail.order_profiles.cheques.list() - assert_matches_type(AsyncSkipLimit[ChequeListResponse], cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncPostGrid) -> None: - cheque = await async_client.print_mail.order_profiles.cheques.list( - limit=0, - search="search", - skip=0, - ) - assert_matches_type(AsyncSkipLimit[ChequeListResponse], cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_list(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.cheques.with_raw_response.list() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - cheque = await response.parse() - assert_matches_type(AsyncSkipLimit[ChequeListResponse], cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_list(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.cheques.with_streaming_response.list() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - cheque = await response.parse() - assert_matches_type(AsyncSkipLimit[ChequeListResponse], cheque, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_delete(self, async_client: AsyncPostGrid) -> None: - cheque = await async_client.print_mail.order_profiles.cheques.delete( - "id", - ) - assert_matches_type(ChequeDeleteResponse, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_delete(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.cheques.with_raw_response.delete( - "id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - cheque = await response.parse() - assert_matches_type(ChequeDeleteResponse, cheque, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.cheques.with_streaming_response.delete( - "id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - cheque = await response.parse() - assert_matches_type(ChequeDeleteResponse, cheque, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_delete(self, async_client: AsyncPostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.print_mail.order_profiles.cheques.with_raw_response.delete( - "", - ) diff --git a/tests/api_resources/print_mail/order_profiles/test_letters.py b/tests/api_resources/print_mail/order_profiles/test_letters.py deleted file mode 100644 index 2929536..0000000 --- a/tests/api_resources/print_mail/order_profiles/test_letters.py +++ /dev/null @@ -1,542 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from postgrid import PostGrid, AsyncPostGrid -from tests.utils import assert_matches_type -from postgrid.pagination import SyncSkipLimit, AsyncSkipLimit -from postgrid.types.print_mail.order_profiles import ( - LetterProfile, - LetterDeleteResponse, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestLetters: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_create(self, client: PostGrid) -> None: - letter = client.print_mail.order_profiles.letters.create( - size="us_letter", - ) - assert_matches_type(LetterProfile, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_create_with_all_params(self, client: PostGrid) -> None: - letter = client.print_mail.order_profiles.letters.create( - size="us_letter", - expand=["string"], - address_placement="top_first_page", - attached_pdf={ - "file": "https://example.com", - "placement": "before_template", - }, - color=True, - description="Monthly Newsletter Profile", - double_sided=True, - envelope="envelope", - mailing_class="first_class", - merge_variables={"salutation": "bar"}, - metadata={"campaign": "Q1 Newsletter"}, - pdf="https://example.com", - perforated_page=1, - return_envelope="returnEnvelope", - template="template_abc", - ) - assert_matches_type(LetterProfile, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_create(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.letters.with_raw_response.create( - size="us_letter", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - letter = response.parse() - assert_matches_type(LetterProfile, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_create(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.letters.with_streaming_response.create( - size="us_letter", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - letter = response.parse() - assert_matches_type(LetterProfile, letter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_retrieve(self, client: PostGrid) -> None: - letter = client.print_mail.order_profiles.letters.retrieve( - id="id", - ) - assert_matches_type(LetterProfile, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_retrieve_with_all_params(self, client: PostGrid) -> None: - letter = client.print_mail.order_profiles.letters.retrieve( - id="id", - expand=["string"], - ) - assert_matches_type(LetterProfile, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_retrieve(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.letters.with_raw_response.retrieve( - id="id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - letter = response.parse() - assert_matches_type(LetterProfile, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_retrieve(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.letters.with_streaming_response.retrieve( - id="id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - letter = response.parse() - assert_matches_type(LetterProfile, letter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_retrieve(self, client: PostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.print_mail.order_profiles.letters.with_raw_response.retrieve( - id="", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_update(self, client: PostGrid) -> None: - letter = client.print_mail.order_profiles.letters.update( - id="id", - ) - assert_matches_type(LetterProfile, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_update_with_all_params(self, client: PostGrid) -> None: - letter = client.print_mail.order_profiles.letters.update( - id="id", - expand=["string"], - address_placement="top_first_page", - attached_pdf={ - "file": "https://example.com", - "placement": "before_template", - }, - color=False, - description="Updated Newsletter Profile", - double_sided=True, - envelope="envelope", - mailing_class="first_class", - merge_variables={"foo": "bar"}, - metadata={"foo": "string"}, - pdf="https://example.com", - perforated_page=1, - return_envelope="returnEnvelope", - template="template", - ) - assert_matches_type(LetterProfile, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_update(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.letters.with_raw_response.update( - id="id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - letter = response.parse() - assert_matches_type(LetterProfile, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_update(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.letters.with_streaming_response.update( - id="id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - letter = response.parse() - assert_matches_type(LetterProfile, letter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_update(self, client: PostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.print_mail.order_profiles.letters.with_raw_response.update( - id="", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_list(self, client: PostGrid) -> None: - letter = client.print_mail.order_profiles.letters.list() - assert_matches_type(SyncSkipLimit[LetterProfile], letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_list_with_all_params(self, client: PostGrid) -> None: - letter = client.print_mail.order_profiles.letters.list( - limit=0, - search="search", - skip=0, - ) - assert_matches_type(SyncSkipLimit[LetterProfile], letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_list(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.letters.with_raw_response.list() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - letter = response.parse() - assert_matches_type(SyncSkipLimit[LetterProfile], letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_list(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.letters.with_streaming_response.list() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - letter = response.parse() - assert_matches_type(SyncSkipLimit[LetterProfile], letter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_delete(self, client: PostGrid) -> None: - letter = client.print_mail.order_profiles.letters.delete( - "id", - ) - assert_matches_type(LetterDeleteResponse, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_delete(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.letters.with_raw_response.delete( - "id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - letter = response.parse() - assert_matches_type(LetterDeleteResponse, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_delete(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.letters.with_streaming_response.delete( - "id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - letter = response.parse() - assert_matches_type(LetterDeleteResponse, letter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_delete(self, client: PostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.print_mail.order_profiles.letters.with_raw_response.delete( - "", - ) - - -class TestAsyncLetters: - parametrize = pytest.mark.parametrize( - "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_create(self, async_client: AsyncPostGrid) -> None: - letter = await async_client.print_mail.order_profiles.letters.create( - size="us_letter", - ) - assert_matches_type(LetterProfile, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncPostGrid) -> None: - letter = await async_client.print_mail.order_profiles.letters.create( - size="us_letter", - expand=["string"], - address_placement="top_first_page", - attached_pdf={ - "file": "https://example.com", - "placement": "before_template", - }, - color=True, - description="Monthly Newsletter Profile", - double_sided=True, - envelope="envelope", - mailing_class="first_class", - merge_variables={"salutation": "bar"}, - metadata={"campaign": "Q1 Newsletter"}, - pdf="https://example.com", - perforated_page=1, - return_envelope="returnEnvelope", - template="template_abc", - ) - assert_matches_type(LetterProfile, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_create(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.letters.with_raw_response.create( - size="us_letter", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - letter = await response.parse() - assert_matches_type(LetterProfile, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_create(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.letters.with_streaming_response.create( - size="us_letter", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - letter = await response.parse() - assert_matches_type(LetterProfile, letter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_retrieve(self, async_client: AsyncPostGrid) -> None: - letter = await async_client.print_mail.order_profiles.letters.retrieve( - id="id", - ) - assert_matches_type(LetterProfile, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_retrieve_with_all_params(self, async_client: AsyncPostGrid) -> None: - letter = await async_client.print_mail.order_profiles.letters.retrieve( - id="id", - expand=["string"], - ) - assert_matches_type(LetterProfile, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_retrieve(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.letters.with_raw_response.retrieve( - id="id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - letter = await response.parse() - assert_matches_type(LetterProfile, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_retrieve(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.letters.with_streaming_response.retrieve( - id="id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - letter = await response.parse() - assert_matches_type(LetterProfile, letter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_retrieve(self, async_client: AsyncPostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.print_mail.order_profiles.letters.with_raw_response.retrieve( - id="", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_update(self, async_client: AsyncPostGrid) -> None: - letter = await async_client.print_mail.order_profiles.letters.update( - id="id", - ) - assert_matches_type(LetterProfile, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncPostGrid) -> None: - letter = await async_client.print_mail.order_profiles.letters.update( - id="id", - expand=["string"], - address_placement="top_first_page", - attached_pdf={ - "file": "https://example.com", - "placement": "before_template", - }, - color=False, - description="Updated Newsletter Profile", - double_sided=True, - envelope="envelope", - mailing_class="first_class", - merge_variables={"foo": "bar"}, - metadata={"foo": "string"}, - pdf="https://example.com", - perforated_page=1, - return_envelope="returnEnvelope", - template="template", - ) - assert_matches_type(LetterProfile, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_update(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.letters.with_raw_response.update( - id="id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - letter = await response.parse() - assert_matches_type(LetterProfile, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_update(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.letters.with_streaming_response.update( - id="id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - letter = await response.parse() - assert_matches_type(LetterProfile, letter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_update(self, async_client: AsyncPostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.print_mail.order_profiles.letters.with_raw_response.update( - id="", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_list(self, async_client: AsyncPostGrid) -> None: - letter = await async_client.print_mail.order_profiles.letters.list() - assert_matches_type(AsyncSkipLimit[LetterProfile], letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncPostGrid) -> None: - letter = await async_client.print_mail.order_profiles.letters.list( - limit=0, - search="search", - skip=0, - ) - assert_matches_type(AsyncSkipLimit[LetterProfile], letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_list(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.letters.with_raw_response.list() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - letter = await response.parse() - assert_matches_type(AsyncSkipLimit[LetterProfile], letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_list(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.letters.with_streaming_response.list() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - letter = await response.parse() - assert_matches_type(AsyncSkipLimit[LetterProfile], letter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_delete(self, async_client: AsyncPostGrid) -> None: - letter = await async_client.print_mail.order_profiles.letters.delete( - "id", - ) - assert_matches_type(LetterDeleteResponse, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_delete(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.letters.with_raw_response.delete( - "id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - letter = await response.parse() - assert_matches_type(LetterDeleteResponse, letter, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.letters.with_streaming_response.delete( - "id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - letter = await response.parse() - assert_matches_type(LetterDeleteResponse, letter, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_delete(self, async_client: AsyncPostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.print_mail.order_profiles.letters.with_raw_response.delete( - "", - ) diff --git a/tests/api_resources/print_mail/order_profiles/test_postcards.py b/tests/api_resources/print_mail/order_profiles/test_postcards.py deleted file mode 100644 index e9172b7..0000000 --- a/tests/api_resources/print_mail/order_profiles/test_postcards.py +++ /dev/null @@ -1,506 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from postgrid import PostGrid, AsyncPostGrid -from tests.utils import assert_matches_type -from postgrid.pagination import SyncSkipLimit, AsyncSkipLimit -from postgrid.types.print_mail.order_profiles import ( - PostcardProfile, - PostcardDeleteResponse, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestPostcards: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_create(self, client: PostGrid) -> None: - postcard = client.print_mail.order_profiles.postcards.create( - size="6x4", - ) - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_create_with_all_params(self, client: PostGrid) -> None: - postcard = client.print_mail.order_profiles.postcards.create( - size="6x4", - expand=["string"], - back_template="backTemplate", - description="description", - front_template="frontTemplate", - mailing_class="first_class", - merge_variables={"foo": "bar"}, - metadata={"foo": "string"}, - pdf="https://example.com", - ) - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_create(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.postcards.with_raw_response.create( - size="6x4", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - postcard = response.parse() - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_create(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.postcards.with_streaming_response.create( - size="6x4", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - postcard = response.parse() - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_retrieve(self, client: PostGrid) -> None: - postcard = client.print_mail.order_profiles.postcards.retrieve( - id="id", - ) - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_retrieve_with_all_params(self, client: PostGrid) -> None: - postcard = client.print_mail.order_profiles.postcards.retrieve( - id="id", - expand=["string"], - ) - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_retrieve(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.postcards.with_raw_response.retrieve( - id="id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - postcard = response.parse() - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_retrieve(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.postcards.with_streaming_response.retrieve( - id="id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - postcard = response.parse() - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_retrieve(self, client: PostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.print_mail.order_profiles.postcards.with_raw_response.retrieve( - id="", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_update(self, client: PostGrid) -> None: - postcard = client.print_mail.order_profiles.postcards.update( - id="id", - ) - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_update_with_all_params(self, client: PostGrid) -> None: - postcard = client.print_mail.order_profiles.postcards.update( - id="id", - expand=["string"], - back_template="backTemplate", - description="description", - front_template="frontTemplate", - mailing_class="first_class", - merge_variables={"foo": "bar"}, - metadata={"foo": "string"}, - pdf="https://example.com", - ) - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_update(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.postcards.with_raw_response.update( - id="id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - postcard = response.parse() - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_update(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.postcards.with_streaming_response.update( - id="id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - postcard = response.parse() - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_update(self, client: PostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.print_mail.order_profiles.postcards.with_raw_response.update( - id="", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_list(self, client: PostGrid) -> None: - postcard = client.print_mail.order_profiles.postcards.list() - assert_matches_type(SyncSkipLimit[PostcardProfile], postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_list_with_all_params(self, client: PostGrid) -> None: - postcard = client.print_mail.order_profiles.postcards.list( - limit=0, - search="search", - skip=0, - ) - assert_matches_type(SyncSkipLimit[PostcardProfile], postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_list(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.postcards.with_raw_response.list() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - postcard = response.parse() - assert_matches_type(SyncSkipLimit[PostcardProfile], postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_list(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.postcards.with_streaming_response.list() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - postcard = response.parse() - assert_matches_type(SyncSkipLimit[PostcardProfile], postcard, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_delete(self, client: PostGrid) -> None: - postcard = client.print_mail.order_profiles.postcards.delete( - "id", - ) - assert_matches_type(PostcardDeleteResponse, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_delete(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.postcards.with_raw_response.delete( - "id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - postcard = response.parse() - assert_matches_type(PostcardDeleteResponse, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_delete(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.postcards.with_streaming_response.delete( - "id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - postcard = response.parse() - assert_matches_type(PostcardDeleteResponse, postcard, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_delete(self, client: PostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.print_mail.order_profiles.postcards.with_raw_response.delete( - "", - ) - - -class TestAsyncPostcards: - parametrize = pytest.mark.parametrize( - "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_create(self, async_client: AsyncPostGrid) -> None: - postcard = await async_client.print_mail.order_profiles.postcards.create( - size="6x4", - ) - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncPostGrid) -> None: - postcard = await async_client.print_mail.order_profiles.postcards.create( - size="6x4", - expand=["string"], - back_template="backTemplate", - description="description", - front_template="frontTemplate", - mailing_class="first_class", - merge_variables={"foo": "bar"}, - metadata={"foo": "string"}, - pdf="https://example.com", - ) - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_create(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.postcards.with_raw_response.create( - size="6x4", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - postcard = await response.parse() - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_create(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.postcards.with_streaming_response.create( - size="6x4", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - postcard = await response.parse() - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_retrieve(self, async_client: AsyncPostGrid) -> None: - postcard = await async_client.print_mail.order_profiles.postcards.retrieve( - id="id", - ) - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_retrieve_with_all_params(self, async_client: AsyncPostGrid) -> None: - postcard = await async_client.print_mail.order_profiles.postcards.retrieve( - id="id", - expand=["string"], - ) - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_retrieve(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.postcards.with_raw_response.retrieve( - id="id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - postcard = await response.parse() - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_retrieve(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.postcards.with_streaming_response.retrieve( - id="id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - postcard = await response.parse() - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_retrieve(self, async_client: AsyncPostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.print_mail.order_profiles.postcards.with_raw_response.retrieve( - id="", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_update(self, async_client: AsyncPostGrid) -> None: - postcard = await async_client.print_mail.order_profiles.postcards.update( - id="id", - ) - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncPostGrid) -> None: - postcard = await async_client.print_mail.order_profiles.postcards.update( - id="id", - expand=["string"], - back_template="backTemplate", - description="description", - front_template="frontTemplate", - mailing_class="first_class", - merge_variables={"foo": "bar"}, - metadata={"foo": "string"}, - pdf="https://example.com", - ) - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_update(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.postcards.with_raw_response.update( - id="id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - postcard = await response.parse() - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_update(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.postcards.with_streaming_response.update( - id="id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - postcard = await response.parse() - assert_matches_type(PostcardProfile, postcard, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_update(self, async_client: AsyncPostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.print_mail.order_profiles.postcards.with_raw_response.update( - id="", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_list(self, async_client: AsyncPostGrid) -> None: - postcard = await async_client.print_mail.order_profiles.postcards.list() - assert_matches_type(AsyncSkipLimit[PostcardProfile], postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncPostGrid) -> None: - postcard = await async_client.print_mail.order_profiles.postcards.list( - limit=0, - search="search", - skip=0, - ) - assert_matches_type(AsyncSkipLimit[PostcardProfile], postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_list(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.postcards.with_raw_response.list() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - postcard = await response.parse() - assert_matches_type(AsyncSkipLimit[PostcardProfile], postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_list(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.postcards.with_streaming_response.list() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - postcard = await response.parse() - assert_matches_type(AsyncSkipLimit[PostcardProfile], postcard, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_delete(self, async_client: AsyncPostGrid) -> None: - postcard = await async_client.print_mail.order_profiles.postcards.delete( - "id", - ) - assert_matches_type(PostcardDeleteResponse, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_delete(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.postcards.with_raw_response.delete( - "id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - postcard = await response.parse() - assert_matches_type(PostcardDeleteResponse, postcard, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.postcards.with_streaming_response.delete( - "id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - postcard = await response.parse() - assert_matches_type(PostcardDeleteResponse, postcard, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_delete(self, async_client: AsyncPostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.print_mail.order_profiles.postcards.with_raw_response.delete( - "", - ) diff --git a/tests/api_resources/print_mail/order_profiles/test_self_mailers.py b/tests/api_resources/print_mail/order_profiles/test_self_mailers.py deleted file mode 100644 index e679be9..0000000 --- a/tests/api_resources/print_mail/order_profiles/test_self_mailers.py +++ /dev/null @@ -1,516 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from postgrid import PostGrid, AsyncPostGrid -from tests.utils import assert_matches_type -from postgrid.pagination import SyncSkipLimit, AsyncSkipLimit -from postgrid.types.print_mail.order_profiles import ( - SelfMailerProfile, - SelfMailerDeleteResponse, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestSelfMailers: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_create(self, client: PostGrid) -> None: - self_mailer = client.print_mail.order_profiles.self_mailers.create( - size="8.5x11_bifold", - ) - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_create_with_all_params(self, client: PostGrid) -> None: - self_mailer = client.print_mail.order_profiles.self_mailers.create( - size="8.5x11_bifold", - expand=["string"], - description="description", - inside_template="insideTemplate", - mailing_class="first_class", - merge_variables={"foo": "bar"}, - metadata={"foo": "string"}, - outside_template="outsideTemplate", - pdf="https://example.com", - ) - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_create(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.self_mailers.with_raw_response.create( - size="8.5x11_bifold", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - self_mailer = response.parse() - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_create(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.self_mailers.with_streaming_response.create( - size="8.5x11_bifold", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - self_mailer = response.parse() - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_retrieve(self, client: PostGrid) -> None: - self_mailer = client.print_mail.order_profiles.self_mailers.retrieve( - id="id", - ) - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_retrieve_with_all_params(self, client: PostGrid) -> None: - self_mailer = client.print_mail.order_profiles.self_mailers.retrieve( - id="id", - expand=["string"], - ) - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_retrieve(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.self_mailers.with_raw_response.retrieve( - id="id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - self_mailer = response.parse() - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_retrieve(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.self_mailers.with_streaming_response.retrieve( - id="id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - self_mailer = response.parse() - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_retrieve(self, client: PostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.print_mail.order_profiles.self_mailers.with_raw_response.retrieve( - id="", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_update(self, client: PostGrid) -> None: - self_mailer = client.print_mail.order_profiles.self_mailers.update( - id="id", - size="8.5x11_bifold", - ) - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_update_with_all_params(self, client: PostGrid) -> None: - self_mailer = client.print_mail.order_profiles.self_mailers.update( - id="id", - size="8.5x11_bifold", - expand=["string"], - description="description", - inside_template="insideTemplate", - mailing_class="first_class", - merge_variables={"foo": "bar"}, - metadata={"foo": "string"}, - outside_template="outsideTemplate", - pdf="https://example.com", - ) - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_update(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.self_mailers.with_raw_response.update( - id="id", - size="8.5x11_bifold", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - self_mailer = response.parse() - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_update(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.self_mailers.with_streaming_response.update( - id="id", - size="8.5x11_bifold", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - self_mailer = response.parse() - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_update(self, client: PostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.print_mail.order_profiles.self_mailers.with_raw_response.update( - id="", - size="8.5x11_bifold", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_list(self, client: PostGrid) -> None: - self_mailer = client.print_mail.order_profiles.self_mailers.list() - assert_matches_type(SyncSkipLimit[SelfMailerProfile], self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_list_with_all_params(self, client: PostGrid) -> None: - self_mailer = client.print_mail.order_profiles.self_mailers.list( - limit=0, - search="search", - skip=0, - ) - assert_matches_type(SyncSkipLimit[SelfMailerProfile], self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_list(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.self_mailers.with_raw_response.list() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - self_mailer = response.parse() - assert_matches_type(SyncSkipLimit[SelfMailerProfile], self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_list(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.self_mailers.with_streaming_response.list() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - self_mailer = response.parse() - assert_matches_type(SyncSkipLimit[SelfMailerProfile], self_mailer, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_delete(self, client: PostGrid) -> None: - self_mailer = client.print_mail.order_profiles.self_mailers.delete( - "id", - ) - assert_matches_type(SelfMailerDeleteResponse, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_delete(self, client: PostGrid) -> None: - response = client.print_mail.order_profiles.self_mailers.with_raw_response.delete( - "id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - self_mailer = response.parse() - assert_matches_type(SelfMailerDeleteResponse, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_delete(self, client: PostGrid) -> None: - with client.print_mail.order_profiles.self_mailers.with_streaming_response.delete( - "id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - self_mailer = response.parse() - assert_matches_type(SelfMailerDeleteResponse, self_mailer, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_delete(self, client: PostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.print_mail.order_profiles.self_mailers.with_raw_response.delete( - "", - ) - - -class TestAsyncSelfMailers: - parametrize = pytest.mark.parametrize( - "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_create(self, async_client: AsyncPostGrid) -> None: - self_mailer = await async_client.print_mail.order_profiles.self_mailers.create( - size="8.5x11_bifold", - ) - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncPostGrid) -> None: - self_mailer = await async_client.print_mail.order_profiles.self_mailers.create( - size="8.5x11_bifold", - expand=["string"], - description="description", - inside_template="insideTemplate", - mailing_class="first_class", - merge_variables={"foo": "bar"}, - metadata={"foo": "string"}, - outside_template="outsideTemplate", - pdf="https://example.com", - ) - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_create(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.self_mailers.with_raw_response.create( - size="8.5x11_bifold", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - self_mailer = await response.parse() - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_create(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.self_mailers.with_streaming_response.create( - size="8.5x11_bifold", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - self_mailer = await response.parse() - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_retrieve(self, async_client: AsyncPostGrid) -> None: - self_mailer = await async_client.print_mail.order_profiles.self_mailers.retrieve( - id="id", - ) - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_retrieve_with_all_params(self, async_client: AsyncPostGrid) -> None: - self_mailer = await async_client.print_mail.order_profiles.self_mailers.retrieve( - id="id", - expand=["string"], - ) - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_retrieve(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.self_mailers.with_raw_response.retrieve( - id="id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - self_mailer = await response.parse() - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_retrieve(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.self_mailers.with_streaming_response.retrieve( - id="id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - self_mailer = await response.parse() - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_retrieve(self, async_client: AsyncPostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.print_mail.order_profiles.self_mailers.with_raw_response.retrieve( - id="", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_update(self, async_client: AsyncPostGrid) -> None: - self_mailer = await async_client.print_mail.order_profiles.self_mailers.update( - id="id", - size="8.5x11_bifold", - ) - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncPostGrid) -> None: - self_mailer = await async_client.print_mail.order_profiles.self_mailers.update( - id="id", - size="8.5x11_bifold", - expand=["string"], - description="description", - inside_template="insideTemplate", - mailing_class="first_class", - merge_variables={"foo": "bar"}, - metadata={"foo": "string"}, - outside_template="outsideTemplate", - pdf="https://example.com", - ) - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_update(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.self_mailers.with_raw_response.update( - id="id", - size="8.5x11_bifold", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - self_mailer = await response.parse() - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_update(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.self_mailers.with_streaming_response.update( - id="id", - size="8.5x11_bifold", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - self_mailer = await response.parse() - assert_matches_type(SelfMailerProfile, self_mailer, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_update(self, async_client: AsyncPostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.print_mail.order_profiles.self_mailers.with_raw_response.update( - id="", - size="8.5x11_bifold", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_list(self, async_client: AsyncPostGrid) -> None: - self_mailer = await async_client.print_mail.order_profiles.self_mailers.list() - assert_matches_type(AsyncSkipLimit[SelfMailerProfile], self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncPostGrid) -> None: - self_mailer = await async_client.print_mail.order_profiles.self_mailers.list( - limit=0, - search="search", - skip=0, - ) - assert_matches_type(AsyncSkipLimit[SelfMailerProfile], self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_list(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.self_mailers.with_raw_response.list() - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - self_mailer = await response.parse() - assert_matches_type(AsyncSkipLimit[SelfMailerProfile], self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_list(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.self_mailers.with_streaming_response.list() as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - self_mailer = await response.parse() - assert_matches_type(AsyncSkipLimit[SelfMailerProfile], self_mailer, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_delete(self, async_client: AsyncPostGrid) -> None: - self_mailer = await async_client.print_mail.order_profiles.self_mailers.delete( - "id", - ) - assert_matches_type(SelfMailerDeleteResponse, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_delete(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.order_profiles.self_mailers.with_raw_response.delete( - "id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - self_mailer = await response.parse() - assert_matches_type(SelfMailerDeleteResponse, self_mailer, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.order_profiles.self_mailers.with_streaming_response.delete( - "id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - self_mailer = await response.parse() - assert_matches_type(SelfMailerDeleteResponse, self_mailer, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_delete(self, async_client: AsyncPostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.print_mail.order_profiles.self_mailers.with_raw_response.delete( - "", - ) diff --git a/tests/api_resources/print_mail/test_campaigns.py b/tests/api_resources/print_mail/test_campaigns.py index c65ae01..eb188b7 100644 --- a/tests/api_resources/print_mail/test_campaigns.py +++ b/tests/api_resources/print_mail/test_campaigns.py @@ -35,14 +35,78 @@ def test_method_create(self, client: PostGrid) -> None: def test_method_create_with_all_params(self, client: PostGrid) -> None: campaign = client.print_mail.campaigns.create( mailing_list="mailingList", - cheque_profile="chequeProfile", + cheque={ + "bank_account": "bankAccount", + "currency_code": "CAD", + "description": "description", + "envelope": "envelope", + "letter_pdf": "U3RhaW5sZXNzIHJvY2tz", + "letter_settings": {"color": True}, + "letter_template": "letterTemplate", + "logo": "https://example.com", + "mailing_class": "first_class", + "memo": "memo", + "merge_variables": {"foo": "bar"}, + "message": "message", + "metadata": {"foo": "string"}, + "return_envelope": "returnEnvelope", + "size": "us_letter", + }, default_sender_contact="defaultSenderContact", description="description", - letter_profile="letterProfile", + letter={ + "address_placement": "top_first_page", + "attached_pdf": { + "file": "https://example.com", + "placement": "before_template", + }, + "color": True, + "description": "description", + "double_sided": True, + "envelope": "envelope", + "envelope_type": "standard_double_window", + "mailing_class": "first_class", + "merge_variables": {"foo": "bar"}, + "metadata": {"foo": "string"}, + "pdf": "https://example.com", + "perforated_page": 1, + "return_envelope": "returnEnvelope", + "size": "us_letter", + "template": "template", + }, metadata={"foo": "bar"}, - postcard_profile="postcardProfile", - self_mailer_profile="selfMailerProfile", + postcard={ + "back_template": "backTemplate", + "description": "description", + "front_template": "frontTemplate", + "mailing_class": "first_class", + "merge_variables": {"foo": "bar"}, + "metadata": {"foo": "string"}, + "paper": "premium_paper_L6fw2k_N_j", + "pdf": "https://example.com", + "size": "6x4", + }, + self_mailer={ + "description": "description", + "inside_template": "insideTemplate", + "mailing_class": "first_class", + "merge_variables": {"foo": "bar"}, + "metadata": {"foo": "string"}, + "outside_template": "outsideTemplate", + "pdf": "https://example.com", + "size": "8.5x11_bifold", + }, send_date=parse_datetime("2019-12-27T18:11:19.117Z"), + snap_pack={ + "description": "description", + "inside_template": "insideTemplate", + "mailing_class": "first_class", + "merge_variables": {"foo": "bar"}, + "metadata": {"foo": "string"}, + "outside_template": "outsideTemplate", + "pdf": "https://example.com", + "size": "8.5x11_bifold_v", + }, idempotency_key="idempotency-key", ) assert_matches_type(Campaign, campaign, path=["response"]) @@ -128,14 +192,78 @@ def test_method_update(self, client: PostGrid) -> None: def test_method_update_with_all_params(self, client: PostGrid) -> None: campaign = client.print_mail.campaigns.update( id="id", - cheque_profile="chequeProfile", + cheque={ + "bank_account": "bankAccount", + "currency_code": "CAD", + "description": "description", + "envelope": "envelope", + "letter_pdf": "U3RhaW5sZXNzIHJvY2tz", + "letter_settings": {"color": True}, + "letter_template": "letterTemplate", + "logo": "https://example.com", + "mailing_class": "first_class", + "memo": "memo", + "merge_variables": {"foo": "bar"}, + "message": "message", + "metadata": {"foo": "string"}, + "return_envelope": "returnEnvelope", + "size": "us_letter", + }, default_sender_contact="defaultSenderContact", description="description", - letter_profile="letterProfile", + letter={ + "address_placement": "top_first_page", + "attached_pdf": { + "file": "https://example.com", + "placement": "before_template", + }, + "color": True, + "description": "description", + "double_sided": True, + "envelope": "envelope", + "envelope_type": "standard_double_window", + "mailing_class": "first_class", + "merge_variables": {"foo": "bar"}, + "metadata": {"foo": "string"}, + "pdf": "https://example.com", + "perforated_page": 1, + "return_envelope": "returnEnvelope", + "size": "us_letter", + "template": "template", + }, mailing_list="mailingList", metadata={"foo": "string"}, - postcard_profile="postcardProfile", - self_mailer_profile="selfMailerProfile", + postcard={ + "back_template": "backTemplate", + "description": "description", + "front_template": "frontTemplate", + "mailing_class": "first_class", + "merge_variables": {"foo": "bar"}, + "metadata": {"foo": "string"}, + "paper": "premium_paper_L6fw2k_N_j", + "pdf": "https://example.com", + "size": "6x4", + }, + self_mailer={ + "description": "description", + "inside_template": "insideTemplate", + "mailing_class": "first_class", + "merge_variables": {"foo": "bar"}, + "metadata": {"foo": "string"}, + "outside_template": "outsideTemplate", + "pdf": "https://example.com", + "size": "8.5x11_bifold", + }, + snap_pack={ + "description": "description", + "inside_template": "insideTemplate", + "mailing_class": "first_class", + "merge_variables": {"foo": "bar"}, + "metadata": {"foo": "string"}, + "outside_template": "outsideTemplate", + "pdf": "https://example.com", + "size": "8.5x11_bifold_v", + }, ) assert_matches_type(Campaign, campaign, path=["response"]) @@ -323,14 +451,78 @@ async def test_method_create(self, async_client: AsyncPostGrid) -> None: async def test_method_create_with_all_params(self, async_client: AsyncPostGrid) -> None: campaign = await async_client.print_mail.campaigns.create( mailing_list="mailingList", - cheque_profile="chequeProfile", + cheque={ + "bank_account": "bankAccount", + "currency_code": "CAD", + "description": "description", + "envelope": "envelope", + "letter_pdf": "U3RhaW5sZXNzIHJvY2tz", + "letter_settings": {"color": True}, + "letter_template": "letterTemplate", + "logo": "https://example.com", + "mailing_class": "first_class", + "memo": "memo", + "merge_variables": {"foo": "bar"}, + "message": "message", + "metadata": {"foo": "string"}, + "return_envelope": "returnEnvelope", + "size": "us_letter", + }, default_sender_contact="defaultSenderContact", description="description", - letter_profile="letterProfile", + letter={ + "address_placement": "top_first_page", + "attached_pdf": { + "file": "https://example.com", + "placement": "before_template", + }, + "color": True, + "description": "description", + "double_sided": True, + "envelope": "envelope", + "envelope_type": "standard_double_window", + "mailing_class": "first_class", + "merge_variables": {"foo": "bar"}, + "metadata": {"foo": "string"}, + "pdf": "https://example.com", + "perforated_page": 1, + "return_envelope": "returnEnvelope", + "size": "us_letter", + "template": "template", + }, metadata={"foo": "bar"}, - postcard_profile="postcardProfile", - self_mailer_profile="selfMailerProfile", + postcard={ + "back_template": "backTemplate", + "description": "description", + "front_template": "frontTemplate", + "mailing_class": "first_class", + "merge_variables": {"foo": "bar"}, + "metadata": {"foo": "string"}, + "paper": "premium_paper_L6fw2k_N_j", + "pdf": "https://example.com", + "size": "6x4", + }, + self_mailer={ + "description": "description", + "inside_template": "insideTemplate", + "mailing_class": "first_class", + "merge_variables": {"foo": "bar"}, + "metadata": {"foo": "string"}, + "outside_template": "outsideTemplate", + "pdf": "https://example.com", + "size": "8.5x11_bifold", + }, send_date=parse_datetime("2019-12-27T18:11:19.117Z"), + snap_pack={ + "description": "description", + "inside_template": "insideTemplate", + "mailing_class": "first_class", + "merge_variables": {"foo": "bar"}, + "metadata": {"foo": "string"}, + "outside_template": "outsideTemplate", + "pdf": "https://example.com", + "size": "8.5x11_bifold_v", + }, idempotency_key="idempotency-key", ) assert_matches_type(Campaign, campaign, path=["response"]) @@ -416,14 +608,78 @@ async def test_method_update(self, async_client: AsyncPostGrid) -> None: async def test_method_update_with_all_params(self, async_client: AsyncPostGrid) -> None: campaign = await async_client.print_mail.campaigns.update( id="id", - cheque_profile="chequeProfile", + cheque={ + "bank_account": "bankAccount", + "currency_code": "CAD", + "description": "description", + "envelope": "envelope", + "letter_pdf": "U3RhaW5sZXNzIHJvY2tz", + "letter_settings": {"color": True}, + "letter_template": "letterTemplate", + "logo": "https://example.com", + "mailing_class": "first_class", + "memo": "memo", + "merge_variables": {"foo": "bar"}, + "message": "message", + "metadata": {"foo": "string"}, + "return_envelope": "returnEnvelope", + "size": "us_letter", + }, default_sender_contact="defaultSenderContact", description="description", - letter_profile="letterProfile", + letter={ + "address_placement": "top_first_page", + "attached_pdf": { + "file": "https://example.com", + "placement": "before_template", + }, + "color": True, + "description": "description", + "double_sided": True, + "envelope": "envelope", + "envelope_type": "standard_double_window", + "mailing_class": "first_class", + "merge_variables": {"foo": "bar"}, + "metadata": {"foo": "string"}, + "pdf": "https://example.com", + "perforated_page": 1, + "return_envelope": "returnEnvelope", + "size": "us_letter", + "template": "template", + }, mailing_list="mailingList", metadata={"foo": "string"}, - postcard_profile="postcardProfile", - self_mailer_profile="selfMailerProfile", + postcard={ + "back_template": "backTemplate", + "description": "description", + "front_template": "frontTemplate", + "mailing_class": "first_class", + "merge_variables": {"foo": "bar"}, + "metadata": {"foo": "string"}, + "paper": "premium_paper_L6fw2k_N_j", + "pdf": "https://example.com", + "size": "6x4", + }, + self_mailer={ + "description": "description", + "inside_template": "insideTemplate", + "mailing_class": "first_class", + "merge_variables": {"foo": "bar"}, + "metadata": {"foo": "string"}, + "outside_template": "outsideTemplate", + "pdf": "https://example.com", + "size": "8.5x11_bifold", + }, + snap_pack={ + "description": "description", + "inside_template": "insideTemplate", + "mailing_class": "first_class", + "merge_variables": {"foo": "bar"}, + "metadata": {"foo": "string"}, + "outside_template": "outsideTemplate", + "pdf": "https://example.com", + "size": "8.5x11_bifold_v", + }, ) assert_matches_type(Campaign, campaign, path=["response"]) diff --git a/tests/api_resources/print_mail/test_postcards.py b/tests/api_resources/print_mail/test_postcards.py index dbae238..cb47fc4 100644 --- a/tests/api_resources/print_mail/test_postcards.py +++ b/tests/api_resources/print_mail/test_postcards.py @@ -84,6 +84,7 @@ def test_method_create_with_all_params_overload_1(self, client: PostGrid) -> Non mailing_class="first_class", merge_variables={"foo": "bar"}, metadata={"foo": "bar"}, + paper="premium_paper_L6fw2k_N_j", send_date=parse_datetime("2019-12-27T18:11:19.117Z"), ) assert_matches_type(Postcard, postcard, path=["response"]) @@ -225,6 +226,7 @@ def test_method_create_with_all_params_overload_3(self, client: PostGrid) -> Non mailing_class="first_class", merge_variables={"foo": "bar"}, metadata={"foo": "bar"}, + paper="premium_paper_L6fw2k_N_j", send_date=parse_datetime("2019-12-27T18:11:19.117Z"), ) assert_matches_type(Postcard, postcard, path=["response"]) @@ -327,6 +329,7 @@ def test_method_create_with_all_params_overload_4(self, client: PostGrid) -> Non mailing_class="first_class", merge_variables={"foo": "bar"}, metadata={"foo": "bar"}, + paper="premium_paper_L6fw2k_N_j", send_date=parse_datetime("2019-12-27T18:11:19.117Z"), ) assert_matches_type(Postcard, postcard, path=["response"]) @@ -601,6 +604,7 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn mailing_class="first_class", merge_variables={"foo": "bar"}, metadata={"foo": "bar"}, + paper="premium_paper_L6fw2k_N_j", send_date=parse_datetime("2019-12-27T18:11:19.117Z"), ) assert_matches_type(Postcard, postcard, path=["response"]) @@ -742,6 +746,7 @@ async def test_method_create_with_all_params_overload_3(self, async_client: Asyn mailing_class="first_class", merge_variables={"foo": "bar"}, metadata={"foo": "bar"}, + paper="premium_paper_L6fw2k_N_j", send_date=parse_datetime("2019-12-27T18:11:19.117Z"), ) assert_matches_type(Postcard, postcard, path=["response"]) @@ -844,6 +849,7 @@ async def test_method_create_with_all_params_overload_4(self, async_client: Asyn mailing_class="first_class", merge_variables={"foo": "bar"}, metadata={"foo": "bar"}, + paper="premium_paper_L6fw2k_N_j", send_date=parse_datetime("2019-12-27T18:11:19.117Z"), ) assert_matches_type(Postcard, postcard, path=["response"]) diff --git a/tests/api_resources/test_address_verification.py b/tests/api_resources/test_address_verification.py index 184a596..afdc9f9 100644 --- a/tests/api_resources/test_address_verification.py +++ b/tests/api_resources/test_address_verification.py @@ -9,7 +9,17 @@ from postgrid import PostGrid, AsyncPostGrid from tests.utils import assert_matches_type -from postgrid.types import AddressVerificationVerifyResponse +from postgrid.types import ( + AddressVerificationVerifyResponse, + AddressVerificationAutocompleteResponse, + AddressVerificationGetLookupInfoResponse, + AddressVerificationParseAnAddressResponse, + AddressVerificationSuggestAddressesResponse, + AddressVerificationBatchVerificationResponse, + AddressVerificationGetAutocompletePreviewsResponse, + AddressVerificationLookupZipCodeFromCityOrStateResponse, + AddressVerificationLookupCityOrStateFromPostalOrZipCodeResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -19,53 +29,354 @@ class TestAddressVerification: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - def test_method_verify_overload_1(self, client: PostGrid) -> None: - address_verification = client.address_verification.verify( + def test_method_autocomplete(self, client: PostGrid) -> None: + address_verification = client.address_verification.autocomplete( + partial_street="partialStreet", + ) + assert_matches_type(AddressVerificationAutocompleteResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_autocomplete_with_all_params(self, client: PostGrid) -> None: + address_verification = client.address_verification.autocomplete( + partial_street="partialStreet", + filter_exact=True, + geocode=True, + include_details=True, + index=0, + limit=0, + proper_case=True, + query_verified_only=True, + verify=True, + city_filter="cityFilter", + country_filter="countryFilter", + pc_filter="pcFilter", + state_filter="stateFilter", + body_verified_only=True, + ) + assert_matches_type(AddressVerificationAutocompleteResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_autocomplete(self, client: PostGrid) -> None: + response = client.address_verification.with_raw_response.autocomplete( + partial_street="partialStreet", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + address_verification = response.parse() + assert_matches_type(AddressVerificationAutocompleteResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_autocomplete(self, client: PostGrid) -> None: + with client.address_verification.with_streaming_response.autocomplete( + partial_street="partialStreet", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + address_verification = response.parse() + assert_matches_type(AddressVerificationAutocompleteResponse, address_verification, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_batch_verification(self, client: PostGrid) -> None: + address_verification = client.address_verification.batch_verification( + addresses=[{"address": "address"}], + ) + assert_matches_type(AddressVerificationBatchVerificationResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_batch_verification_with_all_params(self, client: PostGrid) -> None: + address_verification = client.address_verification.batch_verification( + addresses=[{"address": "address"}], + geocode=True, + include_details=True, + proper_case=True, + ) + assert_matches_type(AddressVerificationBatchVerificationResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_batch_verification(self, client: PostGrid) -> None: + response = client.address_verification.with_raw_response.batch_verification( + addresses=[{"address": "address"}], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + address_verification = response.parse() + assert_matches_type(AddressVerificationBatchVerificationResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_batch_verification(self, client: PostGrid) -> None: + with client.address_verification.with_streaming_response.batch_verification( + addresses=[{"address": "address"}], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + address_verification = response.parse() + assert_matches_type(AddressVerificationBatchVerificationResponse, address_verification, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_get_autocomplete_previews(self, client: PostGrid) -> None: + address_verification = client.address_verification.get_autocomplete_previews( + partial_street="partialStreet", + ) + assert_matches_type(AddressVerificationGetAutocompletePreviewsResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_get_autocomplete_previews_with_all_params(self, client: PostGrid) -> None: + address_verification = client.address_verification.get_autocomplete_previews( + partial_street="partialStreet", + city_filter="cityFilter", + country_filter="countryFilter", + filter_exact=True, + limit=0, + pc_filter="pcFilter", + proper_case=True, + prov_instead_of_pc=True, + state_filter="stateFilter", + verified_only=True, + ) + assert_matches_type(AddressVerificationGetAutocompletePreviewsResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_get_autocomplete_previews(self, client: PostGrid) -> None: + response = client.address_verification.with_raw_response.get_autocomplete_previews( + partial_street="partialStreet", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + address_verification = response.parse() + assert_matches_type(AddressVerificationGetAutocompletePreviewsResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_get_autocomplete_previews(self, client: PostGrid) -> None: + with client.address_verification.with_streaming_response.get_autocomplete_previews( + partial_street="partialStreet", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + address_verification = response.parse() + assert_matches_type( + AddressVerificationGetAutocompletePreviewsResponse, address_verification, path=["response"] + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_get_lookup_info(self, client: PostGrid) -> None: + address_verification = client.address_verification.get_lookup_info() + assert_matches_type(AddressVerificationGetLookupInfoResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_get_lookup_info(self, client: PostGrid) -> None: + response = client.address_verification.with_raw_response.get_lookup_info() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + address_verification = response.parse() + assert_matches_type(AddressVerificationGetLookupInfoResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_get_lookup_info(self, client: PostGrid) -> None: + with client.address_verification.with_streaming_response.get_lookup_info() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + address_verification = response.parse() + assert_matches_type(AddressVerificationGetLookupInfoResponse, address_verification, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_lookup_city_or_state_from_postal_or_zip_code(self, client: PostGrid) -> None: + address_verification = client.address_verification.lookup_city_or_state_from_postal_or_zip_code( + postal_or_zip="postalOrZip", + ) + assert_matches_type( + AddressVerificationLookupCityOrStateFromPostalOrZipCodeResponse, address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_lookup_city_or_state_from_postal_or_zip_code(self, client: PostGrid) -> None: + response = client.address_verification.with_raw_response.lookup_city_or_state_from_postal_or_zip_code( + postal_or_zip="postalOrZip", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + address_verification = response.parse() + assert_matches_type( + AddressVerificationLookupCityOrStateFromPostalOrZipCodeResponse, address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_lookup_city_or_state_from_postal_or_zip_code(self, client: PostGrid) -> None: + with client.address_verification.with_streaming_response.lookup_city_or_state_from_postal_or_zip_code( + postal_or_zip="postalOrZip", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + address_verification = response.parse() + assert_matches_type( + AddressVerificationLookupCityOrStateFromPostalOrZipCodeResponse, address_verification, path=["response"] + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_lookup_zip_code_from_city_or_state(self, client: PostGrid) -> None: + address_verification = client.address_verification.lookup_zip_code_from_city_or_state( + city="city", + country_code="countryCode", + state="state", + ) + assert_matches_type( + AddressVerificationLookupZipCodeFromCityOrStateResponse, address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_lookup_zip_code_from_city_or_state(self, client: PostGrid) -> None: + response = client.address_verification.with_raw_response.lookup_zip_code_from_city_or_state( + city="city", + country_code="countryCode", + state="state", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + address_verification = response.parse() + assert_matches_type( + AddressVerificationLookupZipCodeFromCityOrStateResponse, address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_lookup_zip_code_from_city_or_state(self, client: PostGrid) -> None: + with client.address_verification.with_streaming_response.lookup_zip_code_from_city_or_state( + city="city", + country_code="countryCode", + state="state", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + address_verification = response.parse() + assert_matches_type( + AddressVerificationLookupZipCodeFromCityOrStateResponse, address_verification, path=["response"] + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_parse_an_address(self, client: PostGrid) -> None: + address_verification = client.address_verification.parse_an_address( address="address", ) - assert_matches_type(AddressVerificationVerifyResponse, address_verification, path=["response"]) + assert_matches_type(AddressVerificationParseAnAddressResponse, address_verification, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - def test_method_verify_with_all_params_overload_1(self, client: PostGrid) -> None: - address_verification = client.address_verification.verify( + def test_raw_response_parse_an_address(self, client: PostGrid) -> None: + response = client.address_verification.with_raw_response.parse_an_address( + address="address", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + address_verification = response.parse() + assert_matches_type(AddressVerificationParseAnAddressResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_parse_an_address(self, client: PostGrid) -> None: + with client.address_verification.with_streaming_response.parse_an_address( + address="address", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + address_verification = response.parse() + assert_matches_type(AddressVerificationParseAnAddressResponse, address_verification, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_suggest_addresses_overload_1(self, client: PostGrid) -> None: + address_verification = client.address_verification.suggest_addresses( + address="address", + ) + assert_matches_type(AddressVerificationSuggestAddressesResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_suggest_addresses_with_all_params_overload_1(self, client: PostGrid) -> None: + address_verification = client.address_verification.suggest_addresses( address="address", geocode=True, include_details=True, proper_case=True, ) - assert_matches_type(AddressVerificationVerifyResponse, address_verification, path=["response"]) + assert_matches_type(AddressVerificationSuggestAddressesResponse, address_verification, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - def test_raw_response_verify_overload_1(self, client: PostGrid) -> None: - response = client.address_verification.with_raw_response.verify( + def test_raw_response_suggest_addresses_overload_1(self, client: PostGrid) -> None: + response = client.address_verification.with_raw_response.suggest_addresses( address="address", ) assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" address_verification = response.parse() - assert_matches_type(AddressVerificationVerifyResponse, address_verification, path=["response"]) + assert_matches_type(AddressVerificationSuggestAddressesResponse, address_verification, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - def test_streaming_response_verify_overload_1(self, client: PostGrid) -> None: - with client.address_verification.with_streaming_response.verify( + def test_streaming_response_suggest_addresses_overload_1(self, client: PostGrid) -> None: + with client.address_verification.with_streaming_response.suggest_addresses( address="address", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" address_verification = response.parse() - assert_matches_type(AddressVerificationVerifyResponse, address_verification, path=["response"]) + assert_matches_type(AddressVerificationSuggestAddressesResponse, address_verification, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - def test_method_verify_overload_2(self, client: PostGrid) -> None: - address_verification = client.address_verification.verify( + def test_method_suggest_addresses_overload_2(self, client: PostGrid) -> None: + address_verification = client.address_verification.suggest_addresses( address={ "city": "city", "country": "ca", @@ -74,12 +385,12 @@ def test_method_verify_overload_2(self, client: PostGrid) -> None: "province_or_state": "provinceOrState", }, ) - assert_matches_type(AddressVerificationVerifyResponse, address_verification, path=["response"]) + assert_matches_type(AddressVerificationSuggestAddressesResponse, address_verification, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - def test_method_verify_with_all_params_overload_2(self, client: PostGrid) -> None: - address_verification = client.address_verification.verify( + def test_method_suggest_addresses_with_all_params_overload_2(self, client: PostGrid) -> None: + address_verification = client.address_verification.suggest_addresses( address={ "city": "city", "country": "ca", @@ -93,12 +404,12 @@ def test_method_verify_with_all_params_overload_2(self, client: PostGrid) -> Non include_details=True, proper_case=True, ) - assert_matches_type(AddressVerificationVerifyResponse, address_verification, path=["response"]) + assert_matches_type(AddressVerificationSuggestAddressesResponse, address_verification, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - def test_raw_response_verify_overload_2(self, client: PostGrid) -> None: - response = client.address_verification.with_raw_response.verify( + def test_raw_response_suggest_addresses_overload_2(self, client: PostGrid) -> None: + response = client.address_verification.with_raw_response.suggest_addresses( address={ "city": "city", "country": "ca", @@ -111,12 +422,12 @@ def test_raw_response_verify_overload_2(self, client: PostGrid) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" address_verification = response.parse() - assert_matches_type(AddressVerificationVerifyResponse, address_verification, path=["response"]) + assert_matches_type(AddressVerificationSuggestAddressesResponse, address_verification, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - def test_streaming_response_verify_overload_2(self, client: PostGrid) -> None: - with client.address_verification.with_streaming_response.verify( + def test_streaming_response_suggest_addresses_overload_2(self, client: PostGrid) -> None: + with client.address_verification.with_streaming_response.suggest_addresses( address={ "city": "city", "country": "ca", @@ -129,15 +440,554 @@ def test_streaming_response_verify_overload_2(self, client: PostGrid) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" address_verification = response.parse() - assert_matches_type(AddressVerificationVerifyResponse, address_verification, path=["response"]) + assert_matches_type(AddressVerificationSuggestAddressesResponse, address_verification, path=["response"]) assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_verify_overload_1(self, client: PostGrid) -> None: + address_verification = client.address_verification.verify( + address="address", + ) + assert_matches_type(AddressVerificationVerifyResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_verify_with_all_params_overload_1(self, client: PostGrid) -> None: + address_verification = client.address_verification.verify( + address="address", + geocode=True, + include_details=True, + proper_case=True, + ) + assert_matches_type(AddressVerificationVerifyResponse, address_verification, path=["response"]) -class TestAsyncAddressVerification: - parametrize = pytest.mark.parametrize( - "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] - ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_verify_overload_1(self, client: PostGrid) -> None: + response = client.address_verification.with_raw_response.verify( + address="address", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + address_verification = response.parse() + assert_matches_type(AddressVerificationVerifyResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_verify_overload_1(self, client: PostGrid) -> None: + with client.address_verification.with_streaming_response.verify( + address="address", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + address_verification = response.parse() + assert_matches_type(AddressVerificationVerifyResponse, address_verification, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_verify_overload_2(self, client: PostGrid) -> None: + address_verification = client.address_verification.verify( + address={ + "city": "city", + "country": "ca", + "line1": "line1", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + }, + ) + assert_matches_type(AddressVerificationVerifyResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_verify_with_all_params_overload_2(self, client: PostGrid) -> None: + address_verification = client.address_verification.verify( + address={ + "city": "city", + "country": "ca", + "line1": "line1", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + "line2": "line2", + "recipient": "recipient", + }, + geocode=True, + include_details=True, + proper_case=True, + ) + assert_matches_type(AddressVerificationVerifyResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_verify_overload_2(self, client: PostGrid) -> None: + response = client.address_verification.with_raw_response.verify( + address={ + "city": "city", + "country": "ca", + "line1": "line1", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + }, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + address_verification = response.parse() + assert_matches_type(AddressVerificationVerifyResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_verify_overload_2(self, client: PostGrid) -> None: + with client.address_verification.with_streaming_response.verify( + address={ + "city": "city", + "country": "ca", + "line1": "line1", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + }, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + address_verification = response.parse() + assert_matches_type(AddressVerificationVerifyResponse, address_verification, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncAddressVerification: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_autocomplete(self, async_client: AsyncPostGrid) -> None: + address_verification = await async_client.address_verification.autocomplete( + partial_street="partialStreet", + ) + assert_matches_type(AddressVerificationAutocompleteResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_autocomplete_with_all_params(self, async_client: AsyncPostGrid) -> None: + address_verification = await async_client.address_verification.autocomplete( + partial_street="partialStreet", + filter_exact=True, + geocode=True, + include_details=True, + index=0, + limit=0, + proper_case=True, + query_verified_only=True, + verify=True, + city_filter="cityFilter", + country_filter="countryFilter", + pc_filter="pcFilter", + state_filter="stateFilter", + body_verified_only=True, + ) + assert_matches_type(AddressVerificationAutocompleteResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_autocomplete(self, async_client: AsyncPostGrid) -> None: + response = await async_client.address_verification.with_raw_response.autocomplete( + partial_street="partialStreet", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + address_verification = await response.parse() + assert_matches_type(AddressVerificationAutocompleteResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_autocomplete(self, async_client: AsyncPostGrid) -> None: + async with async_client.address_verification.with_streaming_response.autocomplete( + partial_street="partialStreet", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + address_verification = await response.parse() + assert_matches_type(AddressVerificationAutocompleteResponse, address_verification, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_batch_verification(self, async_client: AsyncPostGrid) -> None: + address_verification = await async_client.address_verification.batch_verification( + addresses=[{"address": "address"}], + ) + assert_matches_type(AddressVerificationBatchVerificationResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_batch_verification_with_all_params(self, async_client: AsyncPostGrid) -> None: + address_verification = await async_client.address_verification.batch_verification( + addresses=[{"address": "address"}], + geocode=True, + include_details=True, + proper_case=True, + ) + assert_matches_type(AddressVerificationBatchVerificationResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_batch_verification(self, async_client: AsyncPostGrid) -> None: + response = await async_client.address_verification.with_raw_response.batch_verification( + addresses=[{"address": "address"}], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + address_verification = await response.parse() + assert_matches_type(AddressVerificationBatchVerificationResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_batch_verification(self, async_client: AsyncPostGrid) -> None: + async with async_client.address_verification.with_streaming_response.batch_verification( + addresses=[{"address": "address"}], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + address_verification = await response.parse() + assert_matches_type(AddressVerificationBatchVerificationResponse, address_verification, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_get_autocomplete_previews(self, async_client: AsyncPostGrid) -> None: + address_verification = await async_client.address_verification.get_autocomplete_previews( + partial_street="partialStreet", + ) + assert_matches_type(AddressVerificationGetAutocompletePreviewsResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_get_autocomplete_previews_with_all_params(self, async_client: AsyncPostGrid) -> None: + address_verification = await async_client.address_verification.get_autocomplete_previews( + partial_street="partialStreet", + city_filter="cityFilter", + country_filter="countryFilter", + filter_exact=True, + limit=0, + pc_filter="pcFilter", + proper_case=True, + prov_instead_of_pc=True, + state_filter="stateFilter", + verified_only=True, + ) + assert_matches_type(AddressVerificationGetAutocompletePreviewsResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_get_autocomplete_previews(self, async_client: AsyncPostGrid) -> None: + response = await async_client.address_verification.with_raw_response.get_autocomplete_previews( + partial_street="partialStreet", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + address_verification = await response.parse() + assert_matches_type(AddressVerificationGetAutocompletePreviewsResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_get_autocomplete_previews(self, async_client: AsyncPostGrid) -> None: + async with async_client.address_verification.with_streaming_response.get_autocomplete_previews( + partial_street="partialStreet", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + address_verification = await response.parse() + assert_matches_type( + AddressVerificationGetAutocompletePreviewsResponse, address_verification, path=["response"] + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_get_lookup_info(self, async_client: AsyncPostGrid) -> None: + address_verification = await async_client.address_verification.get_lookup_info() + assert_matches_type(AddressVerificationGetLookupInfoResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_get_lookup_info(self, async_client: AsyncPostGrid) -> None: + response = await async_client.address_verification.with_raw_response.get_lookup_info() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + address_verification = await response.parse() + assert_matches_type(AddressVerificationGetLookupInfoResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_get_lookup_info(self, async_client: AsyncPostGrid) -> None: + async with async_client.address_verification.with_streaming_response.get_lookup_info() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + address_verification = await response.parse() + assert_matches_type(AddressVerificationGetLookupInfoResponse, address_verification, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_lookup_city_or_state_from_postal_or_zip_code(self, async_client: AsyncPostGrid) -> None: + address_verification = await async_client.address_verification.lookup_city_or_state_from_postal_or_zip_code( + postal_or_zip="postalOrZip", + ) + assert_matches_type( + AddressVerificationLookupCityOrStateFromPostalOrZipCodeResponse, address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_lookup_city_or_state_from_postal_or_zip_code(self, async_client: AsyncPostGrid) -> None: + response = ( + await async_client.address_verification.with_raw_response.lookup_city_or_state_from_postal_or_zip_code( + postal_or_zip="postalOrZip", + ) + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + address_verification = await response.parse() + assert_matches_type( + AddressVerificationLookupCityOrStateFromPostalOrZipCodeResponse, address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_lookup_city_or_state_from_postal_or_zip_code( + self, async_client: AsyncPostGrid + ) -> None: + async with ( + async_client.address_verification.with_streaming_response.lookup_city_or_state_from_postal_or_zip_code( + postal_or_zip="postalOrZip", + ) + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + address_verification = await response.parse() + assert_matches_type( + AddressVerificationLookupCityOrStateFromPostalOrZipCodeResponse, address_verification, path=["response"] + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_lookup_zip_code_from_city_or_state(self, async_client: AsyncPostGrid) -> None: + address_verification = await async_client.address_verification.lookup_zip_code_from_city_or_state( + city="city", + country_code="countryCode", + state="state", + ) + assert_matches_type( + AddressVerificationLookupZipCodeFromCityOrStateResponse, address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_lookup_zip_code_from_city_or_state(self, async_client: AsyncPostGrid) -> None: + response = await async_client.address_verification.with_raw_response.lookup_zip_code_from_city_or_state( + city="city", + country_code="countryCode", + state="state", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + address_verification = await response.parse() + assert_matches_type( + AddressVerificationLookupZipCodeFromCityOrStateResponse, address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_lookup_zip_code_from_city_or_state(self, async_client: AsyncPostGrid) -> None: + async with async_client.address_verification.with_streaming_response.lookup_zip_code_from_city_or_state( + city="city", + country_code="countryCode", + state="state", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + address_verification = await response.parse() + assert_matches_type( + AddressVerificationLookupZipCodeFromCityOrStateResponse, address_verification, path=["response"] + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_parse_an_address(self, async_client: AsyncPostGrid) -> None: + address_verification = await async_client.address_verification.parse_an_address( + address="address", + ) + assert_matches_type(AddressVerificationParseAnAddressResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_parse_an_address(self, async_client: AsyncPostGrid) -> None: + response = await async_client.address_verification.with_raw_response.parse_an_address( + address="address", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + address_verification = await response.parse() + assert_matches_type(AddressVerificationParseAnAddressResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_parse_an_address(self, async_client: AsyncPostGrid) -> None: + async with async_client.address_verification.with_streaming_response.parse_an_address( + address="address", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + address_verification = await response.parse() + assert_matches_type(AddressVerificationParseAnAddressResponse, address_verification, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_suggest_addresses_overload_1(self, async_client: AsyncPostGrid) -> None: + address_verification = await async_client.address_verification.suggest_addresses( + address="address", + ) + assert_matches_type(AddressVerificationSuggestAddressesResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_suggest_addresses_with_all_params_overload_1(self, async_client: AsyncPostGrid) -> None: + address_verification = await async_client.address_verification.suggest_addresses( + address="address", + geocode=True, + include_details=True, + proper_case=True, + ) + assert_matches_type(AddressVerificationSuggestAddressesResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_suggest_addresses_overload_1(self, async_client: AsyncPostGrid) -> None: + response = await async_client.address_verification.with_raw_response.suggest_addresses( + address="address", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + address_verification = await response.parse() + assert_matches_type(AddressVerificationSuggestAddressesResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_suggest_addresses_overload_1(self, async_client: AsyncPostGrid) -> None: + async with async_client.address_verification.with_streaming_response.suggest_addresses( + address="address", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + address_verification = await response.parse() + assert_matches_type(AddressVerificationSuggestAddressesResponse, address_verification, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_suggest_addresses_overload_2(self, async_client: AsyncPostGrid) -> None: + address_verification = await async_client.address_verification.suggest_addresses( + address={ + "city": "city", + "country": "ca", + "line1": "line1", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + }, + ) + assert_matches_type(AddressVerificationSuggestAddressesResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_suggest_addresses_with_all_params_overload_2(self, async_client: AsyncPostGrid) -> None: + address_verification = await async_client.address_verification.suggest_addresses( + address={ + "city": "city", + "country": "ca", + "line1": "line1", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + "line2": "line2", + "recipient": "recipient", + }, + geocode=True, + include_details=True, + proper_case=True, + ) + assert_matches_type(AddressVerificationSuggestAddressesResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_suggest_addresses_overload_2(self, async_client: AsyncPostGrid) -> None: + response = await async_client.address_verification.with_raw_response.suggest_addresses( + address={ + "city": "city", + "country": "ca", + "line1": "line1", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + }, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + address_verification = await response.parse() + assert_matches_type(AddressVerificationSuggestAddressesResponse, address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_suggest_addresses_overload_2(self, async_client: AsyncPostGrid) -> None: + async with async_client.address_verification.with_streaming_response.suggest_addresses( + address={ + "city": "city", + "country": "ca", + "line1": "line1", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + }, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + address_verification = await response.parse() + assert_matches_type(AddressVerificationSuggestAddressesResponse, address_verification, path=["response"]) + + assert cast(Any, response.is_closed) is True @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize diff --git a/tests/api_resources/test_intl_address_verification.py b/tests/api_resources/test_intl_address_verification.py index 72226a4..558072e 100644 --- a/tests/api_resources/test_intl_address_verification.py +++ b/tests/api_resources/test_intl_address_verification.py @@ -9,7 +9,13 @@ from postgrid import PostGrid, AsyncPostGrid from tests.utils import assert_matches_type -from postgrid.types import IntlAddressVerificationVerifyResponse +from postgrid.types import ( + IntlAddressVerificationVerifyResponse, + IntlAddressVerificationAutocompleteResponse, + IntlAddressVerificationBatchVerificationResponse, + IntlAddressVerificationGetAutocompletePreviewsResponse, + IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -17,6 +23,260 @@ class TestIntlAddressVerification: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_autocomplete(self, client: PostGrid) -> None: + intl_address_verification = client.intl_address_verification.autocomplete( + id="id", + ) + assert_matches_type(IntlAddressVerificationAutocompleteResponse, intl_address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_autocomplete_with_all_params(self, client: PostGrid) -> None: + intl_address_verification = client.intl_address_verification.autocomplete( + id="id", + include_details=True, + proper_case=True, + use_enhanced_china_dataset=True, + verify=True, + ) + assert_matches_type(IntlAddressVerificationAutocompleteResponse, intl_address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_autocomplete(self, client: PostGrid) -> None: + response = client.intl_address_verification.with_raw_response.autocomplete( + id="id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + intl_address_verification = response.parse() + assert_matches_type(IntlAddressVerificationAutocompleteResponse, intl_address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_autocomplete(self, client: PostGrid) -> None: + with client.intl_address_verification.with_streaming_response.autocomplete( + id="id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + intl_address_verification = response.parse() + assert_matches_type( + IntlAddressVerificationAutocompleteResponse, intl_address_verification, path=["response"] + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_batch_verification(self, client: PostGrid) -> None: + intl_address_verification = client.intl_address_verification.batch_verification( + addresses=[ + { + "address": { + "country": "country", + "line1": "line1", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + } + } + ], + ) + assert_matches_type( + IntlAddressVerificationBatchVerificationResponse, intl_address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_batch_verification_with_all_params(self, client: PostGrid) -> None: + intl_address_verification = client.intl_address_verification.batch_verification( + addresses=[ + { + "address": { + "country": "country", + "line1": "line1", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + "city": "city", + "line2": "line2", + "line3": "line3", + "line4": "line4", + } + } + ], + geo_data=True, + include_details=True, + proper_case=True, + use_enhanced_china_dataset=True, + ) + assert_matches_type( + IntlAddressVerificationBatchVerificationResponse, intl_address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_batch_verification(self, client: PostGrid) -> None: + response = client.intl_address_verification.with_raw_response.batch_verification( + addresses=[ + { + "address": { + "country": "country", + "line1": "line1", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + } + } + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + intl_address_verification = response.parse() + assert_matches_type( + IntlAddressVerificationBatchVerificationResponse, intl_address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_batch_verification(self, client: PostGrid) -> None: + with client.intl_address_verification.with_streaming_response.batch_verification( + addresses=[ + { + "address": { + "country": "country", + "line1": "line1", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + } + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + intl_address_verification = response.parse() + assert_matches_type( + IntlAddressVerificationBatchVerificationResponse, intl_address_verification, path=["response"] + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_get_autocomplete_advanced_previews(self, client: PostGrid) -> None: + intl_address_verification = client.intl_address_verification.get_autocomplete_advanced_previews() + assert_matches_type( + IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse, intl_address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_get_autocomplete_advanced_previews_with_all_params(self, client: PostGrid) -> None: + intl_address_verification = client.intl_address_verification.get_autocomplete_advanced_previews( + advanced=True, + city_filter="cityFilter", + container="container", + countries_filter="countriesFilter", + disable_ip_biasing=True, + language="language", + limit=0, + partial_street="partialStreet", + postal_or_zip_filter="postalOrZipFilter", + standard_fallback=True, + street_filter="streetFilter", + use_enhanced_china_dataset=True, + ) + assert_matches_type( + IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse, intl_address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_get_autocomplete_advanced_previews(self, client: PostGrid) -> None: + response = client.intl_address_verification.with_raw_response.get_autocomplete_advanced_previews() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + intl_address_verification = response.parse() + assert_matches_type( + IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse, intl_address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_get_autocomplete_advanced_previews(self, client: PostGrid) -> None: + with client.intl_address_verification.with_streaming_response.get_autocomplete_advanced_previews() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + intl_address_verification = response.parse() + assert_matches_type( + IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse, + intl_address_verification, + path=["response"], + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_get_autocomplete_previews(self, client: PostGrid) -> None: + intl_address_verification = client.intl_address_verification.get_autocomplete_previews() + assert_matches_type( + IntlAddressVerificationGetAutocompletePreviewsResponse, intl_address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_get_autocomplete_previews_with_all_params(self, client: PostGrid) -> None: + intl_address_verification = client.intl_address_verification.get_autocomplete_previews( + advanced=True, + city_filter="cityFilter", + container="container", + countries_filter="countriesFilter", + disable_ip_biasing=True, + language="language", + limit=0, + partial_street="partialStreet", + postal_or_zip_filter="postalOrZipFilter", + standard_fallback=True, + street_filter="streetFilter", + use_enhanced_china_dataset=True, + ) + assert_matches_type( + IntlAddressVerificationGetAutocompletePreviewsResponse, intl_address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_get_autocomplete_previews(self, client: PostGrid) -> None: + response = client.intl_address_verification.with_raw_response.get_autocomplete_previews() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + intl_address_verification = response.parse() + assert_matches_type( + IntlAddressVerificationGetAutocompletePreviewsResponse, intl_address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_get_autocomplete_previews(self, client: PostGrid) -> None: + with client.intl_address_verification.with_streaming_response.get_autocomplete_previews() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + intl_address_verification = response.parse() + assert_matches_type( + IntlAddressVerificationGetAutocompletePreviewsResponse, intl_address_verification, path=["response"] + ) + + assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_verify_overload_1(self, client: PostGrid) -> None: @@ -137,6 +397,264 @@ class TestAsyncIntlAddressVerification: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_autocomplete(self, async_client: AsyncPostGrid) -> None: + intl_address_verification = await async_client.intl_address_verification.autocomplete( + id="id", + ) + assert_matches_type(IntlAddressVerificationAutocompleteResponse, intl_address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_autocomplete_with_all_params(self, async_client: AsyncPostGrid) -> None: + intl_address_verification = await async_client.intl_address_verification.autocomplete( + id="id", + include_details=True, + proper_case=True, + use_enhanced_china_dataset=True, + verify=True, + ) + assert_matches_type(IntlAddressVerificationAutocompleteResponse, intl_address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_autocomplete(self, async_client: AsyncPostGrid) -> None: + response = await async_client.intl_address_verification.with_raw_response.autocomplete( + id="id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + intl_address_verification = await response.parse() + assert_matches_type(IntlAddressVerificationAutocompleteResponse, intl_address_verification, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_autocomplete(self, async_client: AsyncPostGrid) -> None: + async with async_client.intl_address_verification.with_streaming_response.autocomplete( + id="id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + intl_address_verification = await response.parse() + assert_matches_type( + IntlAddressVerificationAutocompleteResponse, intl_address_verification, path=["response"] + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_batch_verification(self, async_client: AsyncPostGrid) -> None: + intl_address_verification = await async_client.intl_address_verification.batch_verification( + addresses=[ + { + "address": { + "country": "country", + "line1": "line1", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + } + } + ], + ) + assert_matches_type( + IntlAddressVerificationBatchVerificationResponse, intl_address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_batch_verification_with_all_params(self, async_client: AsyncPostGrid) -> None: + intl_address_verification = await async_client.intl_address_verification.batch_verification( + addresses=[ + { + "address": { + "country": "country", + "line1": "line1", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + "city": "city", + "line2": "line2", + "line3": "line3", + "line4": "line4", + } + } + ], + geo_data=True, + include_details=True, + proper_case=True, + use_enhanced_china_dataset=True, + ) + assert_matches_type( + IntlAddressVerificationBatchVerificationResponse, intl_address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_batch_verification(self, async_client: AsyncPostGrid) -> None: + response = await async_client.intl_address_verification.with_raw_response.batch_verification( + addresses=[ + { + "address": { + "country": "country", + "line1": "line1", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + } + } + ], + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + intl_address_verification = await response.parse() + assert_matches_type( + IntlAddressVerificationBatchVerificationResponse, intl_address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_batch_verification(self, async_client: AsyncPostGrid) -> None: + async with async_client.intl_address_verification.with_streaming_response.batch_verification( + addresses=[ + { + "address": { + "country": "country", + "line1": "line1", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + } + } + ], + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + intl_address_verification = await response.parse() + assert_matches_type( + IntlAddressVerificationBatchVerificationResponse, intl_address_verification, path=["response"] + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_get_autocomplete_advanced_previews(self, async_client: AsyncPostGrid) -> None: + intl_address_verification = await async_client.intl_address_verification.get_autocomplete_advanced_previews() + assert_matches_type( + IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse, intl_address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_get_autocomplete_advanced_previews_with_all_params(self, async_client: AsyncPostGrid) -> None: + intl_address_verification = await async_client.intl_address_verification.get_autocomplete_advanced_previews( + advanced=True, + city_filter="cityFilter", + container="container", + countries_filter="countriesFilter", + disable_ip_biasing=True, + language="language", + limit=0, + partial_street="partialStreet", + postal_or_zip_filter="postalOrZipFilter", + standard_fallback=True, + street_filter="streetFilter", + use_enhanced_china_dataset=True, + ) + assert_matches_type( + IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse, intl_address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_get_autocomplete_advanced_previews(self, async_client: AsyncPostGrid) -> None: + response = await async_client.intl_address_verification.with_raw_response.get_autocomplete_advanced_previews() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + intl_address_verification = await response.parse() + assert_matches_type( + IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse, intl_address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_get_autocomplete_advanced_previews(self, async_client: AsyncPostGrid) -> None: + async with ( + async_client.intl_address_verification.with_streaming_response.get_autocomplete_advanced_previews() + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + intl_address_verification = await response.parse() + assert_matches_type( + IntlAddressVerificationGetAutocompleteAdvancedPreviewsResponse, + intl_address_verification, + path=["response"], + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_get_autocomplete_previews(self, async_client: AsyncPostGrid) -> None: + intl_address_verification = await async_client.intl_address_verification.get_autocomplete_previews() + assert_matches_type( + IntlAddressVerificationGetAutocompletePreviewsResponse, intl_address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_get_autocomplete_previews_with_all_params(self, async_client: AsyncPostGrid) -> None: + intl_address_verification = await async_client.intl_address_verification.get_autocomplete_previews( + advanced=True, + city_filter="cityFilter", + container="container", + countries_filter="countriesFilter", + disable_ip_biasing=True, + language="language", + limit=0, + partial_street="partialStreet", + postal_or_zip_filter="postalOrZipFilter", + standard_fallback=True, + street_filter="streetFilter", + use_enhanced_china_dataset=True, + ) + assert_matches_type( + IntlAddressVerificationGetAutocompletePreviewsResponse, intl_address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_get_autocomplete_previews(self, async_client: AsyncPostGrid) -> None: + response = await async_client.intl_address_verification.with_raw_response.get_autocomplete_previews() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + intl_address_verification = await response.parse() + assert_matches_type( + IntlAddressVerificationGetAutocompletePreviewsResponse, intl_address_verification, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_get_autocomplete_previews(self, async_client: AsyncPostGrid) -> None: + async with ( + async_client.intl_address_verification.with_streaming_response.get_autocomplete_previews() + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + intl_address_verification = await response.parse() + assert_matches_type( + IntlAddressVerificationGetAutocompletePreviewsResponse, intl_address_verification, path=["response"] + ) + + assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_verify_overload_1(self, async_client: AsyncPostGrid) -> None: From bdc7fef6407b6906f7289f302a1281bc76730297 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 5 May 2026 17:27:41 +0000 Subject: [PATCH 09/14] feat(api): sheikh's updates - Added config for template editor sessions and trackers - Added pagination:true for retrieve tracker visits (odd name, why not list) - Re-ordered routes to be closer to their logical neighbours (Campaigns with Mailing Lists and Mailing List Imports, Bank Account and Cheques together and more) --- .stats.yml | 8 +- api.md | 317 +++- src/postgrid/resources/print_mail/__init__.py | 156 +- src/postgrid/resources/print_mail/boxes.py | 712 +++++++++ src/postgrid/resources/print_mail/cheques.py | 178 ++- src/postgrid/resources/print_mail/letters.py | 177 +++ .../resources/print_mail/mailing_lists.py | 10 + .../resources/print_mail/postcards.py | 178 ++- .../resources/print_mail/print_mail.py | 1002 ++++++++++-- .../resources/print_mail/self_mailers.py | 90 ++ .../resources/print_mail/snap_packs.py | 1375 +++++++++++++++++ .../resources/print_mail/sub_organizations.py | 26 + .../targeted_list_builds/__init__.py | 33 + .../targeted_list_builds/filters.py | 259 ++++ .../targeted_list_builds.py | 1003 ++++++++++++ .../print_mail/template_editor_sessions.py | 449 ++++++ src/postgrid/resources/print_mail/trackers.py | 757 +++++++++ .../print_mail/virtual_mailboxes/__init__.py | 33 + .../print_mail/virtual_mailboxes/items.py | 434 ++++++ .../virtual_mailboxes/virtual_mailboxes.py | 589 +++++++ src/postgrid/types/__init__.py | 4 - src/postgrid/types/print_mail/__init__.py | 69 + .../types/print_mail/box_create_params.py | 141 ++ .../types/print_mail/box_create_response.py | 198 +++ .../types/print_mail/box_delete_response.py | 198 +++ .../types/print_mail/box_list_params.py | 22 + .../types/print_mail/box_list_response.py | 198 +++ .../print_mail/box_progressions_response.py | 198 +++ .../types/print_mail/box_retrieve_response.py | 198 +++ .../types/print_mail/cheque_cancel_params.py | 11 + .../types/print_mail/cheque_create_params.py | 4 +- .../types/print_mail/contact_create_param.py | 4 +- .../contact_create_with_company_name_param.py | 2 +- .../contact_create_with_first_name_param.py | 2 +- .../types/print_mail/letter_cancel_params.py | 11 + .../types/print_mail/letter_create_params.py | 4 +- .../print_mail/postcard_cancel_params.py | 11 + .../print_mail/postcard_create_params.py | 4 +- .../print_mail/self_mailer_create_params.py | 4 +- .../print_mail/snap_pack_create_params.py | 313 ++++ .../print_mail/snap_pack_create_response.py | 196 +++ .../print_mail/snap_pack_delete_response.py | 196 +++ .../types/print_mail/snap_pack_list_params.py | 22 + .../print_mail/snap_pack_list_response.py | 196 +++ .../snap_pack_progressions_response.py | 196 +++ .../snap_pack_retrieve_capabilities_params.py | 26 + ...nap_pack_retrieve_capabilities_response.py | 45 + .../print_mail/snap_pack_retrieve_response.py | 196 +++ .../targeted_list_build_confirm_response.py | 277 ++++ .../targeted_list_build_create_params.py | 169 ++ .../targeted_list_build_create_response.py | 277 ++++ .../targeted_list_build_delete_response.py | 14 + .../targeted_list_build_list_params.py | 22 + .../targeted_list_build_list_response.py | 277 ++++ .../targeted_list_build_retrieve_response.py | 277 ++++ .../targeted_list_build_update_params.py | 167 ++ .../targeted_list_build_update_response.py | 277 ++++ .../targeted_list_builds/__init__.py | 6 + .../filter_autocomplete_params.py | 21 + .../filter_autocomplete_response.py | 26 + .../template_editor_session_create_params.py | 65 + ...template_editor_session_create_response.py | 80 + ...template_editor_session_delete_response.py | 17 + .../template_editor_session_list_params.py | 22 + .../template_editor_session_list_response.py | 80 + .../types/print_mail/tracker_create_params.py | 27 + .../print_mail/tracker_create_response.py | 50 + .../print_mail/tracker_delete_response.py | 17 + .../types/print_mail/tracker_list_params.py | 22 + .../types/print_mail/tracker_list_response.py | 50 + .../print_mail/tracker_retrieve_response.py | 50 + .../tracker_retrieve_visits_params.py | 22 + .../tracker_retrieve_visits_response.py | 39 + .../types/print_mail/tracker_update_params.py | 27 + .../print_mail/tracker_update_response.py | 50 + .../virtual_mailbox_create_params.py | 33 + .../virtual_mailbox_create_response.py | 60 + .../print_mail/virtual_mailbox_list_params.py | 22 + .../virtual_mailbox_list_response.py | 60 + ...rtual_mailbox_retrieve_address_response.py | 32 + .../virtual_mailbox_retrieve_response.py | 60 + .../print_mail/virtual_mailboxes/__init__.py | 9 + .../virtual_mailboxes/item_create_params.py | 21 + .../virtual_mailboxes/item_create_response.py | 49 + .../virtual_mailboxes/item_list_params.py | 22 + .../virtual_mailboxes/item_list_response.py | 49 + .../item_retrieve_response.py | 49 + .../targeted_list_builds/__init__.py | 1 + .../targeted_list_builds/test_filters.py | 112 ++ tests/api_resources/print_mail/test_boxes.py | 542 +++++++ .../api_resources/print_mail/test_cheques.py | 176 +++ .../api_resources/print_mail/test_letters.py | 176 +++ .../print_mail/test_postcards.py | 176 +++ .../print_mail/test_self_mailers.py | 84 + .../print_mail/test_snap_packs.py | 1167 ++++++++++++++ .../print_mail/test_targeted_list_builds.py | 640 ++++++++ .../test_template_editor_sessions.py | 311 ++++ .../api_resources/print_mail/test_trackers.py | 602 ++++++++ .../print_mail/test_virtual_mailboxes.py | 366 +++++ .../print_mail/virtual_mailboxes/__init__.py | 1 + .../virtual_mailboxes/test_items.py | 345 +++++ 101 files changed, 17790 insertions(+), 258 deletions(-) create mode 100644 src/postgrid/resources/print_mail/boxes.py create mode 100644 src/postgrid/resources/print_mail/snap_packs.py create mode 100644 src/postgrid/resources/print_mail/targeted_list_builds/__init__.py create mode 100644 src/postgrid/resources/print_mail/targeted_list_builds/filters.py create mode 100644 src/postgrid/resources/print_mail/targeted_list_builds/targeted_list_builds.py create mode 100644 src/postgrid/resources/print_mail/template_editor_sessions.py create mode 100644 src/postgrid/resources/print_mail/trackers.py create mode 100644 src/postgrid/resources/print_mail/virtual_mailboxes/__init__.py create mode 100644 src/postgrid/resources/print_mail/virtual_mailboxes/items.py create mode 100644 src/postgrid/resources/print_mail/virtual_mailboxes/virtual_mailboxes.py create mode 100644 src/postgrid/types/print_mail/box_create_params.py create mode 100644 src/postgrid/types/print_mail/box_create_response.py create mode 100644 src/postgrid/types/print_mail/box_delete_response.py create mode 100644 src/postgrid/types/print_mail/box_list_params.py create mode 100644 src/postgrid/types/print_mail/box_list_response.py create mode 100644 src/postgrid/types/print_mail/box_progressions_response.py create mode 100644 src/postgrid/types/print_mail/box_retrieve_response.py create mode 100644 src/postgrid/types/print_mail/cheque_cancel_params.py rename src/postgrid/types/{ => print_mail}/contact_create_with_company_name_param.py (98%) rename src/postgrid/types/{ => print_mail}/contact_create_with_first_name_param.py (98%) create mode 100644 src/postgrid/types/print_mail/letter_cancel_params.py create mode 100644 src/postgrid/types/print_mail/postcard_cancel_params.py create mode 100644 src/postgrid/types/print_mail/snap_pack_create_params.py create mode 100644 src/postgrid/types/print_mail/snap_pack_create_response.py create mode 100644 src/postgrid/types/print_mail/snap_pack_delete_response.py create mode 100644 src/postgrid/types/print_mail/snap_pack_list_params.py create mode 100644 src/postgrid/types/print_mail/snap_pack_list_response.py create mode 100644 src/postgrid/types/print_mail/snap_pack_progressions_response.py create mode 100644 src/postgrid/types/print_mail/snap_pack_retrieve_capabilities_params.py create mode 100644 src/postgrid/types/print_mail/snap_pack_retrieve_capabilities_response.py create mode 100644 src/postgrid/types/print_mail/snap_pack_retrieve_response.py create mode 100644 src/postgrid/types/print_mail/targeted_list_build_confirm_response.py create mode 100644 src/postgrid/types/print_mail/targeted_list_build_create_params.py create mode 100644 src/postgrid/types/print_mail/targeted_list_build_create_response.py create mode 100644 src/postgrid/types/print_mail/targeted_list_build_delete_response.py create mode 100644 src/postgrid/types/print_mail/targeted_list_build_list_params.py create mode 100644 src/postgrid/types/print_mail/targeted_list_build_list_response.py create mode 100644 src/postgrid/types/print_mail/targeted_list_build_retrieve_response.py create mode 100644 src/postgrid/types/print_mail/targeted_list_build_update_params.py create mode 100644 src/postgrid/types/print_mail/targeted_list_build_update_response.py create mode 100644 src/postgrid/types/print_mail/targeted_list_builds/__init__.py create mode 100644 src/postgrid/types/print_mail/targeted_list_builds/filter_autocomplete_params.py create mode 100644 src/postgrid/types/print_mail/targeted_list_builds/filter_autocomplete_response.py create mode 100644 src/postgrid/types/print_mail/template_editor_session_create_params.py create mode 100644 src/postgrid/types/print_mail/template_editor_session_create_response.py create mode 100644 src/postgrid/types/print_mail/template_editor_session_delete_response.py create mode 100644 src/postgrid/types/print_mail/template_editor_session_list_params.py create mode 100644 src/postgrid/types/print_mail/template_editor_session_list_response.py create mode 100644 src/postgrid/types/print_mail/tracker_create_params.py create mode 100644 src/postgrid/types/print_mail/tracker_create_response.py create mode 100644 src/postgrid/types/print_mail/tracker_delete_response.py create mode 100644 src/postgrid/types/print_mail/tracker_list_params.py create mode 100644 src/postgrid/types/print_mail/tracker_list_response.py create mode 100644 src/postgrid/types/print_mail/tracker_retrieve_response.py create mode 100644 src/postgrid/types/print_mail/tracker_retrieve_visits_params.py create mode 100644 src/postgrid/types/print_mail/tracker_retrieve_visits_response.py create mode 100644 src/postgrid/types/print_mail/tracker_update_params.py create mode 100644 src/postgrid/types/print_mail/tracker_update_response.py create mode 100644 src/postgrid/types/print_mail/virtual_mailbox_create_params.py create mode 100644 src/postgrid/types/print_mail/virtual_mailbox_create_response.py create mode 100644 src/postgrid/types/print_mail/virtual_mailbox_list_params.py create mode 100644 src/postgrid/types/print_mail/virtual_mailbox_list_response.py create mode 100644 src/postgrid/types/print_mail/virtual_mailbox_retrieve_address_response.py create mode 100644 src/postgrid/types/print_mail/virtual_mailbox_retrieve_response.py create mode 100644 src/postgrid/types/print_mail/virtual_mailboxes/__init__.py create mode 100644 src/postgrid/types/print_mail/virtual_mailboxes/item_create_params.py create mode 100644 src/postgrid/types/print_mail/virtual_mailboxes/item_create_response.py create mode 100644 src/postgrid/types/print_mail/virtual_mailboxes/item_list_params.py create mode 100644 src/postgrid/types/print_mail/virtual_mailboxes/item_list_response.py create mode 100644 src/postgrid/types/print_mail/virtual_mailboxes/item_retrieve_response.py create mode 100644 tests/api_resources/print_mail/targeted_list_builds/__init__.py create mode 100644 tests/api_resources/print_mail/targeted_list_builds/test_filters.py create mode 100644 tests/api_resources/print_mail/test_boxes.py create mode 100644 tests/api_resources/print_mail/test_snap_packs.py create mode 100644 tests/api_resources/print_mail/test_targeted_list_builds.py create mode 100644 tests/api_resources/print_mail/test_template_editor_sessions.py create mode 100644 tests/api_resources/print_mail/test_trackers.py create mode 100644 tests/api_resources/print_mail/test_virtual_mailboxes.py create mode 100644 tests/api_resources/print_mail/virtual_mailboxes/__init__.py create mode 100644 tests/api_resources/print_mail/virtual_mailboxes/test_items.py diff --git a/.stats.yml b/.stats.yml index 641e7c9..1b3eb7f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 78 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/postgrid/postgrid-65072e2fb134f32ca48c7c05c1a03e5f78a8622c084a8b56b91a0e10955e02a8.yml -openapi_spec_hash: 6dc0a877bf8ec7526d6557d4b232a332 -config_hash: 2916502bb96c402e0d3d8c8c6e804206 +configured_endpoints: 119 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/postgrid/postgrid-c0cbc48dd2e521e8bcf17c9e76d60390fd5e797a0c2529e29a382fe629628fb7.yml +openapi_spec_hash: 3562a11137635f5a513f3c1ae8421fda +config_hash: a9de56c02f36eab1b7bc2758f27e5f8c diff --git a/api.md b/api.md index b9f1bb5..a5febf1 100644 --- a/api.md +++ b/api.md @@ -54,43 +54,124 @@ Methods: # PrintMail +## Contacts + Types: ```python -from postgrid.types import ContactCreateWithCompanyName, ContactCreateWithFirstName +from postgrid.types.print_mail import ( + Contact, + ContactCreate, + ContactCreateWithCompanyName, + ContactCreateWithFirstName, + ContactDeleteResponse, +) ``` -## BankAccounts +Methods: + +- client.print_mail.contacts.create(\*\*params) -> Contact +- client.print_mail.contacts.retrieve(id) -> Contact +- client.print_mail.contacts.list(\*\*params) -> SyncSkipLimit[Contact] +- client.print_mail.contacts.delete(id) -> ContactDeleteResponse + +## Templates Types: ```python -from postgrid.types.print_mail import BankAccount, BankAccountCountryCode, BankAccountDeleteResponse +from postgrid.types.print_mail import Template, TemplateDeleteResponse ``` Methods: -- client.print_mail.bank_accounts.create(\*\*params) -> BankAccount -- client.print_mail.bank_accounts.retrieve(id) -> BankAccount -- client.print_mail.bank_accounts.list(\*\*params) -> SyncSkipLimit[BankAccount] -- client.print_mail.bank_accounts.delete(id) -> BankAccountDeleteResponse +- client.print_mail.templates.create(\*\*params) -> Template +- client.print_mail.templates.retrieve(id) -> Template +- client.print_mail.templates.update(id, \*\*params) -> Template +- client.print_mail.templates.list(\*\*params) -> SyncSkipLimit[Template] +- client.print_mail.templates.delete(id) -> TemplateDeleteResponse -## Campaigns +## Trackers Types: ```python -from postgrid.types.print_mail import Campaign, CampaignDeleteResponse +from postgrid.types.print_mail import ( + TrackerCreateResponse, + TrackerRetrieveResponse, + TrackerUpdateResponse, + TrackerListResponse, + TrackerDeleteResponse, + TrackerRetrieveVisitsResponse, +) ``` Methods: -- client.print_mail.campaigns.create(\*\*params) -> Campaign -- client.print_mail.campaigns.retrieve(id) -> Campaign -- client.print_mail.campaigns.update(id, \*\*params) -> Campaign -- client.print_mail.campaigns.list(\*\*params) -> SyncSkipLimit[Campaign] -- client.print_mail.campaigns.delete(id) -> CampaignDeleteResponse -- client.print_mail.campaigns.send(id, \*\*params) -> Campaign +- client.print_mail.trackers.create(\*\*params) -> TrackerCreateResponse +- client.print_mail.trackers.retrieve(id) -> TrackerRetrieveResponse +- client.print_mail.trackers.update(id, \*\*params) -> TrackerUpdateResponse +- client.print_mail.trackers.list(\*\*params) -> SyncSkipLimit[TrackerListResponse] +- client.print_mail.trackers.delete(id) -> TrackerDeleteResponse +- client.print_mail.trackers.retrieve_visits(id, \*\*params) -> SyncSkipLimit[TrackerRetrieveVisitsResponse] + +## Letters + +Types: + +```python +from postgrid.types.print_mail import ( + AddressPlacement, + AttachedPdf, + Letter, + LetterSize, + PlasticCard, + LetterRetrieveURLResponse, +) +``` + +Methods: + +- client.print_mail.letters.create(\*\*params) -> Letter +- client.print_mail.letters.retrieve(id) -> Letter +- client.print_mail.letters.list(\*\*params) -> SyncSkipLimit[Letter] +- client.print_mail.letters.delete(id) -> Letter +- client.print_mail.letters.cancel(id, \*\*params) -> Letter +- client.print_mail.letters.progress(id) -> Letter +- client.print_mail.letters.retrieve_url(id) -> LetterRetrieveURLResponse + +## Postcards + +Types: + +```python +from postgrid.types.print_mail import Postcard, PostcardRetrieveURLResponse +``` + +Methods: + +- client.print_mail.postcards.create(\*\*params) -> Postcard +- client.print_mail.postcards.retrieve(id) -> Postcard +- client.print_mail.postcards.list(\*\*params) -> SyncSkipLimit[Postcard] +- client.print_mail.postcards.delete(id) -> Postcard +- client.print_mail.postcards.cancel(id, \*\*params) -> Postcard +- client.print_mail.postcards.progress(id) -> Postcard +- client.print_mail.postcards.retrieve_url(id) -> PostcardRetrieveURLResponse + +## BankAccounts + +Types: + +```python +from postgrid.types.print_mail import BankAccount, BankAccountCountryCode, BankAccountDeleteResponse +``` + +Methods: + +- client.print_mail.bank_accounts.create(\*\*params) -> BankAccount +- client.print_mail.bank_accounts.retrieve(id) -> BankAccount +- client.print_mail.bank_accounts.list(\*\*params) -> SyncSkipLimit[BankAccount] +- client.print_mail.bank_accounts.delete(id) -> BankAccountDeleteResponse ## Cheques @@ -106,46 +187,44 @@ Methods: - client.print_mail.cheques.retrieve(id) -> Cheque - client.print_mail.cheques.list(\*\*params) -> SyncSkipLimit[Cheque] - client.print_mail.cheques.delete(id) -> Cheque +- client.print_mail.cheques.cancel(id, \*\*params) -> Cheque +- client.print_mail.cheques.progress(id) -> Cheque - client.print_mail.cheques.retrieve_url(id) -> ChequeRetrieveURLResponse - client.print_mail.cheques.retrieve_with_deposit_ready_pdf(id) -> Cheque -## Contacts +## SelfMailers Types: ```python -from postgrid.types.print_mail import Contact, ContactCreate, ContactDeleteResponse +from postgrid.types.print_mail import SelfMailer, SelfMailerRetrieveURLResponse ``` Methods: -- client.print_mail.contacts.create(\*\*params) -> Contact -- client.print_mail.contacts.retrieve(id) -> Contact -- client.print_mail.contacts.list(\*\*params) -> SyncSkipLimit[Contact] -- client.print_mail.contacts.delete(id) -> ContactDeleteResponse +- client.print_mail.self_mailers.create(\*\*params) -> SelfMailer +- client.print_mail.self_mailers.retrieve(id) -> SelfMailer +- client.print_mail.self_mailers.list(\*\*params) -> SyncSkipLimit[SelfMailer] +- client.print_mail.self_mailers.delete(id) -> SelfMailer +- client.print_mail.self_mailers.progress(id) -> SelfMailer +- client.print_mail.self_mailers.retrieve_url(id) -> SelfMailerRetrieveURLResponse -## Letters +## Campaigns Types: ```python -from postgrid.types.print_mail import ( - AddressPlacement, - AttachedPdf, - Letter, - LetterSize, - PlasticCard, - LetterRetrieveURLResponse, -) +from postgrid.types.print_mail import Campaign, CampaignDeleteResponse ``` Methods: -- client.print_mail.letters.create(\*\*params) -> Letter -- client.print_mail.letters.retrieve(id) -> Letter -- client.print_mail.letters.list(\*\*params) -> SyncSkipLimit[Letter] -- client.print_mail.letters.delete(id) -> Letter -- client.print_mail.letters.retrieve_url(id) -> LetterRetrieveURLResponse +- client.print_mail.campaigns.create(\*\*params) -> Campaign +- client.print_mail.campaigns.retrieve(id) -> Campaign +- client.print_mail.campaigns.update(id, \*\*params) -> Campaign +- client.print_mail.campaigns.list(\*\*params) -> SyncSkipLimit[Campaign] +- client.print_mail.campaigns.delete(id) -> CampaignDeleteResponse +- client.print_mail.campaigns.send(id, \*\*params) -> Campaign ## MailingListImports @@ -185,22 +264,6 @@ Methods: - client.print_mail.mailing_lists.delete(id) -> MailingListDeleteResponse - client.print_mail.mailing_lists.jobs(id, \*\*params) -> MailingList -## Postcards - -Types: - -```python -from postgrid.types.print_mail import Postcard, PostcardRetrieveURLResponse -``` - -Methods: - -- client.print_mail.postcards.create(\*\*params) -> Postcard -- client.print_mail.postcards.retrieve(id) -> Postcard -- client.print_mail.postcards.list(\*\*params) -> SyncSkipLimit[Postcard] -- client.print_mail.postcards.delete(id) -> Postcard -- client.print_mail.postcards.retrieve_url(id) -> PostcardRetrieveURLResponse - ## Reports Types: @@ -244,22 +307,6 @@ Methods: - client.print_mail.reports.exports.retrieve(export_id, \*, report_id) -> ReportExport - client.print_mail.reports.exports.delete(export_id, \*, report_id) -> DeletedResponse -## SelfMailers - -Types: - -```python -from postgrid.types.print_mail import SelfMailer, SelfMailerRetrieveURLResponse -``` - -Methods: - -- client.print_mail.self_mailers.create(\*\*params) -> SelfMailer -- client.print_mail.self_mailers.retrieve(id) -> SelfMailer -- client.print_mail.self_mailers.list(\*\*params) -> SyncSkipLimit[SelfMailer] -- client.print_mail.self_mailers.delete(id) -> SelfMailer -- client.print_mail.self_mailers.retrieve_url(id) -> SelfMailerRetrieveURLResponse - ## SubOrganizations Types: @@ -280,18 +327,140 @@ Methods: - client.print_mail.sub_organizations.list(\*\*params) -> SyncSkipLimit[SubOrganization] - client.print_mail.sub_organizations.retrieve_users(id, \*\*params) -> SubOrganizationRetrieveUsersResponse -## Templates +## Boxes Types: ```python -from postgrid.types.print_mail import Template, TemplateDeleteResponse +from postgrid.types.print_mail import ( + BoxCreateResponse, + BoxRetrieveResponse, + BoxListResponse, + BoxDeleteResponse, + BoxProgressionsResponse, +) ``` Methods: -- client.print_mail.templates.create(\*\*params) -> Template -- client.print_mail.templates.retrieve(id) -> Template -- client.print_mail.templates.update(id, \*\*params) -> Template -- client.print_mail.templates.list(\*\*params) -> SyncSkipLimit[Template] -- client.print_mail.templates.delete(id) -> TemplateDeleteResponse +- client.print_mail.boxes.create(\*\*params) -> BoxCreateResponse +- client.print_mail.boxes.retrieve(id) -> BoxRetrieveResponse +- client.print_mail.boxes.list(\*\*params) -> SyncSkipLimit[BoxListResponse] +- client.print_mail.boxes.delete(id) -> BoxDeleteResponse +- client.print_mail.boxes.progressions(id) -> BoxProgressionsResponse + +## SnapPacks + +Types: + +```python +from postgrid.types.print_mail import ( + SnapPackCreateResponse, + SnapPackRetrieveResponse, + SnapPackListResponse, + SnapPackDeleteResponse, + SnapPackProgressionsResponse, + SnapPackRetrieveCapabilitiesResponse, +) +``` + +Methods: + +- client.print_mail.snap_packs.create(\*\*params) -> SnapPackCreateResponse +- client.print_mail.snap_packs.retrieve(id) -> SnapPackRetrieveResponse +- client.print_mail.snap_packs.list(\*\*params) -> SyncSkipLimit[SnapPackListResponse] +- client.print_mail.snap_packs.delete(id) -> SnapPackDeleteResponse +- client.print_mail.snap_packs.progressions(id) -> SnapPackProgressionsResponse +- client.print_mail.snap_packs.retrieve_capabilities(\*\*params) -> SnapPackRetrieveCapabilitiesResponse + +## TargetedListBuilds + +Types: + +```python +from postgrid.types.print_mail import ( + TargetedListBuildCreateResponse, + TargetedListBuildRetrieveResponse, + TargetedListBuildUpdateResponse, + TargetedListBuildListResponse, + TargetedListBuildDeleteResponse, + TargetedListBuildConfirmResponse, +) +``` + +Methods: + +- client.print_mail.targeted_list_builds.create(\*\*params) -> TargetedListBuildCreateResponse +- client.print_mail.targeted_list_builds.retrieve(id) -> TargetedListBuildRetrieveResponse +- client.print_mail.targeted_list_builds.update(id, \*\*params) -> TargetedListBuildUpdateResponse +- client.print_mail.targeted_list_builds.list(\*\*params) -> SyncSkipLimit[TargetedListBuildListResponse] +- client.print_mail.targeted_list_builds.delete(id) -> TargetedListBuildDeleteResponse +- client.print_mail.targeted_list_builds.confirm(id) -> TargetedListBuildConfirmResponse + +### Filters + +Types: + +```python +from postgrid.types.print_mail.targeted_list_builds import FilterAutocompleteResponse +``` + +Methods: + +- client.print_mail.targeted_list_builds.filters.autocomplete(\*\*params) -> FilterAutocompleteResponse + +## TemplateEditorSessions + +Types: + +```python +from postgrid.types.print_mail import ( + TemplateEditorSessionCreateResponse, + TemplateEditorSessionListResponse, + TemplateEditorSessionDeleteResponse, +) +``` + +Methods: + +- client.print_mail.template_editor_sessions.create(\*\*params) -> TemplateEditorSessionCreateResponse +- client.print_mail.template_editor_sessions.list(\*\*params) -> SyncSkipLimit[TemplateEditorSessionListResponse] +- client.print_mail.template_editor_sessions.delete(id) -> TemplateEditorSessionDeleteResponse + +## VirtualMailboxes + +Types: + +```python +from postgrid.types.print_mail import ( + VirtualMailboxCreateResponse, + VirtualMailboxRetrieveResponse, + VirtualMailboxListResponse, + VirtualMailboxRetrieveAddressResponse, +) +``` + +Methods: + +- client.print_mail.virtual_mailboxes.create(\*\*params) -> VirtualMailboxCreateResponse +- client.print_mail.virtual_mailboxes.retrieve(id) -> VirtualMailboxRetrieveResponse +- client.print_mail.virtual_mailboxes.list(\*\*params) -> SyncSkipLimit[VirtualMailboxListResponse] +- client.print_mail.virtual_mailboxes.retrieve_address(id) -> VirtualMailboxRetrieveAddressResponse + +### Items + +Types: + +```python +from postgrid.types.print_mail.virtual_mailboxes import ( + ItemCreateResponse, + ItemRetrieveResponse, + ItemListResponse, +) +``` + +Methods: + +- client.print_mail.virtual_mailboxes.items.create(id, \*\*params) -> ItemCreateResponse +- client.print_mail.virtual_mailboxes.items.retrieve(item_id, \*, id) -> ItemRetrieveResponse +- client.print_mail.virtual_mailboxes.items.list(id, \*\*params) -> SyncSkipLimit[ItemListResponse] diff --git a/src/postgrid/resources/print_mail/__init__.py b/src/postgrid/resources/print_mail/__init__.py index cb21176..8ac29b0 100644 --- a/src/postgrid/resources/print_mail/__init__.py +++ b/src/postgrid/resources/print_mail/__init__.py @@ -1,5 +1,13 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from .boxes import ( + BoxesResource, + AsyncBoxesResource, + BoxesResourceWithRawResponse, + AsyncBoxesResourceWithRawResponse, + BoxesResourceWithStreamingResponse, + AsyncBoxesResourceWithStreamingResponse, +) from .cheques import ( ChequesResource, AsyncChequesResource, @@ -32,6 +40,14 @@ ContactsResourceWithStreamingResponse, AsyncContactsResourceWithStreamingResponse, ) +from .trackers import ( + TrackersResource, + AsyncTrackersResource, + TrackersResourceWithRawResponse, + AsyncTrackersResourceWithRawResponse, + TrackersResourceWithStreamingResponse, + AsyncTrackersResourceWithStreamingResponse, +) from .campaigns import ( CampaignsResource, AsyncCampaignsResource, @@ -64,6 +80,14 @@ PrintMailResourceWithStreamingResponse, AsyncPrintMailResourceWithStreamingResponse, ) +from .snap_packs import ( + SnapPacksResource, + AsyncSnapPacksResource, + SnapPacksResourceWithRawResponse, + AsyncSnapPacksResourceWithRawResponse, + SnapPacksResourceWithStreamingResponse, + AsyncSnapPacksResourceWithStreamingResponse, +) from .self_mailers import ( SelfMailersResource, AsyncSelfMailersResource, @@ -96,6 +120,14 @@ SubOrganizationsResourceWithStreamingResponse, AsyncSubOrganizationsResourceWithStreamingResponse, ) +from .virtual_mailboxes import ( + VirtualMailboxesResource, + AsyncVirtualMailboxesResource, + VirtualMailboxesResourceWithRawResponse, + AsyncVirtualMailboxesResourceWithRawResponse, + VirtualMailboxesResourceWithStreamingResponse, + AsyncVirtualMailboxesResourceWithStreamingResponse, +) from .mailing_list_imports import ( MailingListImportsResource, AsyncMailingListImportsResource, @@ -104,38 +136,78 @@ MailingListImportsResourceWithStreamingResponse, AsyncMailingListImportsResourceWithStreamingResponse, ) +from .targeted_list_builds import ( + TargetedListBuildsResource, + AsyncTargetedListBuildsResource, + TargetedListBuildsResourceWithRawResponse, + AsyncTargetedListBuildsResourceWithRawResponse, + TargetedListBuildsResourceWithStreamingResponse, + AsyncTargetedListBuildsResourceWithStreamingResponse, +) +from .template_editor_sessions import ( + TemplateEditorSessionsResource, + AsyncTemplateEditorSessionsResource, + TemplateEditorSessionsResourceWithRawResponse, + AsyncTemplateEditorSessionsResourceWithRawResponse, + TemplateEditorSessionsResourceWithStreamingResponse, + AsyncTemplateEditorSessionsResourceWithStreamingResponse, +) __all__ = [ - "BankAccountsResource", - "AsyncBankAccountsResource", - "BankAccountsResourceWithRawResponse", - "AsyncBankAccountsResourceWithRawResponse", - "BankAccountsResourceWithStreamingResponse", - "AsyncBankAccountsResourceWithStreamingResponse", - "CampaignsResource", - "AsyncCampaignsResource", - "CampaignsResourceWithRawResponse", - "AsyncCampaignsResourceWithRawResponse", - "CampaignsResourceWithStreamingResponse", - "AsyncCampaignsResourceWithStreamingResponse", - "ChequesResource", - "AsyncChequesResource", - "ChequesResourceWithRawResponse", - "AsyncChequesResourceWithRawResponse", - "ChequesResourceWithStreamingResponse", - "AsyncChequesResourceWithStreamingResponse", "ContactsResource", "AsyncContactsResource", "ContactsResourceWithRawResponse", "AsyncContactsResourceWithRawResponse", "ContactsResourceWithStreamingResponse", "AsyncContactsResourceWithStreamingResponse", + "TemplatesResource", + "AsyncTemplatesResource", + "TemplatesResourceWithRawResponse", + "AsyncTemplatesResourceWithRawResponse", + "TemplatesResourceWithStreamingResponse", + "AsyncTemplatesResourceWithStreamingResponse", + "TrackersResource", + "AsyncTrackersResource", + "TrackersResourceWithRawResponse", + "AsyncTrackersResourceWithRawResponse", + "TrackersResourceWithStreamingResponse", + "AsyncTrackersResourceWithStreamingResponse", "LettersResource", "AsyncLettersResource", "LettersResourceWithRawResponse", "AsyncLettersResourceWithRawResponse", "LettersResourceWithStreamingResponse", "AsyncLettersResourceWithStreamingResponse", + "PostcardsResource", + "AsyncPostcardsResource", + "PostcardsResourceWithRawResponse", + "AsyncPostcardsResourceWithRawResponse", + "PostcardsResourceWithStreamingResponse", + "AsyncPostcardsResourceWithStreamingResponse", + "BankAccountsResource", + "AsyncBankAccountsResource", + "BankAccountsResourceWithRawResponse", + "AsyncBankAccountsResourceWithRawResponse", + "BankAccountsResourceWithStreamingResponse", + "AsyncBankAccountsResourceWithStreamingResponse", + "ChequesResource", + "AsyncChequesResource", + "ChequesResourceWithRawResponse", + "AsyncChequesResourceWithRawResponse", + "ChequesResourceWithStreamingResponse", + "AsyncChequesResourceWithStreamingResponse", + "SelfMailersResource", + "AsyncSelfMailersResource", + "SelfMailersResourceWithRawResponse", + "AsyncSelfMailersResourceWithRawResponse", + "SelfMailersResourceWithStreamingResponse", + "AsyncSelfMailersResourceWithStreamingResponse", + "CampaignsResource", + "AsyncCampaignsResource", + "CampaignsResourceWithRawResponse", + "AsyncCampaignsResourceWithRawResponse", + "CampaignsResourceWithStreamingResponse", + "AsyncCampaignsResourceWithStreamingResponse", "MailingListImportsResource", "AsyncMailingListImportsResource", "MailingListImportsResourceWithRawResponse", @@ -148,36 +220,48 @@ "AsyncMailingListsResourceWithRawResponse", "MailingListsResourceWithStreamingResponse", "AsyncMailingListsResourceWithStreamingResponse", - "PostcardsResource", - "AsyncPostcardsResource", - "PostcardsResourceWithRawResponse", - "AsyncPostcardsResourceWithRawResponse", - "PostcardsResourceWithStreamingResponse", - "AsyncPostcardsResourceWithStreamingResponse", "ReportsResource", "AsyncReportsResource", "ReportsResourceWithRawResponse", "AsyncReportsResourceWithRawResponse", "ReportsResourceWithStreamingResponse", "AsyncReportsResourceWithStreamingResponse", - "SelfMailersResource", - "AsyncSelfMailersResource", - "SelfMailersResourceWithRawResponse", - "AsyncSelfMailersResourceWithRawResponse", - "SelfMailersResourceWithStreamingResponse", - "AsyncSelfMailersResourceWithStreamingResponse", "SubOrganizationsResource", "AsyncSubOrganizationsResource", "SubOrganizationsResourceWithRawResponse", "AsyncSubOrganizationsResourceWithRawResponse", "SubOrganizationsResourceWithStreamingResponse", "AsyncSubOrganizationsResourceWithStreamingResponse", - "TemplatesResource", - "AsyncTemplatesResource", - "TemplatesResourceWithRawResponse", - "AsyncTemplatesResourceWithRawResponse", - "TemplatesResourceWithStreamingResponse", - "AsyncTemplatesResourceWithStreamingResponse", + "BoxesResource", + "AsyncBoxesResource", + "BoxesResourceWithRawResponse", + "AsyncBoxesResourceWithRawResponse", + "BoxesResourceWithStreamingResponse", + "AsyncBoxesResourceWithStreamingResponse", + "SnapPacksResource", + "AsyncSnapPacksResource", + "SnapPacksResourceWithRawResponse", + "AsyncSnapPacksResourceWithRawResponse", + "SnapPacksResourceWithStreamingResponse", + "AsyncSnapPacksResourceWithStreamingResponse", + "TargetedListBuildsResource", + "AsyncTargetedListBuildsResource", + "TargetedListBuildsResourceWithRawResponse", + "AsyncTargetedListBuildsResourceWithRawResponse", + "TargetedListBuildsResourceWithStreamingResponse", + "AsyncTargetedListBuildsResourceWithStreamingResponse", + "TemplateEditorSessionsResource", + "AsyncTemplateEditorSessionsResource", + "TemplateEditorSessionsResourceWithRawResponse", + "AsyncTemplateEditorSessionsResourceWithRawResponse", + "TemplateEditorSessionsResourceWithStreamingResponse", + "AsyncTemplateEditorSessionsResourceWithStreamingResponse", + "VirtualMailboxesResource", + "AsyncVirtualMailboxesResource", + "VirtualMailboxesResourceWithRawResponse", + "AsyncVirtualMailboxesResourceWithRawResponse", + "VirtualMailboxesResourceWithStreamingResponse", + "AsyncVirtualMailboxesResourceWithStreamingResponse", "PrintMailResource", "AsyncPrintMailResource", "PrintMailResourceWithRawResponse", diff --git a/src/postgrid/resources/print_mail/boxes.py b/src/postgrid/resources/print_mail/boxes.py new file mode 100644 index 0000000..bfb8ea2 --- /dev/null +++ b/src/postgrid/resources/print_mail/boxes.py @@ -0,0 +1,712 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Union, Iterable +from datetime import datetime +from typing_extensions import Literal + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import path_template, maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...pagination import SyncSkipLimit, AsyncSkipLimit +from ..._base_client import AsyncPaginator, make_request_options +from ...types.print_mail import box_list_params, box_create_params +from ...types.print_mail.box_list_response import BoxListResponse +from ...types.print_mail.box_create_response import BoxCreateResponse +from ...types.print_mail.box_delete_response import BoxDeleteResponse +from ...types.print_mail.box_retrieve_response import BoxRetrieveResponse +from ...types.print_mail.box_progressions_response import BoxProgressionsResponse + +__all__ = ["BoxesResource", "AsyncBoxesResource"] + + +class BoxesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> BoxesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + """ + return BoxesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> BoxesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + """ + return BoxesResourceWithStreamingResponse(self) + + def create( + self, + *, + cheques: Iterable[box_create_params.Cheque], + from_: box_create_params.From, + to: box_create_params.To, + description: str | Omit = omit, + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] + | Omit = omit, + merge_variables: Dict[str, object] | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + send_date: Union[str, datetime] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> BoxCreateResponse: + """This endpoint allows you to create a box containing up to 100 cheques. + + A Box is + mailed to a single destination. + + To create a box. You must specify: + + - `to`: The recipient (contact or contact ID) + - `from`: The sender (contact or contact ID) + - `cheques`: An array of cheques to go in the box + + For each cheque You must specify: + + - `to`: The recipient (contact or contact ID) + - `from`: The sender (contact or contact ID) + - `bankAccount`: The bank account ID + - `amount`: The amount to be sent + - `number`: The cheque number + + Args: + cheques: The cheques to be mailed in the box. Only 100 cheques can be included in a box + at a time. + + from_: The 'from' (sender) of the entire box. Accepts inline ContactCreate or a + contactID. + + to: The recipient of this order. You can either supply the contact information + inline here or provide a contact ID. PostGrid will automatically deduplicate + contacts regardless of whether you provide the information inline here or call + the contact creation endpoint. + + description: An optional string describing this resource. Will be visible in the API and the + dashboard. + + mailing_class: The mailing class of this order. If not provided, automatically set to + `first_class`. + + merge_variables: These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + + metadata: See the section on Metadata. + + send_date: This order will transition from `ready` to `printing` on the day after this + date. You can use this parameter to schedule orders for a future date. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/print-mail/v1/boxes", + body=maybe_transform( + { + "cheques": cheques, + "from_": from_, + "to": to, + "description": description, + "mailing_class": mailing_class, + "merge_variables": merge_variables, + "metadata": metadata, + "send_date": send_date, + }, + box_create_params.BoxCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=BoxCreateResponse, + ) + + def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> BoxRetrieveResponse: + """ + Retrieve a box by ID. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + path_template("/print-mail/v1/boxes/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=BoxRetrieveResponse, + ) + + def list( + self, + *, + limit: int | Omit = omit, + search: str | Omit = omit, + skip: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSkipLimit[BoxListResponse]: + """ + List all boxes. + + Args: + search: You can supply any string to help narrow down the list of resources. For + example, if you pass `"New York"` (quoted), it will return resources that have + that string present somewhere in their response. Alternatively, you can supply a + structured search query. See the documentation on `StructuredSearchQuery` for + more details. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get_api_list( + "/print-mail/v1/boxes", + page=SyncSkipLimit[BoxListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "search": search, + "skip": skip, + }, + box_list_params.BoxListParams, + ), + ), + model=BoxListResponse, + ) + + def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> BoxDeleteResponse: + """ + Cancel a box by ID (cannot be undone). + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._delete( + path_template("/print-mail/v1/boxes/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=BoxDeleteResponse, + ) + + def progressions( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> BoxProgressionsResponse: + """Progresses a box's `status` to the next stage. + + This is only available in test + mode and can be used to simulate how a live order would progress through the + different statuses. + + Note: this will fail with an `invalid_progression_error` if the status is one of + `completed` or `cancelled`. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + path_template("/print-mail/v1/boxes/{id}/progressions", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=BoxProgressionsResponse, + ) + + +class AsyncBoxesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncBoxesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + """ + return AsyncBoxesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncBoxesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + """ + return AsyncBoxesResourceWithStreamingResponse(self) + + async def create( + self, + *, + cheques: Iterable[box_create_params.Cheque], + from_: box_create_params.From, + to: box_create_params.To, + description: str | Omit = omit, + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] + | Omit = omit, + merge_variables: Dict[str, object] | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + send_date: Union[str, datetime] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> BoxCreateResponse: + """This endpoint allows you to create a box containing up to 100 cheques. + + A Box is + mailed to a single destination. + + To create a box. You must specify: + + - `to`: The recipient (contact or contact ID) + - `from`: The sender (contact or contact ID) + - `cheques`: An array of cheques to go in the box + + For each cheque You must specify: + + - `to`: The recipient (contact or contact ID) + - `from`: The sender (contact or contact ID) + - `bankAccount`: The bank account ID + - `amount`: The amount to be sent + - `number`: The cheque number + + Args: + cheques: The cheques to be mailed in the box. Only 100 cheques can be included in a box + at a time. + + from_: The 'from' (sender) of the entire box. Accepts inline ContactCreate or a + contactID. + + to: The recipient of this order. You can either supply the contact information + inline here or provide a contact ID. PostGrid will automatically deduplicate + contacts regardless of whether you provide the information inline here or call + the contact creation endpoint. + + description: An optional string describing this resource. Will be visible in the API and the + dashboard. + + mailing_class: The mailing class of this order. If not provided, automatically set to + `first_class`. + + merge_variables: These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + + metadata: See the section on Metadata. + + send_date: This order will transition from `ready` to `printing` on the day after this + date. You can use this parameter to schedule orders for a future date. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/print-mail/v1/boxes", + body=await async_maybe_transform( + { + "cheques": cheques, + "from_": from_, + "to": to, + "description": description, + "mailing_class": mailing_class, + "merge_variables": merge_variables, + "metadata": metadata, + "send_date": send_date, + }, + box_create_params.BoxCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=BoxCreateResponse, + ) + + async def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> BoxRetrieveResponse: + """ + Retrieve a box by ID. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + path_template("/print-mail/v1/boxes/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=BoxRetrieveResponse, + ) + + def list( + self, + *, + limit: int | Omit = omit, + search: str | Omit = omit, + skip: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[BoxListResponse, AsyncSkipLimit[BoxListResponse]]: + """ + List all boxes. + + Args: + search: You can supply any string to help narrow down the list of resources. For + example, if you pass `"New York"` (quoted), it will return resources that have + that string present somewhere in their response. Alternatively, you can supply a + structured search query. See the documentation on `StructuredSearchQuery` for + more details. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get_api_list( + "/print-mail/v1/boxes", + page=AsyncSkipLimit[BoxListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "search": search, + "skip": skip, + }, + box_list_params.BoxListParams, + ), + ), + model=BoxListResponse, + ) + + async def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> BoxDeleteResponse: + """ + Cancel a box by ID (cannot be undone). + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._delete( + path_template("/print-mail/v1/boxes/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=BoxDeleteResponse, + ) + + async def progressions( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> BoxProgressionsResponse: + """Progresses a box's `status` to the next stage. + + This is only available in test + mode and can be used to simulate how a live order would progress through the + different statuses. + + Note: this will fail with an `invalid_progression_error` if the status is one of + `completed` or `cancelled`. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + path_template("/print-mail/v1/boxes/{id}/progressions", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=BoxProgressionsResponse, + ) + + +class BoxesResourceWithRawResponse: + def __init__(self, boxes: BoxesResource) -> None: + self._boxes = boxes + + self.create = to_raw_response_wrapper( + boxes.create, + ) + self.retrieve = to_raw_response_wrapper( + boxes.retrieve, + ) + self.list = to_raw_response_wrapper( + boxes.list, + ) + self.delete = to_raw_response_wrapper( + boxes.delete, + ) + self.progressions = to_raw_response_wrapper( + boxes.progressions, + ) + + +class AsyncBoxesResourceWithRawResponse: + def __init__(self, boxes: AsyncBoxesResource) -> None: + self._boxes = boxes + + self.create = async_to_raw_response_wrapper( + boxes.create, + ) + self.retrieve = async_to_raw_response_wrapper( + boxes.retrieve, + ) + self.list = async_to_raw_response_wrapper( + boxes.list, + ) + self.delete = async_to_raw_response_wrapper( + boxes.delete, + ) + self.progressions = async_to_raw_response_wrapper( + boxes.progressions, + ) + + +class BoxesResourceWithStreamingResponse: + def __init__(self, boxes: BoxesResource) -> None: + self._boxes = boxes + + self.create = to_streamed_response_wrapper( + boxes.create, + ) + self.retrieve = to_streamed_response_wrapper( + boxes.retrieve, + ) + self.list = to_streamed_response_wrapper( + boxes.list, + ) + self.delete = to_streamed_response_wrapper( + boxes.delete, + ) + self.progressions = to_streamed_response_wrapper( + boxes.progressions, + ) + + +class AsyncBoxesResourceWithStreamingResponse: + def __init__(self, boxes: AsyncBoxesResource) -> None: + self._boxes = boxes + + self.create = async_to_streamed_response_wrapper( + boxes.create, + ) + self.retrieve = async_to_streamed_response_wrapper( + boxes.retrieve, + ) + self.list = async_to_streamed_response_wrapper( + boxes.list, + ) + self.delete = async_to_streamed_response_wrapper( + boxes.delete, + ) + self.progressions = async_to_streamed_response_wrapper( + boxes.progressions, + ) diff --git a/src/postgrid/resources/print_mail/cheques.py b/src/postgrid/resources/print_mail/cheques.py index f7d8f81..2a25344 100644 --- a/src/postgrid/resources/print_mail/cheques.py +++ b/src/postgrid/resources/print_mail/cheques.py @@ -20,7 +20,7 @@ ) from ...pagination import SyncSkipLimit, AsyncSkipLimit from ..._base_client import AsyncPaginator, make_request_options -from ...types.print_mail import ChequeSize, cheque_list_params, cheque_create_params +from ...types.print_mail import ChequeSize, cheque_list_params, cheque_cancel_params, cheque_create_params from ...types.print_mail.cheque import Cheque from ...types.print_mail.cheque_size import ChequeSize from ...types.print_mail.digital_only_param import DigitalOnlyParam @@ -347,6 +347,82 @@ def delete( cast_to=Cheque, ) + def cancel( + self, + id: str, + *, + note: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Cheque: + """Cancel a cheque by ID with a note. + + Note that this operation cannot be undone and + that only cheques with a status of `ready` can be cancelled. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + path_template("/print-mail/v1/cheques/{id}/cancellation", id=id), + body=maybe_transform({"note": note}, cheque_cancel_params.ChequeCancelParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Cheque, + ) + + def progress( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Cheque: + """Progresses a cheque's `status` to the next stage. + + This is only available in test + mode and can be used to simulate how a live order would progress through the + different statuses. + + Note: this will fail with an `invalid_progression_error` if the status is one of + `completed` or `cancelled`. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + path_template("/print-mail/v1/cheques/{id}/progressions", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Cheque, + ) + def retrieve_url( self, id: str, @@ -741,6 +817,82 @@ async def delete( cast_to=Cheque, ) + async def cancel( + self, + id: str, + *, + note: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Cheque: + """Cancel a cheque by ID with a note. + + Note that this operation cannot be undone and + that only cheques with a status of `ready` can be cancelled. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + path_template("/print-mail/v1/cheques/{id}/cancellation", id=id), + body=await async_maybe_transform({"note": note}, cheque_cancel_params.ChequeCancelParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Cheque, + ) + + async def progress( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Cheque: + """Progresses a cheque's `status` to the next stage. + + This is only available in test + mode and can be used to simulate how a live order would progress through the + different statuses. + + Note: this will fail with an `invalid_progression_error` if the status is one of + `completed` or `cancelled`. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + path_template("/print-mail/v1/cheques/{id}/progressions", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Cheque, + ) + async def retrieve_url( self, id: str, @@ -833,6 +985,12 @@ def __init__(self, cheques: ChequesResource) -> None: self.delete = to_raw_response_wrapper( cheques.delete, ) + self.cancel = to_raw_response_wrapper( + cheques.cancel, + ) + self.progress = to_raw_response_wrapper( + cheques.progress, + ) self.retrieve_url = to_raw_response_wrapper( cheques.retrieve_url, ) @@ -857,6 +1015,12 @@ def __init__(self, cheques: AsyncChequesResource) -> None: self.delete = async_to_raw_response_wrapper( cheques.delete, ) + self.cancel = async_to_raw_response_wrapper( + cheques.cancel, + ) + self.progress = async_to_raw_response_wrapper( + cheques.progress, + ) self.retrieve_url = async_to_raw_response_wrapper( cheques.retrieve_url, ) @@ -881,6 +1045,12 @@ def __init__(self, cheques: ChequesResource) -> None: self.delete = to_streamed_response_wrapper( cheques.delete, ) + self.cancel = to_streamed_response_wrapper( + cheques.cancel, + ) + self.progress = to_streamed_response_wrapper( + cheques.progress, + ) self.retrieve_url = to_streamed_response_wrapper( cheques.retrieve_url, ) @@ -905,6 +1075,12 @@ def __init__(self, cheques: AsyncChequesResource) -> None: self.delete = async_to_streamed_response_wrapper( cheques.delete, ) + self.cancel = async_to_streamed_response_wrapper( + cheques.cancel, + ) + self.progress = async_to_streamed_response_wrapper( + cheques.progress, + ) self.retrieve_url = async_to_streamed_response_wrapper( cheques.retrieve_url, ) diff --git a/src/postgrid/resources/print_mail/letters.py b/src/postgrid/resources/print_mail/letters.py index 7a924ea..04a3e11 100644 --- a/src/postgrid/resources/print_mail/letters.py +++ b/src/postgrid/resources/print_mail/letters.py @@ -24,6 +24,7 @@ LetterSize, AddressPlacement, letter_list_params, + letter_cancel_params, letter_create_params, ) from ...types.print_mail.letter import Letter @@ -546,6 +547,82 @@ def delete( cast_to=Letter, ) + def cancel( + self, + id: str, + *, + note: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Letter: + """Cancel a letter by ID with a note. + + Note that this operation cannot be undone and + that only letters with a status of `ready` can be cancelled. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + path_template("/print-mail/v1/letters/{id}/cancellation", id=id), + body=maybe_transform({"note": note}, letter_cancel_params.LetterCancelParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Letter, + ) + + def progress( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Letter: + """Progresses a letter's `status` to the next stage. + + This is only available in test + mode and can be used to simulate how a live order would progress through the + different statuses. + + Note: this will fail with an `invalid_progression_error` if the status is one of + `completed` or `cancelled`. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + path_template("/print-mail/v1/letters/{id}/progressions", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Letter, + ) + def retrieve_url( self, id: str, @@ -1095,6 +1172,82 @@ async def delete( cast_to=Letter, ) + async def cancel( + self, + id: str, + *, + note: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Letter: + """Cancel a letter by ID with a note. + + Note that this operation cannot be undone and + that only letters with a status of `ready` can be cancelled. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + path_template("/print-mail/v1/letters/{id}/cancellation", id=id), + body=await async_maybe_transform({"note": note}, letter_cancel_params.LetterCancelParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Letter, + ) + + async def progress( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Letter: + """Progresses a letter's `status` to the next stage. + + This is only available in test + mode and can be used to simulate how a live order would progress through the + different statuses. + + Note: this will fail with an `invalid_progression_error` if the status is one of + `completed` or `cancelled`. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + path_template("/print-mail/v1/letters/{id}/progressions", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Letter, + ) + async def retrieve_url( self, id: str, @@ -1150,6 +1303,12 @@ def __init__(self, letters: LettersResource) -> None: self.delete = to_raw_response_wrapper( letters.delete, ) + self.cancel = to_raw_response_wrapper( + letters.cancel, + ) + self.progress = to_raw_response_wrapper( + letters.progress, + ) self.retrieve_url = to_raw_response_wrapper( letters.retrieve_url, ) @@ -1171,6 +1330,12 @@ def __init__(self, letters: AsyncLettersResource) -> None: self.delete = async_to_raw_response_wrapper( letters.delete, ) + self.cancel = async_to_raw_response_wrapper( + letters.cancel, + ) + self.progress = async_to_raw_response_wrapper( + letters.progress, + ) self.retrieve_url = async_to_raw_response_wrapper( letters.retrieve_url, ) @@ -1192,6 +1357,12 @@ def __init__(self, letters: LettersResource) -> None: self.delete = to_streamed_response_wrapper( letters.delete, ) + self.cancel = to_streamed_response_wrapper( + letters.cancel, + ) + self.progress = to_streamed_response_wrapper( + letters.progress, + ) self.retrieve_url = to_streamed_response_wrapper( letters.retrieve_url, ) @@ -1213,6 +1384,12 @@ def __init__(self, letters: AsyncLettersResource) -> None: self.delete = async_to_streamed_response_wrapper( letters.delete, ) + self.cancel = async_to_streamed_response_wrapper( + letters.cancel, + ) + self.progress = async_to_streamed_response_wrapper( + letters.progress, + ) self.retrieve_url = async_to_streamed_response_wrapper( letters.retrieve_url, ) diff --git a/src/postgrid/resources/print_mail/mailing_lists.py b/src/postgrid/resources/print_mail/mailing_lists.py index 350e6d5..e08dc87 100644 --- a/src/postgrid/resources/print_mail/mailing_lists.py +++ b/src/postgrid/resources/print_mail/mailing_lists.py @@ -32,6 +32,11 @@ class MailingListsResource(SyncAPIResource): + """ + The mailing lists API enables you to manage collections of contacts + that can be used for bulk mail campaigns. + """ + @cached_property def with_raw_response(self) -> MailingListsResourceWithRawResponse: """ @@ -338,6 +343,11 @@ def jobs( class AsyncMailingListsResource(AsyncAPIResource): + """ + The mailing lists API enables you to manage collections of contacts + that can be used for bulk mail campaigns. + """ + @cached_property def with_raw_response(self) -> AsyncMailingListsResourceWithRawResponse: """ diff --git a/src/postgrid/resources/print_mail/postcards.py b/src/postgrid/resources/print_mail/postcards.py index 746ac36..d7ca458 100644 --- a/src/postgrid/resources/print_mail/postcards.py +++ b/src/postgrid/resources/print_mail/postcards.py @@ -20,7 +20,7 @@ ) from ...pagination import SyncSkipLimit, AsyncSkipLimit from ..._base_client import AsyncPaginator, make_request_options -from ...types.print_mail import postcard_list_params, postcard_create_params +from ...types.print_mail import postcard_list_params, postcard_cancel_params, postcard_create_params from ...types.print_mail.postcard import Postcard from ...types.print_mail.postcard_retrieve_url_response import PostcardRetrieveURLResponse @@ -606,6 +606,82 @@ def delete( cast_to=Postcard, ) + def cancel( + self, + id: str, + *, + note: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Postcard: + """Cancel a postcard by ID with a note. + + Note that this operation cannot be undone + and that only postcards with a status of `ready` can be cancelled. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + path_template("/print-mail/v1/postcards/{id}/cancellation", id=id), + body=maybe_transform({"note": note}, postcard_cancel_params.PostcardCancelParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Postcard, + ) + + def progress( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Postcard: + """Progresses a postcard's `status` to the next stage. + + This is only available in + test mode and can be used to simulate how a live order would progress through + the different statuses. + + Note: this will fail with an `invalid_progression_error` if the status is one of + `completed` or `cancelled`. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + path_template("/print-mail/v1/postcards/{id}/progressions", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Postcard, + ) + def retrieve_url( self, id: str, @@ -1224,6 +1300,82 @@ async def delete( cast_to=Postcard, ) + async def cancel( + self, + id: str, + *, + note: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Postcard: + """Cancel a postcard by ID with a note. + + Note that this operation cannot be undone + and that only postcards with a status of `ready` can be cancelled. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + path_template("/print-mail/v1/postcards/{id}/cancellation", id=id), + body=await async_maybe_transform({"note": note}, postcard_cancel_params.PostcardCancelParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Postcard, + ) + + async def progress( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> Postcard: + """Progresses a postcard's `status` to the next stage. + + This is only available in + test mode and can be used to simulate how a live order would progress through + the different statuses. + + Note: this will fail with an `invalid_progression_error` if the status is one of + `completed` or `cancelled`. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + path_template("/print-mail/v1/postcards/{id}/progressions", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=Postcard, + ) + async def retrieve_url( self, id: str, @@ -1279,6 +1431,12 @@ def __init__(self, postcards: PostcardsResource) -> None: self.delete = to_raw_response_wrapper( postcards.delete, ) + self.cancel = to_raw_response_wrapper( + postcards.cancel, + ) + self.progress = to_raw_response_wrapper( + postcards.progress, + ) self.retrieve_url = to_raw_response_wrapper( postcards.retrieve_url, ) @@ -1300,6 +1458,12 @@ def __init__(self, postcards: AsyncPostcardsResource) -> None: self.delete = async_to_raw_response_wrapper( postcards.delete, ) + self.cancel = async_to_raw_response_wrapper( + postcards.cancel, + ) + self.progress = async_to_raw_response_wrapper( + postcards.progress, + ) self.retrieve_url = async_to_raw_response_wrapper( postcards.retrieve_url, ) @@ -1321,6 +1485,12 @@ def __init__(self, postcards: PostcardsResource) -> None: self.delete = to_streamed_response_wrapper( postcards.delete, ) + self.cancel = to_streamed_response_wrapper( + postcards.cancel, + ) + self.progress = to_streamed_response_wrapper( + postcards.progress, + ) self.retrieve_url = to_streamed_response_wrapper( postcards.retrieve_url, ) @@ -1342,6 +1512,12 @@ def __init__(self, postcards: AsyncPostcardsResource) -> None: self.delete = async_to_streamed_response_wrapper( postcards.delete, ) + self.cancel = async_to_streamed_response_wrapper( + postcards.cancel, + ) + self.progress = async_to_streamed_response_wrapper( + postcards.progress, + ) self.retrieve_url = async_to_streamed_response_wrapper( postcards.retrieve_url, ) diff --git a/src/postgrid/resources/print_mail/print_mail.py b/src/postgrid/resources/print_mail/print_mail.py index 6681005..e25edc4 100644 --- a/src/postgrid/resources/print_mail/print_mail.py +++ b/src/postgrid/resources/print_mail/print_mail.py @@ -2,6 +2,14 @@ from __future__ import annotations +from .boxes import ( + BoxesResource, + AsyncBoxesResource, + BoxesResourceWithRawResponse, + AsyncBoxesResourceWithRawResponse, + BoxesResourceWithStreamingResponse, + AsyncBoxesResourceWithStreamingResponse, +) from .cheques import ( ChequesResource, AsyncChequesResource, @@ -26,6 +34,14 @@ ContactsResourceWithStreamingResponse, AsyncContactsResourceWithStreamingResponse, ) +from .trackers import ( + TrackersResource, + AsyncTrackersResource, + TrackersResourceWithRawResponse, + AsyncTrackersResourceWithRawResponse, + TrackersResourceWithStreamingResponse, + AsyncTrackersResourceWithStreamingResponse, +) from ..._compat import cached_property from .campaigns import ( CampaignsResource, @@ -51,6 +67,14 @@ TemplatesResourceWithStreamingResponse, AsyncTemplatesResourceWithStreamingResponse, ) +from .snap_packs import ( + SnapPacksResource, + AsyncSnapPacksResource, + SnapPacksResourceWithRawResponse, + AsyncSnapPacksResourceWithRawResponse, + SnapPacksResourceWithStreamingResponse, + AsyncSnapPacksResourceWithStreamingResponse, +) from ..._resource import SyncAPIResource, AsyncAPIResource from .self_mailers import ( SelfMailersResource, @@ -100,34 +124,86 @@ MailingListImportsResourceWithStreamingResponse, AsyncMailingListImportsResourceWithStreamingResponse, ) +from .template_editor_sessions import ( + TemplateEditorSessionsResource, + AsyncTemplateEditorSessionsResource, + TemplateEditorSessionsResourceWithRawResponse, + AsyncTemplateEditorSessionsResourceWithRawResponse, + TemplateEditorSessionsResourceWithStreamingResponse, + AsyncTemplateEditorSessionsResourceWithStreamingResponse, +) +from .virtual_mailboxes.virtual_mailboxes import ( + VirtualMailboxesResource, + AsyncVirtualMailboxesResource, + VirtualMailboxesResourceWithRawResponse, + AsyncVirtualMailboxesResourceWithRawResponse, + VirtualMailboxesResourceWithStreamingResponse, + AsyncVirtualMailboxesResourceWithStreamingResponse, +) +from .targeted_list_builds.targeted_list_builds import ( + TargetedListBuildsResource, + AsyncTargetedListBuildsResource, + TargetedListBuildsResourceWithRawResponse, + AsyncTargetedListBuildsResourceWithRawResponse, + TargetedListBuildsResourceWithStreamingResponse, + AsyncTargetedListBuildsResourceWithStreamingResponse, +) __all__ = ["PrintMailResource", "AsyncPrintMailResource"] class PrintMailResource(SyncAPIResource): @cached_property - def bank_accounts(self) -> BankAccountsResource: - return BankAccountsResource(self._client) + def contacts(self) -> ContactsResource: + return ContactsResource(self._client) @cached_property - def campaigns(self) -> CampaignsResource: - """ - The campaigns API enables you to send out large volumes of fully - personalized mail to a mailing list. + def templates(self) -> TemplatesResource: + return TemplatesResource(self._client) + + @cached_property + def trackers(self) -> TrackersResource: + """Create and manage Trackers. + + Trackers can be used to track interactions in your orders through + personalized URLs and QR codes. + + As a brief introduction to using Trackers in your orders, a QR code can be + generated by using the Tracker's ID as a merge variable in your orders HTML + and Templates. The following example HTML uses Trackers to generate + personalized URLs (PURLs) in your orders. + + See the following guide for more details: https://postgrid.readme.io/reference/trackers-1 """ - return CampaignsResource(self._client) + return TrackersResource(self._client) + + @cached_property + def letters(self) -> LettersResource: + return LettersResource(self._client) + + @cached_property + def postcards(self) -> PostcardsResource: + return PostcardsResource(self._client) + + @cached_property + def bank_accounts(self) -> BankAccountsResource: + return BankAccountsResource(self._client) @cached_property def cheques(self) -> ChequesResource: return ChequesResource(self._client) @cached_property - def contacts(self) -> ContactsResource: - return ContactsResource(self._client) + def self_mailers(self) -> SelfMailersResource: + return SelfMailersResource(self._client) @cached_property - def letters(self) -> LettersResource: - return LettersResource(self._client) + def campaigns(self) -> CampaignsResource: + """ + The campaigns API enables you to send out large volumes of fully + personalized mail to a mailing list. + """ + return CampaignsResource(self._client) @cached_property def mailing_list_imports(self) -> MailingListImportsResource: @@ -139,12 +215,12 @@ def mailing_list_imports(self) -> MailingListImportsResource: @cached_property def mailing_lists(self) -> MailingListsResource: + """ + The mailing lists API enables you to manage collections of contacts + that can be used for bulk mail campaigns. + """ return MailingListsResource(self._client) - @cached_property - def postcards(self) -> PostcardsResource: - return PostcardsResource(self._client) - @cached_property def reports(self) -> ReportsResource: """ @@ -156,17 +232,106 @@ def reports(self) -> ReportsResource: """ return ReportsResource(self._client) - @cached_property - def self_mailers(self) -> SelfMailersResource: - return SelfMailersResource(self._client) - @cached_property def sub_organizations(self) -> SubOrganizationsResource: + """ + Sub-organizations enable you to create isolated PostGrid accounts + ("sub-organizations") under your PostGrid account (the "parent organization"). + Each sub-organization has fully isolated resources + and users, and can act independently. + + This allows you to isolate different departments or even re-sell PostGrid + entirely. + + You can request access to this feature by reaching out to + support@postgrid.com + """ return SubOrganizationsResource(self._client) @cached_property - def templates(self) -> TemplatesResource: - return TemplatesResource(self._client) + def boxes(self) -> BoxesResource: + return BoxesResource(self._client) + + @cached_property + def snap_packs(self) -> SnapPacksResource: + """ + Snap packs are pressure-sealed mailers that resemble official documents + and encourage higher open rates. They do not require envelopes and are + opened by tearing along perforated edges. The sealed design keeps contents + hidden until opened, making snap packs ideal for sensitive or important + documents such as contracts, forms, or notices. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + return SnapPacksResource(self._client) + + @cached_property + def targeted_list_builds(self) -> TargetedListBuildsResource: + """ + **Beta:** the targeted list builds API is in beta and is subject to + breaking changes. Endpoint shapes, status values, and filter fields may + change without notice. + + The targeted list builds API lets you programmatically build mailing + lists of US consumers (B2C) or US companies (B2B) that match a set of + demographic, geographic, and firmographic filters. + + The lifecycle of a list build is: + + 1. Create a list build by supplying either `usConsumers` or `usCompanies` + filters. A quote is generated asynchronously — poll the resource or + wait for its `status` to become `quote_ready`. + 2. Review the `quote` (total count and price per contact) and masked + `previewRecords`. Adjust the filters with an update call if needed — + this will regenerate the quote. + 3. Confirm the build. This deducts the appropriate amount of list build + credits from your organization (in live mode) and begins constructing + the mailing list. `buildProgressPercent` reflects progress from 0 to + 100. + 4. Once `status` is `completed`, the ID of the resulting mailing list is + available in the `mailingList` field and can be used like any other + mailing list in the PostGrid API. + + Targeted list builds must be enabled on your organization before they + can be used. Contact PostGrid support to request access. + """ + return TargetedListBuildsResource(self._client) + + @cached_property + def template_editor_sessions(self) -> TemplateEditorSessionsResource: + """ + You can use template editor sessions to bring the capabilities of our + template editor to your website. When you create a session, you provide the + `template` which you want to edit, and we return a session with a `url` that + you can `iframe` or redirect your customers to. + + When users save their changes in the editor session, it will update the + underlying template. Note that sessions are only valid for 24 hours, after + which point they are automatically deleted for security reasons. + + You can have multiple sessions active for the same template at the same time. + In general, we recommend creating a new session every time you present our + editor to your users. + + Note: you can use the template editor to modify templates created using HTML, + but saving a session from the editor will override the original HTML content. + """ + return TemplateEditorSessionsResource(self._client) + + @cached_property + def virtual_mailboxes(self) -> VirtualMailboxesResource: + """ + Virtual mailboxes let you receive, scan, and forward your physical mail + without needing a traditional physical mailbox. Each mailbox is fully + digital, giving you a unique ID, status, and a set of capabilities such as + forwarding mail to another address or viewing envelope scans. This allows you + to manage physical correspondence entirely online. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + return VirtualMailboxesResource(self._client) @cached_property def with_raw_response(self) -> PrintMailResourceWithRawResponse: @@ -190,28 +355,56 @@ def with_streaming_response(self) -> PrintMailResourceWithStreamingResponse: class AsyncPrintMailResource(AsyncAPIResource): @cached_property - def bank_accounts(self) -> AsyncBankAccountsResource: - return AsyncBankAccountsResource(self._client) + def contacts(self) -> AsyncContactsResource: + return AsyncContactsResource(self._client) @cached_property - def campaigns(self) -> AsyncCampaignsResource: - """ - The campaigns API enables you to send out large volumes of fully - personalized mail to a mailing list. + def templates(self) -> AsyncTemplatesResource: + return AsyncTemplatesResource(self._client) + + @cached_property + def trackers(self) -> AsyncTrackersResource: + """Create and manage Trackers. + + Trackers can be used to track interactions in your orders through + personalized URLs and QR codes. + + As a brief introduction to using Trackers in your orders, a QR code can be + generated by using the Tracker's ID as a merge variable in your orders HTML + and Templates. The following example HTML uses Trackers to generate + personalized URLs (PURLs) in your orders. + + See the following guide for more details: https://postgrid.readme.io/reference/trackers-1 """ - return AsyncCampaignsResource(self._client) + return AsyncTrackersResource(self._client) + + @cached_property + def letters(self) -> AsyncLettersResource: + return AsyncLettersResource(self._client) + + @cached_property + def postcards(self) -> AsyncPostcardsResource: + return AsyncPostcardsResource(self._client) + + @cached_property + def bank_accounts(self) -> AsyncBankAccountsResource: + return AsyncBankAccountsResource(self._client) @cached_property def cheques(self) -> AsyncChequesResource: return AsyncChequesResource(self._client) @cached_property - def contacts(self) -> AsyncContactsResource: - return AsyncContactsResource(self._client) + def self_mailers(self) -> AsyncSelfMailersResource: + return AsyncSelfMailersResource(self._client) @cached_property - def letters(self) -> AsyncLettersResource: - return AsyncLettersResource(self._client) + def campaigns(self) -> AsyncCampaignsResource: + """ + The campaigns API enables you to send out large volumes of fully + personalized mail to a mailing list. + """ + return AsyncCampaignsResource(self._client) @cached_property def mailing_list_imports(self) -> AsyncMailingListImportsResource: @@ -223,12 +416,12 @@ def mailing_list_imports(self) -> AsyncMailingListImportsResource: @cached_property def mailing_lists(self) -> AsyncMailingListsResource: + """ + The mailing lists API enables you to manage collections of contacts + that can be used for bulk mail campaigns. + """ return AsyncMailingListsResource(self._client) - @cached_property - def postcards(self) -> AsyncPostcardsResource: - return AsyncPostcardsResource(self._client) - @cached_property def reports(self) -> AsyncReportsResource: """ @@ -240,17 +433,106 @@ def reports(self) -> AsyncReportsResource: """ return AsyncReportsResource(self._client) - @cached_property - def self_mailers(self) -> AsyncSelfMailersResource: - return AsyncSelfMailersResource(self._client) - @cached_property def sub_organizations(self) -> AsyncSubOrganizationsResource: + """ + Sub-organizations enable you to create isolated PostGrid accounts + ("sub-organizations") under your PostGrid account (the "parent organization"). + Each sub-organization has fully isolated resources + and users, and can act independently. + + This allows you to isolate different departments or even re-sell PostGrid + entirely. + + You can request access to this feature by reaching out to + support@postgrid.com + """ return AsyncSubOrganizationsResource(self._client) @cached_property - def templates(self) -> AsyncTemplatesResource: - return AsyncTemplatesResource(self._client) + def boxes(self) -> AsyncBoxesResource: + return AsyncBoxesResource(self._client) + + @cached_property + def snap_packs(self) -> AsyncSnapPacksResource: + """ + Snap packs are pressure-sealed mailers that resemble official documents + and encourage higher open rates. They do not require envelopes and are + opened by tearing along perforated edges. The sealed design keeps contents + hidden until opened, making snap packs ideal for sensitive or important + documents such as contracts, forms, or notices. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + return AsyncSnapPacksResource(self._client) + + @cached_property + def targeted_list_builds(self) -> AsyncTargetedListBuildsResource: + """ + **Beta:** the targeted list builds API is in beta and is subject to + breaking changes. Endpoint shapes, status values, and filter fields may + change without notice. + + The targeted list builds API lets you programmatically build mailing + lists of US consumers (B2C) or US companies (B2B) that match a set of + demographic, geographic, and firmographic filters. + + The lifecycle of a list build is: + + 1. Create a list build by supplying either `usConsumers` or `usCompanies` + filters. A quote is generated asynchronously — poll the resource or + wait for its `status` to become `quote_ready`. + 2. Review the `quote` (total count and price per contact) and masked + `previewRecords`. Adjust the filters with an update call if needed — + this will regenerate the quote. + 3. Confirm the build. This deducts the appropriate amount of list build + credits from your organization (in live mode) and begins constructing + the mailing list. `buildProgressPercent` reflects progress from 0 to + 100. + 4. Once `status` is `completed`, the ID of the resulting mailing list is + available in the `mailingList` field and can be used like any other + mailing list in the PostGrid API. + + Targeted list builds must be enabled on your organization before they + can be used. Contact PostGrid support to request access. + """ + return AsyncTargetedListBuildsResource(self._client) + + @cached_property + def template_editor_sessions(self) -> AsyncTemplateEditorSessionsResource: + """ + You can use template editor sessions to bring the capabilities of our + template editor to your website. When you create a session, you provide the + `template` which you want to edit, and we return a session with a `url` that + you can `iframe` or redirect your customers to. + + When users save their changes in the editor session, it will update the + underlying template. Note that sessions are only valid for 24 hours, after + which point they are automatically deleted for security reasons. + + You can have multiple sessions active for the same template at the same time. + In general, we recommend creating a new session every time you present our + editor to your users. + + Note: you can use the template editor to modify templates created using HTML, + but saving a session from the editor will override the original HTML content. + """ + return AsyncTemplateEditorSessionsResource(self._client) + + @cached_property + def virtual_mailboxes(self) -> AsyncVirtualMailboxesResource: + """ + Virtual mailboxes let you receive, scan, and forward your physical mail + without needing a traditional physical mailbox. Each mailbox is fully + digital, giving you a unique ID, status, and a set of capabilities such as + forwarding mail to another address or viewing envelope scans. This allows you + to manage physical correspondence entirely online. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + return AsyncVirtualMailboxesResource(self._client) @cached_property def with_raw_response(self) -> AsyncPrintMailResourceWithRawResponse: @@ -277,28 +559,56 @@ def __init__(self, print_mail: PrintMailResource) -> None: self._print_mail = print_mail @cached_property - def bank_accounts(self) -> BankAccountsResourceWithRawResponse: - return BankAccountsResourceWithRawResponse(self._print_mail.bank_accounts) + def contacts(self) -> ContactsResourceWithRawResponse: + return ContactsResourceWithRawResponse(self._print_mail.contacts) @cached_property - def campaigns(self) -> CampaignsResourceWithRawResponse: - """ - The campaigns API enables you to send out large volumes of fully - personalized mail to a mailing list. + def templates(self) -> TemplatesResourceWithRawResponse: + return TemplatesResourceWithRawResponse(self._print_mail.templates) + + @cached_property + def trackers(self) -> TrackersResourceWithRawResponse: + """Create and manage Trackers. + + Trackers can be used to track interactions in your orders through + personalized URLs and QR codes. + + As a brief introduction to using Trackers in your orders, a QR code can be + generated by using the Tracker's ID as a merge variable in your orders HTML + and Templates. The following example HTML uses Trackers to generate + personalized URLs (PURLs) in your orders. + + See the following guide for more details: https://postgrid.readme.io/reference/trackers-1 """ - return CampaignsResourceWithRawResponse(self._print_mail.campaigns) + return TrackersResourceWithRawResponse(self._print_mail.trackers) + + @cached_property + def letters(self) -> LettersResourceWithRawResponse: + return LettersResourceWithRawResponse(self._print_mail.letters) + + @cached_property + def postcards(self) -> PostcardsResourceWithRawResponse: + return PostcardsResourceWithRawResponse(self._print_mail.postcards) + + @cached_property + def bank_accounts(self) -> BankAccountsResourceWithRawResponse: + return BankAccountsResourceWithRawResponse(self._print_mail.bank_accounts) @cached_property def cheques(self) -> ChequesResourceWithRawResponse: return ChequesResourceWithRawResponse(self._print_mail.cheques) @cached_property - def contacts(self) -> ContactsResourceWithRawResponse: - return ContactsResourceWithRawResponse(self._print_mail.contacts) + def self_mailers(self) -> SelfMailersResourceWithRawResponse: + return SelfMailersResourceWithRawResponse(self._print_mail.self_mailers) @cached_property - def letters(self) -> LettersResourceWithRawResponse: - return LettersResourceWithRawResponse(self._print_mail.letters) + def campaigns(self) -> CampaignsResourceWithRawResponse: + """ + The campaigns API enables you to send out large volumes of fully + personalized mail to a mailing list. + """ + return CampaignsResourceWithRawResponse(self._print_mail.campaigns) @cached_property def mailing_list_imports(self) -> MailingListImportsResourceWithRawResponse: @@ -310,12 +620,12 @@ def mailing_list_imports(self) -> MailingListImportsResourceWithRawResponse: @cached_property def mailing_lists(self) -> MailingListsResourceWithRawResponse: + """ + The mailing lists API enables you to manage collections of contacts + that can be used for bulk mail campaigns. + """ return MailingListsResourceWithRawResponse(self._print_mail.mailing_lists) - @cached_property - def postcards(self) -> PostcardsResourceWithRawResponse: - return PostcardsResourceWithRawResponse(self._print_mail.postcards) - @cached_property def reports(self) -> ReportsResourceWithRawResponse: """ @@ -327,17 +637,106 @@ def reports(self) -> ReportsResourceWithRawResponse: """ return ReportsResourceWithRawResponse(self._print_mail.reports) - @cached_property - def self_mailers(self) -> SelfMailersResourceWithRawResponse: - return SelfMailersResourceWithRawResponse(self._print_mail.self_mailers) - @cached_property def sub_organizations(self) -> SubOrganizationsResourceWithRawResponse: + """ + Sub-organizations enable you to create isolated PostGrid accounts + ("sub-organizations") under your PostGrid account (the "parent organization"). + Each sub-organization has fully isolated resources + and users, and can act independently. + + This allows you to isolate different departments or even re-sell PostGrid + entirely. + + You can request access to this feature by reaching out to + support@postgrid.com + """ return SubOrganizationsResourceWithRawResponse(self._print_mail.sub_organizations) @cached_property - def templates(self) -> TemplatesResourceWithRawResponse: - return TemplatesResourceWithRawResponse(self._print_mail.templates) + def boxes(self) -> BoxesResourceWithRawResponse: + return BoxesResourceWithRawResponse(self._print_mail.boxes) + + @cached_property + def snap_packs(self) -> SnapPacksResourceWithRawResponse: + """ + Snap packs are pressure-sealed mailers that resemble official documents + and encourage higher open rates. They do not require envelopes and are + opened by tearing along perforated edges. The sealed design keeps contents + hidden until opened, making snap packs ideal for sensitive or important + documents such as contracts, forms, or notices. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + return SnapPacksResourceWithRawResponse(self._print_mail.snap_packs) + + @cached_property + def targeted_list_builds(self) -> TargetedListBuildsResourceWithRawResponse: + """ + **Beta:** the targeted list builds API is in beta and is subject to + breaking changes. Endpoint shapes, status values, and filter fields may + change without notice. + + The targeted list builds API lets you programmatically build mailing + lists of US consumers (B2C) or US companies (B2B) that match a set of + demographic, geographic, and firmographic filters. + + The lifecycle of a list build is: + + 1. Create a list build by supplying either `usConsumers` or `usCompanies` + filters. A quote is generated asynchronously — poll the resource or + wait for its `status` to become `quote_ready`. + 2. Review the `quote` (total count and price per contact) and masked + `previewRecords`. Adjust the filters with an update call if needed — + this will regenerate the quote. + 3. Confirm the build. This deducts the appropriate amount of list build + credits from your organization (in live mode) and begins constructing + the mailing list. `buildProgressPercent` reflects progress from 0 to + 100. + 4. Once `status` is `completed`, the ID of the resulting mailing list is + available in the `mailingList` field and can be used like any other + mailing list in the PostGrid API. + + Targeted list builds must be enabled on your organization before they + can be used. Contact PostGrid support to request access. + """ + return TargetedListBuildsResourceWithRawResponse(self._print_mail.targeted_list_builds) + + @cached_property + def template_editor_sessions(self) -> TemplateEditorSessionsResourceWithRawResponse: + """ + You can use template editor sessions to bring the capabilities of our + template editor to your website. When you create a session, you provide the + `template` which you want to edit, and we return a session with a `url` that + you can `iframe` or redirect your customers to. + + When users save their changes in the editor session, it will update the + underlying template. Note that sessions are only valid for 24 hours, after + which point they are automatically deleted for security reasons. + + You can have multiple sessions active for the same template at the same time. + In general, we recommend creating a new session every time you present our + editor to your users. + + Note: you can use the template editor to modify templates created using HTML, + but saving a session from the editor will override the original HTML content. + """ + return TemplateEditorSessionsResourceWithRawResponse(self._print_mail.template_editor_sessions) + + @cached_property + def virtual_mailboxes(self) -> VirtualMailboxesResourceWithRawResponse: + """ + Virtual mailboxes let you receive, scan, and forward your physical mail + without needing a traditional physical mailbox. Each mailbox is fully + digital, giving you a unique ID, status, and a set of capabilities such as + forwarding mail to another address or viewing envelope scans. This allows you + to manage physical correspondence entirely online. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + return VirtualMailboxesResourceWithRawResponse(self._print_mail.virtual_mailboxes) class AsyncPrintMailResourceWithRawResponse: @@ -345,28 +744,56 @@ def __init__(self, print_mail: AsyncPrintMailResource) -> None: self._print_mail = print_mail @cached_property - def bank_accounts(self) -> AsyncBankAccountsResourceWithRawResponse: - return AsyncBankAccountsResourceWithRawResponse(self._print_mail.bank_accounts) + def contacts(self) -> AsyncContactsResourceWithRawResponse: + return AsyncContactsResourceWithRawResponse(self._print_mail.contacts) @cached_property - def campaigns(self) -> AsyncCampaignsResourceWithRawResponse: - """ - The campaigns API enables you to send out large volumes of fully - personalized mail to a mailing list. + def templates(self) -> AsyncTemplatesResourceWithRawResponse: + return AsyncTemplatesResourceWithRawResponse(self._print_mail.templates) + + @cached_property + def trackers(self) -> AsyncTrackersResourceWithRawResponse: + """Create and manage Trackers. + + Trackers can be used to track interactions in your orders through + personalized URLs and QR codes. + + As a brief introduction to using Trackers in your orders, a QR code can be + generated by using the Tracker's ID as a merge variable in your orders HTML + and Templates. The following example HTML uses Trackers to generate + personalized URLs (PURLs) in your orders. + + See the following guide for more details: https://postgrid.readme.io/reference/trackers-1 """ - return AsyncCampaignsResourceWithRawResponse(self._print_mail.campaigns) + return AsyncTrackersResourceWithRawResponse(self._print_mail.trackers) + + @cached_property + def letters(self) -> AsyncLettersResourceWithRawResponse: + return AsyncLettersResourceWithRawResponse(self._print_mail.letters) + + @cached_property + def postcards(self) -> AsyncPostcardsResourceWithRawResponse: + return AsyncPostcardsResourceWithRawResponse(self._print_mail.postcards) + + @cached_property + def bank_accounts(self) -> AsyncBankAccountsResourceWithRawResponse: + return AsyncBankAccountsResourceWithRawResponse(self._print_mail.bank_accounts) @cached_property def cheques(self) -> AsyncChequesResourceWithRawResponse: return AsyncChequesResourceWithRawResponse(self._print_mail.cheques) @cached_property - def contacts(self) -> AsyncContactsResourceWithRawResponse: - return AsyncContactsResourceWithRawResponse(self._print_mail.contacts) + def self_mailers(self) -> AsyncSelfMailersResourceWithRawResponse: + return AsyncSelfMailersResourceWithRawResponse(self._print_mail.self_mailers) @cached_property - def letters(self) -> AsyncLettersResourceWithRawResponse: - return AsyncLettersResourceWithRawResponse(self._print_mail.letters) + def campaigns(self) -> AsyncCampaignsResourceWithRawResponse: + """ + The campaigns API enables you to send out large volumes of fully + personalized mail to a mailing list. + """ + return AsyncCampaignsResourceWithRawResponse(self._print_mail.campaigns) @cached_property def mailing_list_imports(self) -> AsyncMailingListImportsResourceWithRawResponse: @@ -378,12 +805,12 @@ def mailing_list_imports(self) -> AsyncMailingListImportsResourceWithRawResponse @cached_property def mailing_lists(self) -> AsyncMailingListsResourceWithRawResponse: + """ + The mailing lists API enables you to manage collections of contacts + that can be used for bulk mail campaigns. + """ return AsyncMailingListsResourceWithRawResponse(self._print_mail.mailing_lists) - @cached_property - def postcards(self) -> AsyncPostcardsResourceWithRawResponse: - return AsyncPostcardsResourceWithRawResponse(self._print_mail.postcards) - @cached_property def reports(self) -> AsyncReportsResourceWithRawResponse: """ @@ -395,17 +822,106 @@ def reports(self) -> AsyncReportsResourceWithRawResponse: """ return AsyncReportsResourceWithRawResponse(self._print_mail.reports) - @cached_property - def self_mailers(self) -> AsyncSelfMailersResourceWithRawResponse: - return AsyncSelfMailersResourceWithRawResponse(self._print_mail.self_mailers) - @cached_property def sub_organizations(self) -> AsyncSubOrganizationsResourceWithRawResponse: + """ + Sub-organizations enable you to create isolated PostGrid accounts + ("sub-organizations") under your PostGrid account (the "parent organization"). + Each sub-organization has fully isolated resources + and users, and can act independently. + + This allows you to isolate different departments or even re-sell PostGrid + entirely. + + You can request access to this feature by reaching out to + support@postgrid.com + """ return AsyncSubOrganizationsResourceWithRawResponse(self._print_mail.sub_organizations) @cached_property - def templates(self) -> AsyncTemplatesResourceWithRawResponse: - return AsyncTemplatesResourceWithRawResponse(self._print_mail.templates) + def boxes(self) -> AsyncBoxesResourceWithRawResponse: + return AsyncBoxesResourceWithRawResponse(self._print_mail.boxes) + + @cached_property + def snap_packs(self) -> AsyncSnapPacksResourceWithRawResponse: + """ + Snap packs are pressure-sealed mailers that resemble official documents + and encourage higher open rates. They do not require envelopes and are + opened by tearing along perforated edges. The sealed design keeps contents + hidden until opened, making snap packs ideal for sensitive or important + documents such as contracts, forms, or notices. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + return AsyncSnapPacksResourceWithRawResponse(self._print_mail.snap_packs) + + @cached_property + def targeted_list_builds(self) -> AsyncTargetedListBuildsResourceWithRawResponse: + """ + **Beta:** the targeted list builds API is in beta and is subject to + breaking changes. Endpoint shapes, status values, and filter fields may + change without notice. + + The targeted list builds API lets you programmatically build mailing + lists of US consumers (B2C) or US companies (B2B) that match a set of + demographic, geographic, and firmographic filters. + + The lifecycle of a list build is: + + 1. Create a list build by supplying either `usConsumers` or `usCompanies` + filters. A quote is generated asynchronously — poll the resource or + wait for its `status` to become `quote_ready`. + 2. Review the `quote` (total count and price per contact) and masked + `previewRecords`. Adjust the filters with an update call if needed — + this will regenerate the quote. + 3. Confirm the build. This deducts the appropriate amount of list build + credits from your organization (in live mode) and begins constructing + the mailing list. `buildProgressPercent` reflects progress from 0 to + 100. + 4. Once `status` is `completed`, the ID of the resulting mailing list is + available in the `mailingList` field and can be used like any other + mailing list in the PostGrid API. + + Targeted list builds must be enabled on your organization before they + can be used. Contact PostGrid support to request access. + """ + return AsyncTargetedListBuildsResourceWithRawResponse(self._print_mail.targeted_list_builds) + + @cached_property + def template_editor_sessions(self) -> AsyncTemplateEditorSessionsResourceWithRawResponse: + """ + You can use template editor sessions to bring the capabilities of our + template editor to your website. When you create a session, you provide the + `template` which you want to edit, and we return a session with a `url` that + you can `iframe` or redirect your customers to. + + When users save their changes in the editor session, it will update the + underlying template. Note that sessions are only valid for 24 hours, after + which point they are automatically deleted for security reasons. + + You can have multiple sessions active for the same template at the same time. + In general, we recommend creating a new session every time you present our + editor to your users. + + Note: you can use the template editor to modify templates created using HTML, + but saving a session from the editor will override the original HTML content. + """ + return AsyncTemplateEditorSessionsResourceWithRawResponse(self._print_mail.template_editor_sessions) + + @cached_property + def virtual_mailboxes(self) -> AsyncVirtualMailboxesResourceWithRawResponse: + """ + Virtual mailboxes let you receive, scan, and forward your physical mail + without needing a traditional physical mailbox. Each mailbox is fully + digital, giving you a unique ID, status, and a set of capabilities such as + forwarding mail to another address or viewing envelope scans. This allows you + to manage physical correspondence entirely online. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + return AsyncVirtualMailboxesResourceWithRawResponse(self._print_mail.virtual_mailboxes) class PrintMailResourceWithStreamingResponse: @@ -413,28 +929,56 @@ def __init__(self, print_mail: PrintMailResource) -> None: self._print_mail = print_mail @cached_property - def bank_accounts(self) -> BankAccountsResourceWithStreamingResponse: - return BankAccountsResourceWithStreamingResponse(self._print_mail.bank_accounts) + def contacts(self) -> ContactsResourceWithStreamingResponse: + return ContactsResourceWithStreamingResponse(self._print_mail.contacts) @cached_property - def campaigns(self) -> CampaignsResourceWithStreamingResponse: - """ - The campaigns API enables you to send out large volumes of fully - personalized mail to a mailing list. + def templates(self) -> TemplatesResourceWithStreamingResponse: + return TemplatesResourceWithStreamingResponse(self._print_mail.templates) + + @cached_property + def trackers(self) -> TrackersResourceWithStreamingResponse: + """Create and manage Trackers. + + Trackers can be used to track interactions in your orders through + personalized URLs and QR codes. + + As a brief introduction to using Trackers in your orders, a QR code can be + generated by using the Tracker's ID as a merge variable in your orders HTML + and Templates. The following example HTML uses Trackers to generate + personalized URLs (PURLs) in your orders. + + See the following guide for more details: https://postgrid.readme.io/reference/trackers-1 """ - return CampaignsResourceWithStreamingResponse(self._print_mail.campaigns) + return TrackersResourceWithStreamingResponse(self._print_mail.trackers) + + @cached_property + def letters(self) -> LettersResourceWithStreamingResponse: + return LettersResourceWithStreamingResponse(self._print_mail.letters) + + @cached_property + def postcards(self) -> PostcardsResourceWithStreamingResponse: + return PostcardsResourceWithStreamingResponse(self._print_mail.postcards) + + @cached_property + def bank_accounts(self) -> BankAccountsResourceWithStreamingResponse: + return BankAccountsResourceWithStreamingResponse(self._print_mail.bank_accounts) @cached_property def cheques(self) -> ChequesResourceWithStreamingResponse: return ChequesResourceWithStreamingResponse(self._print_mail.cheques) @cached_property - def contacts(self) -> ContactsResourceWithStreamingResponse: - return ContactsResourceWithStreamingResponse(self._print_mail.contacts) + def self_mailers(self) -> SelfMailersResourceWithStreamingResponse: + return SelfMailersResourceWithStreamingResponse(self._print_mail.self_mailers) @cached_property - def letters(self) -> LettersResourceWithStreamingResponse: - return LettersResourceWithStreamingResponse(self._print_mail.letters) + def campaigns(self) -> CampaignsResourceWithStreamingResponse: + """ + The campaigns API enables you to send out large volumes of fully + personalized mail to a mailing list. + """ + return CampaignsResourceWithStreamingResponse(self._print_mail.campaigns) @cached_property def mailing_list_imports(self) -> MailingListImportsResourceWithStreamingResponse: @@ -446,12 +990,12 @@ def mailing_list_imports(self) -> MailingListImportsResourceWithStreamingRespons @cached_property def mailing_lists(self) -> MailingListsResourceWithStreamingResponse: + """ + The mailing lists API enables you to manage collections of contacts + that can be used for bulk mail campaigns. + """ return MailingListsResourceWithStreamingResponse(self._print_mail.mailing_lists) - @cached_property - def postcards(self) -> PostcardsResourceWithStreamingResponse: - return PostcardsResourceWithStreamingResponse(self._print_mail.postcards) - @cached_property def reports(self) -> ReportsResourceWithStreamingResponse: """ @@ -463,17 +1007,106 @@ def reports(self) -> ReportsResourceWithStreamingResponse: """ return ReportsResourceWithStreamingResponse(self._print_mail.reports) - @cached_property - def self_mailers(self) -> SelfMailersResourceWithStreamingResponse: - return SelfMailersResourceWithStreamingResponse(self._print_mail.self_mailers) - @cached_property def sub_organizations(self) -> SubOrganizationsResourceWithStreamingResponse: + """ + Sub-organizations enable you to create isolated PostGrid accounts + ("sub-organizations") under your PostGrid account (the "parent organization"). + Each sub-organization has fully isolated resources + and users, and can act independently. + + This allows you to isolate different departments or even re-sell PostGrid + entirely. + + You can request access to this feature by reaching out to + support@postgrid.com + """ return SubOrganizationsResourceWithStreamingResponse(self._print_mail.sub_organizations) @cached_property - def templates(self) -> TemplatesResourceWithStreamingResponse: - return TemplatesResourceWithStreamingResponse(self._print_mail.templates) + def boxes(self) -> BoxesResourceWithStreamingResponse: + return BoxesResourceWithStreamingResponse(self._print_mail.boxes) + + @cached_property + def snap_packs(self) -> SnapPacksResourceWithStreamingResponse: + """ + Snap packs are pressure-sealed mailers that resemble official documents + and encourage higher open rates. They do not require envelopes and are + opened by tearing along perforated edges. The sealed design keeps contents + hidden until opened, making snap packs ideal for sensitive or important + documents such as contracts, forms, or notices. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + return SnapPacksResourceWithStreamingResponse(self._print_mail.snap_packs) + + @cached_property + def targeted_list_builds(self) -> TargetedListBuildsResourceWithStreamingResponse: + """ + **Beta:** the targeted list builds API is in beta and is subject to + breaking changes. Endpoint shapes, status values, and filter fields may + change without notice. + + The targeted list builds API lets you programmatically build mailing + lists of US consumers (B2C) or US companies (B2B) that match a set of + demographic, geographic, and firmographic filters. + + The lifecycle of a list build is: + + 1. Create a list build by supplying either `usConsumers` or `usCompanies` + filters. A quote is generated asynchronously — poll the resource or + wait for its `status` to become `quote_ready`. + 2. Review the `quote` (total count and price per contact) and masked + `previewRecords`. Adjust the filters with an update call if needed — + this will regenerate the quote. + 3. Confirm the build. This deducts the appropriate amount of list build + credits from your organization (in live mode) and begins constructing + the mailing list. `buildProgressPercent` reflects progress from 0 to + 100. + 4. Once `status` is `completed`, the ID of the resulting mailing list is + available in the `mailingList` field and can be used like any other + mailing list in the PostGrid API. + + Targeted list builds must be enabled on your organization before they + can be used. Contact PostGrid support to request access. + """ + return TargetedListBuildsResourceWithStreamingResponse(self._print_mail.targeted_list_builds) + + @cached_property + def template_editor_sessions(self) -> TemplateEditorSessionsResourceWithStreamingResponse: + """ + You can use template editor sessions to bring the capabilities of our + template editor to your website. When you create a session, you provide the + `template` which you want to edit, and we return a session with a `url` that + you can `iframe` or redirect your customers to. + + When users save their changes in the editor session, it will update the + underlying template. Note that sessions are only valid for 24 hours, after + which point they are automatically deleted for security reasons. + + You can have multiple sessions active for the same template at the same time. + In general, we recommend creating a new session every time you present our + editor to your users. + + Note: you can use the template editor to modify templates created using HTML, + but saving a session from the editor will override the original HTML content. + """ + return TemplateEditorSessionsResourceWithStreamingResponse(self._print_mail.template_editor_sessions) + + @cached_property + def virtual_mailboxes(self) -> VirtualMailboxesResourceWithStreamingResponse: + """ + Virtual mailboxes let you receive, scan, and forward your physical mail + without needing a traditional physical mailbox. Each mailbox is fully + digital, giving you a unique ID, status, and a set of capabilities such as + forwarding mail to another address or viewing envelope scans. This allows you + to manage physical correspondence entirely online. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + return VirtualMailboxesResourceWithStreamingResponse(self._print_mail.virtual_mailboxes) class AsyncPrintMailResourceWithStreamingResponse: @@ -481,28 +1114,56 @@ def __init__(self, print_mail: AsyncPrintMailResource) -> None: self._print_mail = print_mail @cached_property - def bank_accounts(self) -> AsyncBankAccountsResourceWithStreamingResponse: - return AsyncBankAccountsResourceWithStreamingResponse(self._print_mail.bank_accounts) + def contacts(self) -> AsyncContactsResourceWithStreamingResponse: + return AsyncContactsResourceWithStreamingResponse(self._print_mail.contacts) @cached_property - def campaigns(self) -> AsyncCampaignsResourceWithStreamingResponse: - """ - The campaigns API enables you to send out large volumes of fully - personalized mail to a mailing list. + def templates(self) -> AsyncTemplatesResourceWithStreamingResponse: + return AsyncTemplatesResourceWithStreamingResponse(self._print_mail.templates) + + @cached_property + def trackers(self) -> AsyncTrackersResourceWithStreamingResponse: + """Create and manage Trackers. + + Trackers can be used to track interactions in your orders through + personalized URLs and QR codes. + + As a brief introduction to using Trackers in your orders, a QR code can be + generated by using the Tracker's ID as a merge variable in your orders HTML + and Templates. The following example HTML uses Trackers to generate + personalized URLs (PURLs) in your orders. + + See the following guide for more details: https://postgrid.readme.io/reference/trackers-1 """ - return AsyncCampaignsResourceWithStreamingResponse(self._print_mail.campaigns) + return AsyncTrackersResourceWithStreamingResponse(self._print_mail.trackers) + + @cached_property + def letters(self) -> AsyncLettersResourceWithStreamingResponse: + return AsyncLettersResourceWithStreamingResponse(self._print_mail.letters) + + @cached_property + def postcards(self) -> AsyncPostcardsResourceWithStreamingResponse: + return AsyncPostcardsResourceWithStreamingResponse(self._print_mail.postcards) + + @cached_property + def bank_accounts(self) -> AsyncBankAccountsResourceWithStreamingResponse: + return AsyncBankAccountsResourceWithStreamingResponse(self._print_mail.bank_accounts) @cached_property def cheques(self) -> AsyncChequesResourceWithStreamingResponse: return AsyncChequesResourceWithStreamingResponse(self._print_mail.cheques) @cached_property - def contacts(self) -> AsyncContactsResourceWithStreamingResponse: - return AsyncContactsResourceWithStreamingResponse(self._print_mail.contacts) + def self_mailers(self) -> AsyncSelfMailersResourceWithStreamingResponse: + return AsyncSelfMailersResourceWithStreamingResponse(self._print_mail.self_mailers) @cached_property - def letters(self) -> AsyncLettersResourceWithStreamingResponse: - return AsyncLettersResourceWithStreamingResponse(self._print_mail.letters) + def campaigns(self) -> AsyncCampaignsResourceWithStreamingResponse: + """ + The campaigns API enables you to send out large volumes of fully + personalized mail to a mailing list. + """ + return AsyncCampaignsResourceWithStreamingResponse(self._print_mail.campaigns) @cached_property def mailing_list_imports(self) -> AsyncMailingListImportsResourceWithStreamingResponse: @@ -514,12 +1175,12 @@ def mailing_list_imports(self) -> AsyncMailingListImportsResourceWithStreamingRe @cached_property def mailing_lists(self) -> AsyncMailingListsResourceWithStreamingResponse: + """ + The mailing lists API enables you to manage collections of contacts + that can be used for bulk mail campaigns. + """ return AsyncMailingListsResourceWithStreamingResponse(self._print_mail.mailing_lists) - @cached_property - def postcards(self) -> AsyncPostcardsResourceWithStreamingResponse: - return AsyncPostcardsResourceWithStreamingResponse(self._print_mail.postcards) - @cached_property def reports(self) -> AsyncReportsResourceWithStreamingResponse: """ @@ -531,14 +1192,103 @@ def reports(self) -> AsyncReportsResourceWithStreamingResponse: """ return AsyncReportsResourceWithStreamingResponse(self._print_mail.reports) - @cached_property - def self_mailers(self) -> AsyncSelfMailersResourceWithStreamingResponse: - return AsyncSelfMailersResourceWithStreamingResponse(self._print_mail.self_mailers) - @cached_property def sub_organizations(self) -> AsyncSubOrganizationsResourceWithStreamingResponse: + """ + Sub-organizations enable you to create isolated PostGrid accounts + ("sub-organizations") under your PostGrid account (the "parent organization"). + Each sub-organization has fully isolated resources + and users, and can act independently. + + This allows you to isolate different departments or even re-sell PostGrid + entirely. + + You can request access to this feature by reaching out to + support@postgrid.com + """ return AsyncSubOrganizationsResourceWithStreamingResponse(self._print_mail.sub_organizations) @cached_property - def templates(self) -> AsyncTemplatesResourceWithStreamingResponse: - return AsyncTemplatesResourceWithStreamingResponse(self._print_mail.templates) + def boxes(self) -> AsyncBoxesResourceWithStreamingResponse: + return AsyncBoxesResourceWithStreamingResponse(self._print_mail.boxes) + + @cached_property + def snap_packs(self) -> AsyncSnapPacksResourceWithStreamingResponse: + """ + Snap packs are pressure-sealed mailers that resemble official documents + and encourage higher open rates. They do not require envelopes and are + opened by tearing along perforated edges. The sealed design keeps contents + hidden until opened, making snap packs ideal for sensitive or important + documents such as contracts, forms, or notices. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + return AsyncSnapPacksResourceWithStreamingResponse(self._print_mail.snap_packs) + + @cached_property + def targeted_list_builds(self) -> AsyncTargetedListBuildsResourceWithStreamingResponse: + """ + **Beta:** the targeted list builds API is in beta and is subject to + breaking changes. Endpoint shapes, status values, and filter fields may + change without notice. + + The targeted list builds API lets you programmatically build mailing + lists of US consumers (B2C) or US companies (B2B) that match a set of + demographic, geographic, and firmographic filters. + + The lifecycle of a list build is: + + 1. Create a list build by supplying either `usConsumers` or `usCompanies` + filters. A quote is generated asynchronously — poll the resource or + wait for its `status` to become `quote_ready`. + 2. Review the `quote` (total count and price per contact) and masked + `previewRecords`. Adjust the filters with an update call if needed — + this will regenerate the quote. + 3. Confirm the build. This deducts the appropriate amount of list build + credits from your organization (in live mode) and begins constructing + the mailing list. `buildProgressPercent` reflects progress from 0 to + 100. + 4. Once `status` is `completed`, the ID of the resulting mailing list is + available in the `mailingList` field and can be used like any other + mailing list in the PostGrid API. + + Targeted list builds must be enabled on your organization before they + can be used. Contact PostGrid support to request access. + """ + return AsyncTargetedListBuildsResourceWithStreamingResponse(self._print_mail.targeted_list_builds) + + @cached_property + def template_editor_sessions(self) -> AsyncTemplateEditorSessionsResourceWithStreamingResponse: + """ + You can use template editor sessions to bring the capabilities of our + template editor to your website. When you create a session, you provide the + `template` which you want to edit, and we return a session with a `url` that + you can `iframe` or redirect your customers to. + + When users save their changes in the editor session, it will update the + underlying template. Note that sessions are only valid for 24 hours, after + which point they are automatically deleted for security reasons. + + You can have multiple sessions active for the same template at the same time. + In general, we recommend creating a new session every time you present our + editor to your users. + + Note: you can use the template editor to modify templates created using HTML, + but saving a session from the editor will override the original HTML content. + """ + return AsyncTemplateEditorSessionsResourceWithStreamingResponse(self._print_mail.template_editor_sessions) + + @cached_property + def virtual_mailboxes(self) -> AsyncVirtualMailboxesResourceWithStreamingResponse: + """ + Virtual mailboxes let you receive, scan, and forward your physical mail + without needing a traditional physical mailbox. Each mailbox is fully + digital, giving you a unique ID, status, and a set of capabilities such as + forwarding mail to another address or viewing envelope scans. This allows you + to manage physical correspondence entirely online. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + return AsyncVirtualMailboxesResourceWithStreamingResponse(self._print_mail.virtual_mailboxes) diff --git a/src/postgrid/resources/print_mail/self_mailers.py b/src/postgrid/resources/print_mail/self_mailers.py index 1b63dda..4ad5f4b 100644 --- a/src/postgrid/resources/print_mail/self_mailers.py +++ b/src/postgrid/resources/print_mail/self_mailers.py @@ -592,6 +592,45 @@ def delete( cast_to=SelfMailer, ) + def progress( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SelfMailer: + """Progresses a self-mailer's `status` to the next stage. + + This is only available in + test mode and can be used to simulate how a live order would progress through + the different statuses. + + Note: this will fail with an `invalid_progression_error` if the status is one of + `completed` or `cancelled`. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + path_template("/print-mail/v1/self_mailers/{id}/progressions", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SelfMailer, + ) + def retrieve_url( self, id: str, @@ -1196,6 +1235,45 @@ async def delete( cast_to=SelfMailer, ) + async def progress( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SelfMailer: + """Progresses a self-mailer's `status` to the next stage. + + This is only available in + test mode and can be used to simulate how a live order would progress through + the different statuses. + + Note: this will fail with an `invalid_progression_error` if the status is one of + `completed` or `cancelled`. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + path_template("/print-mail/v1/self_mailers/{id}/progressions", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SelfMailer, + ) + async def retrieve_url( self, id: str, @@ -1251,6 +1329,9 @@ def __init__(self, self_mailers: SelfMailersResource) -> None: self.delete = to_raw_response_wrapper( self_mailers.delete, ) + self.progress = to_raw_response_wrapper( + self_mailers.progress, + ) self.retrieve_url = to_raw_response_wrapper( self_mailers.retrieve_url, ) @@ -1272,6 +1353,9 @@ def __init__(self, self_mailers: AsyncSelfMailersResource) -> None: self.delete = async_to_raw_response_wrapper( self_mailers.delete, ) + self.progress = async_to_raw_response_wrapper( + self_mailers.progress, + ) self.retrieve_url = async_to_raw_response_wrapper( self_mailers.retrieve_url, ) @@ -1293,6 +1377,9 @@ def __init__(self, self_mailers: SelfMailersResource) -> None: self.delete = to_streamed_response_wrapper( self_mailers.delete, ) + self.progress = to_streamed_response_wrapper( + self_mailers.progress, + ) self.retrieve_url = to_streamed_response_wrapper( self_mailers.retrieve_url, ) @@ -1314,6 +1401,9 @@ def __init__(self, self_mailers: AsyncSelfMailersResource) -> None: self.delete = async_to_streamed_response_wrapper( self_mailers.delete, ) + self.progress = async_to_streamed_response_wrapper( + self_mailers.progress, + ) self.retrieve_url = async_to_streamed_response_wrapper( self_mailers.retrieve_url, ) diff --git a/src/postgrid/resources/print_mail/snap_packs.py b/src/postgrid/resources/print_mail/snap_packs.py new file mode 100644 index 0000000..29dec0f --- /dev/null +++ b/src/postgrid/resources/print_mail/snap_packs.py @@ -0,0 +1,1375 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Union +from datetime import datetime +from typing_extensions import Literal, overload + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import path_template, required_args, maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...pagination import SyncSkipLimit, AsyncSkipLimit +from ..._base_client import AsyncPaginator, make_request_options +from ...types.print_mail import snap_pack_list_params, snap_pack_create_params, snap_pack_retrieve_capabilities_params +from ...types.print_mail.snap_pack_list_response import SnapPackListResponse +from ...types.print_mail.snap_pack_create_response import SnapPackCreateResponse +from ...types.print_mail.snap_pack_delete_response import SnapPackDeleteResponse +from ...types.print_mail.snap_pack_retrieve_response import SnapPackRetrieveResponse +from ...types.print_mail.snap_pack_progressions_response import SnapPackProgressionsResponse +from ...types.print_mail.snap_pack_retrieve_capabilities_response import SnapPackRetrieveCapabilitiesResponse + +__all__ = ["SnapPacksResource", "AsyncSnapPacksResource"] + + +class SnapPacksResource(SyncAPIResource): + """ + Snap packs are pressure-sealed mailers that resemble official documents + and encourage higher open rates. They do not require envelopes and are + opened by tearing along perforated edges. The sealed design keeps contents + hidden until opened, making snap packs ideal for sensitive or important + documents such as contracts, forms, or notices. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + + @cached_property + def with_raw_response(self) -> SnapPacksResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + """ + return SnapPacksResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SnapPacksResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + """ + return SnapPacksResourceWithStreamingResponse(self) + + @overload + def create( + self, + *, + from_: snap_pack_create_params.SnapPackCreateWithHTMLFrom, + inside_html: str, + outside_html: str, + size: Literal["8.5x11_bifold_v"], + to: snap_pack_create_params.SnapPackCreateWithHTMLTo, + description: str | Omit = omit, + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] + | Omit = omit, + merge_variables: Dict[str, object] | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + send_date: Union[str, datetime] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SnapPackCreateResponse: + """Create a snap pack. + + You can supply one of the following: + + - HTML content for the inside and outside of the snap pack + - Template IDs for the inside and outside of the snap pack + - A URL or file upload for a two-page PDF that matches the snap pack layout + + Args: + from_: The contact information of the sender. You can pass contact information inline + here just like you can for the `to` contact. + + inside_html: The HTML content for the inside of the snap pack. You can supply _either_ this + or `insideTemplate` but not both. + + outside_html: The HTML content for the outside of the snap pack. You can supply _either_ this + or `outsideTemplate` but not both. + + size: Enum representing the supported snap pack sizes. + + to: The recipient of this order. You can either supply the contact information + inline here or provide a contact ID. PostGrid will automatically deduplicate + contacts regardless of whether you provide the information inline here or call + the contact creation endpoint. + + description: An optional string describing this resource. Will be visible in the API and the + dashboard. + + mailing_class: The mailing class of this order. If not provided, automatically set to + `first_class`. + + merge_variables: These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + + metadata: See the section on Metadata. + + send_date: This order will transition from `ready` to `printing` on the day after this + date. You can use this parameter to schedule orders for a future date. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + *, + from_: snap_pack_create_params.SnapPackCreateWithTemplateFrom, + inside_template: str, + outside_template: str, + size: Literal["8.5x11_bifold_v"], + to: snap_pack_create_params.SnapPackCreateWithTemplateTo, + description: str | Omit = omit, + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] + | Omit = omit, + merge_variables: Dict[str, object] | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + send_date: Union[str, datetime] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SnapPackCreateResponse: + """Create a snap pack. + + You can supply one of the following: + + - HTML content for the inside and outside of the snap pack + - Template IDs for the inside and outside of the snap pack + - A URL or file upload for a two-page PDF that matches the snap pack layout + + Args: + from_: The contact information of the sender. You can pass contact information inline + here just like you can for the `to` contact. + + inside_template: The template ID for the inside of the snap pack. You can supply _either_ this or + `insideHTML` but not both. + + outside_template: The template ID for the outside of the snap pack. You can supply _either_ this + or `outsideHTML` but not both. + + size: Enum representing the supported snap pack sizes. + + to: The recipient of this order. You can either supply the contact information + inline here or provide a contact ID. PostGrid will automatically deduplicate + contacts regardless of whether you provide the information inline here or call + the contact creation endpoint. + + description: An optional string describing this resource. Will be visible in the API and the + dashboard. + + mailing_class: The mailing class of this order. If not provided, automatically set to + `first_class`. + + merge_variables: These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + + metadata: See the section on Metadata. + + send_date: This order will transition from `ready` to `printing` on the day after this + date. You can use this parameter to schedule orders for a future date. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + *, + from_: snap_pack_create_params.SnapPackCreateWithPdfFrom, + pdf: str, + size: Literal["8.5x11_bifold_v"], + to: snap_pack_create_params.SnapPackCreateWithPdfTo, + description: str | Omit = omit, + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] + | Omit = omit, + merge_variables: Dict[str, object] | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + send_date: Union[str, datetime] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SnapPackCreateResponse: + """Create a snap pack. + + You can supply one of the following: + + - HTML content for the inside and outside of the snap pack + - Template IDs for the inside and outside of the snap pack + - A URL or file upload for a two-page PDF that matches the snap pack layout + + Args: + from_: The contact information of the sender. You can pass contact information inline + here just like you can for the `to` contact. + + pdf: A URL or a multipart-uploaded two-page PDF (first page is the outside, second + page is the inside) that matches the selected snap pack size. + + size: Enum representing the supported snap pack sizes. + + to: The recipient of this order. You can either supply the contact information + inline here or provide a contact ID. PostGrid will automatically deduplicate + contacts regardless of whether you provide the information inline here or call + the contact creation endpoint. + + description: An optional string describing this resource. Will be visible in the API and the + dashboard. + + mailing_class: The mailing class of this order. If not provided, automatically set to + `first_class`. + + merge_variables: These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + + metadata: See the section on Metadata. + + send_date: This order will transition from `ready` to `printing` on the day after this + date. You can use this parameter to schedule orders for a future date. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args( + ["from_", "inside_html", "outside_html", "size", "to"], + ["from_", "inside_template", "outside_template", "size", "to"], + ["from_", "pdf", "size", "to"], + ) + def create( + self, + *, + from_: snap_pack_create_params.SnapPackCreateWithHTMLFrom + | snap_pack_create_params.SnapPackCreateWithTemplateFrom + | snap_pack_create_params.SnapPackCreateWithPdfFrom, + inside_html: str | Omit = omit, + outside_html: str | Omit = omit, + size: Literal["8.5x11_bifold_v"], + to: snap_pack_create_params.SnapPackCreateWithHTMLTo + | snap_pack_create_params.SnapPackCreateWithTemplateTo + | snap_pack_create_params.SnapPackCreateWithPdfTo, + description: str | Omit = omit, + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] + | Omit = omit, + merge_variables: Dict[str, object] | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + send_date: Union[str, datetime] | Omit = omit, + inside_template: str | Omit = omit, + outside_template: str | Omit = omit, + pdf: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SnapPackCreateResponse: + return self._post( + "/print-mail/v1/snap_packs", + body=maybe_transform( + { + "from_": from_, + "inside_html": inside_html, + "outside_html": outside_html, + "size": size, + "to": to, + "description": description, + "mailing_class": mailing_class, + "merge_variables": merge_variables, + "metadata": metadata, + "send_date": send_date, + "inside_template": inside_template, + "outside_template": outside_template, + "pdf": pdf, + }, + snap_pack_create_params.SnapPackCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SnapPackCreateResponse, + ) + + def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SnapPackRetrieveResponse: + """ + Retrieve a snap pack by ID. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + path_template("/print-mail/v1/snap_packs/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SnapPackRetrieveResponse, + ) + + def list( + self, + *, + limit: int | Omit = omit, + search: str | Omit = omit, + skip: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSkipLimit[SnapPackListResponse]: + """ + Get a list of snap packs. + + Args: + search: You can supply any string to help narrow down the list of resources. For + example, if you pass `"New York"` (quoted), it will return resources that have + that string present somewhere in their response. Alternatively, you can supply a + structured search query. See the documentation on `StructuredSearchQuery` for + more details. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get_api_list( + "/print-mail/v1/snap_packs", + page=SyncSkipLimit[SnapPackListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "search": search, + "skip": skip, + }, + snap_pack_list_params.SnapPackListParams, + ), + ), + model=SnapPackListResponse, + ) + + def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SnapPackDeleteResponse: + """Cancel a snap pack by ID. + + Note that this operation cannot be undone and that + only snap packs with a status of `ready` can be cancelled. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._delete( + path_template("/print-mail/v1/snap_packs/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SnapPackDeleteResponse, + ) + + def progressions( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SnapPackProgressionsResponse: + """Progresses a snap pack's `status` to the next stage. + + This is only available in + test mode and can be used to simulate how a live order would progress through + the different statuses. + + Note: this will fail with an `invalid_progression_error` if the status is one of + `completed` or `cancelled`. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + path_template("/print-mail/v1/snap_packs/{id}/progressions", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SnapPackProgressionsResponse, + ) + + def retrieve_capabilities( + self, + *, + return_country_code: str, + destination_country_code: str | Omit = omit, + mailing_list: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SnapPackRetrieveCapabilitiesResponse: + """ + Provides sizes and mailing classes available for the destination. + + Args: + return_country_code: The country code where mail may be returned to. + + destination_country_code: The country code of where the snap pack will be sent to. One of `mailingList` or + `destinationCountryCode` must be supplied but not both. + + mailing_list: Sources destination countries from the provided mailing list. One of + `mailingList` or `destinationCountryCode` must be supplied but not both. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get( + "/print-mail/v1/snap_packs/capabilities", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "return_country_code": return_country_code, + "destination_country_code": destination_country_code, + "mailing_list": mailing_list, + }, + snap_pack_retrieve_capabilities_params.SnapPackRetrieveCapabilitiesParams, + ), + ), + cast_to=SnapPackRetrieveCapabilitiesResponse, + ) + + +class AsyncSnapPacksResource(AsyncAPIResource): + """ + Snap packs are pressure-sealed mailers that resemble official documents + and encourage higher open rates. They do not require envelopes and are + opened by tearing along perforated edges. The sealed design keeps contents + hidden until opened, making snap packs ideal for sensitive or important + documents such as contracts, forms, or notices. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + + @cached_property + def with_raw_response(self) -> AsyncSnapPacksResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + """ + return AsyncSnapPacksResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSnapPacksResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + """ + return AsyncSnapPacksResourceWithStreamingResponse(self) + + @overload + async def create( + self, + *, + from_: snap_pack_create_params.SnapPackCreateWithHTMLFrom, + inside_html: str, + outside_html: str, + size: Literal["8.5x11_bifold_v"], + to: snap_pack_create_params.SnapPackCreateWithHTMLTo, + description: str | Omit = omit, + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] + | Omit = omit, + merge_variables: Dict[str, object] | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + send_date: Union[str, datetime] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SnapPackCreateResponse: + """Create a snap pack. + + You can supply one of the following: + + - HTML content for the inside and outside of the snap pack + - Template IDs for the inside and outside of the snap pack + - A URL or file upload for a two-page PDF that matches the snap pack layout + + Args: + from_: The contact information of the sender. You can pass contact information inline + here just like you can for the `to` contact. + + inside_html: The HTML content for the inside of the snap pack. You can supply _either_ this + or `insideTemplate` but not both. + + outside_html: The HTML content for the outside of the snap pack. You can supply _either_ this + or `outsideTemplate` but not both. + + size: Enum representing the supported snap pack sizes. + + to: The recipient of this order. You can either supply the contact information + inline here or provide a contact ID. PostGrid will automatically deduplicate + contacts regardless of whether you provide the information inline here or call + the contact creation endpoint. + + description: An optional string describing this resource. Will be visible in the API and the + dashboard. + + mailing_class: The mailing class of this order. If not provided, automatically set to + `first_class`. + + merge_variables: These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + + metadata: See the section on Metadata. + + send_date: This order will transition from `ready` to `printing` on the day after this + date. You can use this parameter to schedule orders for a future date. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + *, + from_: snap_pack_create_params.SnapPackCreateWithTemplateFrom, + inside_template: str, + outside_template: str, + size: Literal["8.5x11_bifold_v"], + to: snap_pack_create_params.SnapPackCreateWithTemplateTo, + description: str | Omit = omit, + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] + | Omit = omit, + merge_variables: Dict[str, object] | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + send_date: Union[str, datetime] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SnapPackCreateResponse: + """Create a snap pack. + + You can supply one of the following: + + - HTML content for the inside and outside of the snap pack + - Template IDs for the inside and outside of the snap pack + - A URL or file upload for a two-page PDF that matches the snap pack layout + + Args: + from_: The contact information of the sender. You can pass contact information inline + here just like you can for the `to` contact. + + inside_template: The template ID for the inside of the snap pack. You can supply _either_ this or + `insideHTML` but not both. + + outside_template: The template ID for the outside of the snap pack. You can supply _either_ this + or `outsideHTML` but not both. + + size: Enum representing the supported snap pack sizes. + + to: The recipient of this order. You can either supply the contact information + inline here or provide a contact ID. PostGrid will automatically deduplicate + contacts regardless of whether you provide the information inline here or call + the contact creation endpoint. + + description: An optional string describing this resource. Will be visible in the API and the + dashboard. + + mailing_class: The mailing class of this order. If not provided, automatically set to + `first_class`. + + merge_variables: These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + + metadata: See the section on Metadata. + + send_date: This order will transition from `ready` to `printing` on the day after this + date. You can use this parameter to schedule orders for a future date. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + *, + from_: snap_pack_create_params.SnapPackCreateWithPdfFrom, + pdf: str, + size: Literal["8.5x11_bifold_v"], + to: snap_pack_create_params.SnapPackCreateWithPdfTo, + description: str | Omit = omit, + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] + | Omit = omit, + merge_variables: Dict[str, object] | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + send_date: Union[str, datetime] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SnapPackCreateResponse: + """Create a snap pack. + + You can supply one of the following: + + - HTML content for the inside and outside of the snap pack + - Template IDs for the inside and outside of the snap pack + - A URL or file upload for a two-page PDF that matches the snap pack layout + + Args: + from_: The contact information of the sender. You can pass contact information inline + here just like you can for the `to` contact. + + pdf: A URL or a multipart-uploaded two-page PDF (first page is the outside, second + page is the inside) that matches the selected snap pack size. + + size: Enum representing the supported snap pack sizes. + + to: The recipient of this order. You can either supply the contact information + inline here or provide a contact ID. PostGrid will automatically deduplicate + contacts regardless of whether you provide the information inline here or call + the contact creation endpoint. + + description: An optional string describing this resource. Will be visible in the API and the + dashboard. + + mailing_class: The mailing class of this order. If not provided, automatically set to + `first_class`. + + merge_variables: These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + + metadata: See the section on Metadata. + + send_date: This order will transition from `ready` to `printing` on the day after this + date. You can use this parameter to schedule orders for a future date. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args( + ["from_", "inside_html", "outside_html", "size", "to"], + ["from_", "inside_template", "outside_template", "size", "to"], + ["from_", "pdf", "size", "to"], + ) + async def create( + self, + *, + from_: snap_pack_create_params.SnapPackCreateWithHTMLFrom + | snap_pack_create_params.SnapPackCreateWithTemplateFrom + | snap_pack_create_params.SnapPackCreateWithPdfFrom, + inside_html: str | Omit = omit, + outside_html: str | Omit = omit, + size: Literal["8.5x11_bifold_v"], + to: snap_pack_create_params.SnapPackCreateWithHTMLTo + | snap_pack_create_params.SnapPackCreateWithTemplateTo + | snap_pack_create_params.SnapPackCreateWithPdfTo, + description: str | Omit = omit, + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] + | Omit = omit, + merge_variables: Dict[str, object] | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + send_date: Union[str, datetime] | Omit = omit, + inside_template: str | Omit = omit, + outside_template: str | Omit = omit, + pdf: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SnapPackCreateResponse: + return await self._post( + "/print-mail/v1/snap_packs", + body=await async_maybe_transform( + { + "from_": from_, + "inside_html": inside_html, + "outside_html": outside_html, + "size": size, + "to": to, + "description": description, + "mailing_class": mailing_class, + "merge_variables": merge_variables, + "metadata": metadata, + "send_date": send_date, + "inside_template": inside_template, + "outside_template": outside_template, + "pdf": pdf, + }, + snap_pack_create_params.SnapPackCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SnapPackCreateResponse, + ) + + async def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SnapPackRetrieveResponse: + """ + Retrieve a snap pack by ID. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + path_template("/print-mail/v1/snap_packs/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SnapPackRetrieveResponse, + ) + + def list( + self, + *, + limit: int | Omit = omit, + search: str | Omit = omit, + skip: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[SnapPackListResponse, AsyncSkipLimit[SnapPackListResponse]]: + """ + Get a list of snap packs. + + Args: + search: You can supply any string to help narrow down the list of resources. For + example, if you pass `"New York"` (quoted), it will return resources that have + that string present somewhere in their response. Alternatively, you can supply a + structured search query. See the documentation on `StructuredSearchQuery` for + more details. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get_api_list( + "/print-mail/v1/snap_packs", + page=AsyncSkipLimit[SnapPackListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "search": search, + "skip": skip, + }, + snap_pack_list_params.SnapPackListParams, + ), + ), + model=SnapPackListResponse, + ) + + async def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SnapPackDeleteResponse: + """Cancel a snap pack by ID. + + Note that this operation cannot be undone and that + only snap packs with a status of `ready` can be cancelled. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._delete( + path_template("/print-mail/v1/snap_packs/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SnapPackDeleteResponse, + ) + + async def progressions( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SnapPackProgressionsResponse: + """Progresses a snap pack's `status` to the next stage. + + This is only available in + test mode and can be used to simulate how a live order would progress through + the different statuses. + + Note: this will fail with an `invalid_progression_error` if the status is one of + `completed` or `cancelled`. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + path_template("/print-mail/v1/snap_packs/{id}/progressions", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=SnapPackProgressionsResponse, + ) + + async def retrieve_capabilities( + self, + *, + return_country_code: str, + destination_country_code: str | Omit = omit, + mailing_list: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SnapPackRetrieveCapabilitiesResponse: + """ + Provides sizes and mailing classes available for the destination. + + Args: + return_country_code: The country code where mail may be returned to. + + destination_country_code: The country code of where the snap pack will be sent to. One of `mailingList` or + `destinationCountryCode` must be supplied but not both. + + mailing_list: Sources destination countries from the provided mailing list. One of + `mailingList` or `destinationCountryCode` must be supplied but not both. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._get( + "/print-mail/v1/snap_packs/capabilities", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "return_country_code": return_country_code, + "destination_country_code": destination_country_code, + "mailing_list": mailing_list, + }, + snap_pack_retrieve_capabilities_params.SnapPackRetrieveCapabilitiesParams, + ), + ), + cast_to=SnapPackRetrieveCapabilitiesResponse, + ) + + +class SnapPacksResourceWithRawResponse: + def __init__(self, snap_packs: SnapPacksResource) -> None: + self._snap_packs = snap_packs + + self.create = to_raw_response_wrapper( + snap_packs.create, + ) + self.retrieve = to_raw_response_wrapper( + snap_packs.retrieve, + ) + self.list = to_raw_response_wrapper( + snap_packs.list, + ) + self.delete = to_raw_response_wrapper( + snap_packs.delete, + ) + self.progressions = to_raw_response_wrapper( + snap_packs.progressions, + ) + self.retrieve_capabilities = to_raw_response_wrapper( + snap_packs.retrieve_capabilities, + ) + + +class AsyncSnapPacksResourceWithRawResponse: + def __init__(self, snap_packs: AsyncSnapPacksResource) -> None: + self._snap_packs = snap_packs + + self.create = async_to_raw_response_wrapper( + snap_packs.create, + ) + self.retrieve = async_to_raw_response_wrapper( + snap_packs.retrieve, + ) + self.list = async_to_raw_response_wrapper( + snap_packs.list, + ) + self.delete = async_to_raw_response_wrapper( + snap_packs.delete, + ) + self.progressions = async_to_raw_response_wrapper( + snap_packs.progressions, + ) + self.retrieve_capabilities = async_to_raw_response_wrapper( + snap_packs.retrieve_capabilities, + ) + + +class SnapPacksResourceWithStreamingResponse: + def __init__(self, snap_packs: SnapPacksResource) -> None: + self._snap_packs = snap_packs + + self.create = to_streamed_response_wrapper( + snap_packs.create, + ) + self.retrieve = to_streamed_response_wrapper( + snap_packs.retrieve, + ) + self.list = to_streamed_response_wrapper( + snap_packs.list, + ) + self.delete = to_streamed_response_wrapper( + snap_packs.delete, + ) + self.progressions = to_streamed_response_wrapper( + snap_packs.progressions, + ) + self.retrieve_capabilities = to_streamed_response_wrapper( + snap_packs.retrieve_capabilities, + ) + + +class AsyncSnapPacksResourceWithStreamingResponse: + def __init__(self, snap_packs: AsyncSnapPacksResource) -> None: + self._snap_packs = snap_packs + + self.create = async_to_streamed_response_wrapper( + snap_packs.create, + ) + self.retrieve = async_to_streamed_response_wrapper( + snap_packs.retrieve, + ) + self.list = async_to_streamed_response_wrapper( + snap_packs.list, + ) + self.delete = async_to_streamed_response_wrapper( + snap_packs.delete, + ) + self.progressions = async_to_streamed_response_wrapper( + snap_packs.progressions, + ) + self.retrieve_capabilities = async_to_streamed_response_wrapper( + snap_packs.retrieve_capabilities, + ) diff --git a/src/postgrid/resources/print_mail/sub_organizations.py b/src/postgrid/resources/print_mail/sub_organizations.py index 0499a50..9ac0561 100644 --- a/src/postgrid/resources/print_mail/sub_organizations.py +++ b/src/postgrid/resources/print_mail/sub_organizations.py @@ -29,6 +29,19 @@ class SubOrganizationsResource(SyncAPIResource): + """ + Sub-organizations enable you to create isolated PostGrid accounts + ("sub-organizations") under your PostGrid account (the "parent organization"). + Each sub-organization has fully isolated resources + and users, and can act independently. + + This allows you to isolate different departments or even re-sell PostGrid + entirely. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + @cached_property def with_raw_response(self) -> SubOrganizationsResourceWithRawResponse: """ @@ -248,6 +261,19 @@ def retrieve_users( class AsyncSubOrganizationsResource(AsyncAPIResource): + """ + Sub-organizations enable you to create isolated PostGrid accounts + ("sub-organizations") under your PostGrid account (the "parent organization"). + Each sub-organization has fully isolated resources + and users, and can act independently. + + This allows you to isolate different departments or even re-sell PostGrid + entirely. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + @cached_property def with_raw_response(self) -> AsyncSubOrganizationsResourceWithRawResponse: """ diff --git a/src/postgrid/resources/print_mail/targeted_list_builds/__init__.py b/src/postgrid/resources/print_mail/targeted_list_builds/__init__.py new file mode 100644 index 0000000..c761032 --- /dev/null +++ b/src/postgrid/resources/print_mail/targeted_list_builds/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .filters import ( + FiltersResource, + AsyncFiltersResource, + FiltersResourceWithRawResponse, + AsyncFiltersResourceWithRawResponse, + FiltersResourceWithStreamingResponse, + AsyncFiltersResourceWithStreamingResponse, +) +from .targeted_list_builds import ( + TargetedListBuildsResource, + AsyncTargetedListBuildsResource, + TargetedListBuildsResourceWithRawResponse, + AsyncTargetedListBuildsResourceWithRawResponse, + TargetedListBuildsResourceWithStreamingResponse, + AsyncTargetedListBuildsResourceWithStreamingResponse, +) + +__all__ = [ + "FiltersResource", + "AsyncFiltersResource", + "FiltersResourceWithRawResponse", + "AsyncFiltersResourceWithRawResponse", + "FiltersResourceWithStreamingResponse", + "AsyncFiltersResourceWithStreamingResponse", + "TargetedListBuildsResource", + "AsyncTargetedListBuildsResource", + "TargetedListBuildsResourceWithRawResponse", + "AsyncTargetedListBuildsResourceWithRawResponse", + "TargetedListBuildsResourceWithStreamingResponse", + "AsyncTargetedListBuildsResourceWithStreamingResponse", +] diff --git a/src/postgrid/resources/print_mail/targeted_list_builds/filters.py b/src/postgrid/resources/print_mail/targeted_list_builds/filters.py new file mode 100644 index 0000000..ded8387 --- /dev/null +++ b/src/postgrid/resources/print_mail/targeted_list_builds/filters.py @@ -0,0 +1,259 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._base_client import make_request_options +from ....types.print_mail.targeted_list_builds import filter_autocomplete_params +from ....types.print_mail.targeted_list_builds.filter_autocomplete_response import FilterAutocompleteResponse + +__all__ = ["FiltersResource", "AsyncFiltersResource"] + + +class FiltersResource(SyncAPIResource): + """ + **Beta:** the targeted list builds API is in beta and is subject to + breaking changes. Endpoint shapes, status values, and filter fields may + change without notice. + + The targeted list builds API lets you programmatically build mailing + lists of US consumers (B2C) or US companies (B2B) that match a set of + demographic, geographic, and firmographic filters. + + The lifecycle of a list build is: + + 1. Create a list build by supplying either `usConsumers` or `usCompanies` + filters. A quote is generated asynchronously — poll the resource or + wait for its `status` to become `quote_ready`. + 2. Review the `quote` (total count and price per contact) and masked + `previewRecords`. Adjust the filters with an update call if needed — + this will regenerate the quote. + 3. Confirm the build. This deducts the appropriate amount of list build + credits from your organization (in live mode) and begins constructing + the mailing list. `buildProgressPercent` reflects progress from 0 to + 100. + 4. Once `status` is `completed`, the ID of the resulting mailing list is + available in the `mailingList` field and can be used like any other + mailing list in the PostGrid API. + + Targeted list builds must be enabled on your organization before they + can be used. Contact PostGrid support to request access. + """ + + @cached_property + def with_raw_response(self) -> FiltersResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + """ + return FiltersResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> FiltersResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + """ + return FiltersResourceWithStreamingResponse(self) + + def autocomplete( + self, + *, + field: Literal["industry"], + size: int | Omit = omit, + text: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> FilterAutocompleteResponse: + """ + Return a list of autocomplete suggestions for a given filter field (currently + only `industry` is supported). Useful when building a UI around the `industries` + company filter. + + Args: + field: A field that can be autocompleted when configuring list build filters. + + size: Maximum number of suggestions to return. Between 1 and 100. Defaults to 25 if + omitted. + + text: Optional text prefix to narrow the autocomplete suggestions. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/print-mail/v1/targeted_list_builds/filters/autocomplete", + body=maybe_transform( + { + "field": field, + "size": size, + "text": text, + }, + filter_autocomplete_params.FilterAutocompleteParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=FilterAutocompleteResponse, + ) + + +class AsyncFiltersResource(AsyncAPIResource): + """ + **Beta:** the targeted list builds API is in beta and is subject to + breaking changes. Endpoint shapes, status values, and filter fields may + change without notice. + + The targeted list builds API lets you programmatically build mailing + lists of US consumers (B2C) or US companies (B2B) that match a set of + demographic, geographic, and firmographic filters. + + The lifecycle of a list build is: + + 1. Create a list build by supplying either `usConsumers` or `usCompanies` + filters. A quote is generated asynchronously — poll the resource or + wait for its `status` to become `quote_ready`. + 2. Review the `quote` (total count and price per contact) and masked + `previewRecords`. Adjust the filters with an update call if needed — + this will regenerate the quote. + 3. Confirm the build. This deducts the appropriate amount of list build + credits from your organization (in live mode) and begins constructing + the mailing list. `buildProgressPercent` reflects progress from 0 to + 100. + 4. Once `status` is `completed`, the ID of the resulting mailing list is + available in the `mailingList` field and can be used like any other + mailing list in the PostGrid API. + + Targeted list builds must be enabled on your organization before they + can be used. Contact PostGrid support to request access. + """ + + @cached_property + def with_raw_response(self) -> AsyncFiltersResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + """ + return AsyncFiltersResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncFiltersResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + """ + return AsyncFiltersResourceWithStreamingResponse(self) + + async def autocomplete( + self, + *, + field: Literal["industry"], + size: int | Omit = omit, + text: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> FilterAutocompleteResponse: + """ + Return a list of autocomplete suggestions for a given filter field (currently + only `industry` is supported). Useful when building a UI around the `industries` + company filter. + + Args: + field: A field that can be autocompleted when configuring list build filters. + + size: Maximum number of suggestions to return. Between 1 and 100. Defaults to 25 if + omitted. + + text: Optional text prefix to narrow the autocomplete suggestions. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/print-mail/v1/targeted_list_builds/filters/autocomplete", + body=await async_maybe_transform( + { + "field": field, + "size": size, + "text": text, + }, + filter_autocomplete_params.FilterAutocompleteParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=FilterAutocompleteResponse, + ) + + +class FiltersResourceWithRawResponse: + def __init__(self, filters: FiltersResource) -> None: + self._filters = filters + + self.autocomplete = to_raw_response_wrapper( + filters.autocomplete, + ) + + +class AsyncFiltersResourceWithRawResponse: + def __init__(self, filters: AsyncFiltersResource) -> None: + self._filters = filters + + self.autocomplete = async_to_raw_response_wrapper( + filters.autocomplete, + ) + + +class FiltersResourceWithStreamingResponse: + def __init__(self, filters: FiltersResource) -> None: + self._filters = filters + + self.autocomplete = to_streamed_response_wrapper( + filters.autocomplete, + ) + + +class AsyncFiltersResourceWithStreamingResponse: + def __init__(self, filters: AsyncFiltersResource) -> None: + self._filters = filters + + self.autocomplete = async_to_streamed_response_wrapper( + filters.autocomplete, + ) diff --git a/src/postgrid/resources/print_mail/targeted_list_builds/targeted_list_builds.py b/src/postgrid/resources/print_mail/targeted_list_builds/targeted_list_builds.py new file mode 100644 index 0000000..a8ae428 --- /dev/null +++ b/src/postgrid/resources/print_mail/targeted_list_builds/targeted_list_builds.py @@ -0,0 +1,1003 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict + +import httpx + +from .filters import ( + FiltersResource, + AsyncFiltersResource, + FiltersResourceWithRawResponse, + AsyncFiltersResourceWithRawResponse, + FiltersResourceWithStreamingResponse, + AsyncFiltersResourceWithStreamingResponse, +) +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import path_template, maybe_transform, strip_not_given, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....pagination import SyncSkipLimit, AsyncSkipLimit +from ...._base_client import AsyncPaginator, make_request_options +from ....types.print_mail import ( + targeted_list_build_list_params, + targeted_list_build_create_params, + targeted_list_build_update_params, +) +from ....types.print_mail.targeted_list_build_list_response import TargetedListBuildListResponse +from ....types.print_mail.targeted_list_build_create_response import TargetedListBuildCreateResponse +from ....types.print_mail.targeted_list_build_delete_response import TargetedListBuildDeleteResponse +from ....types.print_mail.targeted_list_build_update_response import TargetedListBuildUpdateResponse +from ....types.print_mail.targeted_list_build_confirm_response import TargetedListBuildConfirmResponse +from ....types.print_mail.targeted_list_build_retrieve_response import TargetedListBuildRetrieveResponse + +__all__ = ["TargetedListBuildsResource", "AsyncTargetedListBuildsResource"] + + +class TargetedListBuildsResource(SyncAPIResource): + """ + **Beta:** the targeted list builds API is in beta and is subject to + breaking changes. Endpoint shapes, status values, and filter fields may + change without notice. + + The targeted list builds API lets you programmatically build mailing + lists of US consumers (B2C) or US companies (B2B) that match a set of + demographic, geographic, and firmographic filters. + + The lifecycle of a list build is: + + 1. Create a list build by supplying either `usConsumers` or `usCompanies` + filters. A quote is generated asynchronously — poll the resource or + wait for its `status` to become `quote_ready`. + 2. Review the `quote` (total count and price per contact) and masked + `previewRecords`. Adjust the filters with an update call if needed — + this will regenerate the quote. + 3. Confirm the build. This deducts the appropriate amount of list build + credits from your organization (in live mode) and begins constructing + the mailing list. `buildProgressPercent` reflects progress from 0 to + 100. + 4. Once `status` is `completed`, the ID of the resulting mailing list is + available in the `mailingList` field and can be used like any other + mailing list in the PostGrid API. + + Targeted list builds must be enabled on your organization before they + can be used. Contact PostGrid support to request access. + """ + + @cached_property + def filters(self) -> FiltersResource: + """ + **Beta:** the targeted list builds API is in beta and is subject to + breaking changes. Endpoint shapes, status values, and filter fields may + change without notice. + + The targeted list builds API lets you programmatically build mailing + lists of US consumers (B2C) or US companies (B2B) that match a set of + demographic, geographic, and firmographic filters. + + The lifecycle of a list build is: + + 1. Create a list build by supplying either `usConsumers` or `usCompanies` + filters. A quote is generated asynchronously — poll the resource or + wait for its `status` to become `quote_ready`. + 2. Review the `quote` (total count and price per contact) and masked + `previewRecords`. Adjust the filters with an update call if needed — + this will regenerate the quote. + 3. Confirm the build. This deducts the appropriate amount of list build + credits from your organization (in live mode) and begins constructing + the mailing list. `buildProgressPercent` reflects progress from 0 to + 100. + 4. Once `status` is `completed`, the ID of the resulting mailing list is + available in the `mailingList` field and can be used like any other + mailing list in the PostGrid API. + + Targeted list builds must be enabled on your organization before they + can be used. Contact PostGrid support to request access. + """ + return FiltersResource(self._client) + + @cached_property + def with_raw_response(self) -> TargetedListBuildsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + """ + return TargetedListBuildsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> TargetedListBuildsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + """ + return TargetedListBuildsResourceWithStreamingResponse(self) + + def create( + self, + *, + description: str | Omit = omit, + limit: int | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + us_companies: targeted_list_build_create_params.UsCompanies | Omit = omit, + us_consumers: targeted_list_build_create_params.UsConsumers | Omit = omit, + idempotency_key: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TargetedListBuildCreateResponse: + """Create a new targeted list build. + + A quote will be generated asynchronously based + on the provided filters. + + Args: + description: An optional string describing this resource. Will be visible in the API and the + dashboard. + + limit: Maximum number of contacts to include in the built mailing list. If omitted, all + matching contacts are included. + + metadata: See the section on Metadata. + + us_companies: Filters used to target US companies (B2B) when building a list. + + us_consumers: Filters used to target US consumers (B2C) when building a list. + + The geographic filters (`zipCodesAround`, `cityStates`, `zipCodes`) are mutually + exclusive — you may supply at most one of them. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + extra_headers = {**strip_not_given({"idempotency-key": idempotency_key}), **(extra_headers or {})} + return self._post( + "/print-mail/v1/targeted_list_builds", + body=maybe_transform( + { + "description": description, + "limit": limit, + "metadata": metadata, + "us_companies": us_companies, + "us_consumers": us_consumers, + }, + targeted_list_build_create_params.TargetedListBuildCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TargetedListBuildCreateResponse, + ) + + def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TargetedListBuildRetrieveResponse: + """ + Retrieve a specific targeted list build by its ID. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + path_template("/print-mail/v1/targeted_list_builds/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TargetedListBuildRetrieveResponse, + ) + + def update( + self, + id: str, + *, + description: str | Omit = omit, + limit: int | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + us_companies: targeted_list_build_update_params.UsCompanies | Omit = omit, + us_consumers: targeted_list_build_update_params.UsConsumers | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TargetedListBuildUpdateResponse: + """Update an existing targeted list build. + + Only builds that have not yet been + confirmed may be updated. Updating the filters or `limit` will reset the build's + status back to `generating_quote` and a new quote will be generated. + + Args: + description: An optional string describing this resource. Will be visible in the API and the + dashboard. + + limit: Maximum number of contacts to include in the built mailing list. If omitted, all + matching contacts are included. + + metadata: See the section on Metadata. + + us_companies: Filters used to target US companies (B2B) when building a list. + + us_consumers: Filters used to target US consumers (B2C) when building a list. + + The geographic filters (`zipCodesAround`, `cityStates`, `zipCodes`) are mutually + exclusive — you may supply at most one of them. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + path_template("/print-mail/v1/targeted_list_builds/{id}", id=id), + body=maybe_transform( + { + "description": description, + "limit": limit, + "metadata": metadata, + "us_companies": us_companies, + "us_consumers": us_consumers, + }, + targeted_list_build_update_params.TargetedListBuildUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TargetedListBuildUpdateResponse, + ) + + def list( + self, + *, + limit: int | Omit = omit, + search: str | Omit = omit, + skip: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSkipLimit[TargetedListBuildListResponse]: + """ + Retrieve a paginated list of targeted list builds for the authenticated + organization, ordered from most recently updated to least recently updated. + + Args: + search: You can supply any string to help narrow down the list of resources. For + example, if you pass `"New York"` (quoted), it will return resources that have + that string present somewhere in their response. Alternatively, you can supply a + structured search query. See the documentation on `StructuredSearchQuery` for + more details. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get_api_list( + "/print-mail/v1/targeted_list_builds", + page=SyncSkipLimit[TargetedListBuildListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "search": search, + "skip": skip, + }, + targeted_list_build_list_params.TargetedListBuildListParams, + ), + ), + model=TargetedListBuildListResponse, + ) + + def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TargetedListBuildDeleteResponse: + """Delete a targeted list build. + + List builds can only be deleted before they have + been confirmed — once a build has transitioned to `creating_list` or `completed` + it cannot be deleted. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._delete( + path_template("/print-mail/v1/targeted_list_builds/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TargetedListBuildDeleteResponse, + ) + + def confirm( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TargetedListBuildConfirmResponse: + """Confirm a targeted list build whose quote is ready. + + This deducts the appropriate + amount of list build credits from the organization (in live mode) and kicks off + the asynchronous creation of the underlying mailing list. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + path_template("/print-mail/v1/targeted_list_builds/{id}/confirm", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TargetedListBuildConfirmResponse, + ) + + +class AsyncTargetedListBuildsResource(AsyncAPIResource): + """ + **Beta:** the targeted list builds API is in beta and is subject to + breaking changes. Endpoint shapes, status values, and filter fields may + change without notice. + + The targeted list builds API lets you programmatically build mailing + lists of US consumers (B2C) or US companies (B2B) that match a set of + demographic, geographic, and firmographic filters. + + The lifecycle of a list build is: + + 1. Create a list build by supplying either `usConsumers` or `usCompanies` + filters. A quote is generated asynchronously — poll the resource or + wait for its `status` to become `quote_ready`. + 2. Review the `quote` (total count and price per contact) and masked + `previewRecords`. Adjust the filters with an update call if needed — + this will regenerate the quote. + 3. Confirm the build. This deducts the appropriate amount of list build + credits from your organization (in live mode) and begins constructing + the mailing list. `buildProgressPercent` reflects progress from 0 to + 100. + 4. Once `status` is `completed`, the ID of the resulting mailing list is + available in the `mailingList` field and can be used like any other + mailing list in the PostGrid API. + + Targeted list builds must be enabled on your organization before they + can be used. Contact PostGrid support to request access. + """ + + @cached_property + def filters(self) -> AsyncFiltersResource: + """ + **Beta:** the targeted list builds API is in beta and is subject to + breaking changes. Endpoint shapes, status values, and filter fields may + change without notice. + + The targeted list builds API lets you programmatically build mailing + lists of US consumers (B2C) or US companies (B2B) that match a set of + demographic, geographic, and firmographic filters. + + The lifecycle of a list build is: + + 1. Create a list build by supplying either `usConsumers` or `usCompanies` + filters. A quote is generated asynchronously — poll the resource or + wait for its `status` to become `quote_ready`. + 2. Review the `quote` (total count and price per contact) and masked + `previewRecords`. Adjust the filters with an update call if needed — + this will regenerate the quote. + 3. Confirm the build. This deducts the appropriate amount of list build + credits from your organization (in live mode) and begins constructing + the mailing list. `buildProgressPercent` reflects progress from 0 to + 100. + 4. Once `status` is `completed`, the ID of the resulting mailing list is + available in the `mailingList` field and can be used like any other + mailing list in the PostGrid API. + + Targeted list builds must be enabled on your organization before they + can be used. Contact PostGrid support to request access. + """ + return AsyncFiltersResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncTargetedListBuildsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + """ + return AsyncTargetedListBuildsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncTargetedListBuildsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + """ + return AsyncTargetedListBuildsResourceWithStreamingResponse(self) + + async def create( + self, + *, + description: str | Omit = omit, + limit: int | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + us_companies: targeted_list_build_create_params.UsCompanies | Omit = omit, + us_consumers: targeted_list_build_create_params.UsConsumers | Omit = omit, + idempotency_key: str | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TargetedListBuildCreateResponse: + """Create a new targeted list build. + + A quote will be generated asynchronously based + on the provided filters. + + Args: + description: An optional string describing this resource. Will be visible in the API and the + dashboard. + + limit: Maximum number of contacts to include in the built mailing list. If omitted, all + matching contacts are included. + + metadata: See the section on Metadata. + + us_companies: Filters used to target US companies (B2B) when building a list. + + us_consumers: Filters used to target US consumers (B2C) when building a list. + + The geographic filters (`zipCodesAround`, `cityStates`, `zipCodes`) are mutually + exclusive — you may supply at most one of them. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + extra_headers = {**strip_not_given({"idempotency-key": idempotency_key}), **(extra_headers or {})} + return await self._post( + "/print-mail/v1/targeted_list_builds", + body=await async_maybe_transform( + { + "description": description, + "limit": limit, + "metadata": metadata, + "us_companies": us_companies, + "us_consumers": us_consumers, + }, + targeted_list_build_create_params.TargetedListBuildCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TargetedListBuildCreateResponse, + ) + + async def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TargetedListBuildRetrieveResponse: + """ + Retrieve a specific targeted list build by its ID. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + path_template("/print-mail/v1/targeted_list_builds/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TargetedListBuildRetrieveResponse, + ) + + async def update( + self, + id: str, + *, + description: str | Omit = omit, + limit: int | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + us_companies: targeted_list_build_update_params.UsCompanies | Omit = omit, + us_consumers: targeted_list_build_update_params.UsConsumers | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TargetedListBuildUpdateResponse: + """Update an existing targeted list build. + + Only builds that have not yet been + confirmed may be updated. Updating the filters or `limit` will reset the build's + status back to `generating_quote` and a new quote will be generated. + + Args: + description: An optional string describing this resource. Will be visible in the API and the + dashboard. + + limit: Maximum number of contacts to include in the built mailing list. If omitted, all + matching contacts are included. + + metadata: See the section on Metadata. + + us_companies: Filters used to target US companies (B2B) when building a list. + + us_consumers: Filters used to target US consumers (B2C) when building a list. + + The geographic filters (`zipCodesAround`, `cityStates`, `zipCodes`) are mutually + exclusive — you may supply at most one of them. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + path_template("/print-mail/v1/targeted_list_builds/{id}", id=id), + body=await async_maybe_transform( + { + "description": description, + "limit": limit, + "metadata": metadata, + "us_companies": us_companies, + "us_consumers": us_consumers, + }, + targeted_list_build_update_params.TargetedListBuildUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TargetedListBuildUpdateResponse, + ) + + def list( + self, + *, + limit: int | Omit = omit, + search: str | Omit = omit, + skip: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[TargetedListBuildListResponse, AsyncSkipLimit[TargetedListBuildListResponse]]: + """ + Retrieve a paginated list of targeted list builds for the authenticated + organization, ordered from most recently updated to least recently updated. + + Args: + search: You can supply any string to help narrow down the list of resources. For + example, if you pass `"New York"` (quoted), it will return resources that have + that string present somewhere in their response. Alternatively, you can supply a + structured search query. See the documentation on `StructuredSearchQuery` for + more details. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get_api_list( + "/print-mail/v1/targeted_list_builds", + page=AsyncSkipLimit[TargetedListBuildListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "search": search, + "skip": skip, + }, + targeted_list_build_list_params.TargetedListBuildListParams, + ), + ), + model=TargetedListBuildListResponse, + ) + + async def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TargetedListBuildDeleteResponse: + """Delete a targeted list build. + + List builds can only be deleted before they have + been confirmed — once a build has transitioned to `creating_list` or `completed` + it cannot be deleted. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._delete( + path_template("/print-mail/v1/targeted_list_builds/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TargetedListBuildDeleteResponse, + ) + + async def confirm( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TargetedListBuildConfirmResponse: + """Confirm a targeted list build whose quote is ready. + + This deducts the appropriate + amount of list build credits from the organization (in live mode) and kicks off + the asynchronous creation of the underlying mailing list. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + path_template("/print-mail/v1/targeted_list_builds/{id}/confirm", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TargetedListBuildConfirmResponse, + ) + + +class TargetedListBuildsResourceWithRawResponse: + def __init__(self, targeted_list_builds: TargetedListBuildsResource) -> None: + self._targeted_list_builds = targeted_list_builds + + self.create = to_raw_response_wrapper( + targeted_list_builds.create, + ) + self.retrieve = to_raw_response_wrapper( + targeted_list_builds.retrieve, + ) + self.update = to_raw_response_wrapper( + targeted_list_builds.update, + ) + self.list = to_raw_response_wrapper( + targeted_list_builds.list, + ) + self.delete = to_raw_response_wrapper( + targeted_list_builds.delete, + ) + self.confirm = to_raw_response_wrapper( + targeted_list_builds.confirm, + ) + + @cached_property + def filters(self) -> FiltersResourceWithRawResponse: + """ + **Beta:** the targeted list builds API is in beta and is subject to + breaking changes. Endpoint shapes, status values, and filter fields may + change without notice. + + The targeted list builds API lets you programmatically build mailing + lists of US consumers (B2C) or US companies (B2B) that match a set of + demographic, geographic, and firmographic filters. + + The lifecycle of a list build is: + + 1. Create a list build by supplying either `usConsumers` or `usCompanies` + filters. A quote is generated asynchronously — poll the resource or + wait for its `status` to become `quote_ready`. + 2. Review the `quote` (total count and price per contact) and masked + `previewRecords`. Adjust the filters with an update call if needed — + this will regenerate the quote. + 3. Confirm the build. This deducts the appropriate amount of list build + credits from your organization (in live mode) and begins constructing + the mailing list. `buildProgressPercent` reflects progress from 0 to + 100. + 4. Once `status` is `completed`, the ID of the resulting mailing list is + available in the `mailingList` field and can be used like any other + mailing list in the PostGrid API. + + Targeted list builds must be enabled on your organization before they + can be used. Contact PostGrid support to request access. + """ + return FiltersResourceWithRawResponse(self._targeted_list_builds.filters) + + +class AsyncTargetedListBuildsResourceWithRawResponse: + def __init__(self, targeted_list_builds: AsyncTargetedListBuildsResource) -> None: + self._targeted_list_builds = targeted_list_builds + + self.create = async_to_raw_response_wrapper( + targeted_list_builds.create, + ) + self.retrieve = async_to_raw_response_wrapper( + targeted_list_builds.retrieve, + ) + self.update = async_to_raw_response_wrapper( + targeted_list_builds.update, + ) + self.list = async_to_raw_response_wrapper( + targeted_list_builds.list, + ) + self.delete = async_to_raw_response_wrapper( + targeted_list_builds.delete, + ) + self.confirm = async_to_raw_response_wrapper( + targeted_list_builds.confirm, + ) + + @cached_property + def filters(self) -> AsyncFiltersResourceWithRawResponse: + """ + **Beta:** the targeted list builds API is in beta and is subject to + breaking changes. Endpoint shapes, status values, and filter fields may + change without notice. + + The targeted list builds API lets you programmatically build mailing + lists of US consumers (B2C) or US companies (B2B) that match a set of + demographic, geographic, and firmographic filters. + + The lifecycle of a list build is: + + 1. Create a list build by supplying either `usConsumers` or `usCompanies` + filters. A quote is generated asynchronously — poll the resource or + wait for its `status` to become `quote_ready`. + 2. Review the `quote` (total count and price per contact) and masked + `previewRecords`. Adjust the filters with an update call if needed — + this will regenerate the quote. + 3. Confirm the build. This deducts the appropriate amount of list build + credits from your organization (in live mode) and begins constructing + the mailing list. `buildProgressPercent` reflects progress from 0 to + 100. + 4. Once `status` is `completed`, the ID of the resulting mailing list is + available in the `mailingList` field and can be used like any other + mailing list in the PostGrid API. + + Targeted list builds must be enabled on your organization before they + can be used. Contact PostGrid support to request access. + """ + return AsyncFiltersResourceWithRawResponse(self._targeted_list_builds.filters) + + +class TargetedListBuildsResourceWithStreamingResponse: + def __init__(self, targeted_list_builds: TargetedListBuildsResource) -> None: + self._targeted_list_builds = targeted_list_builds + + self.create = to_streamed_response_wrapper( + targeted_list_builds.create, + ) + self.retrieve = to_streamed_response_wrapper( + targeted_list_builds.retrieve, + ) + self.update = to_streamed_response_wrapper( + targeted_list_builds.update, + ) + self.list = to_streamed_response_wrapper( + targeted_list_builds.list, + ) + self.delete = to_streamed_response_wrapper( + targeted_list_builds.delete, + ) + self.confirm = to_streamed_response_wrapper( + targeted_list_builds.confirm, + ) + + @cached_property + def filters(self) -> FiltersResourceWithStreamingResponse: + """ + **Beta:** the targeted list builds API is in beta and is subject to + breaking changes. Endpoint shapes, status values, and filter fields may + change without notice. + + The targeted list builds API lets you programmatically build mailing + lists of US consumers (B2C) or US companies (B2B) that match a set of + demographic, geographic, and firmographic filters. + + The lifecycle of a list build is: + + 1. Create a list build by supplying either `usConsumers` or `usCompanies` + filters. A quote is generated asynchronously — poll the resource or + wait for its `status` to become `quote_ready`. + 2. Review the `quote` (total count and price per contact) and masked + `previewRecords`. Adjust the filters with an update call if needed — + this will regenerate the quote. + 3. Confirm the build. This deducts the appropriate amount of list build + credits from your organization (in live mode) and begins constructing + the mailing list. `buildProgressPercent` reflects progress from 0 to + 100. + 4. Once `status` is `completed`, the ID of the resulting mailing list is + available in the `mailingList` field and can be used like any other + mailing list in the PostGrid API. + + Targeted list builds must be enabled on your organization before they + can be used. Contact PostGrid support to request access. + """ + return FiltersResourceWithStreamingResponse(self._targeted_list_builds.filters) + + +class AsyncTargetedListBuildsResourceWithStreamingResponse: + def __init__(self, targeted_list_builds: AsyncTargetedListBuildsResource) -> None: + self._targeted_list_builds = targeted_list_builds + + self.create = async_to_streamed_response_wrapper( + targeted_list_builds.create, + ) + self.retrieve = async_to_streamed_response_wrapper( + targeted_list_builds.retrieve, + ) + self.update = async_to_streamed_response_wrapper( + targeted_list_builds.update, + ) + self.list = async_to_streamed_response_wrapper( + targeted_list_builds.list, + ) + self.delete = async_to_streamed_response_wrapper( + targeted_list_builds.delete, + ) + self.confirm = async_to_streamed_response_wrapper( + targeted_list_builds.confirm, + ) + + @cached_property + def filters(self) -> AsyncFiltersResourceWithStreamingResponse: + """ + **Beta:** the targeted list builds API is in beta and is subject to + breaking changes. Endpoint shapes, status values, and filter fields may + change without notice. + + The targeted list builds API lets you programmatically build mailing + lists of US consumers (B2C) or US companies (B2B) that match a set of + demographic, geographic, and firmographic filters. + + The lifecycle of a list build is: + + 1. Create a list build by supplying either `usConsumers` or `usCompanies` + filters. A quote is generated asynchronously — poll the resource or + wait for its `status` to become `quote_ready`. + 2. Review the `quote` (total count and price per contact) and masked + `previewRecords`. Adjust the filters with an update call if needed — + this will regenerate the quote. + 3. Confirm the build. This deducts the appropriate amount of list build + credits from your organization (in live mode) and begins constructing + the mailing list. `buildProgressPercent` reflects progress from 0 to + 100. + 4. Once `status` is `completed`, the ID of the resulting mailing list is + available in the `mailingList` field and can be used like any other + mailing list in the PostGrid API. + + Targeted list builds must be enabled on your organization before they + can be used. Contact PostGrid support to request access. + """ + return AsyncFiltersResourceWithStreamingResponse(self._targeted_list_builds.filters) diff --git a/src/postgrid/resources/print_mail/template_editor_sessions.py b/src/postgrid/resources/print_mail/template_editor_sessions.py new file mode 100644 index 0000000..5768c93 --- /dev/null +++ b/src/postgrid/resources/print_mail/template_editor_sessions.py @@ -0,0 +1,449 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import Literal + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given +from ..._utils import path_template, maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...pagination import SyncSkipLimit, AsyncSkipLimit +from ..._base_client import AsyncPaginator, make_request_options +from ...types.print_mail import template_editor_session_list_params, template_editor_session_create_params +from ...types.print_mail.template_editor_session_list_response import TemplateEditorSessionListResponse +from ...types.print_mail.template_editor_session_create_response import TemplateEditorSessionCreateResponse +from ...types.print_mail.template_editor_session_delete_response import TemplateEditorSessionDeleteResponse + +__all__ = ["TemplateEditorSessionsResource", "AsyncTemplateEditorSessionsResource"] + + +class TemplateEditorSessionsResource(SyncAPIResource): + """ + You can use template editor sessions to bring the capabilities of our + template editor to your website. When you create a session, you provide the + `template` which you want to edit, and we return a session with a `url` that + you can `iframe` or redirect your customers to. + + When users save their changes in the editor session, it will update the + underlying template. Note that sessions are only valid for 24 hours, after + which point they are automatically deleted for security reasons. + + You can have multiple sessions active for the same template at the same time. + In general, we recommend creating a new session every time you present our + editor to your users. + + Note: you can use the template editor to modify templates created using HTML, + but saving a session from the editor will override the original HTML content. + """ + + @cached_property + def with_raw_response(self) -> TemplateEditorSessionsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + """ + return TemplateEditorSessionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> TemplateEditorSessionsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + """ + return TemplateEditorSessionsResourceWithStreamingResponse(self) + + def create( + self, + *, + template: str, + back_url: str | Omit = omit, + styles: template_editor_session_create_params.Styles | Omit = omit, + title: str | Omit = omit, + trackers: Union[Literal["all", "none"], SequenceNotStr[str]] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TemplateEditorSessionCreateResponse: + """ + Create a Template Editor Session. + + Note that if no `backURL` is supplied, PostGrid removes the Back button from the + editor page. This is ideal for when you `iframe` the editor. + + Args: + template: ID of the underlying template that this edits. + + back_url: The URL supplied when this editor session was created. + + styles: Style overrides for the template editor session. + + title: The title supplied when this editor session was created. + + trackers: Controls which Trackers are displayed in the template editor session. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/print-mail/v1/template_editor_sessions", + body=maybe_transform( + { + "template": template, + "back_url": back_url, + "styles": styles, + "title": title, + "trackers": trackers, + }, + template_editor_session_create_params.TemplateEditorSessionCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TemplateEditorSessionCreateResponse, + ) + + def list( + self, + *, + limit: int | Omit = omit, + search: str | Omit = omit, + skip: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSkipLimit[TemplateEditorSessionListResponse]: + """ + Retrieve a paginated list of Template Editor Sessions. + + Args: + search: You can supply any string to help narrow down the list of resources. For + example, if you pass `"New York"` (quoted), it will return resources that have + that string present somewhere in their response. Alternatively, you can supply a + structured search query. See the documentation on `StructuredSearchQuery` for + more details. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get_api_list( + "/print-mail/v1/template_editor_sessions", + page=SyncSkipLimit[TemplateEditorSessionListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "search": search, + "skip": skip, + }, + template_editor_session_list_params.TemplateEditorSessionListParams, + ), + ), + model=TemplateEditorSessionListResponse, + ) + + def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TemplateEditorSessionDeleteResponse: + """ + Delete a Template Editor Session by ID. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._delete( + path_template("/print-mail/v1/template_editor_sessions/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TemplateEditorSessionDeleteResponse, + ) + + +class AsyncTemplateEditorSessionsResource(AsyncAPIResource): + """ + You can use template editor sessions to bring the capabilities of our + template editor to your website. When you create a session, you provide the + `template` which you want to edit, and we return a session with a `url` that + you can `iframe` or redirect your customers to. + + When users save their changes in the editor session, it will update the + underlying template. Note that sessions are only valid for 24 hours, after + which point they are automatically deleted for security reasons. + + You can have multiple sessions active for the same template at the same time. + In general, we recommend creating a new session every time you present our + editor to your users. + + Note: you can use the template editor to modify templates created using HTML, + but saving a session from the editor will override the original HTML content. + """ + + @cached_property + def with_raw_response(self) -> AsyncTemplateEditorSessionsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + """ + return AsyncTemplateEditorSessionsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncTemplateEditorSessionsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + """ + return AsyncTemplateEditorSessionsResourceWithStreamingResponse(self) + + async def create( + self, + *, + template: str, + back_url: str | Omit = omit, + styles: template_editor_session_create_params.Styles | Omit = omit, + title: str | Omit = omit, + trackers: Union[Literal["all", "none"], SequenceNotStr[str]] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TemplateEditorSessionCreateResponse: + """ + Create a Template Editor Session. + + Note that if no `backURL` is supplied, PostGrid removes the Back button from the + editor page. This is ideal for when you `iframe` the editor. + + Args: + template: ID of the underlying template that this edits. + + back_url: The URL supplied when this editor session was created. + + styles: Style overrides for the template editor session. + + title: The title supplied when this editor session was created. + + trackers: Controls which Trackers are displayed in the template editor session. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/print-mail/v1/template_editor_sessions", + body=await async_maybe_transform( + { + "template": template, + "back_url": back_url, + "styles": styles, + "title": title, + "trackers": trackers, + }, + template_editor_session_create_params.TemplateEditorSessionCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TemplateEditorSessionCreateResponse, + ) + + def list( + self, + *, + limit: int | Omit = omit, + search: str | Omit = omit, + skip: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[TemplateEditorSessionListResponse, AsyncSkipLimit[TemplateEditorSessionListResponse]]: + """ + Retrieve a paginated list of Template Editor Sessions. + + Args: + search: You can supply any string to help narrow down the list of resources. For + example, if you pass `"New York"` (quoted), it will return resources that have + that string present somewhere in their response. Alternatively, you can supply a + structured search query. See the documentation on `StructuredSearchQuery` for + more details. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get_api_list( + "/print-mail/v1/template_editor_sessions", + page=AsyncSkipLimit[TemplateEditorSessionListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "search": search, + "skip": skip, + }, + template_editor_session_list_params.TemplateEditorSessionListParams, + ), + ), + model=TemplateEditorSessionListResponse, + ) + + async def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TemplateEditorSessionDeleteResponse: + """ + Delete a Template Editor Session by ID. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._delete( + path_template("/print-mail/v1/template_editor_sessions/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TemplateEditorSessionDeleteResponse, + ) + + +class TemplateEditorSessionsResourceWithRawResponse: + def __init__(self, template_editor_sessions: TemplateEditorSessionsResource) -> None: + self._template_editor_sessions = template_editor_sessions + + self.create = to_raw_response_wrapper( + template_editor_sessions.create, + ) + self.list = to_raw_response_wrapper( + template_editor_sessions.list, + ) + self.delete = to_raw_response_wrapper( + template_editor_sessions.delete, + ) + + +class AsyncTemplateEditorSessionsResourceWithRawResponse: + def __init__(self, template_editor_sessions: AsyncTemplateEditorSessionsResource) -> None: + self._template_editor_sessions = template_editor_sessions + + self.create = async_to_raw_response_wrapper( + template_editor_sessions.create, + ) + self.list = async_to_raw_response_wrapper( + template_editor_sessions.list, + ) + self.delete = async_to_raw_response_wrapper( + template_editor_sessions.delete, + ) + + +class TemplateEditorSessionsResourceWithStreamingResponse: + def __init__(self, template_editor_sessions: TemplateEditorSessionsResource) -> None: + self._template_editor_sessions = template_editor_sessions + + self.create = to_streamed_response_wrapper( + template_editor_sessions.create, + ) + self.list = to_streamed_response_wrapper( + template_editor_sessions.list, + ) + self.delete = to_streamed_response_wrapper( + template_editor_sessions.delete, + ) + + +class AsyncTemplateEditorSessionsResourceWithStreamingResponse: + def __init__(self, template_editor_sessions: AsyncTemplateEditorSessionsResource) -> None: + self._template_editor_sessions = template_editor_sessions + + self.create = async_to_streamed_response_wrapper( + template_editor_sessions.create, + ) + self.list = async_to_streamed_response_wrapper( + template_editor_sessions.list, + ) + self.delete = async_to_streamed_response_wrapper( + template_editor_sessions.delete, + ) diff --git a/src/postgrid/resources/print_mail/trackers.py b/src/postgrid/resources/print_mail/trackers.py new file mode 100644 index 0000000..bbb42fb --- /dev/null +++ b/src/postgrid/resources/print_mail/trackers.py @@ -0,0 +1,757 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict +from typing_extensions import Literal + +import httpx + +from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ..._utils import path_template, maybe_transform, async_maybe_transform +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...pagination import SyncSkipLimit, AsyncSkipLimit +from ..._base_client import AsyncPaginator, make_request_options +from ...types.print_mail import ( + tracker_list_params, + tracker_create_params, + tracker_update_params, + tracker_retrieve_visits_params, +) +from ...types.print_mail.tracker_list_response import TrackerListResponse +from ...types.print_mail.tracker_create_response import TrackerCreateResponse +from ...types.print_mail.tracker_delete_response import TrackerDeleteResponse +from ...types.print_mail.tracker_update_response import TrackerUpdateResponse +from ...types.print_mail.tracker_retrieve_response import TrackerRetrieveResponse +from ...types.print_mail.tracker_retrieve_visits_response import TrackerRetrieveVisitsResponse + +__all__ = ["TrackersResource", "AsyncTrackersResource"] + + +class TrackersResource(SyncAPIResource): + """Create and manage Trackers. + + Trackers can be used to track interactions in your orders through + personalized URLs and QR codes. + + As a brief introduction to using Trackers in your orders, a QR code can be + generated by using the Tracker's ID as a merge variable in your orders HTML + and Templates. The following example HTML uses Trackers to generate + personalized URLs (PURLs) in your orders. + + See the following guide for more details: https://postgrid.readme.io/reference/trackers-1 + """ + + @cached_property + def with_raw_response(self) -> TrackersResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + """ + return TrackersResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> TrackersResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + """ + return TrackersResourceWithStreamingResponse(self) + + def create( + self, + *, + redirect_url_template: str, + url_expire_after_days: Literal[30, 60, 90, 180, 365], + description: str | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TrackerCreateResponse: + """ + Create a Tracker. + + Args: + redirect_url_template: The base template for URLs generated by this Tracker. + + url_expire_after_days: The number of days generated Tracker URLs remain valid. + + description: An optional string describing this resource. Will be visible in the API and the + dashboard. + + metadata: See the section on Metadata. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/print-mail/v1/trackers", + body=maybe_transform( + { + "redirect_url_template": redirect_url_template, + "url_expire_after_days": url_expire_after_days, + "description": description, + "metadata": metadata, + }, + tracker_create_params.TrackerCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TrackerCreateResponse, + ) + + def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TrackerRetrieveResponse: + """ + Retrieve a Tracker by ID. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + path_template("/print-mail/v1/trackers/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TrackerRetrieveResponse, + ) + + def update( + self, + id: str, + *, + redirect_url_template: str, + url_expire_after_days: Literal[30, 60, 90, 180, 365], + description: str | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TrackerUpdateResponse: + """ + Update a Tracker by ID. + + Args: + redirect_url_template: The base template for URLs generated by this Tracker. + + url_expire_after_days: The number of days generated Tracker URLs remain valid. + + description: An optional string describing this resource. Will be visible in the API and the + dashboard. + + metadata: See the section on Metadata. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + path_template("/print-mail/v1/trackers/{id}", id=id), + body=maybe_transform( + { + "redirect_url_template": redirect_url_template, + "url_expire_after_days": url_expire_after_days, + "description": description, + "metadata": metadata, + }, + tracker_update_params.TrackerUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TrackerUpdateResponse, + ) + + def list( + self, + *, + limit: int | Omit = omit, + search: str | Omit = omit, + skip: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSkipLimit[TrackerListResponse]: + """ + Retrieve a paginated list of Trackers. + + Args: + search: You can supply any string to help narrow down the list of resources. For + example, if you pass `"New York"` (quoted), it will return resources that have + that string present somewhere in their response. Alternatively, you can supply a + structured search query. See the documentation on `StructuredSearchQuery` for + more details. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get_api_list( + "/print-mail/v1/trackers", + page=SyncSkipLimit[TrackerListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "search": search, + "skip": skip, + }, + tracker_list_params.TrackerListParams, + ), + ), + model=TrackerListResponse, + ) + + def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TrackerDeleteResponse: + """Delete a Tracker by ID. + + Note that this operation cannot be undone. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._delete( + path_template("/print-mail/v1/trackers/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TrackerDeleteResponse, + ) + + def retrieve_visits( + self, + id: str, + *, + limit: int | Omit = omit, + search: str | Omit = omit, + skip: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSkipLimit[TrackerRetrieveVisitsResponse]: + """ + Retrieve a paginated list of visits for a Tracker. + + Args: + search: You can supply any string to help narrow down the list of resources. For + example, if you pass `"New York"` (quoted), it will return resources that have + that string present somewhere in their response. Alternatively, you can supply a + structured search query. See the documentation on `StructuredSearchQuery` for + more details. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get_api_list( + path_template("/print-mail/v1/trackers/{id}/visits", id=id), + page=SyncSkipLimit[TrackerRetrieveVisitsResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "search": search, + "skip": skip, + }, + tracker_retrieve_visits_params.TrackerRetrieveVisitsParams, + ), + ), + model=TrackerRetrieveVisitsResponse, + ) + + +class AsyncTrackersResource(AsyncAPIResource): + """Create and manage Trackers. + + Trackers can be used to track interactions in your orders through + personalized URLs and QR codes. + + As a brief introduction to using Trackers in your orders, a QR code can be + generated by using the Tracker's ID as a merge variable in your orders HTML + and Templates. The following example HTML uses Trackers to generate + personalized URLs (PURLs) in your orders. + + See the following guide for more details: https://postgrid.readme.io/reference/trackers-1 + """ + + @cached_property + def with_raw_response(self) -> AsyncTrackersResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + """ + return AsyncTrackersResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncTrackersResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + """ + return AsyncTrackersResourceWithStreamingResponse(self) + + async def create( + self, + *, + redirect_url_template: str, + url_expire_after_days: Literal[30, 60, 90, 180, 365], + description: str | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TrackerCreateResponse: + """ + Create a Tracker. + + Args: + redirect_url_template: The base template for URLs generated by this Tracker. + + url_expire_after_days: The number of days generated Tracker URLs remain valid. + + description: An optional string describing this resource. Will be visible in the API and the + dashboard. + + metadata: See the section on Metadata. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/print-mail/v1/trackers", + body=await async_maybe_transform( + { + "redirect_url_template": redirect_url_template, + "url_expire_after_days": url_expire_after_days, + "description": description, + "metadata": metadata, + }, + tracker_create_params.TrackerCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TrackerCreateResponse, + ) + + async def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TrackerRetrieveResponse: + """ + Retrieve a Tracker by ID. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + path_template("/print-mail/v1/trackers/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TrackerRetrieveResponse, + ) + + async def update( + self, + id: str, + *, + redirect_url_template: str, + url_expire_after_days: Literal[30, 60, 90, 180, 365], + description: str | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TrackerUpdateResponse: + """ + Update a Tracker by ID. + + Args: + redirect_url_template: The base template for URLs generated by this Tracker. + + url_expire_after_days: The number of days generated Tracker URLs remain valid. + + description: An optional string describing this resource. Will be visible in the API and the + dashboard. + + metadata: See the section on Metadata. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + path_template("/print-mail/v1/trackers/{id}", id=id), + body=await async_maybe_transform( + { + "redirect_url_template": redirect_url_template, + "url_expire_after_days": url_expire_after_days, + "description": description, + "metadata": metadata, + }, + tracker_update_params.TrackerUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TrackerUpdateResponse, + ) + + def list( + self, + *, + limit: int | Omit = omit, + search: str | Omit = omit, + skip: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[TrackerListResponse, AsyncSkipLimit[TrackerListResponse]]: + """ + Retrieve a paginated list of Trackers. + + Args: + search: You can supply any string to help narrow down the list of resources. For + example, if you pass `"New York"` (quoted), it will return resources that have + that string present somewhere in their response. Alternatively, you can supply a + structured search query. See the documentation on `StructuredSearchQuery` for + more details. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get_api_list( + "/print-mail/v1/trackers", + page=AsyncSkipLimit[TrackerListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "search": search, + "skip": skip, + }, + tracker_list_params.TrackerListParams, + ), + ), + model=TrackerListResponse, + ) + + async def delete( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> TrackerDeleteResponse: + """Delete a Tracker by ID. + + Note that this operation cannot be undone. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._delete( + path_template("/print-mail/v1/trackers/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=TrackerDeleteResponse, + ) + + def retrieve_visits( + self, + id: str, + *, + limit: int | Omit = omit, + search: str | Omit = omit, + skip: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[TrackerRetrieveVisitsResponse, AsyncSkipLimit[TrackerRetrieveVisitsResponse]]: + """ + Retrieve a paginated list of visits for a Tracker. + + Args: + search: You can supply any string to help narrow down the list of resources. For + example, if you pass `"New York"` (quoted), it will return resources that have + that string present somewhere in their response. Alternatively, you can supply a + structured search query. See the documentation on `StructuredSearchQuery` for + more details. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get_api_list( + path_template("/print-mail/v1/trackers/{id}/visits", id=id), + page=AsyncSkipLimit[TrackerRetrieveVisitsResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "search": search, + "skip": skip, + }, + tracker_retrieve_visits_params.TrackerRetrieveVisitsParams, + ), + ), + model=TrackerRetrieveVisitsResponse, + ) + + +class TrackersResourceWithRawResponse: + def __init__(self, trackers: TrackersResource) -> None: + self._trackers = trackers + + self.create = to_raw_response_wrapper( + trackers.create, + ) + self.retrieve = to_raw_response_wrapper( + trackers.retrieve, + ) + self.update = to_raw_response_wrapper( + trackers.update, + ) + self.list = to_raw_response_wrapper( + trackers.list, + ) + self.delete = to_raw_response_wrapper( + trackers.delete, + ) + self.retrieve_visits = to_raw_response_wrapper( + trackers.retrieve_visits, + ) + + +class AsyncTrackersResourceWithRawResponse: + def __init__(self, trackers: AsyncTrackersResource) -> None: + self._trackers = trackers + + self.create = async_to_raw_response_wrapper( + trackers.create, + ) + self.retrieve = async_to_raw_response_wrapper( + trackers.retrieve, + ) + self.update = async_to_raw_response_wrapper( + trackers.update, + ) + self.list = async_to_raw_response_wrapper( + trackers.list, + ) + self.delete = async_to_raw_response_wrapper( + trackers.delete, + ) + self.retrieve_visits = async_to_raw_response_wrapper( + trackers.retrieve_visits, + ) + + +class TrackersResourceWithStreamingResponse: + def __init__(self, trackers: TrackersResource) -> None: + self._trackers = trackers + + self.create = to_streamed_response_wrapper( + trackers.create, + ) + self.retrieve = to_streamed_response_wrapper( + trackers.retrieve, + ) + self.update = to_streamed_response_wrapper( + trackers.update, + ) + self.list = to_streamed_response_wrapper( + trackers.list, + ) + self.delete = to_streamed_response_wrapper( + trackers.delete, + ) + self.retrieve_visits = to_streamed_response_wrapper( + trackers.retrieve_visits, + ) + + +class AsyncTrackersResourceWithStreamingResponse: + def __init__(self, trackers: AsyncTrackersResource) -> None: + self._trackers = trackers + + self.create = async_to_streamed_response_wrapper( + trackers.create, + ) + self.retrieve = async_to_streamed_response_wrapper( + trackers.retrieve, + ) + self.update = async_to_streamed_response_wrapper( + trackers.update, + ) + self.list = async_to_streamed_response_wrapper( + trackers.list, + ) + self.delete = async_to_streamed_response_wrapper( + trackers.delete, + ) + self.retrieve_visits = async_to_streamed_response_wrapper( + trackers.retrieve_visits, + ) diff --git a/src/postgrid/resources/print_mail/virtual_mailboxes/__init__.py b/src/postgrid/resources/print_mail/virtual_mailboxes/__init__.py new file mode 100644 index 0000000..3d7bd27 --- /dev/null +++ b/src/postgrid/resources/print_mail/virtual_mailboxes/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .items import ( + ItemsResource, + AsyncItemsResource, + ItemsResourceWithRawResponse, + AsyncItemsResourceWithRawResponse, + ItemsResourceWithStreamingResponse, + AsyncItemsResourceWithStreamingResponse, +) +from .virtual_mailboxes import ( + VirtualMailboxesResource, + AsyncVirtualMailboxesResource, + VirtualMailboxesResourceWithRawResponse, + AsyncVirtualMailboxesResourceWithRawResponse, + VirtualMailboxesResourceWithStreamingResponse, + AsyncVirtualMailboxesResourceWithStreamingResponse, +) + +__all__ = [ + "ItemsResource", + "AsyncItemsResource", + "ItemsResourceWithRawResponse", + "AsyncItemsResourceWithRawResponse", + "ItemsResourceWithStreamingResponse", + "AsyncItemsResourceWithStreamingResponse", + "VirtualMailboxesResource", + "AsyncVirtualMailboxesResource", + "VirtualMailboxesResourceWithRawResponse", + "AsyncVirtualMailboxesResourceWithRawResponse", + "VirtualMailboxesResourceWithStreamingResponse", + "AsyncVirtualMailboxesResourceWithStreamingResponse", +] diff --git a/src/postgrid/resources/print_mail/virtual_mailboxes/items.py b/src/postgrid/resources/print_mail/virtual_mailboxes/items.py new file mode 100644 index 0000000..0907d59 --- /dev/null +++ b/src/postgrid/resources/print_mail/virtual_mailboxes/items.py @@ -0,0 +1,434 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict + +import httpx + +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import path_template, maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....pagination import SyncSkipLimit, AsyncSkipLimit +from ...._base_client import AsyncPaginator, make_request_options +from ....types.print_mail.virtual_mailboxes import item_list_params, item_create_params +from ....types.print_mail.virtual_mailboxes.item_list_response import ItemListResponse +from ....types.print_mail.virtual_mailboxes.item_create_response import ItemCreateResponse +from ....types.print_mail.virtual_mailboxes.item_retrieve_response import ItemRetrieveResponse + +__all__ = ["ItemsResource", "AsyncItemsResource"] + + +class ItemsResource(SyncAPIResource): + """ + Virtual mailboxes let you receive, scan, and forward your physical mail + without needing a traditional physical mailbox. Each mailbox is fully + digital, giving you a unique ID, status, and a set of capabilities such as + forwarding mail to another address or viewing envelope scans. This allows you + to manage physical correspondence entirely online. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + + @cached_property + def with_raw_response(self) -> ItemsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + """ + return ItemsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ItemsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + """ + return ItemsResourceWithStreamingResponse(self) + + def create( + self, + id: str, + *, + description: str | Omit = omit, + matched_letter: str | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ItemCreateResponse: + """Create a test item for a virtual mailbox. + + This is only available in test mode, + an error will be returned if you attempt this call in live mode. + + Args: + description: The description of the item. + + matched_letter: The ID of a letter to match this test item to. + + metadata: The metadata of the item. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._post( + path_template("/print-mail/v1/virtual_mailboxes/{id}/items", id=id), + body=maybe_transform( + { + "description": description, + "matched_letter": matched_letter, + "metadata": metadata, + }, + item_create_params.ItemCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ItemCreateResponse, + ) + + def retrieve( + self, + item_id: str, + *, + id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ItemRetrieveResponse: + """ + Retrieves a single item for a virtual mailbox. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + if not item_id: + raise ValueError(f"Expected a non-empty value for `item_id` but received {item_id!r}") + return self._get( + path_template("/print-mail/v1/virtual_mailboxes/{id}/items/{item_id}", id=id, item_id=item_id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ItemRetrieveResponse, + ) + + def list( + self, + id: str, + *, + limit: int | Omit = omit, + search: str | Omit = omit, + skip: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSkipLimit[ItemListResponse]: + """ + Lists items for a virtual mailbox. + + Args: + search: You can supply any string to help narrow down the list of resources. For + example, if you pass `"New York"` (quoted), it will return resources that have + that string present somewhere in their response. Alternatively, you can supply a + structured search query. See the documentation on `StructuredSearchQuery` for + more details. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get_api_list( + path_template("/print-mail/v1/virtual_mailboxes/{id}/items", id=id), + page=SyncSkipLimit[ItemListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "search": search, + "skip": skip, + }, + item_list_params.ItemListParams, + ), + ), + model=ItemListResponse, + ) + + +class AsyncItemsResource(AsyncAPIResource): + """ + Virtual mailboxes let you receive, scan, and forward your physical mail + without needing a traditional physical mailbox. Each mailbox is fully + digital, giving you a unique ID, status, and a set of capabilities such as + forwarding mail to another address or viewing envelope scans. This allows you + to manage physical correspondence entirely online. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + + @cached_property + def with_raw_response(self) -> AsyncItemsResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + """ + return AsyncItemsResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncItemsResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + """ + return AsyncItemsResourceWithStreamingResponse(self) + + async def create( + self, + id: str, + *, + description: str | Omit = omit, + matched_letter: str | Omit = omit, + metadata: Dict[str, object] | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ItemCreateResponse: + """Create a test item for a virtual mailbox. + + This is only available in test mode, + an error will be returned if you attempt this call in live mode. + + Args: + description: The description of the item. + + matched_letter: The ID of a letter to match this test item to. + + metadata: The metadata of the item. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._post( + path_template("/print-mail/v1/virtual_mailboxes/{id}/items", id=id), + body=await async_maybe_transform( + { + "description": description, + "matched_letter": matched_letter, + "metadata": metadata, + }, + item_create_params.ItemCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ItemCreateResponse, + ) + + async def retrieve( + self, + item_id: str, + *, + id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> ItemRetrieveResponse: + """ + Retrieves a single item for a virtual mailbox. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + if not item_id: + raise ValueError(f"Expected a non-empty value for `item_id` but received {item_id!r}") + return await self._get( + path_template("/print-mail/v1/virtual_mailboxes/{id}/items/{item_id}", id=id, item_id=item_id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ItemRetrieveResponse, + ) + + def list( + self, + id: str, + *, + limit: int | Omit = omit, + search: str | Omit = omit, + skip: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[ItemListResponse, AsyncSkipLimit[ItemListResponse]]: + """ + Lists items for a virtual mailbox. + + Args: + search: You can supply any string to help narrow down the list of resources. For + example, if you pass `"New York"` (quoted), it will return resources that have + that string present somewhere in their response. Alternatively, you can supply a + structured search query. See the documentation on `StructuredSearchQuery` for + more details. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get_api_list( + path_template("/print-mail/v1/virtual_mailboxes/{id}/items", id=id), + page=AsyncSkipLimit[ItemListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "search": search, + "skip": skip, + }, + item_list_params.ItemListParams, + ), + ), + model=ItemListResponse, + ) + + +class ItemsResourceWithRawResponse: + def __init__(self, items: ItemsResource) -> None: + self._items = items + + self.create = to_raw_response_wrapper( + items.create, + ) + self.retrieve = to_raw_response_wrapper( + items.retrieve, + ) + self.list = to_raw_response_wrapper( + items.list, + ) + + +class AsyncItemsResourceWithRawResponse: + def __init__(self, items: AsyncItemsResource) -> None: + self._items = items + + self.create = async_to_raw_response_wrapper( + items.create, + ) + self.retrieve = async_to_raw_response_wrapper( + items.retrieve, + ) + self.list = async_to_raw_response_wrapper( + items.list, + ) + + +class ItemsResourceWithStreamingResponse: + def __init__(self, items: ItemsResource) -> None: + self._items = items + + self.create = to_streamed_response_wrapper( + items.create, + ) + self.retrieve = to_streamed_response_wrapper( + items.retrieve, + ) + self.list = to_streamed_response_wrapper( + items.list, + ) + + +class AsyncItemsResourceWithStreamingResponse: + def __init__(self, items: AsyncItemsResource) -> None: + self._items = items + + self.create = async_to_streamed_response_wrapper( + items.create, + ) + self.retrieve = async_to_streamed_response_wrapper( + items.retrieve, + ) + self.list = async_to_streamed_response_wrapper( + items.list, + ) diff --git a/src/postgrid/resources/print_mail/virtual_mailboxes/virtual_mailboxes.py b/src/postgrid/resources/print_mail/virtual_mailboxes/virtual_mailboxes.py new file mode 100644 index 0000000..ebb3f9d --- /dev/null +++ b/src/postgrid/resources/print_mail/virtual_mailboxes/virtual_mailboxes.py @@ -0,0 +1,589 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal + +import httpx + +from .items import ( + ItemsResource, + AsyncItemsResource, + ItemsResourceWithRawResponse, + AsyncItemsResourceWithRawResponse, + ItemsResourceWithStreamingResponse, + AsyncItemsResourceWithStreamingResponse, +) +from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ...._utils import path_template, maybe_transform, async_maybe_transform +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ....pagination import SyncSkipLimit, AsyncSkipLimit +from ...._base_client import AsyncPaginator, make_request_options +from ....types.print_mail import virtual_mailbox_list_params, virtual_mailbox_create_params +from ....types.print_mail.virtual_mailbox_list_response import VirtualMailboxListResponse +from ....types.print_mail.virtual_mailbox_create_response import VirtualMailboxCreateResponse +from ....types.print_mail.virtual_mailbox_retrieve_response import VirtualMailboxRetrieveResponse +from ....types.print_mail.virtual_mailbox_retrieve_address_response import VirtualMailboxRetrieveAddressResponse + +__all__ = ["VirtualMailboxesResource", "AsyncVirtualMailboxesResource"] + + +class VirtualMailboxesResource(SyncAPIResource): + """ + Virtual mailboxes let you receive, scan, and forward your physical mail + without needing a traditional physical mailbox. Each mailbox is fully + digital, giving you a unique ID, status, and a set of capabilities such as + forwarding mail to another address or viewing envelope scans. This allows you + to manage physical correspondence entirely online. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + + @cached_property + def items(self) -> ItemsResource: + """ + Virtual mailboxes let you receive, scan, and forward your physical mail + without needing a traditional physical mailbox. Each mailbox is fully + digital, giving you a unique ID, status, and a set of capabilities such as + forwarding mail to another address or viewing envelope scans. This allows you + to manage physical correspondence entirely online. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + return ItemsResource(self._client) + + @cached_property + def with_raw_response(self) -> VirtualMailboxesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + """ + return VirtualMailboxesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> VirtualMailboxesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + """ + return VirtualMailboxesResourceWithStreamingResponse(self) + + def create( + self, + *, + country_code: Literal["US"], + capabilities: virtual_mailbox_create_params.Capabilities | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VirtualMailboxCreateResponse: + """Creates a new virtual mailbox. + + In live mode, the virtual mailbox will be pending + assignment and cannot be used until it has been assigned and activated by our + team. You will be notified via email once the virtual mailbox has been + activated. In test mode, the virtual mailbox will be activated immediately upon + creation. + + Args: + country_code: All of the supported countries for virtual mailboxes. + + capabilities: The capabilities the virtual mailbox should support. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/print-mail/v1/virtual_mailboxes", + body=maybe_transform( + { + "country_code": country_code, + "capabilities": capabilities, + }, + virtual_mailbox_create_params.VirtualMailboxCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VirtualMailboxCreateResponse, + ) + + def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VirtualMailboxRetrieveResponse: + """ + Retrieve Virtual Mailbox + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + path_template("/print-mail/v1/virtual_mailboxes/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VirtualMailboxRetrieveResponse, + ) + + def list( + self, + *, + limit: int | Omit = omit, + search: str | Omit = omit, + skip: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SyncSkipLimit[VirtualMailboxListResponse]: + """Lists virtual mailboxes. + + You can use the `skip`, `limit`, and `search` query + parameters to refine the list. + + Args: + search: You can supply any string to help narrow down the list of resources. For + example, if you pass `"New York"` (quoted), it will return resources that have + that string present somewhere in their response. Alternatively, you can supply a + structured search query. See the documentation on `StructuredSearchQuery` for + more details. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get_api_list( + "/print-mail/v1/virtual_mailboxes", + page=SyncSkipLimit[VirtualMailboxListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "search": search, + "skip": skip, + }, + virtual_mailbox_list_params.VirtualMailboxListParams, + ), + ), + model=VirtualMailboxListResponse, + ) + + def retrieve_address( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VirtualMailboxRetrieveAddressResponse: + """ + Retrieves the physical address of the virtual mailbox. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + path_template("/print-mail/v1/virtual_mailboxes/{id}/address", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VirtualMailboxRetrieveAddressResponse, + ) + + +class AsyncVirtualMailboxesResource(AsyncAPIResource): + """ + Virtual mailboxes let you receive, scan, and forward your physical mail + without needing a traditional physical mailbox. Each mailbox is fully + digital, giving you a unique ID, status, and a set of capabilities such as + forwarding mail to another address or viewing envelope scans. This allows you + to manage physical correspondence entirely online. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + + @cached_property + def items(self) -> AsyncItemsResource: + """ + Virtual mailboxes let you receive, scan, and forward your physical mail + without needing a traditional physical mailbox. Each mailbox is fully + digital, giving you a unique ID, status, and a set of capabilities such as + forwarding mail to another address or viewing envelope scans. This allows you + to manage physical correspondence entirely online. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + return AsyncItemsResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncVirtualMailboxesResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/postgrid/postgrid-python#accessing-raw-response-data-eg-headers + """ + return AsyncVirtualMailboxesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncVirtualMailboxesResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/postgrid/postgrid-python#with_streaming_response + """ + return AsyncVirtualMailboxesResourceWithStreamingResponse(self) + + async def create( + self, + *, + country_code: Literal["US"], + capabilities: virtual_mailbox_create_params.Capabilities | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VirtualMailboxCreateResponse: + """Creates a new virtual mailbox. + + In live mode, the virtual mailbox will be pending + assignment and cannot be used until it has been assigned and activated by our + team. You will be notified via email once the virtual mailbox has been + activated. In test mode, the virtual mailbox will be activated immediately upon + creation. + + Args: + country_code: All of the supported countries for virtual mailboxes. + + capabilities: The capabilities the virtual mailbox should support. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/print-mail/v1/virtual_mailboxes", + body=await async_maybe_transform( + { + "country_code": country_code, + "capabilities": capabilities, + }, + virtual_mailbox_create_params.VirtualMailboxCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VirtualMailboxCreateResponse, + ) + + async def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VirtualMailboxRetrieveResponse: + """ + Retrieve Virtual Mailbox + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + path_template("/print-mail/v1/virtual_mailboxes/{id}", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VirtualMailboxRetrieveResponse, + ) + + def list( + self, + *, + limit: int | Omit = omit, + search: str | Omit = omit, + skip: int | Omit = omit, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[VirtualMailboxListResponse, AsyncSkipLimit[VirtualMailboxListResponse]]: + """Lists virtual mailboxes. + + You can use the `skip`, `limit`, and `search` query + parameters to refine the list. + + Args: + search: You can supply any string to help narrow down the list of resources. For + example, if you pass `"New York"` (quoted), it will return resources that have + that string present somewhere in their response. Alternatively, you can supply a + structured search query. See the documentation on `StructuredSearchQuery` for + more details. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._get_api_list( + "/print-mail/v1/virtual_mailboxes", + page=AsyncSkipLimit[VirtualMailboxListResponse], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "search": search, + "skip": skip, + }, + virtual_mailbox_list_params.VirtualMailboxListParams, + ), + ), + model=VirtualMailboxListResponse, + ) + + async def retrieve_address( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> VirtualMailboxRetrieveAddressResponse: + """ + Retrieves the physical address of the virtual mailbox. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + path_template("/print-mail/v1/virtual_mailboxes/{id}/address", id=id), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=VirtualMailboxRetrieveAddressResponse, + ) + + +class VirtualMailboxesResourceWithRawResponse: + def __init__(self, virtual_mailboxes: VirtualMailboxesResource) -> None: + self._virtual_mailboxes = virtual_mailboxes + + self.create = to_raw_response_wrapper( + virtual_mailboxes.create, + ) + self.retrieve = to_raw_response_wrapper( + virtual_mailboxes.retrieve, + ) + self.list = to_raw_response_wrapper( + virtual_mailboxes.list, + ) + self.retrieve_address = to_raw_response_wrapper( + virtual_mailboxes.retrieve_address, + ) + + @cached_property + def items(self) -> ItemsResourceWithRawResponse: + """ + Virtual mailboxes let you receive, scan, and forward your physical mail + without needing a traditional physical mailbox. Each mailbox is fully + digital, giving you a unique ID, status, and a set of capabilities such as + forwarding mail to another address or viewing envelope scans. This allows you + to manage physical correspondence entirely online. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + return ItemsResourceWithRawResponse(self._virtual_mailboxes.items) + + +class AsyncVirtualMailboxesResourceWithRawResponse: + def __init__(self, virtual_mailboxes: AsyncVirtualMailboxesResource) -> None: + self._virtual_mailboxes = virtual_mailboxes + + self.create = async_to_raw_response_wrapper( + virtual_mailboxes.create, + ) + self.retrieve = async_to_raw_response_wrapper( + virtual_mailboxes.retrieve, + ) + self.list = async_to_raw_response_wrapper( + virtual_mailboxes.list, + ) + self.retrieve_address = async_to_raw_response_wrapper( + virtual_mailboxes.retrieve_address, + ) + + @cached_property + def items(self) -> AsyncItemsResourceWithRawResponse: + """ + Virtual mailboxes let you receive, scan, and forward your physical mail + without needing a traditional physical mailbox. Each mailbox is fully + digital, giving you a unique ID, status, and a set of capabilities such as + forwarding mail to another address or viewing envelope scans. This allows you + to manage physical correspondence entirely online. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + return AsyncItemsResourceWithRawResponse(self._virtual_mailboxes.items) + + +class VirtualMailboxesResourceWithStreamingResponse: + def __init__(self, virtual_mailboxes: VirtualMailboxesResource) -> None: + self._virtual_mailboxes = virtual_mailboxes + + self.create = to_streamed_response_wrapper( + virtual_mailboxes.create, + ) + self.retrieve = to_streamed_response_wrapper( + virtual_mailboxes.retrieve, + ) + self.list = to_streamed_response_wrapper( + virtual_mailboxes.list, + ) + self.retrieve_address = to_streamed_response_wrapper( + virtual_mailboxes.retrieve_address, + ) + + @cached_property + def items(self) -> ItemsResourceWithStreamingResponse: + """ + Virtual mailboxes let you receive, scan, and forward your physical mail + without needing a traditional physical mailbox. Each mailbox is fully + digital, giving you a unique ID, status, and a set of capabilities such as + forwarding mail to another address or viewing envelope scans. This allows you + to manage physical correspondence entirely online. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + return ItemsResourceWithStreamingResponse(self._virtual_mailboxes.items) + + +class AsyncVirtualMailboxesResourceWithStreamingResponse: + def __init__(self, virtual_mailboxes: AsyncVirtualMailboxesResource) -> None: + self._virtual_mailboxes = virtual_mailboxes + + self.create = async_to_streamed_response_wrapper( + virtual_mailboxes.create, + ) + self.retrieve = async_to_streamed_response_wrapper( + virtual_mailboxes.retrieve, + ) + self.list = async_to_streamed_response_wrapper( + virtual_mailboxes.list, + ) + self.retrieve_address = async_to_streamed_response_wrapper( + virtual_mailboxes.retrieve_address, + ) + + @cached_property + def items(self) -> AsyncItemsResourceWithStreamingResponse: + """ + Virtual mailboxes let you receive, scan, and forward your physical mail + without needing a traditional physical mailbox. Each mailbox is fully + digital, giving you a unique ID, status, and a set of capabilities such as + forwarding mail to another address or viewing envelope scans. This allows you + to manage physical correspondence entirely online. + + You can request access to this feature by reaching out to + support@postgrid.com + """ + return AsyncItemsResourceWithStreamingResponse(self._virtual_mailboxes.items) diff --git a/src/postgrid/types/__init__.py b/src/postgrid/types/__init__.py index 9246b3b..0853cc0 100644 --- a/src/postgrid/types/__init__.py +++ b/src/postgrid/types/__init__.py @@ -6,10 +6,6 @@ from .status import Status as Status from .address_verification_verify_params import AddressVerificationVerifyParams as AddressVerificationVerifyParams from .address_verification_verify_response import AddressVerificationVerifyResponse as AddressVerificationVerifyResponse -from .contact_create_with_first_name_param import ContactCreateWithFirstNameParam as ContactCreateWithFirstNameParam -from .contact_create_with_company_name_param import ( - ContactCreateWithCompanyNameParam as ContactCreateWithCompanyNameParam, -) from .intl_address_verification_verify_params import ( IntlAddressVerificationVerifyParams as IntlAddressVerificationVerifyParams, ) diff --git a/src/postgrid/types/print_mail/__init__.py b/src/postgrid/types/print_mail/__init__.py index 2e35113..5760aa8 100644 --- a/src/postgrid/types/print_mail/__init__.py +++ b/src/postgrid/types/print_mail/__init__.py @@ -18,9 +18,12 @@ from .digital_only import DigitalOnly as DigitalOnly from .mailing_list import MailingList as MailingList from .plastic_card import PlasticCard as PlasticCard +from .box_list_params import BoxListParams as BoxListParams from .deleted_response import DeletedResponse as DeletedResponse from .sub_organization import SubOrganization as SubOrganization from .address_placement import AddressPlacement as AddressPlacement +from .box_create_params import BoxCreateParams as BoxCreateParams +from .box_list_response import BoxListResponse as BoxListResponse from .email_preferences import EmailPreferences as EmailPreferences from .attached_pdf_param import AttachedPdfParam as AttachedPdfParam from .cheque_list_params import ChequeListParams as ChequeListParams @@ -28,54 +31,120 @@ from .letter_list_params import LetterListParams as LetterListParams from .plastic_card_param import PlasticCardParam as PlasticCardParam from .report_list_params import ReportListParams as ReportListParams +from .box_create_response import BoxCreateResponse as BoxCreateResponse +from .box_delete_response import BoxDeleteResponse as BoxDeleteResponse from .contact_list_params import ContactListParams as ContactListParams from .mailing_list_update import MailingListUpdate as MailingListUpdate +from .tracker_list_params import TrackerListParams as TrackerListParams from .campaign_list_params import CampaignListParams as CampaignListParams from .campaign_send_params import CampaignSendParams as CampaignSendParams +from .cheque_cancel_params import ChequeCancelParams as ChequeCancelParams from .cheque_create_params import ChequeCreateParams as ChequeCreateParams from .contact_create_param import ContactCreateParam as ContactCreateParam +from .letter_cancel_params import LetterCancelParams as LetterCancelParams from .letter_create_params import LetterCreateParams as LetterCreateParams from .postcard_list_params import PostcardListParams as PostcardListParams from .report_create_params import ReportCreateParams as ReportCreateParams from .report_sample_params import ReportSampleParams as ReportSampleParams from .report_update_params import ReportUpdateParams as ReportUpdateParams from .template_list_params import TemplateListParams as TemplateListParams +from .box_retrieve_response import BoxRetrieveResponse as BoxRetrieveResponse from .contact_create_params import ContactCreateParams as ContactCreateParams +from .snap_pack_list_params import SnapPackListParams as SnapPackListParams +from .tracker_create_params import TrackerCreateParams as TrackerCreateParams +from .tracker_list_response import TrackerListResponse as TrackerListResponse +from .tracker_update_params import TrackerUpdateParams as TrackerUpdateParams from .campaign_create_params import CampaignCreateParams as CampaignCreateParams from .campaign_update_params import CampaignUpdateParams as CampaignUpdateParams +from .postcard_cancel_params import PostcardCancelParams as PostcardCancelParams from .postcard_create_params import PostcardCreateParams as PostcardCreateParams from .template_create_params import TemplateCreateParams as TemplateCreateParams from .template_update_params import TemplateUpdateParams as TemplateUpdateParams from .contact_delete_response import ContactDeleteResponse as ContactDeleteResponse from .self_mailer_list_params import SelfMailerListParams as SelfMailerListParams +from .snap_pack_create_params import SnapPackCreateParams as SnapPackCreateParams +from .snap_pack_list_response import SnapPackListResponse as SnapPackListResponse +from .tracker_create_response import TrackerCreateResponse as TrackerCreateResponse +from .tracker_delete_response import TrackerDeleteResponse as TrackerDeleteResponse +from .tracker_update_response import TrackerUpdateResponse as TrackerUpdateResponse from .bank_account_list_params import BankAccountListParams as BankAccountListParams from .campaign_delete_response import CampaignDeleteResponse as CampaignDeleteResponse from .mailing_list_jobs_params import MailingListJobsParams as MailingListJobsParams from .mailing_list_list_params import MailingListListParams as MailingListListParams from .template_delete_response import TemplateDeleteResponse as TemplateDeleteResponse from .bank_account_country_code import BankAccountCountryCode as BankAccountCountryCode +from .box_progressions_response import BoxProgressionsResponse as BoxProgressionsResponse from .self_mailer_create_params import SelfMailerCreateParams as SelfMailerCreateParams +from .snap_pack_create_response import SnapPackCreateResponse as SnapPackCreateResponse +from .snap_pack_delete_response import SnapPackDeleteResponse as SnapPackDeleteResponse +from .tracker_retrieve_response import TrackerRetrieveResponse as TrackerRetrieveResponse from .verification_status_count import VerificationStatusCount as VerificationStatusCount from .bank_account_create_params import BankAccountCreateParams as BankAccountCreateParams from .mailing_list_create_params import MailingListCreateParams as MailingListCreateParams from .mailing_list_update_params import MailingListUpdateParams as MailingListUpdateParams +from .snap_pack_retrieve_response import SnapPackRetrieveResponse as SnapPackRetrieveResponse +from .virtual_mailbox_list_params import VirtualMailboxListParams as VirtualMailboxListParams from .bank_account_delete_response import BankAccountDeleteResponse as BankAccountDeleteResponse from .cheque_retrieve_url_response import ChequeRetrieveURLResponse as ChequeRetrieveURLResponse from .letter_retrieve_url_response import LetterRetrieveURLResponse as LetterRetrieveURLResponse from .mailing_list_delete_response import MailingListDeleteResponse as MailingListDeleteResponse from .mailing_list_import_response import MailingListImportResponse as MailingListImportResponse from .sub_organization_list_params import SubOrganizationListParams as SubOrganizationListParams +from .virtual_mailbox_create_params import VirtualMailboxCreateParams as VirtualMailboxCreateParams +from .virtual_mailbox_list_response import VirtualMailboxListResponse as VirtualMailboxListResponse from .postcard_retrieve_url_response import PostcardRetrieveURLResponse as PostcardRetrieveURLResponse from .sub_organization_update_params import SubOrganizationUpdateParams as SubOrganizationUpdateParams +from .tracker_retrieve_visits_params import TrackerRetrieveVisitsParams as TrackerRetrieveVisitsParams from .mailing_list_import_list_params import MailingListImportListParams as MailingListImportListParams +from .snap_pack_progressions_response import SnapPackProgressionsResponse as SnapPackProgressionsResponse +from .targeted_list_build_list_params import TargetedListBuildListParams as TargetedListBuildListParams +from .virtual_mailbox_create_response import VirtualMailboxCreateResponse as VirtualMailboxCreateResponse from .sub_organization_update_response import SubOrganizationUpdateResponse as SubOrganizationUpdateResponse +from .tracker_retrieve_visits_response import TrackerRetrieveVisitsResponse as TrackerRetrieveVisitsResponse from .mailing_list_import_create_params import MailingListImportCreateParams as MailingListImportCreateParams from .mailing_list_import_update_params import MailingListImportUpdateParams as MailingListImportUpdateParams from .self_mailer_retrieve_url_response import SelfMailerRetrieveURLResponse as SelfMailerRetrieveURLResponse +from .targeted_list_build_create_params import TargetedListBuildCreateParams as TargetedListBuildCreateParams +from .targeted_list_build_list_response import TargetedListBuildListResponse as TargetedListBuildListResponse +from .targeted_list_build_update_params import TargetedListBuildUpdateParams as TargetedListBuildUpdateParams +from .virtual_mailbox_retrieve_response import VirtualMailboxRetrieveResponse as VirtualMailboxRetrieveResponse from .mailing_list_import_delete_response import MailingListImportDeleteResponse as MailingListImportDeleteResponse +from .targeted_list_build_create_response import TargetedListBuildCreateResponse as TargetedListBuildCreateResponse +from .targeted_list_build_delete_response import TargetedListBuildDeleteResponse as TargetedListBuildDeleteResponse +from .targeted_list_build_update_response import TargetedListBuildUpdateResponse as TargetedListBuildUpdateResponse +from .template_editor_session_list_params import TemplateEditorSessionListParams as TemplateEditorSessionListParams +from .contact_create_with_first_name_param import ContactCreateWithFirstNameParam as ContactCreateWithFirstNameParam +from .targeted_list_build_confirm_response import TargetedListBuildConfirmResponse as TargetedListBuildConfirmResponse +from .targeted_list_build_retrieve_response import ( + TargetedListBuildRetrieveResponse as TargetedListBuildRetrieveResponse, +) +from .template_editor_session_create_params import ( + TemplateEditorSessionCreateParams as TemplateEditorSessionCreateParams, +) +from .template_editor_session_list_response import ( + TemplateEditorSessionListResponse as TemplateEditorSessionListResponse, +) +from .contact_create_with_company_name_param import ( + ContactCreateWithCompanyNameParam as ContactCreateWithCompanyNameParam, +) +from .snap_pack_retrieve_capabilities_params import ( + SnapPackRetrieveCapabilitiesParams as SnapPackRetrieveCapabilitiesParams, +) from .sub_organization_retrieve_users_params import ( SubOrganizationRetrieveUsersParams as SubOrganizationRetrieveUsersParams, ) +from .template_editor_session_create_response import ( + TemplateEditorSessionCreateResponse as TemplateEditorSessionCreateResponse, +) +from .template_editor_session_delete_response import ( + TemplateEditorSessionDeleteResponse as TemplateEditorSessionDeleteResponse, +) +from .snap_pack_retrieve_capabilities_response import ( + SnapPackRetrieveCapabilitiesResponse as SnapPackRetrieveCapabilitiesResponse, +) from .sub_organization_retrieve_users_response import ( SubOrganizationRetrieveUsersResponse as SubOrganizationRetrieveUsersResponse, ) +from .virtual_mailbox_retrieve_address_response import ( + VirtualMailboxRetrieveAddressResponse as VirtualMailboxRetrieveAddressResponse, +) diff --git a/src/postgrid/types/print_mail/box_create_params.py b/src/postgrid/types/print_mail/box_create_params.py new file mode 100644 index 0000000..ffc08c8 --- /dev/null +++ b/src/postgrid/types/print_mail/box_create_params.py @@ -0,0 +1,141 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Union, Iterable +from datetime import datetime +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict + +from ..._utils import PropertyInfo +from .contact_create_with_first_name_param import ContactCreateWithFirstNameParam +from .contact_create_with_company_name_param import ContactCreateWithCompanyNameParam + +__all__ = ["BoxCreateParams", "Cheque", "ChequeFrom", "ChequeTo", "From", "To"] + + +class BoxCreateParams(TypedDict, total=False): + cheques: Required[Iterable[Cheque]] + """The cheques to be mailed in the box. + + Only 100 cheques can be included in a box at a time. + """ + + from_: Required[Annotated[From, PropertyInfo(alias="from")]] + """The 'from' (sender) of the entire box. + + Accepts inline ContactCreate or a contactID. + """ + + to: Required[To] + """The recipient of this order. + + You can either supply the contact information inline here or provide a contact + ID. PostGrid will automatically deduplicate contacts regardless of whether you + provide the information inline here or call the contact creation endpoint. + """ + + description: str + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + mailing_class: Annotated[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ], + PropertyInfo(alias="mailingClass"), + ] + """The mailing class of this order. + + If not provided, automatically set to `first_class`. + """ + + merge_variables: Annotated[Dict[str, object], PropertyInfo(alias="mergeVariables")] + """ + These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + """ + + metadata: Dict[str, object] + """See the section on Metadata.""" + + send_date: Annotated[Union[str, datetime], PropertyInfo(alias="sendDate", format="iso8601")] + """This order will transition from `ready` to `printing` on the day after this + date. + + You can use this parameter to schedule orders for a future date. + """ + + +ChequeFrom: TypeAlias = Union[ContactCreateWithFirstNameParam, ContactCreateWithCompanyNameParam, str] + +ChequeTo: TypeAlias = Union[ContactCreateWithFirstNameParam, ContactCreateWithCompanyNameParam, str] + +_ChequeReservedKeywords = TypedDict( + "_ChequeReservedKeywords", + { + "from": ChequeFrom, + }, + total=False, +) + + +class Cheque(_ChequeReservedKeywords, total=False): + amount: Required[int] + """The amount on the cheque.""" + + bank_account: Required[Annotated[str, PropertyInfo(alias="bankAccount")]] + """The bank account (ID or reference) from which the cheque amount is drawn.""" + + number: Required[int] + """The cheque number.""" + + to: Required[ChequeTo] + + logo_url: Annotated[str, PropertyInfo(alias="logoURL")] + """A URL to a logo for the cheque (optional).""" + + memo: str + """The memo text on the cheque (optional).""" + + merge_variables: Annotated[Dict[str, object], PropertyInfo(alias="mergeVariables")] + """ + A set of dynamic merge variables for customizing the cheque or accompanying + documents (optional). + """ + + message_template: Annotated[str, PropertyInfo(alias="messageTemplate")] + """An optional message template to be printed on or with the cheque.""" + + +From: TypeAlias = Union[ContactCreateWithFirstNameParam, ContactCreateWithCompanyNameParam, str] + +To: TypeAlias = Union[ContactCreateWithFirstNameParam, ContactCreateWithCompanyNameParam, str] diff --git a/src/postgrid/types/print_mail/box_create_response.py b/src/postgrid/types/print_mail/box_create_response.py new file mode 100644 index 0000000..9b171c1 --- /dev/null +++ b/src/postgrid/types/print_mail/box_create_response.py @@ -0,0 +1,198 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .contact import Contact +from ..._models import BaseModel + +__all__ = ["BoxCreateResponse", "Cheque", "Cancellation"] + + +class Cheque(BaseModel): + amount: int + """The amount on the cheque.""" + + bank_account: str = FieldInfo(alias="bankAccount") + """The bank account (ID or reference) from which the cheque amount is drawn.""" + + from_: Contact = FieldInfo(alias="from") + + number: int + """The cheque number.""" + + to: Contact + + logo_url: Optional[str] = FieldInfo(alias="logoURL", default=None) + """A URL to a logo for the cheque (optional).""" + + memo: Optional[str] = None + """The memo text on the cheque (optional).""" + + merge_variables: Optional[Dict[str, object]] = FieldInfo(alias="mergeVariables", default=None) + """ + A set of dynamic merge variables for customizing the cheque or accompanying + documents (optional). + """ + + message_template: Optional[str] = FieldInfo(alias="messageTemplate", default=None) + """An optional message template to be printed on or with the cheque.""" + + +class Cancellation(BaseModel): + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + reason: Literal["user_initiated", "invalid_content", "invalid_order_mailing_class"] + """The reason for the cancellation.""" + + cancelled_by_user: Optional[str] = FieldInfo(alias="cancelledByUser", default=None) + """The user ID who cancelled the order.""" + + note: Optional[str] = None + """An optional note provided by the user who cancelled the order.""" + + +class BoxCreateResponse(BaseModel): + id: str + """A unique ID prefixed with box\\__""" + + cheques: List[Cheque] + """The cheques inside this box (in read mode).""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + from_: Contact = FieldInfo(alias="from") + """ + The contact of the 'from' field in read mode should be a fully expanded Contact. + """ + + live: bool + """`true` if this is a live mode resource else `false`.""" + + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] = FieldInfo(alias="mailingClass") + """The mailing class of this order. + + This determines the speed and cost of delivery. See `OrderMailingClass` for more + details. + """ + + object: Literal["box"] + """Always "box".""" + + send_date: datetime = FieldInfo(alias="sendDate") + """This order will transition from `ready` to `printing` on the day after this + date. + + For example, if this is a date on Tuesday, the order will transition to + `printing` on Wednesday at midnight eastern time. + """ + + status: Literal["ready", "printing", "processed_for_delivery", "completed", "cancelled"] + """See `OrderStatus` for more details on the status of this order.""" + + to: Contact + """The recipient of this order. + + This will be provided even if you delete the underlying contact. + """ + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + cancellation: Optional[Cancellation] = None + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + imb_date: Optional[datetime] = FieldInfo(alias="imbDate", default=None) + """The last date that the IMB status was updated. + + See `imbStatus` for more details. + """ + + imb_status: Optional[Literal["entered_mail_stream", "out_for_delivery", "returned_to_sender"]] = FieldInfo( + alias="imbStatus", default=None + ) + """The Intelligent Mail Barcode (IMB) status of this order. + + Only populated for US-printed and US-destined orders. This is the most detailed + way to track non-express/certified orders. + """ + + imb_zip_code: Optional[str] = FieldInfo(alias="imbZIPCode", default=None) + """ + The most recent ZIP code of the USPS facility that the order has been processed + through. Only populated when an `imbStatus` is present. + """ + + merge_variables: Optional[Dict[str, builtins.object]] = FieldInfo(alias="mergeVariables", default=None) + """ + These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + """ + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" + + tracking_number: Optional[str] = FieldInfo(alias="trackingNumber", default=None) + """The tracking number of this order. + + Populated after an express/certified order has been processed for delivery. + """ + + url: Optional[str] = None + """PostGrid renders a PDF preview for all orders. + + This should be inspected to ensure that the order is correct before it is sent + out because it shows what will be printed and mailed to the recipient. Once the + PDF preview is generated, this field will be returned by all `GET` endpoints + which produce this order. + + This URL is a signed link to the PDF preview. It will expire after a short + period of time. If you need to access this URL after it has expired, you can + regenerate it by calling the `GET` endpoint again. + """ diff --git a/src/postgrid/types/print_mail/box_delete_response.py b/src/postgrid/types/print_mail/box_delete_response.py new file mode 100644 index 0000000..e8e9b13 --- /dev/null +++ b/src/postgrid/types/print_mail/box_delete_response.py @@ -0,0 +1,198 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .contact import Contact +from ..._models import BaseModel + +__all__ = ["BoxDeleteResponse", "Cheque", "Cancellation"] + + +class Cheque(BaseModel): + amount: int + """The amount on the cheque.""" + + bank_account: str = FieldInfo(alias="bankAccount") + """The bank account (ID or reference) from which the cheque amount is drawn.""" + + from_: Contact = FieldInfo(alias="from") + + number: int + """The cheque number.""" + + to: Contact + + logo_url: Optional[str] = FieldInfo(alias="logoURL", default=None) + """A URL to a logo for the cheque (optional).""" + + memo: Optional[str] = None + """The memo text on the cheque (optional).""" + + merge_variables: Optional[Dict[str, object]] = FieldInfo(alias="mergeVariables", default=None) + """ + A set of dynamic merge variables for customizing the cheque or accompanying + documents (optional). + """ + + message_template: Optional[str] = FieldInfo(alias="messageTemplate", default=None) + """An optional message template to be printed on or with the cheque.""" + + +class Cancellation(BaseModel): + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + reason: Literal["user_initiated", "invalid_content", "invalid_order_mailing_class"] + """The reason for the cancellation.""" + + cancelled_by_user: Optional[str] = FieldInfo(alias="cancelledByUser", default=None) + """The user ID who cancelled the order.""" + + note: Optional[str] = None + """An optional note provided by the user who cancelled the order.""" + + +class BoxDeleteResponse(BaseModel): + id: str + """A unique ID prefixed with box\\__""" + + cheques: List[Cheque] + """The cheques inside this box (in read mode).""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + from_: Contact = FieldInfo(alias="from") + """ + The contact of the 'from' field in read mode should be a fully expanded Contact. + """ + + live: bool + """`true` if this is a live mode resource else `false`.""" + + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] = FieldInfo(alias="mailingClass") + """The mailing class of this order. + + This determines the speed and cost of delivery. See `OrderMailingClass` for more + details. + """ + + object: Literal["box"] + """Always "box".""" + + send_date: datetime = FieldInfo(alias="sendDate") + """This order will transition from `ready` to `printing` on the day after this + date. + + For example, if this is a date on Tuesday, the order will transition to + `printing` on Wednesday at midnight eastern time. + """ + + status: Literal["ready", "printing", "processed_for_delivery", "completed", "cancelled"] + """See `OrderStatus` for more details on the status of this order.""" + + to: Contact + """The recipient of this order. + + This will be provided even if you delete the underlying contact. + """ + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + cancellation: Optional[Cancellation] = None + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + imb_date: Optional[datetime] = FieldInfo(alias="imbDate", default=None) + """The last date that the IMB status was updated. + + See `imbStatus` for more details. + """ + + imb_status: Optional[Literal["entered_mail_stream", "out_for_delivery", "returned_to_sender"]] = FieldInfo( + alias="imbStatus", default=None + ) + """The Intelligent Mail Barcode (IMB) status of this order. + + Only populated for US-printed and US-destined orders. This is the most detailed + way to track non-express/certified orders. + """ + + imb_zip_code: Optional[str] = FieldInfo(alias="imbZIPCode", default=None) + """ + The most recent ZIP code of the USPS facility that the order has been processed + through. Only populated when an `imbStatus` is present. + """ + + merge_variables: Optional[Dict[str, builtins.object]] = FieldInfo(alias="mergeVariables", default=None) + """ + These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + """ + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" + + tracking_number: Optional[str] = FieldInfo(alias="trackingNumber", default=None) + """The tracking number of this order. + + Populated after an express/certified order has been processed for delivery. + """ + + url: Optional[str] = None + """PostGrid renders a PDF preview for all orders. + + This should be inspected to ensure that the order is correct before it is sent + out because it shows what will be printed and mailed to the recipient. Once the + PDF preview is generated, this field will be returned by all `GET` endpoints + which produce this order. + + This URL is a signed link to the PDF preview. It will expire after a short + period of time. If you need to access this URL after it has expired, you can + regenerate it by calling the `GET` endpoint again. + """ diff --git a/src/postgrid/types/print_mail/box_list_params.py b/src/postgrid/types/print_mail/box_list_params.py new file mode 100644 index 0000000..9832ccc --- /dev/null +++ b/src/postgrid/types/print_mail/box_list_params.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["BoxListParams"] + + +class BoxListParams(TypedDict, total=False): + limit: int + + search: str + """You can supply any string to help narrow down the list of resources. + + For example, if you pass `"New York"` (quoted), it will return resources that + have that string present somewhere in their response. Alternatively, you can + supply a structured search query. See the documentation on + `StructuredSearchQuery` for more details. + """ + + skip: int diff --git a/src/postgrid/types/print_mail/box_list_response.py b/src/postgrid/types/print_mail/box_list_response.py new file mode 100644 index 0000000..38cd91d --- /dev/null +++ b/src/postgrid/types/print_mail/box_list_response.py @@ -0,0 +1,198 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .contact import Contact +from ..._models import BaseModel + +__all__ = ["BoxListResponse", "Cheque", "Cancellation"] + + +class Cheque(BaseModel): + amount: int + """The amount on the cheque.""" + + bank_account: str = FieldInfo(alias="bankAccount") + """The bank account (ID or reference) from which the cheque amount is drawn.""" + + from_: Contact = FieldInfo(alias="from") + + number: int + """The cheque number.""" + + to: Contact + + logo_url: Optional[str] = FieldInfo(alias="logoURL", default=None) + """A URL to a logo for the cheque (optional).""" + + memo: Optional[str] = None + """The memo text on the cheque (optional).""" + + merge_variables: Optional[Dict[str, object]] = FieldInfo(alias="mergeVariables", default=None) + """ + A set of dynamic merge variables for customizing the cheque or accompanying + documents (optional). + """ + + message_template: Optional[str] = FieldInfo(alias="messageTemplate", default=None) + """An optional message template to be printed on or with the cheque.""" + + +class Cancellation(BaseModel): + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + reason: Literal["user_initiated", "invalid_content", "invalid_order_mailing_class"] + """The reason for the cancellation.""" + + cancelled_by_user: Optional[str] = FieldInfo(alias="cancelledByUser", default=None) + """The user ID who cancelled the order.""" + + note: Optional[str] = None + """An optional note provided by the user who cancelled the order.""" + + +class BoxListResponse(BaseModel): + id: str + """A unique ID prefixed with box\\__""" + + cheques: List[Cheque] + """The cheques inside this box (in read mode).""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + from_: Contact = FieldInfo(alias="from") + """ + The contact of the 'from' field in read mode should be a fully expanded Contact. + """ + + live: bool + """`true` if this is a live mode resource else `false`.""" + + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] = FieldInfo(alias="mailingClass") + """The mailing class of this order. + + This determines the speed and cost of delivery. See `OrderMailingClass` for more + details. + """ + + object: Literal["box"] + """Always "box".""" + + send_date: datetime = FieldInfo(alias="sendDate") + """This order will transition from `ready` to `printing` on the day after this + date. + + For example, if this is a date on Tuesday, the order will transition to + `printing` on Wednesday at midnight eastern time. + """ + + status: Literal["ready", "printing", "processed_for_delivery", "completed", "cancelled"] + """See `OrderStatus` for more details on the status of this order.""" + + to: Contact + """The recipient of this order. + + This will be provided even if you delete the underlying contact. + """ + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + cancellation: Optional[Cancellation] = None + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + imb_date: Optional[datetime] = FieldInfo(alias="imbDate", default=None) + """The last date that the IMB status was updated. + + See `imbStatus` for more details. + """ + + imb_status: Optional[Literal["entered_mail_stream", "out_for_delivery", "returned_to_sender"]] = FieldInfo( + alias="imbStatus", default=None + ) + """The Intelligent Mail Barcode (IMB) status of this order. + + Only populated for US-printed and US-destined orders. This is the most detailed + way to track non-express/certified orders. + """ + + imb_zip_code: Optional[str] = FieldInfo(alias="imbZIPCode", default=None) + """ + The most recent ZIP code of the USPS facility that the order has been processed + through. Only populated when an `imbStatus` is present. + """ + + merge_variables: Optional[Dict[str, builtins.object]] = FieldInfo(alias="mergeVariables", default=None) + """ + These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + """ + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" + + tracking_number: Optional[str] = FieldInfo(alias="trackingNumber", default=None) + """The tracking number of this order. + + Populated after an express/certified order has been processed for delivery. + """ + + url: Optional[str] = None + """PostGrid renders a PDF preview for all orders. + + This should be inspected to ensure that the order is correct before it is sent + out because it shows what will be printed and mailed to the recipient. Once the + PDF preview is generated, this field will be returned by all `GET` endpoints + which produce this order. + + This URL is a signed link to the PDF preview. It will expire after a short + period of time. If you need to access this URL after it has expired, you can + regenerate it by calling the `GET` endpoint again. + """ diff --git a/src/postgrid/types/print_mail/box_progressions_response.py b/src/postgrid/types/print_mail/box_progressions_response.py new file mode 100644 index 0000000..477bc85 --- /dev/null +++ b/src/postgrid/types/print_mail/box_progressions_response.py @@ -0,0 +1,198 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .contact import Contact +from ..._models import BaseModel + +__all__ = ["BoxProgressionsResponse", "Cheque", "Cancellation"] + + +class Cheque(BaseModel): + amount: int + """The amount on the cheque.""" + + bank_account: str = FieldInfo(alias="bankAccount") + """The bank account (ID or reference) from which the cheque amount is drawn.""" + + from_: Contact = FieldInfo(alias="from") + + number: int + """The cheque number.""" + + to: Contact + + logo_url: Optional[str] = FieldInfo(alias="logoURL", default=None) + """A URL to a logo for the cheque (optional).""" + + memo: Optional[str] = None + """The memo text on the cheque (optional).""" + + merge_variables: Optional[Dict[str, object]] = FieldInfo(alias="mergeVariables", default=None) + """ + A set of dynamic merge variables for customizing the cheque or accompanying + documents (optional). + """ + + message_template: Optional[str] = FieldInfo(alias="messageTemplate", default=None) + """An optional message template to be printed on or with the cheque.""" + + +class Cancellation(BaseModel): + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + reason: Literal["user_initiated", "invalid_content", "invalid_order_mailing_class"] + """The reason for the cancellation.""" + + cancelled_by_user: Optional[str] = FieldInfo(alias="cancelledByUser", default=None) + """The user ID who cancelled the order.""" + + note: Optional[str] = None + """An optional note provided by the user who cancelled the order.""" + + +class BoxProgressionsResponse(BaseModel): + id: str + """A unique ID prefixed with box\\__""" + + cheques: List[Cheque] + """The cheques inside this box (in read mode).""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + from_: Contact = FieldInfo(alias="from") + """ + The contact of the 'from' field in read mode should be a fully expanded Contact. + """ + + live: bool + """`true` if this is a live mode resource else `false`.""" + + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] = FieldInfo(alias="mailingClass") + """The mailing class of this order. + + This determines the speed and cost of delivery. See `OrderMailingClass` for more + details. + """ + + object: Literal["box"] + """Always "box".""" + + send_date: datetime = FieldInfo(alias="sendDate") + """This order will transition from `ready` to `printing` on the day after this + date. + + For example, if this is a date on Tuesday, the order will transition to + `printing` on Wednesday at midnight eastern time. + """ + + status: Literal["ready", "printing", "processed_for_delivery", "completed", "cancelled"] + """See `OrderStatus` for more details on the status of this order.""" + + to: Contact + """The recipient of this order. + + This will be provided even if you delete the underlying contact. + """ + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + cancellation: Optional[Cancellation] = None + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + imb_date: Optional[datetime] = FieldInfo(alias="imbDate", default=None) + """The last date that the IMB status was updated. + + See `imbStatus` for more details. + """ + + imb_status: Optional[Literal["entered_mail_stream", "out_for_delivery", "returned_to_sender"]] = FieldInfo( + alias="imbStatus", default=None + ) + """The Intelligent Mail Barcode (IMB) status of this order. + + Only populated for US-printed and US-destined orders. This is the most detailed + way to track non-express/certified orders. + """ + + imb_zip_code: Optional[str] = FieldInfo(alias="imbZIPCode", default=None) + """ + The most recent ZIP code of the USPS facility that the order has been processed + through. Only populated when an `imbStatus` is present. + """ + + merge_variables: Optional[Dict[str, builtins.object]] = FieldInfo(alias="mergeVariables", default=None) + """ + These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + """ + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" + + tracking_number: Optional[str] = FieldInfo(alias="trackingNumber", default=None) + """The tracking number of this order. + + Populated after an express/certified order has been processed for delivery. + """ + + url: Optional[str] = None + """PostGrid renders a PDF preview for all orders. + + This should be inspected to ensure that the order is correct before it is sent + out because it shows what will be printed and mailed to the recipient. Once the + PDF preview is generated, this field will be returned by all `GET` endpoints + which produce this order. + + This URL is a signed link to the PDF preview. It will expire after a short + period of time. If you need to access this URL after it has expired, you can + regenerate it by calling the `GET` endpoint again. + """ diff --git a/src/postgrid/types/print_mail/box_retrieve_response.py b/src/postgrid/types/print_mail/box_retrieve_response.py new file mode 100644 index 0000000..f4cf14e --- /dev/null +++ b/src/postgrid/types/print_mail/box_retrieve_response.py @@ -0,0 +1,198 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .contact import Contact +from ..._models import BaseModel + +__all__ = ["BoxRetrieveResponse", "Cheque", "Cancellation"] + + +class Cheque(BaseModel): + amount: int + """The amount on the cheque.""" + + bank_account: str = FieldInfo(alias="bankAccount") + """The bank account (ID or reference) from which the cheque amount is drawn.""" + + from_: Contact = FieldInfo(alias="from") + + number: int + """The cheque number.""" + + to: Contact + + logo_url: Optional[str] = FieldInfo(alias="logoURL", default=None) + """A URL to a logo for the cheque (optional).""" + + memo: Optional[str] = None + """The memo text on the cheque (optional).""" + + merge_variables: Optional[Dict[str, object]] = FieldInfo(alias="mergeVariables", default=None) + """ + A set of dynamic merge variables for customizing the cheque or accompanying + documents (optional). + """ + + message_template: Optional[str] = FieldInfo(alias="messageTemplate", default=None) + """An optional message template to be printed on or with the cheque.""" + + +class Cancellation(BaseModel): + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + reason: Literal["user_initiated", "invalid_content", "invalid_order_mailing_class"] + """The reason for the cancellation.""" + + cancelled_by_user: Optional[str] = FieldInfo(alias="cancelledByUser", default=None) + """The user ID who cancelled the order.""" + + note: Optional[str] = None + """An optional note provided by the user who cancelled the order.""" + + +class BoxRetrieveResponse(BaseModel): + id: str + """A unique ID prefixed with box\\__""" + + cheques: List[Cheque] + """The cheques inside this box (in read mode).""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + from_: Contact = FieldInfo(alias="from") + """ + The contact of the 'from' field in read mode should be a fully expanded Contact. + """ + + live: bool + """`true` if this is a live mode resource else `false`.""" + + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] = FieldInfo(alias="mailingClass") + """The mailing class of this order. + + This determines the speed and cost of delivery. See `OrderMailingClass` for more + details. + """ + + object: Literal["box"] + """Always "box".""" + + send_date: datetime = FieldInfo(alias="sendDate") + """This order will transition from `ready` to `printing` on the day after this + date. + + For example, if this is a date on Tuesday, the order will transition to + `printing` on Wednesday at midnight eastern time. + """ + + status: Literal["ready", "printing", "processed_for_delivery", "completed", "cancelled"] + """See `OrderStatus` for more details on the status of this order.""" + + to: Contact + """The recipient of this order. + + This will be provided even if you delete the underlying contact. + """ + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + cancellation: Optional[Cancellation] = None + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + imb_date: Optional[datetime] = FieldInfo(alias="imbDate", default=None) + """The last date that the IMB status was updated. + + See `imbStatus` for more details. + """ + + imb_status: Optional[Literal["entered_mail_stream", "out_for_delivery", "returned_to_sender"]] = FieldInfo( + alias="imbStatus", default=None + ) + """The Intelligent Mail Barcode (IMB) status of this order. + + Only populated for US-printed and US-destined orders. This is the most detailed + way to track non-express/certified orders. + """ + + imb_zip_code: Optional[str] = FieldInfo(alias="imbZIPCode", default=None) + """ + The most recent ZIP code of the USPS facility that the order has been processed + through. Only populated when an `imbStatus` is present. + """ + + merge_variables: Optional[Dict[str, builtins.object]] = FieldInfo(alias="mergeVariables", default=None) + """ + These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + """ + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" + + tracking_number: Optional[str] = FieldInfo(alias="trackingNumber", default=None) + """The tracking number of this order. + + Populated after an express/certified order has been processed for delivery. + """ + + url: Optional[str] = None + """PostGrid renders a PDF preview for all orders. + + This should be inspected to ensure that the order is correct before it is sent + out because it shows what will be printed and mailed to the recipient. Once the + PDF preview is generated, this field will be returned by all `GET` endpoints + which produce this order. + + This URL is a signed link to the PDF preview. It will expire after a short + period of time. If you need to access this URL after it has expired, you can + regenerate it by calling the `GET` endpoint again. + """ diff --git a/src/postgrid/types/print_mail/cheque_cancel_params.py b/src/postgrid/types/print_mail/cheque_cancel_params.py new file mode 100644 index 0000000..ced5bf3 --- /dev/null +++ b/src/postgrid/types/print_mail/cheque_cancel_params.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["ChequeCancelParams"] + + +class ChequeCancelParams(TypedDict, total=False): + note: Required[str] diff --git a/src/postgrid/types/print_mail/cheque_create_params.py b/src/postgrid/types/print_mail/cheque_create_params.py index 0bde982..365311c 100644 --- a/src/postgrid/types/print_mail/cheque_create_params.py +++ b/src/postgrid/types/print_mail/cheque_create_params.py @@ -9,8 +9,8 @@ from ..._utils import PropertyInfo from .cheque_size import ChequeSize from .digital_only_param import DigitalOnlyParam -from ..contact_create_with_first_name_param import ContactCreateWithFirstNameParam -from ..contact_create_with_company_name_param import ContactCreateWithCompanyNameParam +from .contact_create_with_first_name_param import ContactCreateWithFirstNameParam +from .contact_create_with_company_name_param import ContactCreateWithCompanyNameParam __all__ = ["ChequeCreateParams", "From", "To", "RedirectTo"] diff --git a/src/postgrid/types/print_mail/contact_create_param.py b/src/postgrid/types/print_mail/contact_create_param.py index 5e7d788..879d16e 100644 --- a/src/postgrid/types/print_mail/contact_create_param.py +++ b/src/postgrid/types/print_mail/contact_create_param.py @@ -5,8 +5,8 @@ from typing import Union from typing_extensions import TypeAlias -from ..contact_create_with_first_name_param import ContactCreateWithFirstNameParam -from ..contact_create_with_company_name_param import ContactCreateWithCompanyNameParam +from .contact_create_with_first_name_param import ContactCreateWithFirstNameParam +from .contact_create_with_company_name_param import ContactCreateWithCompanyNameParam __all__ = ["ContactCreateParam"] diff --git a/src/postgrid/types/contact_create_with_company_name_param.py b/src/postgrid/types/print_mail/contact_create_with_company_name_param.py similarity index 98% rename from src/postgrid/types/contact_create_with_company_name_param.py rename to src/postgrid/types/print_mail/contact_create_with_company_name_param.py index ffd12aa..e3ba4f1 100644 --- a/src/postgrid/types/contact_create_with_company_name_param.py +++ b/src/postgrid/types/print_mail/contact_create_with_company_name_param.py @@ -5,7 +5,7 @@ from typing import Dict from typing_extensions import Required, Annotated, TypedDict -from .._utils import PropertyInfo +from ..._utils import PropertyInfo __all__ = ["ContactCreateWithCompanyNameParam"] diff --git a/src/postgrid/types/contact_create_with_first_name_param.py b/src/postgrid/types/print_mail/contact_create_with_first_name_param.py similarity index 98% rename from src/postgrid/types/contact_create_with_first_name_param.py rename to src/postgrid/types/print_mail/contact_create_with_first_name_param.py index 30f0279..b4e0da9 100644 --- a/src/postgrid/types/contact_create_with_first_name_param.py +++ b/src/postgrid/types/print_mail/contact_create_with_first_name_param.py @@ -5,7 +5,7 @@ from typing import Dict from typing_extensions import Required, Annotated, TypedDict -from .._utils import PropertyInfo +from ..._utils import PropertyInfo __all__ = ["ContactCreateWithFirstNameParam"] diff --git a/src/postgrid/types/print_mail/letter_cancel_params.py b/src/postgrid/types/print_mail/letter_cancel_params.py new file mode 100644 index 0000000..35f9903 --- /dev/null +++ b/src/postgrid/types/print_mail/letter_cancel_params.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["LetterCancelParams"] + + +class LetterCancelParams(TypedDict, total=False): + note: Required[str] diff --git a/src/postgrid/types/print_mail/letter_create_params.py b/src/postgrid/types/print_mail/letter_create_params.py index cce3399..6fc7c27 100644 --- a/src/postgrid/types/print_mail/letter_create_params.py +++ b/src/postgrid/types/print_mail/letter_create_params.py @@ -11,8 +11,8 @@ from .address_placement import AddressPlacement from .attached_pdf_param import AttachedPdfParam from .plastic_card_param import PlasticCardParam -from ..contact_create_with_first_name_param import ContactCreateWithFirstNameParam -from ..contact_create_with_company_name_param import ContactCreateWithCompanyNameParam +from .contact_create_with_first_name_param import ContactCreateWithFirstNameParam +from .contact_create_with_company_name_param import ContactCreateWithCompanyNameParam __all__ = [ "LetterCreateParams", diff --git a/src/postgrid/types/print_mail/postcard_cancel_params.py b/src/postgrid/types/print_mail/postcard_cancel_params.py new file mode 100644 index 0000000..8c81cce --- /dev/null +++ b/src/postgrid/types/print_mail/postcard_cancel_params.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["PostcardCancelParams"] + + +class PostcardCancelParams(TypedDict, total=False): + note: Required[str] diff --git a/src/postgrid/types/print_mail/postcard_create_params.py b/src/postgrid/types/print_mail/postcard_create_params.py index 5323a59..473f147 100644 --- a/src/postgrid/types/print_mail/postcard_create_params.py +++ b/src/postgrid/types/print_mail/postcard_create_params.py @@ -8,8 +8,8 @@ from ..._types import Base64FileInput from ..._utils import PropertyInfo -from ..contact_create_with_first_name_param import ContactCreateWithFirstNameParam -from ..contact_create_with_company_name_param import ContactCreateWithCompanyNameParam +from .contact_create_with_first_name_param import ContactCreateWithFirstNameParam +from .contact_create_with_company_name_param import ContactCreateWithCompanyNameParam __all__ = [ "PostcardCreateParams", diff --git a/src/postgrid/types/print_mail/self_mailer_create_params.py b/src/postgrid/types/print_mail/self_mailer_create_params.py index 3b8ba8c..0bfe3ff 100644 --- a/src/postgrid/types/print_mail/self_mailer_create_params.py +++ b/src/postgrid/types/print_mail/self_mailer_create_params.py @@ -8,8 +8,8 @@ from ..._types import Base64FileInput from ..._utils import PropertyInfo -from ..contact_create_with_first_name_param import ContactCreateWithFirstNameParam -from ..contact_create_with_company_name_param import ContactCreateWithCompanyNameParam +from .contact_create_with_first_name_param import ContactCreateWithFirstNameParam +from .contact_create_with_company_name_param import ContactCreateWithCompanyNameParam __all__ = [ "SelfMailerCreateParams", diff --git a/src/postgrid/types/print_mail/snap_pack_create_params.py b/src/postgrid/types/print_mail/snap_pack_create_params.py new file mode 100644 index 0000000..70fb869 --- /dev/null +++ b/src/postgrid/types/print_mail/snap_pack_create_params.py @@ -0,0 +1,313 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Union +from datetime import datetime +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict + +from ..._utils import PropertyInfo +from .contact_create_with_first_name_param import ContactCreateWithFirstNameParam +from .contact_create_with_company_name_param import ContactCreateWithCompanyNameParam + +__all__ = [ + "SnapPackCreateParams", + "SnapPackCreateWithHTML", + "SnapPackCreateWithHTMLFrom", + "SnapPackCreateWithHTMLTo", + "SnapPackCreateWithTemplate", + "SnapPackCreateWithTemplateFrom", + "SnapPackCreateWithTemplateTo", + "SnapPackCreateWithPdf", + "SnapPackCreateWithPdfFrom", + "SnapPackCreateWithPdfTo", +] + + +class SnapPackCreateWithHTML(TypedDict, total=False): + from_: Required[Annotated[SnapPackCreateWithHTMLFrom, PropertyInfo(alias="from")]] + """The contact information of the sender. + + You can pass contact information inline here just like you can for the `to` + contact. + """ + + inside_html: Required[Annotated[str, PropertyInfo(alias="insideHTML")]] + """The HTML content for the inside of the snap pack. + + You can supply _either_ this or `insideTemplate` but not both. + """ + + outside_html: Required[Annotated[str, PropertyInfo(alias="outsideHTML")]] + """The HTML content for the outside of the snap pack. + + You can supply _either_ this or `outsideTemplate` but not both. + """ + + size: Required[Literal["8.5x11_bifold_v"]] + """Enum representing the supported snap pack sizes.""" + + to: Required[SnapPackCreateWithHTMLTo] + """The recipient of this order. + + You can either supply the contact information inline here or provide a contact + ID. PostGrid will automatically deduplicate contacts regardless of whether you + provide the information inline here or call the contact creation endpoint. + """ + + description: str + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + mailing_class: Annotated[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ], + PropertyInfo(alias="mailingClass"), + ] + """The mailing class of this order. + + If not provided, automatically set to `first_class`. + """ + + merge_variables: Annotated[Dict[str, object], PropertyInfo(alias="mergeVariables")] + """ + These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + """ + + metadata: Dict[str, object] + """See the section on Metadata.""" + + send_date: Annotated[Union[str, datetime], PropertyInfo(alias="sendDate", format="iso8601")] + """This order will transition from `ready` to `printing` on the day after this + date. + + You can use this parameter to schedule orders for a future date. + """ + + +SnapPackCreateWithHTMLFrom: TypeAlias = Union[ContactCreateWithFirstNameParam, ContactCreateWithCompanyNameParam, str] + +SnapPackCreateWithHTMLTo: TypeAlias = Union[ContactCreateWithFirstNameParam, ContactCreateWithCompanyNameParam, str] + + +class SnapPackCreateWithTemplate(TypedDict, total=False): + from_: Required[Annotated[SnapPackCreateWithTemplateFrom, PropertyInfo(alias="from")]] + """The contact information of the sender. + + You can pass contact information inline here just like you can for the `to` + contact. + """ + + inside_template: Required[Annotated[str, PropertyInfo(alias="insideTemplate")]] + """The template ID for the inside of the snap pack. + + You can supply _either_ this or `insideHTML` but not both. + """ + + outside_template: Required[Annotated[str, PropertyInfo(alias="outsideTemplate")]] + """The template ID for the outside of the snap pack. + + You can supply _either_ this or `outsideHTML` but not both. + """ + + size: Required[Literal["8.5x11_bifold_v"]] + """Enum representing the supported snap pack sizes.""" + + to: Required[SnapPackCreateWithTemplateTo] + """The recipient of this order. + + You can either supply the contact information inline here or provide a contact + ID. PostGrid will automatically deduplicate contacts regardless of whether you + provide the information inline here or call the contact creation endpoint. + """ + + description: str + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + mailing_class: Annotated[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ], + PropertyInfo(alias="mailingClass"), + ] + """The mailing class of this order. + + If not provided, automatically set to `first_class`. + """ + + merge_variables: Annotated[Dict[str, object], PropertyInfo(alias="mergeVariables")] + """ + These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + """ + + metadata: Dict[str, object] + """See the section on Metadata.""" + + send_date: Annotated[Union[str, datetime], PropertyInfo(alias="sendDate", format="iso8601")] + """This order will transition from `ready` to `printing` on the day after this + date. + + You can use this parameter to schedule orders for a future date. + """ + + +SnapPackCreateWithTemplateFrom: TypeAlias = Union[ + ContactCreateWithFirstNameParam, ContactCreateWithCompanyNameParam, str +] + +SnapPackCreateWithTemplateTo: TypeAlias = Union[ContactCreateWithFirstNameParam, ContactCreateWithCompanyNameParam, str] + + +class SnapPackCreateWithPdf(TypedDict, total=False): + from_: Required[Annotated[SnapPackCreateWithPdfFrom, PropertyInfo(alias="from")]] + """The contact information of the sender. + + You can pass contact information inline here just like you can for the `to` + contact. + """ + + pdf: Required[str] + """ + A URL or a multipart-uploaded two-page PDF (first page is the outside, second + page is the inside) that matches the selected snap pack size. + """ + + size: Required[Literal["8.5x11_bifold_v"]] + """Enum representing the supported snap pack sizes.""" + + to: Required[SnapPackCreateWithPdfTo] + """The recipient of this order. + + You can either supply the contact information inline here or provide a contact + ID. PostGrid will automatically deduplicate contacts regardless of whether you + provide the information inline here or call the contact creation endpoint. + """ + + description: str + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + mailing_class: Annotated[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ], + PropertyInfo(alias="mailingClass"), + ] + """The mailing class of this order. + + If not provided, automatically set to `first_class`. + """ + + merge_variables: Annotated[Dict[str, object], PropertyInfo(alias="mergeVariables")] + """ + These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + """ + + metadata: Dict[str, object] + """See the section on Metadata.""" + + send_date: Annotated[Union[str, datetime], PropertyInfo(alias="sendDate", format="iso8601")] + """This order will transition from `ready` to `printing` on the day after this + date. + + You can use this parameter to schedule orders for a future date. + """ + + +SnapPackCreateWithPdfFrom: TypeAlias = Union[ContactCreateWithFirstNameParam, ContactCreateWithCompanyNameParam, str] + +SnapPackCreateWithPdfTo: TypeAlias = Union[ContactCreateWithFirstNameParam, ContactCreateWithCompanyNameParam, str] + +SnapPackCreateParams: TypeAlias = Union[SnapPackCreateWithHTML, SnapPackCreateWithTemplate, SnapPackCreateWithPdf] diff --git a/src/postgrid/types/print_mail/snap_pack_create_response.py b/src/postgrid/types/print_mail/snap_pack_create_response.py new file mode 100644 index 0000000..801446c --- /dev/null +++ b/src/postgrid/types/print_mail/snap_pack_create_response.py @@ -0,0 +1,196 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .contact import Contact +from ..._models import BaseModel + +__all__ = ["SnapPackCreateResponse", "Cancellation"] + + +class Cancellation(BaseModel): + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + reason: Literal["user_initiated", "invalid_content", "invalid_order_mailing_class"] + """The reason for the cancellation.""" + + cancelled_by_user: Optional[str] = FieldInfo(alias="cancelledByUser", default=None) + """The user ID who cancelled the order.""" + + note: Optional[str] = None + """An optional note provided by the user who cancelled the order.""" + + +class SnapPackCreateResponse(BaseModel): + id: str + """A unique ID prefixed with snap*pack*""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + from_: Contact = FieldInfo(alias="from") + """The contact information of the sender.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] = FieldInfo(alias="mailingClass") + """The mailing class of this order. + + This determines the speed and cost of delivery. See `OrderMailingClass` for more + details. + """ + + object: Literal["snap_pack"] + """Always `snap_pack`.""" + + send_date: datetime = FieldInfo(alias="sendDate") + """This order will transition from `ready` to `printing` on the day after this + date. + + For example, if this is a date on Tuesday, the order will transition to + `printing` on Wednesday at midnight eastern time. + """ + + size: Literal["8.5x11_bifold_v"] + """Enum representing the supported snap pack sizes.""" + + status: Literal["ready", "printing", "processed_for_delivery", "completed", "cancelled"] + """See `OrderStatus` for more details on the status of this order.""" + + to: Contact + """The recipient of this order. + + This will be provided even if you delete the underlying contact. + """ + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + cancellation: Optional[Cancellation] = None + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + imb_date: Optional[datetime] = FieldInfo(alias="imbDate", default=None) + """The last date that the IMB status was updated. + + See `imbStatus` for more details. + """ + + imb_status: Optional[Literal["entered_mail_stream", "out_for_delivery", "returned_to_sender"]] = FieldInfo( + alias="imbStatus", default=None + ) + """The Intelligent Mail Barcode (IMB) status of this order. + + Only populated for US-printed and US-destined orders. This is the most detailed + way to track non-express/certified orders. + """ + + imb_zip_code: Optional[str] = FieldInfo(alias="imbZIPCode", default=None) + """ + The most recent ZIP code of the USPS facility that the order has been processed + through. Only populated when an `imbStatus` is present. + """ + + inside_html: Optional[str] = FieldInfo(alias="insideHTML", default=None) + """ + The HTML content for the inside of the snap pack, when provided instead of a + template or PDF. + """ + + inside_template: Optional[str] = FieldInfo(alias="insideTemplate", default=None) + """ + The template ID for the inside of the snap pack, when provided instead of HTML + or PDF. + """ + + merge_variables: Optional[Dict[str, builtins.object]] = FieldInfo(alias="mergeVariables", default=None) + """ + These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + """ + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" + + outside_html: Optional[str] = FieldInfo(alias="outsideHTML", default=None) + """ + The HTML content for the outside of the snap pack, when provided instead of a + template or PDF. + """ + + outside_template: Optional[str] = FieldInfo(alias="outsideTemplate", default=None) + """ + The template ID for the outside of the snap pack, when provided instead of HTML + or PDF. + """ + + tracking_number: Optional[str] = FieldInfo(alias="trackingNumber", default=None) + """The tracking number of this order. + + Populated after an express/certified order has been processed for delivery. + """ + + uploaded_pdf: Optional[str] = FieldInfo(alias="uploadedPDF", default=None) + """ + A signed URL to the uploaded PDF provided at creation time, if a PDF was + supplied. + """ + + url: Optional[str] = None + """PostGrid renders a PDF preview for all orders. + + This should be inspected to ensure that the order is correct before it is sent + out because it shows what will be printed and mailed to the recipient. Once the + PDF preview is generated, this field will be returned by all `GET` endpoints + which produce this order. + + This URL is a signed link to the PDF preview. It will expire after a short + period of time. If you need to access this URL after it has expired, you can + regenerate it by calling the `GET` endpoint again. + """ diff --git a/src/postgrid/types/print_mail/snap_pack_delete_response.py b/src/postgrid/types/print_mail/snap_pack_delete_response.py new file mode 100644 index 0000000..87b05fd --- /dev/null +++ b/src/postgrid/types/print_mail/snap_pack_delete_response.py @@ -0,0 +1,196 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .contact import Contact +from ..._models import BaseModel + +__all__ = ["SnapPackDeleteResponse", "Cancellation"] + + +class Cancellation(BaseModel): + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + reason: Literal["user_initiated", "invalid_content", "invalid_order_mailing_class"] + """The reason for the cancellation.""" + + cancelled_by_user: Optional[str] = FieldInfo(alias="cancelledByUser", default=None) + """The user ID who cancelled the order.""" + + note: Optional[str] = None + """An optional note provided by the user who cancelled the order.""" + + +class SnapPackDeleteResponse(BaseModel): + id: str + """A unique ID prefixed with snap*pack*""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + from_: Contact = FieldInfo(alias="from") + """The contact information of the sender.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] = FieldInfo(alias="mailingClass") + """The mailing class of this order. + + This determines the speed and cost of delivery. See `OrderMailingClass` for more + details. + """ + + object: Literal["snap_pack"] + """Always `snap_pack`.""" + + send_date: datetime = FieldInfo(alias="sendDate") + """This order will transition from `ready` to `printing` on the day after this + date. + + For example, if this is a date on Tuesday, the order will transition to + `printing` on Wednesday at midnight eastern time. + """ + + size: Literal["8.5x11_bifold_v"] + """Enum representing the supported snap pack sizes.""" + + status: Literal["ready", "printing", "processed_for_delivery", "completed", "cancelled"] + """See `OrderStatus` for more details on the status of this order.""" + + to: Contact + """The recipient of this order. + + This will be provided even if you delete the underlying contact. + """ + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + cancellation: Optional[Cancellation] = None + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + imb_date: Optional[datetime] = FieldInfo(alias="imbDate", default=None) + """The last date that the IMB status was updated. + + See `imbStatus` for more details. + """ + + imb_status: Optional[Literal["entered_mail_stream", "out_for_delivery", "returned_to_sender"]] = FieldInfo( + alias="imbStatus", default=None + ) + """The Intelligent Mail Barcode (IMB) status of this order. + + Only populated for US-printed and US-destined orders. This is the most detailed + way to track non-express/certified orders. + """ + + imb_zip_code: Optional[str] = FieldInfo(alias="imbZIPCode", default=None) + """ + The most recent ZIP code of the USPS facility that the order has been processed + through. Only populated when an `imbStatus` is present. + """ + + inside_html: Optional[str] = FieldInfo(alias="insideHTML", default=None) + """ + The HTML content for the inside of the snap pack, when provided instead of a + template or PDF. + """ + + inside_template: Optional[str] = FieldInfo(alias="insideTemplate", default=None) + """ + The template ID for the inside of the snap pack, when provided instead of HTML + or PDF. + """ + + merge_variables: Optional[Dict[str, builtins.object]] = FieldInfo(alias="mergeVariables", default=None) + """ + These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + """ + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" + + outside_html: Optional[str] = FieldInfo(alias="outsideHTML", default=None) + """ + The HTML content for the outside of the snap pack, when provided instead of a + template or PDF. + """ + + outside_template: Optional[str] = FieldInfo(alias="outsideTemplate", default=None) + """ + The template ID for the outside of the snap pack, when provided instead of HTML + or PDF. + """ + + tracking_number: Optional[str] = FieldInfo(alias="trackingNumber", default=None) + """The tracking number of this order. + + Populated after an express/certified order has been processed for delivery. + """ + + uploaded_pdf: Optional[str] = FieldInfo(alias="uploadedPDF", default=None) + """ + A signed URL to the uploaded PDF provided at creation time, if a PDF was + supplied. + """ + + url: Optional[str] = None + """PostGrid renders a PDF preview for all orders. + + This should be inspected to ensure that the order is correct before it is sent + out because it shows what will be printed and mailed to the recipient. Once the + PDF preview is generated, this field will be returned by all `GET` endpoints + which produce this order. + + This URL is a signed link to the PDF preview. It will expire after a short + period of time. If you need to access this URL after it has expired, you can + regenerate it by calling the `GET` endpoint again. + """ diff --git a/src/postgrid/types/print_mail/snap_pack_list_params.py b/src/postgrid/types/print_mail/snap_pack_list_params.py new file mode 100644 index 0000000..0ff0eab --- /dev/null +++ b/src/postgrid/types/print_mail/snap_pack_list_params.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["SnapPackListParams"] + + +class SnapPackListParams(TypedDict, total=False): + limit: int + + search: str + """You can supply any string to help narrow down the list of resources. + + For example, if you pass `"New York"` (quoted), it will return resources that + have that string present somewhere in their response. Alternatively, you can + supply a structured search query. See the documentation on + `StructuredSearchQuery` for more details. + """ + + skip: int diff --git a/src/postgrid/types/print_mail/snap_pack_list_response.py b/src/postgrid/types/print_mail/snap_pack_list_response.py new file mode 100644 index 0000000..80e17b6 --- /dev/null +++ b/src/postgrid/types/print_mail/snap_pack_list_response.py @@ -0,0 +1,196 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .contact import Contact +from ..._models import BaseModel + +__all__ = ["SnapPackListResponse", "Cancellation"] + + +class Cancellation(BaseModel): + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + reason: Literal["user_initiated", "invalid_content", "invalid_order_mailing_class"] + """The reason for the cancellation.""" + + cancelled_by_user: Optional[str] = FieldInfo(alias="cancelledByUser", default=None) + """The user ID who cancelled the order.""" + + note: Optional[str] = None + """An optional note provided by the user who cancelled the order.""" + + +class SnapPackListResponse(BaseModel): + id: str + """A unique ID prefixed with snap*pack*""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + from_: Contact = FieldInfo(alias="from") + """The contact information of the sender.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] = FieldInfo(alias="mailingClass") + """The mailing class of this order. + + This determines the speed and cost of delivery. See `OrderMailingClass` for more + details. + """ + + object: Literal["snap_pack"] + """Always `snap_pack`.""" + + send_date: datetime = FieldInfo(alias="sendDate") + """This order will transition from `ready` to `printing` on the day after this + date. + + For example, if this is a date on Tuesday, the order will transition to + `printing` on Wednesday at midnight eastern time. + """ + + size: Literal["8.5x11_bifold_v"] + """Enum representing the supported snap pack sizes.""" + + status: Literal["ready", "printing", "processed_for_delivery", "completed", "cancelled"] + """See `OrderStatus` for more details on the status of this order.""" + + to: Contact + """The recipient of this order. + + This will be provided even if you delete the underlying contact. + """ + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + cancellation: Optional[Cancellation] = None + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + imb_date: Optional[datetime] = FieldInfo(alias="imbDate", default=None) + """The last date that the IMB status was updated. + + See `imbStatus` for more details. + """ + + imb_status: Optional[Literal["entered_mail_stream", "out_for_delivery", "returned_to_sender"]] = FieldInfo( + alias="imbStatus", default=None + ) + """The Intelligent Mail Barcode (IMB) status of this order. + + Only populated for US-printed and US-destined orders. This is the most detailed + way to track non-express/certified orders. + """ + + imb_zip_code: Optional[str] = FieldInfo(alias="imbZIPCode", default=None) + """ + The most recent ZIP code of the USPS facility that the order has been processed + through. Only populated when an `imbStatus` is present. + """ + + inside_html: Optional[str] = FieldInfo(alias="insideHTML", default=None) + """ + The HTML content for the inside of the snap pack, when provided instead of a + template or PDF. + """ + + inside_template: Optional[str] = FieldInfo(alias="insideTemplate", default=None) + """ + The template ID for the inside of the snap pack, when provided instead of HTML + or PDF. + """ + + merge_variables: Optional[Dict[str, builtins.object]] = FieldInfo(alias="mergeVariables", default=None) + """ + These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + """ + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" + + outside_html: Optional[str] = FieldInfo(alias="outsideHTML", default=None) + """ + The HTML content for the outside of the snap pack, when provided instead of a + template or PDF. + """ + + outside_template: Optional[str] = FieldInfo(alias="outsideTemplate", default=None) + """ + The template ID for the outside of the snap pack, when provided instead of HTML + or PDF. + """ + + tracking_number: Optional[str] = FieldInfo(alias="trackingNumber", default=None) + """The tracking number of this order. + + Populated after an express/certified order has been processed for delivery. + """ + + uploaded_pdf: Optional[str] = FieldInfo(alias="uploadedPDF", default=None) + """ + A signed URL to the uploaded PDF provided at creation time, if a PDF was + supplied. + """ + + url: Optional[str] = None + """PostGrid renders a PDF preview for all orders. + + This should be inspected to ensure that the order is correct before it is sent + out because it shows what will be printed and mailed to the recipient. Once the + PDF preview is generated, this field will be returned by all `GET` endpoints + which produce this order. + + This URL is a signed link to the PDF preview. It will expire after a short + period of time. If you need to access this URL after it has expired, you can + regenerate it by calling the `GET` endpoint again. + """ diff --git a/src/postgrid/types/print_mail/snap_pack_progressions_response.py b/src/postgrid/types/print_mail/snap_pack_progressions_response.py new file mode 100644 index 0000000..10b5434 --- /dev/null +++ b/src/postgrid/types/print_mail/snap_pack_progressions_response.py @@ -0,0 +1,196 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .contact import Contact +from ..._models import BaseModel + +__all__ = ["SnapPackProgressionsResponse", "Cancellation"] + + +class Cancellation(BaseModel): + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + reason: Literal["user_initiated", "invalid_content", "invalid_order_mailing_class"] + """The reason for the cancellation.""" + + cancelled_by_user: Optional[str] = FieldInfo(alias="cancelledByUser", default=None) + """The user ID who cancelled the order.""" + + note: Optional[str] = None + """An optional note provided by the user who cancelled the order.""" + + +class SnapPackProgressionsResponse(BaseModel): + id: str + """A unique ID prefixed with snap*pack*""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + from_: Contact = FieldInfo(alias="from") + """The contact information of the sender.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] = FieldInfo(alias="mailingClass") + """The mailing class of this order. + + This determines the speed and cost of delivery. See `OrderMailingClass` for more + details. + """ + + object: Literal["snap_pack"] + """Always `snap_pack`.""" + + send_date: datetime = FieldInfo(alias="sendDate") + """This order will transition from `ready` to `printing` on the day after this + date. + + For example, if this is a date on Tuesday, the order will transition to + `printing` on Wednesday at midnight eastern time. + """ + + size: Literal["8.5x11_bifold_v"] + """Enum representing the supported snap pack sizes.""" + + status: Literal["ready", "printing", "processed_for_delivery", "completed", "cancelled"] + """See `OrderStatus` for more details on the status of this order.""" + + to: Contact + """The recipient of this order. + + This will be provided even if you delete the underlying contact. + """ + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + cancellation: Optional[Cancellation] = None + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + imb_date: Optional[datetime] = FieldInfo(alias="imbDate", default=None) + """The last date that the IMB status was updated. + + See `imbStatus` for more details. + """ + + imb_status: Optional[Literal["entered_mail_stream", "out_for_delivery", "returned_to_sender"]] = FieldInfo( + alias="imbStatus", default=None + ) + """The Intelligent Mail Barcode (IMB) status of this order. + + Only populated for US-printed and US-destined orders. This is the most detailed + way to track non-express/certified orders. + """ + + imb_zip_code: Optional[str] = FieldInfo(alias="imbZIPCode", default=None) + """ + The most recent ZIP code of the USPS facility that the order has been processed + through. Only populated when an `imbStatus` is present. + """ + + inside_html: Optional[str] = FieldInfo(alias="insideHTML", default=None) + """ + The HTML content for the inside of the snap pack, when provided instead of a + template or PDF. + """ + + inside_template: Optional[str] = FieldInfo(alias="insideTemplate", default=None) + """ + The template ID for the inside of the snap pack, when provided instead of HTML + or PDF. + """ + + merge_variables: Optional[Dict[str, builtins.object]] = FieldInfo(alias="mergeVariables", default=None) + """ + These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + """ + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" + + outside_html: Optional[str] = FieldInfo(alias="outsideHTML", default=None) + """ + The HTML content for the outside of the snap pack, when provided instead of a + template or PDF. + """ + + outside_template: Optional[str] = FieldInfo(alias="outsideTemplate", default=None) + """ + The template ID for the outside of the snap pack, when provided instead of HTML + or PDF. + """ + + tracking_number: Optional[str] = FieldInfo(alias="trackingNumber", default=None) + """The tracking number of this order. + + Populated after an express/certified order has been processed for delivery. + """ + + uploaded_pdf: Optional[str] = FieldInfo(alias="uploadedPDF", default=None) + """ + A signed URL to the uploaded PDF provided at creation time, if a PDF was + supplied. + """ + + url: Optional[str] = None + """PostGrid renders a PDF preview for all orders. + + This should be inspected to ensure that the order is correct before it is sent + out because it shows what will be printed and mailed to the recipient. Once the + PDF preview is generated, this field will be returned by all `GET` endpoints + which produce this order. + + This URL is a signed link to the PDF preview. It will expire after a short + period of time. If you need to access this URL after it has expired, you can + regenerate it by calling the `GET` endpoint again. + """ diff --git a/src/postgrid/types/print_mail/snap_pack_retrieve_capabilities_params.py b/src/postgrid/types/print_mail/snap_pack_retrieve_capabilities_params.py new file mode 100644 index 0000000..476169a --- /dev/null +++ b/src/postgrid/types/print_mail/snap_pack_retrieve_capabilities_params.py @@ -0,0 +1,26 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, Annotated, TypedDict + +from ..._utils import PropertyInfo + +__all__ = ["SnapPackRetrieveCapabilitiesParams"] + + +class SnapPackRetrieveCapabilitiesParams(TypedDict, total=False): + return_country_code: Required[Annotated[str, PropertyInfo(alias="returnCountryCode")]] + """The country code where mail may be returned to.""" + + destination_country_code: Annotated[str, PropertyInfo(alias="destinationCountryCode")] + """ + The country code of where the snap pack will be sent to. One of `mailingList` or + `destinationCountryCode` must be supplied but not both. + """ + + mailing_list: Annotated[str, PropertyInfo(alias="mailingList")] + """ + Sources destination countries from the provided mailing list. One of + `mailingList` or `destinationCountryCode` must be supplied but not both. + """ diff --git a/src/postgrid/types/print_mail/snap_pack_retrieve_capabilities_response.py b/src/postgrid/types/print_mail/snap_pack_retrieve_capabilities_response.py new file mode 100644 index 0000000..1b10d4b --- /dev/null +++ b/src/postgrid/types/print_mail/snap_pack_retrieve_capabilities_response.py @@ -0,0 +1,45 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = ["SnapPackRetrieveCapabilitiesResponse"] + + +class SnapPackRetrieveCapabilitiesResponse(BaseModel): + mailing_classes: List[ + Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] + ] = FieldInfo(alias="mailingClasses") + + sizes: List[Literal["8.5x11_bifold_v"]] diff --git a/src/postgrid/types/print_mail/snap_pack_retrieve_response.py b/src/postgrid/types/print_mail/snap_pack_retrieve_response.py new file mode 100644 index 0000000..49dd283 --- /dev/null +++ b/src/postgrid/types/print_mail/snap_pack_retrieve_response.py @@ -0,0 +1,196 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .contact import Contact +from ..._models import BaseModel + +__all__ = ["SnapPackRetrieveResponse", "Cancellation"] + + +class Cancellation(BaseModel): + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + reason: Literal["user_initiated", "invalid_content", "invalid_order_mailing_class"] + """The reason for the cancellation.""" + + cancelled_by_user: Optional[str] = FieldInfo(alias="cancelledByUser", default=None) + """The user ID who cancelled the order.""" + + note: Optional[str] = None + """An optional note provided by the user who cancelled the order.""" + + +class SnapPackRetrieveResponse(BaseModel): + id: str + """A unique ID prefixed with snap*pack*""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + from_: Contact = FieldInfo(alias="from") + """The contact information of the sender.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + mailing_class: Literal[ + "first_class", + "standard_class", + "express", + "certified", + "certified_return_receipt", + "registered", + "usps_first_class", + "usps_standard_class", + "usps_eddm", + "usps_express_2_day", + "usps_express_3_day", + "usps_first_class_certified", + "usps_first_class_certified_return_receipt", + "usps_first_class_registered", + "usps_express_3_day_signature_confirmation", + "usps_express_3_day_certified", + "usps_express_3_day_certified_return_receipt", + "ca_post_lettermail", + "ca_post_personalized", + "ca_post_neighbourhood_mail", + "ups_express_overnight", + "ups_express_2_day", + "ups_express_3_day", + "royal_mail_first_class", + "royal_mail_second_class", + "au_post_second_class", + ] = FieldInfo(alias="mailingClass") + """The mailing class of this order. + + This determines the speed and cost of delivery. See `OrderMailingClass` for more + details. + """ + + object: Literal["snap_pack"] + """Always `snap_pack`.""" + + send_date: datetime = FieldInfo(alias="sendDate") + """This order will transition from `ready` to `printing` on the day after this + date. + + For example, if this is a date on Tuesday, the order will transition to + `printing` on Wednesday at midnight eastern time. + """ + + size: Literal["8.5x11_bifold_v"] + """Enum representing the supported snap pack sizes.""" + + status: Literal["ready", "printing", "processed_for_delivery", "completed", "cancelled"] + """See `OrderStatus` for more details on the status of this order.""" + + to: Contact + """The recipient of this order. + + This will be provided even if you delete the underlying contact. + """ + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + cancellation: Optional[Cancellation] = None + """The cancellation details of this order. + + Populated if the order has been cancelled. + """ + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + imb_date: Optional[datetime] = FieldInfo(alias="imbDate", default=None) + """The last date that the IMB status was updated. + + See `imbStatus` for more details. + """ + + imb_status: Optional[Literal["entered_mail_stream", "out_for_delivery", "returned_to_sender"]] = FieldInfo( + alias="imbStatus", default=None + ) + """The Intelligent Mail Barcode (IMB) status of this order. + + Only populated for US-printed and US-destined orders. This is the most detailed + way to track non-express/certified orders. + """ + + imb_zip_code: Optional[str] = FieldInfo(alias="imbZIPCode", default=None) + """ + The most recent ZIP code of the USPS facility that the order has been processed + through. Only populated when an `imbStatus` is present. + """ + + inside_html: Optional[str] = FieldInfo(alias="insideHTML", default=None) + """ + The HTML content for the inside of the snap pack, when provided instead of a + template or PDF. + """ + + inside_template: Optional[str] = FieldInfo(alias="insideTemplate", default=None) + """ + The template ID for the inside of the snap pack, when provided instead of HTML + or PDF. + """ + + merge_variables: Optional[Dict[str, builtins.object]] = FieldInfo(alias="mergeVariables", default=None) + """ + These will be merged with the variables in the template or HTML you create this + order with. The keys in this object should match the variable names in the + template _exactly_ as they are case-sensitive. Note that these _do not_ apply to + PDFs uploaded with the order. + """ + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" + + outside_html: Optional[str] = FieldInfo(alias="outsideHTML", default=None) + """ + The HTML content for the outside of the snap pack, when provided instead of a + template or PDF. + """ + + outside_template: Optional[str] = FieldInfo(alias="outsideTemplate", default=None) + """ + The template ID for the outside of the snap pack, when provided instead of HTML + or PDF. + """ + + tracking_number: Optional[str] = FieldInfo(alias="trackingNumber", default=None) + """The tracking number of this order. + + Populated after an express/certified order has been processed for delivery. + """ + + uploaded_pdf: Optional[str] = FieldInfo(alias="uploadedPDF", default=None) + """ + A signed URL to the uploaded PDF provided at creation time, if a PDF was + supplied. + """ + + url: Optional[str] = None + """PostGrid renders a PDF preview for all orders. + + This should be inspected to ensure that the order is correct before it is sent + out because it shows what will be printed and mailed to the recipient. Once the + PDF preview is generated, this field will be returned by all `GET` endpoints + which produce this order. + + This URL is a signed link to the PDF preview. It will expire after a short + period of time. If you need to access this URL after it has expired, you can + regenerate it by calling the `GET` endpoint again. + """ diff --git a/src/postgrid/types/print_mail/targeted_list_build_confirm_response.py b/src/postgrid/types/print_mail/targeted_list_build_confirm_response.py new file mode 100644 index 0000000..4a3deb4 --- /dev/null +++ b/src/postgrid/types/print_mail/targeted_list_build_confirm_response.py @@ -0,0 +1,277 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = [ + "TargetedListBuildConfirmResponse", + "Error", + "PreviewRecord", + "Quote", + "UsCompanies", + "UsConsumers", + "UsConsumersZipCodesAround", +] + + +class Error(BaseModel): + """Details of an error encountered while processing a targeted list build.""" + + message: str + """A human-readable message describing the error.""" + + type: Literal["not_enough_info_to_quote", "insufficient_credits", "internal_service_error"] + """Type of error encountered while generating a quote or building the list.""" + + +class PreviewRecord(BaseModel): + """ + A single masked preview record returned with a quote so you can sanity + check the kind of contacts that will end up in the mailing list before + confirming the build. + """ + + formatted_address: str = FieldInfo(alias="formattedAddress") + """The masked, comma-joined formatted address of the contact.""" + + name: str + """The masked name of the contact or business.""" + + +class Quote(BaseModel): + """Details of the quote generated for a targeted list build.""" + + count: int + """The number of contacts that will be included in the built mailing list. + + This accounts for any `limit` that was provided. + """ + + generated_at: datetime = FieldInfo(alias="generatedAt") + """The UTC time at which the quote was generated.""" + + price_per_contact_cents: float = FieldInfo(alias="pricePerContactCents") + """The price per contact, in cents. + + Multiply by `count` to get the total cost of building the list. + """ + + +class UsCompanies(BaseModel): + """Filters used to target US companies (B2B) when building a list.""" + + postal_codes: List[str] = FieldInfo(alias="postalCodes") + """Required list of five-digit US ZIP codes to target.""" + + company_types: Optional[ + List[Literal["public", "private", "educational", "government", "nonprofit", "public_subsidiary"]] + ] = FieldInfo(alias="companyTypes", default=None) + """Filter by ownership structure of the company.""" + + employee_count: Optional[List[int]] = FieldInfo(alias="employeeCount", default=None) + """Inclusive `[min, max]` range for the number of employees at the company. + + Values must be between 1 and 1,000,000. + """ + + founded_year: Optional[List[int]] = FieldInfo(alias="foundedYear", default=None) + """ + Inclusive `[min, max]` range for the year the company was founded. Values must + be between 1600 and 2100. + """ + + industries: Optional[List[str]] = None + """Filter by free-form industry names (see the autocomplete endpoint).""" + + naics_codes: Optional[List[str]] = FieldInfo(alias="naicsCodes", default=None) + """Filter by six-digit [NAICS](https://www.census.gov/naics/) industry codes.""" + + tags: Optional[List[str]] = None + """Filter by free-form company tags (e.g., `"saas"`, `"b2b"`).""" + + +class UsConsumersZipCodesAround(BaseModel): + """ + A geographic filter that selects all ZIP codes within a given radius of a + center ZIP code. + """ + + radius_in_miles: float = FieldInfo(alias="radiusInMiles") + """The radius in miles around `zipCode` to include. Between 0.1 and 100.""" + + zip_code: str = FieldInfo(alias="zipCode") + """The five-digit ZIP code at the center of the search circle.""" + + +class UsConsumers(BaseModel): + """Filters used to target US consumers (B2C) when building a list. + + The geographic filters (`zipCodesAround`, `cityStates`, `zipCodes`) are + mutually exclusive — you may supply at most one of them. + """ + + age_range: Optional[List[int]] = FieldInfo(alias="ageRange", default=None) + """Inclusive `[min, max]` age range. Values must be between 18 and 80.""" + + city_states: Optional[List[str]] = FieldInfo(alias="cityStates", default=None) + """A list of `"City, ST"` strings (e.g. `"New York, NY"`) to target.""" + + education_levels: Optional[List[Literal["high_school", "college", "grad_school", "vocational_training"]]] = ( + FieldInfo(alias="educationLevels", default=None) + ) + """Filter by highest level of education completed.""" + + gender: Optional[Literal["male", "female"]] = None + """Gender filter for US consumer list builds.""" + + home_value_range: Optional[List[int]] = FieldInfo(alias="homeValueRange", default=None) + """Inclusive `[min, max]` home value range, in US dollars. + + Values must be between 0 and 1,000,000. + """ + + income_range: Optional[List[int]] = FieldInfo(alias="incomeRange", default=None) + """ + Inclusive `[min, max]` annual household income range, in US dollars. Values must + be between 0 and 200,000. + """ + + num_children_range: Optional[List[int]] = FieldInfo(alias="numChildrenRange", default=None) + """Inclusive `[min, max]` number of children in the household. + + Values must be between 0 and 8. + """ + + occupations: Optional[ + List[ + Literal[ + "professional_technical", + "administration_management", + "sales_service", + "clerical_white_collar", + "craftsmen_blue_collar", + "student", + "homemaker", + "retired", + "farmer", + "military", + "religious", + "self_employed", + "self_employed_professional_technical", + "self_employed_administration_management", + "self_employed_sales_service", + "self_employed_clerical_white_collar", + "self_employed_craftsmen_blue_collar", + "self_employed_student", + "self_employed_homemaker", + "self_employed_retired", + "self_employed_other", + "educator", + "financial_professional", + "legal_professional", + "medical_professional", + "other", + ] + ] + ] = None + """Filter by occupation classification.""" + + zip_codes: Optional[List[str]] = FieldInfo(alias="zipCodes", default=None) + """A list of five-digit US ZIP codes to target.""" + + zip_codes_around: Optional[UsConsumersZipCodesAround] = FieldInfo(alias="zipCodesAround", default=None) + """ + A geographic filter that selects all ZIP codes within a given radius of a center + ZIP code. + """ + + +class TargetedListBuildConfirmResponse(BaseModel): + """ + A targeted list build represents a request to build a new mailing list by + targeting US consumers or companies matching the provided filters. Once + created, a quote is generated asynchronously. After reviewing the quote + and preview records, you may confirm the build, which kicks off the + creation of the underlying mailing list. + """ + + id: str + """A unique ID prefixed with targeted*list_build*""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + organization: str + """The ID of the organization that owns this list build.""" + + status: Literal["generating_quote", "quote_ready", "creating_list", "completed", "failed"] + """Status of a targeted list build.""" + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + build_progress_percent: Optional[float] = FieldInfo(alias="buildProgressPercent", default=None) + """A percentage from 0 to 100 representing how much of the build has completed. + + Only populated while `status` is `creating_list`. + """ + + completed_at: Optional[datetime] = FieldInfo(alias="completedAt", default=None) + """The UTC time at which the build finished successfully. + + Only present once `status` is `completed`. + """ + + confirmed_at: Optional[datetime] = FieldInfo(alias="confirmedAt", default=None) + """The UTC time at which the build was confirmed, if any.""" + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + errors: Optional[List[Error]] = None + """Any errors encountered while generating a quote or building the list.""" + + limit: Optional[int] = None + """Maximum number of contacts to include in the built mailing list. + + If omitted, all matching contacts are included. + """ + + mailing_list: Optional[str] = FieldInfo(alias="mailingList", default=None) + """The ID of the mailing list that was built. + + Present once `status` is `completed`. + """ + + metadata: Optional[Dict[str, object]] = None + """See the section on Metadata.""" + + preview_records: Optional[List[PreviewRecord]] = FieldInfo(alias="previewRecords", default=None) + """ + A small number of masked sample records for the configured filters, populated + alongside `quote`. + """ + + quote: Optional[Quote] = None + """Details of the quote generated for a targeted list build.""" + + us_companies: Optional[UsCompanies] = FieldInfo(alias="usCompanies", default=None) + """Filters used to target US companies (B2B) when building a list.""" + + us_consumers: Optional[UsConsumers] = FieldInfo(alias="usConsumers", default=None) + """Filters used to target US consumers (B2C) when building a list. + + The geographic filters (`zipCodesAround`, `cityStates`, `zipCodes`) are mutually + exclusive — you may supply at most one of them. + """ diff --git a/src/postgrid/types/print_mail/targeted_list_build_create_params.py b/src/postgrid/types/print_mail/targeted_list_build_create_params.py new file mode 100644 index 0000000..0e462a5 --- /dev/null +++ b/src/postgrid/types/print_mail/targeted_list_build_create_params.py @@ -0,0 +1,169 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, List, Iterable +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ..._types import SequenceNotStr +from ..._utils import PropertyInfo + +__all__ = ["TargetedListBuildCreateParams", "UsCompanies", "UsConsumers", "UsConsumersZipCodesAround"] + + +class TargetedListBuildCreateParams(TypedDict, total=False): + description: str + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + limit: int + """Maximum number of contacts to include in the built mailing list. + + If omitted, all matching contacts are included. + """ + + metadata: Dict[str, object] + """See the section on Metadata.""" + + us_companies: Annotated[UsCompanies, PropertyInfo(alias="usCompanies")] + """Filters used to target US companies (B2B) when building a list.""" + + us_consumers: Annotated[UsConsumers, PropertyInfo(alias="usConsumers")] + """Filters used to target US consumers (B2C) when building a list. + + The geographic filters (`zipCodesAround`, `cityStates`, `zipCodes`) are mutually + exclusive — you may supply at most one of them. + """ + + idempotency_key: Annotated[str, PropertyInfo(alias="idempotency-key")] + + +class UsCompanies(TypedDict, total=False): + """Filters used to target US companies (B2B) when building a list.""" + + postal_codes: Required[Annotated[SequenceNotStr[str], PropertyInfo(alias="postalCodes")]] + """Required list of five-digit US ZIP codes to target.""" + + company_types: Annotated[ + List[Literal["public", "private", "educational", "government", "nonprofit", "public_subsidiary"]], + PropertyInfo(alias="companyTypes"), + ] + """Filter by ownership structure of the company.""" + + employee_count: Annotated[Iterable[int], PropertyInfo(alias="employeeCount")] + """Inclusive `[min, max]` range for the number of employees at the company. + + Values must be between 1 and 1,000,000. + """ + + founded_year: Annotated[Iterable[int], PropertyInfo(alias="foundedYear")] + """ + Inclusive `[min, max]` range for the year the company was founded. Values must + be between 1600 and 2100. + """ + + industries: SequenceNotStr[str] + """Filter by free-form industry names (see the autocomplete endpoint).""" + + naics_codes: Annotated[SequenceNotStr[str], PropertyInfo(alias="naicsCodes")] + """Filter by six-digit [NAICS](https://www.census.gov/naics/) industry codes.""" + + tags: SequenceNotStr[str] + """Filter by free-form company tags (e.g., `"saas"`, `"b2b"`).""" + + +class UsConsumersZipCodesAround(TypedDict, total=False): + """ + A geographic filter that selects all ZIP codes within a given radius of a + center ZIP code. + """ + + radius_in_miles: Required[Annotated[float, PropertyInfo(alias="radiusInMiles")]] + """The radius in miles around `zipCode` to include. Between 0.1 and 100.""" + + zip_code: Required[Annotated[str, PropertyInfo(alias="zipCode")]] + """The five-digit ZIP code at the center of the search circle.""" + + +class UsConsumers(TypedDict, total=False): + """Filters used to target US consumers (B2C) when building a list. + + The geographic filters (`zipCodesAround`, `cityStates`, `zipCodes`) are + mutually exclusive — you may supply at most one of them. + """ + + age_range: Annotated[Iterable[int], PropertyInfo(alias="ageRange")] + """Inclusive `[min, max]` age range. Values must be between 18 and 80.""" + + city_states: Annotated[SequenceNotStr[str], PropertyInfo(alias="cityStates")] + """A list of `"City, ST"` strings (e.g. `"New York, NY"`) to target.""" + + education_levels: Annotated[ + List[Literal["high_school", "college", "grad_school", "vocational_training"]], + PropertyInfo(alias="educationLevels"), + ] + """Filter by highest level of education completed.""" + + gender: Literal["male", "female"] + """Gender filter for US consumer list builds.""" + + home_value_range: Annotated[Iterable[int], PropertyInfo(alias="homeValueRange")] + """Inclusive `[min, max]` home value range, in US dollars. + + Values must be between 0 and 1,000,000. + """ + + income_range: Annotated[Iterable[int], PropertyInfo(alias="incomeRange")] + """ + Inclusive `[min, max]` annual household income range, in US dollars. Values must + be between 0 and 200,000. + """ + + num_children_range: Annotated[Iterable[int], PropertyInfo(alias="numChildrenRange")] + """Inclusive `[min, max]` number of children in the household. + + Values must be between 0 and 8. + """ + + occupations: List[ + Literal[ + "professional_technical", + "administration_management", + "sales_service", + "clerical_white_collar", + "craftsmen_blue_collar", + "student", + "homemaker", + "retired", + "farmer", + "military", + "religious", + "self_employed", + "self_employed_professional_technical", + "self_employed_administration_management", + "self_employed_sales_service", + "self_employed_clerical_white_collar", + "self_employed_craftsmen_blue_collar", + "self_employed_student", + "self_employed_homemaker", + "self_employed_retired", + "self_employed_other", + "educator", + "financial_professional", + "legal_professional", + "medical_professional", + "other", + ] + ] + """Filter by occupation classification.""" + + zip_codes: Annotated[SequenceNotStr[str], PropertyInfo(alias="zipCodes")] + """A list of five-digit US ZIP codes to target.""" + + zip_codes_around: Annotated[UsConsumersZipCodesAround, PropertyInfo(alias="zipCodesAround")] + """ + A geographic filter that selects all ZIP codes within a given radius of a center + ZIP code. + """ diff --git a/src/postgrid/types/print_mail/targeted_list_build_create_response.py b/src/postgrid/types/print_mail/targeted_list_build_create_response.py new file mode 100644 index 0000000..3a4f2d4 --- /dev/null +++ b/src/postgrid/types/print_mail/targeted_list_build_create_response.py @@ -0,0 +1,277 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = [ + "TargetedListBuildCreateResponse", + "Error", + "PreviewRecord", + "Quote", + "UsCompanies", + "UsConsumers", + "UsConsumersZipCodesAround", +] + + +class Error(BaseModel): + """Details of an error encountered while processing a targeted list build.""" + + message: str + """A human-readable message describing the error.""" + + type: Literal["not_enough_info_to_quote", "insufficient_credits", "internal_service_error"] + """Type of error encountered while generating a quote or building the list.""" + + +class PreviewRecord(BaseModel): + """ + A single masked preview record returned with a quote so you can sanity + check the kind of contacts that will end up in the mailing list before + confirming the build. + """ + + formatted_address: str = FieldInfo(alias="formattedAddress") + """The masked, comma-joined formatted address of the contact.""" + + name: str + """The masked name of the contact or business.""" + + +class Quote(BaseModel): + """Details of the quote generated for a targeted list build.""" + + count: int + """The number of contacts that will be included in the built mailing list. + + This accounts for any `limit` that was provided. + """ + + generated_at: datetime = FieldInfo(alias="generatedAt") + """The UTC time at which the quote was generated.""" + + price_per_contact_cents: float = FieldInfo(alias="pricePerContactCents") + """The price per contact, in cents. + + Multiply by `count` to get the total cost of building the list. + """ + + +class UsCompanies(BaseModel): + """Filters used to target US companies (B2B) when building a list.""" + + postal_codes: List[str] = FieldInfo(alias="postalCodes") + """Required list of five-digit US ZIP codes to target.""" + + company_types: Optional[ + List[Literal["public", "private", "educational", "government", "nonprofit", "public_subsidiary"]] + ] = FieldInfo(alias="companyTypes", default=None) + """Filter by ownership structure of the company.""" + + employee_count: Optional[List[int]] = FieldInfo(alias="employeeCount", default=None) + """Inclusive `[min, max]` range for the number of employees at the company. + + Values must be between 1 and 1,000,000. + """ + + founded_year: Optional[List[int]] = FieldInfo(alias="foundedYear", default=None) + """ + Inclusive `[min, max]` range for the year the company was founded. Values must + be between 1600 and 2100. + """ + + industries: Optional[List[str]] = None + """Filter by free-form industry names (see the autocomplete endpoint).""" + + naics_codes: Optional[List[str]] = FieldInfo(alias="naicsCodes", default=None) + """Filter by six-digit [NAICS](https://www.census.gov/naics/) industry codes.""" + + tags: Optional[List[str]] = None + """Filter by free-form company tags (e.g., `"saas"`, `"b2b"`).""" + + +class UsConsumersZipCodesAround(BaseModel): + """ + A geographic filter that selects all ZIP codes within a given radius of a + center ZIP code. + """ + + radius_in_miles: float = FieldInfo(alias="radiusInMiles") + """The radius in miles around `zipCode` to include. Between 0.1 and 100.""" + + zip_code: str = FieldInfo(alias="zipCode") + """The five-digit ZIP code at the center of the search circle.""" + + +class UsConsumers(BaseModel): + """Filters used to target US consumers (B2C) when building a list. + + The geographic filters (`zipCodesAround`, `cityStates`, `zipCodes`) are + mutually exclusive — you may supply at most one of them. + """ + + age_range: Optional[List[int]] = FieldInfo(alias="ageRange", default=None) + """Inclusive `[min, max]` age range. Values must be between 18 and 80.""" + + city_states: Optional[List[str]] = FieldInfo(alias="cityStates", default=None) + """A list of `"City, ST"` strings (e.g. `"New York, NY"`) to target.""" + + education_levels: Optional[List[Literal["high_school", "college", "grad_school", "vocational_training"]]] = ( + FieldInfo(alias="educationLevels", default=None) + ) + """Filter by highest level of education completed.""" + + gender: Optional[Literal["male", "female"]] = None + """Gender filter for US consumer list builds.""" + + home_value_range: Optional[List[int]] = FieldInfo(alias="homeValueRange", default=None) + """Inclusive `[min, max]` home value range, in US dollars. + + Values must be between 0 and 1,000,000. + """ + + income_range: Optional[List[int]] = FieldInfo(alias="incomeRange", default=None) + """ + Inclusive `[min, max]` annual household income range, in US dollars. Values must + be between 0 and 200,000. + """ + + num_children_range: Optional[List[int]] = FieldInfo(alias="numChildrenRange", default=None) + """Inclusive `[min, max]` number of children in the household. + + Values must be between 0 and 8. + """ + + occupations: Optional[ + List[ + Literal[ + "professional_technical", + "administration_management", + "sales_service", + "clerical_white_collar", + "craftsmen_blue_collar", + "student", + "homemaker", + "retired", + "farmer", + "military", + "religious", + "self_employed", + "self_employed_professional_technical", + "self_employed_administration_management", + "self_employed_sales_service", + "self_employed_clerical_white_collar", + "self_employed_craftsmen_blue_collar", + "self_employed_student", + "self_employed_homemaker", + "self_employed_retired", + "self_employed_other", + "educator", + "financial_professional", + "legal_professional", + "medical_professional", + "other", + ] + ] + ] = None + """Filter by occupation classification.""" + + zip_codes: Optional[List[str]] = FieldInfo(alias="zipCodes", default=None) + """A list of five-digit US ZIP codes to target.""" + + zip_codes_around: Optional[UsConsumersZipCodesAround] = FieldInfo(alias="zipCodesAround", default=None) + """ + A geographic filter that selects all ZIP codes within a given radius of a center + ZIP code. + """ + + +class TargetedListBuildCreateResponse(BaseModel): + """ + A targeted list build represents a request to build a new mailing list by + targeting US consumers or companies matching the provided filters. Once + created, a quote is generated asynchronously. After reviewing the quote + and preview records, you may confirm the build, which kicks off the + creation of the underlying mailing list. + """ + + id: str + """A unique ID prefixed with targeted*list_build*""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + organization: str + """The ID of the organization that owns this list build.""" + + status: Literal["generating_quote", "quote_ready", "creating_list", "completed", "failed"] + """Status of a targeted list build.""" + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + build_progress_percent: Optional[float] = FieldInfo(alias="buildProgressPercent", default=None) + """A percentage from 0 to 100 representing how much of the build has completed. + + Only populated while `status` is `creating_list`. + """ + + completed_at: Optional[datetime] = FieldInfo(alias="completedAt", default=None) + """The UTC time at which the build finished successfully. + + Only present once `status` is `completed`. + """ + + confirmed_at: Optional[datetime] = FieldInfo(alias="confirmedAt", default=None) + """The UTC time at which the build was confirmed, if any.""" + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + errors: Optional[List[Error]] = None + """Any errors encountered while generating a quote or building the list.""" + + limit: Optional[int] = None + """Maximum number of contacts to include in the built mailing list. + + If omitted, all matching contacts are included. + """ + + mailing_list: Optional[str] = FieldInfo(alias="mailingList", default=None) + """The ID of the mailing list that was built. + + Present once `status` is `completed`. + """ + + metadata: Optional[Dict[str, object]] = None + """See the section on Metadata.""" + + preview_records: Optional[List[PreviewRecord]] = FieldInfo(alias="previewRecords", default=None) + """ + A small number of masked sample records for the configured filters, populated + alongside `quote`. + """ + + quote: Optional[Quote] = None + """Details of the quote generated for a targeted list build.""" + + us_companies: Optional[UsCompanies] = FieldInfo(alias="usCompanies", default=None) + """Filters used to target US companies (B2B) when building a list.""" + + us_consumers: Optional[UsConsumers] = FieldInfo(alias="usConsumers", default=None) + """Filters used to target US consumers (B2C) when building a list. + + The geographic filters (`zipCodesAround`, `cityStates`, `zipCodes`) are mutually + exclusive — you may supply at most one of them. + """ diff --git a/src/postgrid/types/print_mail/targeted_list_build_delete_response.py b/src/postgrid/types/print_mail/targeted_list_build_delete_response.py new file mode 100644 index 0000000..fc55383 --- /dev/null +++ b/src/postgrid/types/print_mail/targeted_list_build_delete_response.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["TargetedListBuildDeleteResponse"] + + +class TargetedListBuildDeleteResponse(BaseModel): + id: str + """A unique ID prefixed with targeted*list_build*""" + + deleted: Literal[True] diff --git a/src/postgrid/types/print_mail/targeted_list_build_list_params.py b/src/postgrid/types/print_mail/targeted_list_build_list_params.py new file mode 100644 index 0000000..3925a53 --- /dev/null +++ b/src/postgrid/types/print_mail/targeted_list_build_list_params.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["TargetedListBuildListParams"] + + +class TargetedListBuildListParams(TypedDict, total=False): + limit: int + + search: str + """You can supply any string to help narrow down the list of resources. + + For example, if you pass `"New York"` (quoted), it will return resources that + have that string present somewhere in their response. Alternatively, you can + supply a structured search query. See the documentation on + `StructuredSearchQuery` for more details. + """ + + skip: int diff --git a/src/postgrid/types/print_mail/targeted_list_build_list_response.py b/src/postgrid/types/print_mail/targeted_list_build_list_response.py new file mode 100644 index 0000000..e2ce60f --- /dev/null +++ b/src/postgrid/types/print_mail/targeted_list_build_list_response.py @@ -0,0 +1,277 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = [ + "TargetedListBuildListResponse", + "Error", + "PreviewRecord", + "Quote", + "UsCompanies", + "UsConsumers", + "UsConsumersZipCodesAround", +] + + +class Error(BaseModel): + """Details of an error encountered while processing a targeted list build.""" + + message: str + """A human-readable message describing the error.""" + + type: Literal["not_enough_info_to_quote", "insufficient_credits", "internal_service_error"] + """Type of error encountered while generating a quote or building the list.""" + + +class PreviewRecord(BaseModel): + """ + A single masked preview record returned with a quote so you can sanity + check the kind of contacts that will end up in the mailing list before + confirming the build. + """ + + formatted_address: str = FieldInfo(alias="formattedAddress") + """The masked, comma-joined formatted address of the contact.""" + + name: str + """The masked name of the contact or business.""" + + +class Quote(BaseModel): + """Details of the quote generated for a targeted list build.""" + + count: int + """The number of contacts that will be included in the built mailing list. + + This accounts for any `limit` that was provided. + """ + + generated_at: datetime = FieldInfo(alias="generatedAt") + """The UTC time at which the quote was generated.""" + + price_per_contact_cents: float = FieldInfo(alias="pricePerContactCents") + """The price per contact, in cents. + + Multiply by `count` to get the total cost of building the list. + """ + + +class UsCompanies(BaseModel): + """Filters used to target US companies (B2B) when building a list.""" + + postal_codes: List[str] = FieldInfo(alias="postalCodes") + """Required list of five-digit US ZIP codes to target.""" + + company_types: Optional[ + List[Literal["public", "private", "educational", "government", "nonprofit", "public_subsidiary"]] + ] = FieldInfo(alias="companyTypes", default=None) + """Filter by ownership structure of the company.""" + + employee_count: Optional[List[int]] = FieldInfo(alias="employeeCount", default=None) + """Inclusive `[min, max]` range for the number of employees at the company. + + Values must be between 1 and 1,000,000. + """ + + founded_year: Optional[List[int]] = FieldInfo(alias="foundedYear", default=None) + """ + Inclusive `[min, max]` range for the year the company was founded. Values must + be between 1600 and 2100. + """ + + industries: Optional[List[str]] = None + """Filter by free-form industry names (see the autocomplete endpoint).""" + + naics_codes: Optional[List[str]] = FieldInfo(alias="naicsCodes", default=None) + """Filter by six-digit [NAICS](https://www.census.gov/naics/) industry codes.""" + + tags: Optional[List[str]] = None + """Filter by free-form company tags (e.g., `"saas"`, `"b2b"`).""" + + +class UsConsumersZipCodesAround(BaseModel): + """ + A geographic filter that selects all ZIP codes within a given radius of a + center ZIP code. + """ + + radius_in_miles: float = FieldInfo(alias="radiusInMiles") + """The radius in miles around `zipCode` to include. Between 0.1 and 100.""" + + zip_code: str = FieldInfo(alias="zipCode") + """The five-digit ZIP code at the center of the search circle.""" + + +class UsConsumers(BaseModel): + """Filters used to target US consumers (B2C) when building a list. + + The geographic filters (`zipCodesAround`, `cityStates`, `zipCodes`) are + mutually exclusive — you may supply at most one of them. + """ + + age_range: Optional[List[int]] = FieldInfo(alias="ageRange", default=None) + """Inclusive `[min, max]` age range. Values must be between 18 and 80.""" + + city_states: Optional[List[str]] = FieldInfo(alias="cityStates", default=None) + """A list of `"City, ST"` strings (e.g. `"New York, NY"`) to target.""" + + education_levels: Optional[List[Literal["high_school", "college", "grad_school", "vocational_training"]]] = ( + FieldInfo(alias="educationLevels", default=None) + ) + """Filter by highest level of education completed.""" + + gender: Optional[Literal["male", "female"]] = None + """Gender filter for US consumer list builds.""" + + home_value_range: Optional[List[int]] = FieldInfo(alias="homeValueRange", default=None) + """Inclusive `[min, max]` home value range, in US dollars. + + Values must be between 0 and 1,000,000. + """ + + income_range: Optional[List[int]] = FieldInfo(alias="incomeRange", default=None) + """ + Inclusive `[min, max]` annual household income range, in US dollars. Values must + be between 0 and 200,000. + """ + + num_children_range: Optional[List[int]] = FieldInfo(alias="numChildrenRange", default=None) + """Inclusive `[min, max]` number of children in the household. + + Values must be between 0 and 8. + """ + + occupations: Optional[ + List[ + Literal[ + "professional_technical", + "administration_management", + "sales_service", + "clerical_white_collar", + "craftsmen_blue_collar", + "student", + "homemaker", + "retired", + "farmer", + "military", + "religious", + "self_employed", + "self_employed_professional_technical", + "self_employed_administration_management", + "self_employed_sales_service", + "self_employed_clerical_white_collar", + "self_employed_craftsmen_blue_collar", + "self_employed_student", + "self_employed_homemaker", + "self_employed_retired", + "self_employed_other", + "educator", + "financial_professional", + "legal_professional", + "medical_professional", + "other", + ] + ] + ] = None + """Filter by occupation classification.""" + + zip_codes: Optional[List[str]] = FieldInfo(alias="zipCodes", default=None) + """A list of five-digit US ZIP codes to target.""" + + zip_codes_around: Optional[UsConsumersZipCodesAround] = FieldInfo(alias="zipCodesAround", default=None) + """ + A geographic filter that selects all ZIP codes within a given radius of a center + ZIP code. + """ + + +class TargetedListBuildListResponse(BaseModel): + """ + A targeted list build represents a request to build a new mailing list by + targeting US consumers or companies matching the provided filters. Once + created, a quote is generated asynchronously. After reviewing the quote + and preview records, you may confirm the build, which kicks off the + creation of the underlying mailing list. + """ + + id: str + """A unique ID prefixed with targeted*list_build*""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + organization: str + """The ID of the organization that owns this list build.""" + + status: Literal["generating_quote", "quote_ready", "creating_list", "completed", "failed"] + """Status of a targeted list build.""" + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + build_progress_percent: Optional[float] = FieldInfo(alias="buildProgressPercent", default=None) + """A percentage from 0 to 100 representing how much of the build has completed. + + Only populated while `status` is `creating_list`. + """ + + completed_at: Optional[datetime] = FieldInfo(alias="completedAt", default=None) + """The UTC time at which the build finished successfully. + + Only present once `status` is `completed`. + """ + + confirmed_at: Optional[datetime] = FieldInfo(alias="confirmedAt", default=None) + """The UTC time at which the build was confirmed, if any.""" + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + errors: Optional[List[Error]] = None + """Any errors encountered while generating a quote or building the list.""" + + limit: Optional[int] = None + """Maximum number of contacts to include in the built mailing list. + + If omitted, all matching contacts are included. + """ + + mailing_list: Optional[str] = FieldInfo(alias="mailingList", default=None) + """The ID of the mailing list that was built. + + Present once `status` is `completed`. + """ + + metadata: Optional[Dict[str, object]] = None + """See the section on Metadata.""" + + preview_records: Optional[List[PreviewRecord]] = FieldInfo(alias="previewRecords", default=None) + """ + A small number of masked sample records for the configured filters, populated + alongside `quote`. + """ + + quote: Optional[Quote] = None + """Details of the quote generated for a targeted list build.""" + + us_companies: Optional[UsCompanies] = FieldInfo(alias="usCompanies", default=None) + """Filters used to target US companies (B2B) when building a list.""" + + us_consumers: Optional[UsConsumers] = FieldInfo(alias="usConsumers", default=None) + """Filters used to target US consumers (B2C) when building a list. + + The geographic filters (`zipCodesAround`, `cityStates`, `zipCodes`) are mutually + exclusive — you may supply at most one of them. + """ diff --git a/src/postgrid/types/print_mail/targeted_list_build_retrieve_response.py b/src/postgrid/types/print_mail/targeted_list_build_retrieve_response.py new file mode 100644 index 0000000..cd641a2 --- /dev/null +++ b/src/postgrid/types/print_mail/targeted_list_build_retrieve_response.py @@ -0,0 +1,277 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = [ + "TargetedListBuildRetrieveResponse", + "Error", + "PreviewRecord", + "Quote", + "UsCompanies", + "UsConsumers", + "UsConsumersZipCodesAround", +] + + +class Error(BaseModel): + """Details of an error encountered while processing a targeted list build.""" + + message: str + """A human-readable message describing the error.""" + + type: Literal["not_enough_info_to_quote", "insufficient_credits", "internal_service_error"] + """Type of error encountered while generating a quote or building the list.""" + + +class PreviewRecord(BaseModel): + """ + A single masked preview record returned with a quote so you can sanity + check the kind of contacts that will end up in the mailing list before + confirming the build. + """ + + formatted_address: str = FieldInfo(alias="formattedAddress") + """The masked, comma-joined formatted address of the contact.""" + + name: str + """The masked name of the contact or business.""" + + +class Quote(BaseModel): + """Details of the quote generated for a targeted list build.""" + + count: int + """The number of contacts that will be included in the built mailing list. + + This accounts for any `limit` that was provided. + """ + + generated_at: datetime = FieldInfo(alias="generatedAt") + """The UTC time at which the quote was generated.""" + + price_per_contact_cents: float = FieldInfo(alias="pricePerContactCents") + """The price per contact, in cents. + + Multiply by `count` to get the total cost of building the list. + """ + + +class UsCompanies(BaseModel): + """Filters used to target US companies (B2B) when building a list.""" + + postal_codes: List[str] = FieldInfo(alias="postalCodes") + """Required list of five-digit US ZIP codes to target.""" + + company_types: Optional[ + List[Literal["public", "private", "educational", "government", "nonprofit", "public_subsidiary"]] + ] = FieldInfo(alias="companyTypes", default=None) + """Filter by ownership structure of the company.""" + + employee_count: Optional[List[int]] = FieldInfo(alias="employeeCount", default=None) + """Inclusive `[min, max]` range for the number of employees at the company. + + Values must be between 1 and 1,000,000. + """ + + founded_year: Optional[List[int]] = FieldInfo(alias="foundedYear", default=None) + """ + Inclusive `[min, max]` range for the year the company was founded. Values must + be between 1600 and 2100. + """ + + industries: Optional[List[str]] = None + """Filter by free-form industry names (see the autocomplete endpoint).""" + + naics_codes: Optional[List[str]] = FieldInfo(alias="naicsCodes", default=None) + """Filter by six-digit [NAICS](https://www.census.gov/naics/) industry codes.""" + + tags: Optional[List[str]] = None + """Filter by free-form company tags (e.g., `"saas"`, `"b2b"`).""" + + +class UsConsumersZipCodesAround(BaseModel): + """ + A geographic filter that selects all ZIP codes within a given radius of a + center ZIP code. + """ + + radius_in_miles: float = FieldInfo(alias="radiusInMiles") + """The radius in miles around `zipCode` to include. Between 0.1 and 100.""" + + zip_code: str = FieldInfo(alias="zipCode") + """The five-digit ZIP code at the center of the search circle.""" + + +class UsConsumers(BaseModel): + """Filters used to target US consumers (B2C) when building a list. + + The geographic filters (`zipCodesAround`, `cityStates`, `zipCodes`) are + mutually exclusive — you may supply at most one of them. + """ + + age_range: Optional[List[int]] = FieldInfo(alias="ageRange", default=None) + """Inclusive `[min, max]` age range. Values must be between 18 and 80.""" + + city_states: Optional[List[str]] = FieldInfo(alias="cityStates", default=None) + """A list of `"City, ST"` strings (e.g. `"New York, NY"`) to target.""" + + education_levels: Optional[List[Literal["high_school", "college", "grad_school", "vocational_training"]]] = ( + FieldInfo(alias="educationLevels", default=None) + ) + """Filter by highest level of education completed.""" + + gender: Optional[Literal["male", "female"]] = None + """Gender filter for US consumer list builds.""" + + home_value_range: Optional[List[int]] = FieldInfo(alias="homeValueRange", default=None) + """Inclusive `[min, max]` home value range, in US dollars. + + Values must be between 0 and 1,000,000. + """ + + income_range: Optional[List[int]] = FieldInfo(alias="incomeRange", default=None) + """ + Inclusive `[min, max]` annual household income range, in US dollars. Values must + be between 0 and 200,000. + """ + + num_children_range: Optional[List[int]] = FieldInfo(alias="numChildrenRange", default=None) + """Inclusive `[min, max]` number of children in the household. + + Values must be between 0 and 8. + """ + + occupations: Optional[ + List[ + Literal[ + "professional_technical", + "administration_management", + "sales_service", + "clerical_white_collar", + "craftsmen_blue_collar", + "student", + "homemaker", + "retired", + "farmer", + "military", + "religious", + "self_employed", + "self_employed_professional_technical", + "self_employed_administration_management", + "self_employed_sales_service", + "self_employed_clerical_white_collar", + "self_employed_craftsmen_blue_collar", + "self_employed_student", + "self_employed_homemaker", + "self_employed_retired", + "self_employed_other", + "educator", + "financial_professional", + "legal_professional", + "medical_professional", + "other", + ] + ] + ] = None + """Filter by occupation classification.""" + + zip_codes: Optional[List[str]] = FieldInfo(alias="zipCodes", default=None) + """A list of five-digit US ZIP codes to target.""" + + zip_codes_around: Optional[UsConsumersZipCodesAround] = FieldInfo(alias="zipCodesAround", default=None) + """ + A geographic filter that selects all ZIP codes within a given radius of a center + ZIP code. + """ + + +class TargetedListBuildRetrieveResponse(BaseModel): + """ + A targeted list build represents a request to build a new mailing list by + targeting US consumers or companies matching the provided filters. Once + created, a quote is generated asynchronously. After reviewing the quote + and preview records, you may confirm the build, which kicks off the + creation of the underlying mailing list. + """ + + id: str + """A unique ID prefixed with targeted*list_build*""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + organization: str + """The ID of the organization that owns this list build.""" + + status: Literal["generating_quote", "quote_ready", "creating_list", "completed", "failed"] + """Status of a targeted list build.""" + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + build_progress_percent: Optional[float] = FieldInfo(alias="buildProgressPercent", default=None) + """A percentage from 0 to 100 representing how much of the build has completed. + + Only populated while `status` is `creating_list`. + """ + + completed_at: Optional[datetime] = FieldInfo(alias="completedAt", default=None) + """The UTC time at which the build finished successfully. + + Only present once `status` is `completed`. + """ + + confirmed_at: Optional[datetime] = FieldInfo(alias="confirmedAt", default=None) + """The UTC time at which the build was confirmed, if any.""" + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + errors: Optional[List[Error]] = None + """Any errors encountered while generating a quote or building the list.""" + + limit: Optional[int] = None + """Maximum number of contacts to include in the built mailing list. + + If omitted, all matching contacts are included. + """ + + mailing_list: Optional[str] = FieldInfo(alias="mailingList", default=None) + """The ID of the mailing list that was built. + + Present once `status` is `completed`. + """ + + metadata: Optional[Dict[str, object]] = None + """See the section on Metadata.""" + + preview_records: Optional[List[PreviewRecord]] = FieldInfo(alias="previewRecords", default=None) + """ + A small number of masked sample records for the configured filters, populated + alongside `quote`. + """ + + quote: Optional[Quote] = None + """Details of the quote generated for a targeted list build.""" + + us_companies: Optional[UsCompanies] = FieldInfo(alias="usCompanies", default=None) + """Filters used to target US companies (B2B) when building a list.""" + + us_consumers: Optional[UsConsumers] = FieldInfo(alias="usConsumers", default=None) + """Filters used to target US consumers (B2C) when building a list. + + The geographic filters (`zipCodesAround`, `cityStates`, `zipCodes`) are mutually + exclusive — you may supply at most one of them. + """ diff --git a/src/postgrid/types/print_mail/targeted_list_build_update_params.py b/src/postgrid/types/print_mail/targeted_list_build_update_params.py new file mode 100644 index 0000000..9f82315 --- /dev/null +++ b/src/postgrid/types/print_mail/targeted_list_build_update_params.py @@ -0,0 +1,167 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, List, Iterable +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ..._types import SequenceNotStr +from ..._utils import PropertyInfo + +__all__ = ["TargetedListBuildUpdateParams", "UsCompanies", "UsConsumers", "UsConsumersZipCodesAround"] + + +class TargetedListBuildUpdateParams(TypedDict, total=False): + description: str + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + limit: int + """Maximum number of contacts to include in the built mailing list. + + If omitted, all matching contacts are included. + """ + + metadata: Dict[str, object] + """See the section on Metadata.""" + + us_companies: Annotated[UsCompanies, PropertyInfo(alias="usCompanies")] + """Filters used to target US companies (B2B) when building a list.""" + + us_consumers: Annotated[UsConsumers, PropertyInfo(alias="usConsumers")] + """Filters used to target US consumers (B2C) when building a list. + + The geographic filters (`zipCodesAround`, `cityStates`, `zipCodes`) are mutually + exclusive — you may supply at most one of them. + """ + + +class UsCompanies(TypedDict, total=False): + """Filters used to target US companies (B2B) when building a list.""" + + postal_codes: Required[Annotated[SequenceNotStr[str], PropertyInfo(alias="postalCodes")]] + """Required list of five-digit US ZIP codes to target.""" + + company_types: Annotated[ + List[Literal["public", "private", "educational", "government", "nonprofit", "public_subsidiary"]], + PropertyInfo(alias="companyTypes"), + ] + """Filter by ownership structure of the company.""" + + employee_count: Annotated[Iterable[int], PropertyInfo(alias="employeeCount")] + """Inclusive `[min, max]` range for the number of employees at the company. + + Values must be between 1 and 1,000,000. + """ + + founded_year: Annotated[Iterable[int], PropertyInfo(alias="foundedYear")] + """ + Inclusive `[min, max]` range for the year the company was founded. Values must + be between 1600 and 2100. + """ + + industries: SequenceNotStr[str] + """Filter by free-form industry names (see the autocomplete endpoint).""" + + naics_codes: Annotated[SequenceNotStr[str], PropertyInfo(alias="naicsCodes")] + """Filter by six-digit [NAICS](https://www.census.gov/naics/) industry codes.""" + + tags: SequenceNotStr[str] + """Filter by free-form company tags (e.g., `"saas"`, `"b2b"`).""" + + +class UsConsumersZipCodesAround(TypedDict, total=False): + """ + A geographic filter that selects all ZIP codes within a given radius of a + center ZIP code. + """ + + radius_in_miles: Required[Annotated[float, PropertyInfo(alias="radiusInMiles")]] + """The radius in miles around `zipCode` to include. Between 0.1 and 100.""" + + zip_code: Required[Annotated[str, PropertyInfo(alias="zipCode")]] + """The five-digit ZIP code at the center of the search circle.""" + + +class UsConsumers(TypedDict, total=False): + """Filters used to target US consumers (B2C) when building a list. + + The geographic filters (`zipCodesAround`, `cityStates`, `zipCodes`) are + mutually exclusive — you may supply at most one of them. + """ + + age_range: Annotated[Iterable[int], PropertyInfo(alias="ageRange")] + """Inclusive `[min, max]` age range. Values must be between 18 and 80.""" + + city_states: Annotated[SequenceNotStr[str], PropertyInfo(alias="cityStates")] + """A list of `"City, ST"` strings (e.g. `"New York, NY"`) to target.""" + + education_levels: Annotated[ + List[Literal["high_school", "college", "grad_school", "vocational_training"]], + PropertyInfo(alias="educationLevels"), + ] + """Filter by highest level of education completed.""" + + gender: Literal["male", "female"] + """Gender filter for US consumer list builds.""" + + home_value_range: Annotated[Iterable[int], PropertyInfo(alias="homeValueRange")] + """Inclusive `[min, max]` home value range, in US dollars. + + Values must be between 0 and 1,000,000. + """ + + income_range: Annotated[Iterable[int], PropertyInfo(alias="incomeRange")] + """ + Inclusive `[min, max]` annual household income range, in US dollars. Values must + be between 0 and 200,000. + """ + + num_children_range: Annotated[Iterable[int], PropertyInfo(alias="numChildrenRange")] + """Inclusive `[min, max]` number of children in the household. + + Values must be between 0 and 8. + """ + + occupations: List[ + Literal[ + "professional_technical", + "administration_management", + "sales_service", + "clerical_white_collar", + "craftsmen_blue_collar", + "student", + "homemaker", + "retired", + "farmer", + "military", + "religious", + "self_employed", + "self_employed_professional_technical", + "self_employed_administration_management", + "self_employed_sales_service", + "self_employed_clerical_white_collar", + "self_employed_craftsmen_blue_collar", + "self_employed_student", + "self_employed_homemaker", + "self_employed_retired", + "self_employed_other", + "educator", + "financial_professional", + "legal_professional", + "medical_professional", + "other", + ] + ] + """Filter by occupation classification.""" + + zip_codes: Annotated[SequenceNotStr[str], PropertyInfo(alias="zipCodes")] + """A list of five-digit US ZIP codes to target.""" + + zip_codes_around: Annotated[UsConsumersZipCodesAround, PropertyInfo(alias="zipCodesAround")] + """ + A geographic filter that selects all ZIP codes within a given radius of a center + ZIP code. + """ diff --git a/src/postgrid/types/print_mail/targeted_list_build_update_response.py b/src/postgrid/types/print_mail/targeted_list_build_update_response.py new file mode 100644 index 0000000..c45e6ba --- /dev/null +++ b/src/postgrid/types/print_mail/targeted_list_build_update_response.py @@ -0,0 +1,277 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = [ + "TargetedListBuildUpdateResponse", + "Error", + "PreviewRecord", + "Quote", + "UsCompanies", + "UsConsumers", + "UsConsumersZipCodesAround", +] + + +class Error(BaseModel): + """Details of an error encountered while processing a targeted list build.""" + + message: str + """A human-readable message describing the error.""" + + type: Literal["not_enough_info_to_quote", "insufficient_credits", "internal_service_error"] + """Type of error encountered while generating a quote or building the list.""" + + +class PreviewRecord(BaseModel): + """ + A single masked preview record returned with a quote so you can sanity + check the kind of contacts that will end up in the mailing list before + confirming the build. + """ + + formatted_address: str = FieldInfo(alias="formattedAddress") + """The masked, comma-joined formatted address of the contact.""" + + name: str + """The masked name of the contact or business.""" + + +class Quote(BaseModel): + """Details of the quote generated for a targeted list build.""" + + count: int + """The number of contacts that will be included in the built mailing list. + + This accounts for any `limit` that was provided. + """ + + generated_at: datetime = FieldInfo(alias="generatedAt") + """The UTC time at which the quote was generated.""" + + price_per_contact_cents: float = FieldInfo(alias="pricePerContactCents") + """The price per contact, in cents. + + Multiply by `count` to get the total cost of building the list. + """ + + +class UsCompanies(BaseModel): + """Filters used to target US companies (B2B) when building a list.""" + + postal_codes: List[str] = FieldInfo(alias="postalCodes") + """Required list of five-digit US ZIP codes to target.""" + + company_types: Optional[ + List[Literal["public", "private", "educational", "government", "nonprofit", "public_subsidiary"]] + ] = FieldInfo(alias="companyTypes", default=None) + """Filter by ownership structure of the company.""" + + employee_count: Optional[List[int]] = FieldInfo(alias="employeeCount", default=None) + """Inclusive `[min, max]` range for the number of employees at the company. + + Values must be between 1 and 1,000,000. + """ + + founded_year: Optional[List[int]] = FieldInfo(alias="foundedYear", default=None) + """ + Inclusive `[min, max]` range for the year the company was founded. Values must + be between 1600 and 2100. + """ + + industries: Optional[List[str]] = None + """Filter by free-form industry names (see the autocomplete endpoint).""" + + naics_codes: Optional[List[str]] = FieldInfo(alias="naicsCodes", default=None) + """Filter by six-digit [NAICS](https://www.census.gov/naics/) industry codes.""" + + tags: Optional[List[str]] = None + """Filter by free-form company tags (e.g., `"saas"`, `"b2b"`).""" + + +class UsConsumersZipCodesAround(BaseModel): + """ + A geographic filter that selects all ZIP codes within a given radius of a + center ZIP code. + """ + + radius_in_miles: float = FieldInfo(alias="radiusInMiles") + """The radius in miles around `zipCode` to include. Between 0.1 and 100.""" + + zip_code: str = FieldInfo(alias="zipCode") + """The five-digit ZIP code at the center of the search circle.""" + + +class UsConsumers(BaseModel): + """Filters used to target US consumers (B2C) when building a list. + + The geographic filters (`zipCodesAround`, `cityStates`, `zipCodes`) are + mutually exclusive — you may supply at most one of them. + """ + + age_range: Optional[List[int]] = FieldInfo(alias="ageRange", default=None) + """Inclusive `[min, max]` age range. Values must be between 18 and 80.""" + + city_states: Optional[List[str]] = FieldInfo(alias="cityStates", default=None) + """A list of `"City, ST"` strings (e.g. `"New York, NY"`) to target.""" + + education_levels: Optional[List[Literal["high_school", "college", "grad_school", "vocational_training"]]] = ( + FieldInfo(alias="educationLevels", default=None) + ) + """Filter by highest level of education completed.""" + + gender: Optional[Literal["male", "female"]] = None + """Gender filter for US consumer list builds.""" + + home_value_range: Optional[List[int]] = FieldInfo(alias="homeValueRange", default=None) + """Inclusive `[min, max]` home value range, in US dollars. + + Values must be between 0 and 1,000,000. + """ + + income_range: Optional[List[int]] = FieldInfo(alias="incomeRange", default=None) + """ + Inclusive `[min, max]` annual household income range, in US dollars. Values must + be between 0 and 200,000. + """ + + num_children_range: Optional[List[int]] = FieldInfo(alias="numChildrenRange", default=None) + """Inclusive `[min, max]` number of children in the household. + + Values must be between 0 and 8. + """ + + occupations: Optional[ + List[ + Literal[ + "professional_technical", + "administration_management", + "sales_service", + "clerical_white_collar", + "craftsmen_blue_collar", + "student", + "homemaker", + "retired", + "farmer", + "military", + "religious", + "self_employed", + "self_employed_professional_technical", + "self_employed_administration_management", + "self_employed_sales_service", + "self_employed_clerical_white_collar", + "self_employed_craftsmen_blue_collar", + "self_employed_student", + "self_employed_homemaker", + "self_employed_retired", + "self_employed_other", + "educator", + "financial_professional", + "legal_professional", + "medical_professional", + "other", + ] + ] + ] = None + """Filter by occupation classification.""" + + zip_codes: Optional[List[str]] = FieldInfo(alias="zipCodes", default=None) + """A list of five-digit US ZIP codes to target.""" + + zip_codes_around: Optional[UsConsumersZipCodesAround] = FieldInfo(alias="zipCodesAround", default=None) + """ + A geographic filter that selects all ZIP codes within a given radius of a center + ZIP code. + """ + + +class TargetedListBuildUpdateResponse(BaseModel): + """ + A targeted list build represents a request to build a new mailing list by + targeting US consumers or companies matching the provided filters. Once + created, a quote is generated asynchronously. After reviewing the quote + and preview records, you may confirm the build, which kicks off the + creation of the underlying mailing list. + """ + + id: str + """A unique ID prefixed with targeted*list_build*""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + organization: str + """The ID of the organization that owns this list build.""" + + status: Literal["generating_quote", "quote_ready", "creating_list", "completed", "failed"] + """Status of a targeted list build.""" + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + build_progress_percent: Optional[float] = FieldInfo(alias="buildProgressPercent", default=None) + """A percentage from 0 to 100 representing how much of the build has completed. + + Only populated while `status` is `creating_list`. + """ + + completed_at: Optional[datetime] = FieldInfo(alias="completedAt", default=None) + """The UTC time at which the build finished successfully. + + Only present once `status` is `completed`. + """ + + confirmed_at: Optional[datetime] = FieldInfo(alias="confirmedAt", default=None) + """The UTC time at which the build was confirmed, if any.""" + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + errors: Optional[List[Error]] = None + """Any errors encountered while generating a quote or building the list.""" + + limit: Optional[int] = None + """Maximum number of contacts to include in the built mailing list. + + If omitted, all matching contacts are included. + """ + + mailing_list: Optional[str] = FieldInfo(alias="mailingList", default=None) + """The ID of the mailing list that was built. + + Present once `status` is `completed`. + """ + + metadata: Optional[Dict[str, object]] = None + """See the section on Metadata.""" + + preview_records: Optional[List[PreviewRecord]] = FieldInfo(alias="previewRecords", default=None) + """ + A small number of masked sample records for the configured filters, populated + alongside `quote`. + """ + + quote: Optional[Quote] = None + """Details of the quote generated for a targeted list build.""" + + us_companies: Optional[UsCompanies] = FieldInfo(alias="usCompanies", default=None) + """Filters used to target US companies (B2B) when building a list.""" + + us_consumers: Optional[UsConsumers] = FieldInfo(alias="usConsumers", default=None) + """Filters used to target US consumers (B2C) when building a list. + + The geographic filters (`zipCodesAround`, `cityStates`, `zipCodes`) are mutually + exclusive — you may supply at most one of them. + """ diff --git a/src/postgrid/types/print_mail/targeted_list_builds/__init__.py b/src/postgrid/types/print_mail/targeted_list_builds/__init__.py new file mode 100644 index 0000000..0557644 --- /dev/null +++ b/src/postgrid/types/print_mail/targeted_list_builds/__init__.py @@ -0,0 +1,6 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .filter_autocomplete_params import FilterAutocompleteParams as FilterAutocompleteParams +from .filter_autocomplete_response import FilterAutocompleteResponse as FilterAutocompleteResponse diff --git a/src/postgrid/types/print_mail/targeted_list_builds/filter_autocomplete_params.py b/src/postgrid/types/print_mail/targeted_list_builds/filter_autocomplete_params.py new file mode 100644 index 0000000..cfb8748 --- /dev/null +++ b/src/postgrid/types/print_mail/targeted_list_builds/filter_autocomplete_params.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["FilterAutocompleteParams"] + + +class FilterAutocompleteParams(TypedDict, total=False): + field: Required[Literal["industry"]] + """A field that can be autocompleted when configuring list build filters.""" + + size: int + """Maximum number of suggestions to return. + + Between 1 and 100. Defaults to 25 if omitted. + """ + + text: str + """Optional text prefix to narrow the autocomplete suggestions.""" diff --git a/src/postgrid/types/print_mail/targeted_list_builds/filter_autocomplete_response.py b/src/postgrid/types/print_mail/targeted_list_builds/filter_autocomplete_response.py new file mode 100644 index 0000000..04d17f8 --- /dev/null +++ b/src/postgrid/types/print_mail/targeted_list_builds/filter_autocomplete_response.py @@ -0,0 +1,26 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["FilterAutocompleteResponse", "Data"] + + +class Data(BaseModel): + """A single autocomplete suggestion.""" + + type: Literal["industry"] + """A field that can be autocompleted when configuring list build filters.""" + + value: str + """The suggested value (e.g., an industry name).""" + + +class FilterAutocompleteResponse(BaseModel): + """The list of suggestions returned by an autocomplete query.""" + + data: List[Data] + + object: Literal["list"] diff --git a/src/postgrid/types/print_mail/template_editor_session_create_params.py b/src/postgrid/types/print_mail/template_editor_session_create_params.py new file mode 100644 index 0000000..182ee86 --- /dev/null +++ b/src/postgrid/types/print_mail/template_editor_session_create_params.py @@ -0,0 +1,65 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ..._types import SequenceNotStr +from ..._utils import PropertyInfo + +__all__ = ["TemplateEditorSessionCreateParams", "Styles", "StylesCanvas", "StylesPanelText", "StylesSaveButton"] + + +class TemplateEditorSessionCreateParams(TypedDict, total=False): + template: Required[str] + """ID of the underlying template that this edits.""" + + back_url: Annotated[str, PropertyInfo(alias="backURL")] + """The URL supplied when this editor session was created.""" + + styles: Styles + """Style overrides for the template editor session.""" + + title: str + """The title supplied when this editor session was created.""" + + trackers: Union[Literal["all", "none"], SequenceNotStr[str]] + """Controls which Trackers are displayed in the template editor session.""" + + +class StylesCanvas(TypedDict, total=False): + """Style overrides for the template editor canvas.""" + + background_color: Annotated[str, PropertyInfo(alias="backgroundColor")] + """The canvas background color.""" + + +class StylesPanelText(TypedDict, total=False): + """Style overrides for template editor panel text.""" + + color: str + """The panel text color.""" + + +class StylesSaveButton(TypedDict, total=False): + """Style overrides for the template editor save button.""" + + background_color: Annotated[str, PropertyInfo(alias="backgroundColor")] + """The save button background color.""" + + text_color: Annotated[str, PropertyInfo(alias="textColor")] + """The save button text color.""" + + +class Styles(TypedDict, total=False): + """Style overrides for the template editor session.""" + + canvas: StylesCanvas + """Style overrides for the template editor canvas.""" + + panel_text: Annotated[StylesPanelText, PropertyInfo(alias="panelText")] + """Style overrides for template editor panel text.""" + + save_button: Annotated[StylesSaveButton, PropertyInfo(alias="saveButton")] + """Style overrides for the template editor save button.""" diff --git a/src/postgrid/types/print_mail/template_editor_session_create_response.py b/src/postgrid/types/print_mail/template_editor_session_create_response.py new file mode 100644 index 0000000..0224b4b --- /dev/null +++ b/src/postgrid/types/print_mail/template_editor_session_create_response.py @@ -0,0 +1,80 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = ["TemplateEditorSessionCreateResponse", "Styles", "StylesCanvas", "StylesPanelText", "StylesSaveButton"] + + +class StylesCanvas(BaseModel): + """Style overrides for the template editor canvas.""" + + background_color: Optional[str] = FieldInfo(alias="backgroundColor", default=None) + """The canvas background color.""" + + +class StylesPanelText(BaseModel): + """Style overrides for template editor panel text.""" + + color: Optional[str] = None + """The panel text color.""" + + +class StylesSaveButton(BaseModel): + """Style overrides for the template editor save button.""" + + background_color: Optional[str] = FieldInfo(alias="backgroundColor", default=None) + """The save button background color.""" + + text_color: Optional[str] = FieldInfo(alias="textColor", default=None) + """The save button text color.""" + + +class Styles(BaseModel): + """Style overrides for the template editor session.""" + + canvas: Optional[StylesCanvas] = None + """Style overrides for the template editor canvas.""" + + panel_text: Optional[StylesPanelText] = FieldInfo(alias="panelText", default=None) + """Style overrides for template editor panel text.""" + + save_button: Optional[StylesSaveButton] = FieldInfo(alias="saveButton", default=None) + """Style overrides for the template editor save button.""" + + +class TemplateEditorSessionCreateResponse(BaseModel): + id: str + """A unique ID prefixed with `template_editor_session_`.""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this session was created.""" + + live: bool + """`true` if this is a live mode session else `false`.""" + + object: Literal["template_editor_session"] + """Always `template_editor_session`.""" + + template: str + """ID of the underlying template that this edits.""" + + url: str + """A URL that can be iframed or redirected to for editing the template.""" + + back_url: Optional[str] = FieldInfo(alias="backURL", default=None) + """The URL supplied when this editor session was created.""" + + styles: Optional[Styles] = None + """Style overrides for the template editor session.""" + + title: Optional[str] = None + """The title supplied when this editor session was created.""" + + trackers: Union[Literal["all", "none"], List[str], None] = None + """Controls which Trackers are displayed in the template editor session.""" diff --git a/src/postgrid/types/print_mail/template_editor_session_delete_response.py b/src/postgrid/types/print_mail/template_editor_session_delete_response.py new file mode 100644 index 0000000..f291fad --- /dev/null +++ b/src/postgrid/types/print_mail/template_editor_session_delete_response.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["TemplateEditorSessionDeleteResponse"] + + +class TemplateEditorSessionDeleteResponse(BaseModel): + id: str + """A unique ID prefixed with `template_editor_session_`.""" + + deleted: Literal[True] + + object: Literal["template_editor_session"] + """Always `template_editor_session`.""" diff --git a/src/postgrid/types/print_mail/template_editor_session_list_params.py b/src/postgrid/types/print_mail/template_editor_session_list_params.py new file mode 100644 index 0000000..9a83f26 --- /dev/null +++ b/src/postgrid/types/print_mail/template_editor_session_list_params.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["TemplateEditorSessionListParams"] + + +class TemplateEditorSessionListParams(TypedDict, total=False): + limit: int + + search: str + """You can supply any string to help narrow down the list of resources. + + For example, if you pass `"New York"` (quoted), it will return resources that + have that string present somewhere in their response. Alternatively, you can + supply a structured search query. See the documentation on + `StructuredSearchQuery` for more details. + """ + + skip: int diff --git a/src/postgrid/types/print_mail/template_editor_session_list_response.py b/src/postgrid/types/print_mail/template_editor_session_list_response.py new file mode 100644 index 0000000..ff07f3e --- /dev/null +++ b/src/postgrid/types/print_mail/template_editor_session_list_response.py @@ -0,0 +1,80 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Union, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = ["TemplateEditorSessionListResponse", "Styles", "StylesCanvas", "StylesPanelText", "StylesSaveButton"] + + +class StylesCanvas(BaseModel): + """Style overrides for the template editor canvas.""" + + background_color: Optional[str] = FieldInfo(alias="backgroundColor", default=None) + """The canvas background color.""" + + +class StylesPanelText(BaseModel): + """Style overrides for template editor panel text.""" + + color: Optional[str] = None + """The panel text color.""" + + +class StylesSaveButton(BaseModel): + """Style overrides for the template editor save button.""" + + background_color: Optional[str] = FieldInfo(alias="backgroundColor", default=None) + """The save button background color.""" + + text_color: Optional[str] = FieldInfo(alias="textColor", default=None) + """The save button text color.""" + + +class Styles(BaseModel): + """Style overrides for the template editor session.""" + + canvas: Optional[StylesCanvas] = None + """Style overrides for the template editor canvas.""" + + panel_text: Optional[StylesPanelText] = FieldInfo(alias="panelText", default=None) + """Style overrides for template editor panel text.""" + + save_button: Optional[StylesSaveButton] = FieldInfo(alias="saveButton", default=None) + """Style overrides for the template editor save button.""" + + +class TemplateEditorSessionListResponse(BaseModel): + id: str + """A unique ID prefixed with `template_editor_session_`.""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this session was created.""" + + live: bool + """`true` if this is a live mode session else `false`.""" + + object: Literal["template_editor_session"] + """Always `template_editor_session`.""" + + template: str + """ID of the underlying template that this edits.""" + + url: str + """A URL that can be iframed or redirected to for editing the template.""" + + back_url: Optional[str] = FieldInfo(alias="backURL", default=None) + """The URL supplied when this editor session was created.""" + + styles: Optional[Styles] = None + """Style overrides for the template editor session.""" + + title: Optional[str] = None + """The title supplied when this editor session was created.""" + + trackers: Union[Literal["all", "none"], List[str], None] = None + """Controls which Trackers are displayed in the template editor session.""" diff --git a/src/postgrid/types/print_mail/tracker_create_params.py b/src/postgrid/types/print_mail/tracker_create_params.py new file mode 100644 index 0000000..fcb0786 --- /dev/null +++ b/src/postgrid/types/print_mail/tracker_create_params.py @@ -0,0 +1,27 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ..._utils import PropertyInfo + +__all__ = ["TrackerCreateParams"] + + +class TrackerCreateParams(TypedDict, total=False): + redirect_url_template: Required[Annotated[str, PropertyInfo(alias="redirectURLTemplate")]] + """The base template for URLs generated by this Tracker.""" + + url_expire_after_days: Required[Annotated[Literal[30, 60, 90, 180, 365], PropertyInfo(alias="urlExpireAfterDays")]] + """The number of days generated Tracker URLs remain valid.""" + + description: str + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + metadata: Dict[str, object] + """See the section on Metadata.""" diff --git a/src/postgrid/types/print_mail/tracker_create_response.py b/src/postgrid/types/print_mail/tracker_create_response.py new file mode 100644 index 0000000..7aee712 --- /dev/null +++ b/src/postgrid/types/print_mail/tracker_create_response.py @@ -0,0 +1,50 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = ["TrackerCreateResponse"] + + +class TrackerCreateResponse(BaseModel): + id: str + """A unique ID prefixed with tracker\\__""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + object: Literal["tracker"] + """Always `tracker`.""" + + redirect_url_template: str = FieldInfo(alias="redirectURLTemplate") + """The base template for URLs generated by this Tracker.""" + + unique_visit_count: int = FieldInfo(alias="uniqueVisitCount") + """The unique number of interactions the Tracker has had.""" + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + url_expire_after_days: Literal[30, 60, 90, 180, 365] = FieldInfo(alias="urlExpireAfterDays") + """The number of days generated Tracker URLs remain valid.""" + + visit_count: int = FieldInfo(alias="visitCount") + """The total number of interactions the Tracker has had.""" + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" diff --git a/src/postgrid/types/print_mail/tracker_delete_response.py b/src/postgrid/types/print_mail/tracker_delete_response.py new file mode 100644 index 0000000..b780661 --- /dev/null +++ b/src/postgrid/types/print_mail/tracker_delete_response.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["TrackerDeleteResponse"] + + +class TrackerDeleteResponse(BaseModel): + id: str + """A unique ID prefixed with tracker\\__""" + + deleted: Literal[True] + + object: Literal["tracker"] + """Always `tracker`.""" diff --git a/src/postgrid/types/print_mail/tracker_list_params.py b/src/postgrid/types/print_mail/tracker_list_params.py new file mode 100644 index 0000000..1539dc7 --- /dev/null +++ b/src/postgrid/types/print_mail/tracker_list_params.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["TrackerListParams"] + + +class TrackerListParams(TypedDict, total=False): + limit: int + + search: str + """You can supply any string to help narrow down the list of resources. + + For example, if you pass `"New York"` (quoted), it will return resources that + have that string present somewhere in their response. Alternatively, you can + supply a structured search query. See the documentation on + `StructuredSearchQuery` for more details. + """ + + skip: int diff --git a/src/postgrid/types/print_mail/tracker_list_response.py b/src/postgrid/types/print_mail/tracker_list_response.py new file mode 100644 index 0000000..a9ae488 --- /dev/null +++ b/src/postgrid/types/print_mail/tracker_list_response.py @@ -0,0 +1,50 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = ["TrackerListResponse"] + + +class TrackerListResponse(BaseModel): + id: str + """A unique ID prefixed with tracker\\__""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + object: Literal["tracker"] + """Always `tracker`.""" + + redirect_url_template: str = FieldInfo(alias="redirectURLTemplate") + """The base template for URLs generated by this Tracker.""" + + unique_visit_count: int = FieldInfo(alias="uniqueVisitCount") + """The unique number of interactions the Tracker has had.""" + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + url_expire_after_days: Literal[30, 60, 90, 180, 365] = FieldInfo(alias="urlExpireAfterDays") + """The number of days generated Tracker URLs remain valid.""" + + visit_count: int = FieldInfo(alias="visitCount") + """The total number of interactions the Tracker has had.""" + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" diff --git a/src/postgrid/types/print_mail/tracker_retrieve_response.py b/src/postgrid/types/print_mail/tracker_retrieve_response.py new file mode 100644 index 0000000..909329f --- /dev/null +++ b/src/postgrid/types/print_mail/tracker_retrieve_response.py @@ -0,0 +1,50 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = ["TrackerRetrieveResponse"] + + +class TrackerRetrieveResponse(BaseModel): + id: str + """A unique ID prefixed with tracker\\__""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + object: Literal["tracker"] + """Always `tracker`.""" + + redirect_url_template: str = FieldInfo(alias="redirectURLTemplate") + """The base template for URLs generated by this Tracker.""" + + unique_visit_count: int = FieldInfo(alias="uniqueVisitCount") + """The unique number of interactions the Tracker has had.""" + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + url_expire_after_days: Literal[30, 60, 90, 180, 365] = FieldInfo(alias="urlExpireAfterDays") + """The number of days generated Tracker URLs remain valid.""" + + visit_count: int = FieldInfo(alias="visitCount") + """The total number of interactions the Tracker has had.""" + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" diff --git a/src/postgrid/types/print_mail/tracker_retrieve_visits_params.py b/src/postgrid/types/print_mail/tracker_retrieve_visits_params.py new file mode 100644 index 0000000..52bcc9e --- /dev/null +++ b/src/postgrid/types/print_mail/tracker_retrieve_visits_params.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["TrackerRetrieveVisitsParams"] + + +class TrackerRetrieveVisitsParams(TypedDict, total=False): + limit: int + + search: str + """You can supply any string to help narrow down the list of resources. + + For example, if you pass `"New York"` (quoted), it will return resources that + have that string present somewhere in their response. Alternatively, you can + supply a structured search query. See the documentation on + `StructuredSearchQuery` for more details. + """ + + skip: int diff --git a/src/postgrid/types/print_mail/tracker_retrieve_visits_response.py b/src/postgrid/types/print_mail/tracker_retrieve_visits_response.py new file mode 100644 index 0000000..50dde82 --- /dev/null +++ b/src/postgrid/types/print_mail/tracker_retrieve_visits_response.py @@ -0,0 +1,39 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = ["TrackerRetrieveVisitsResponse"] + + +class TrackerRetrieveVisitsResponse(BaseModel): + id: str + """A unique ID prefixed with `tracker_visit_`.""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this visit was created.""" + + device: str + """The type of device associated with the visit.""" + + ip_address: str = FieldInfo(alias="ipAddress") + """The IP address associated with the visit.""" + + live: bool + """Indicates if the visit was used in a live order or not.""" + + object: Literal["tracker_visit"] + """Always `tracker_visit`.""" + + order_id: str = FieldInfo(alias="orderID") + """The ID of the order where the interaction occurred.""" + + tracker: str + """The ID of the tracker related to this visit.""" + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this visit was last updated.""" diff --git a/src/postgrid/types/print_mail/tracker_update_params.py b/src/postgrid/types/print_mail/tracker_update_params.py new file mode 100644 index 0000000..365a6dc --- /dev/null +++ b/src/postgrid/types/print_mail/tracker_update_params.py @@ -0,0 +1,27 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict +from typing_extensions import Literal, Required, Annotated, TypedDict + +from ..._utils import PropertyInfo + +__all__ = ["TrackerUpdateParams"] + + +class TrackerUpdateParams(TypedDict, total=False): + redirect_url_template: Required[Annotated[str, PropertyInfo(alias="redirectURLTemplate")]] + """The base template for URLs generated by this Tracker.""" + + url_expire_after_days: Required[Annotated[Literal[30, 60, 90, 180, 365], PropertyInfo(alias="urlExpireAfterDays")]] + """The number of days generated Tracker URLs remain valid.""" + + description: str + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + metadata: Dict[str, object] + """See the section on Metadata.""" diff --git a/src/postgrid/types/print_mail/tracker_update_response.py b/src/postgrid/types/print_mail/tracker_update_response.py new file mode 100644 index 0000000..f36b89a --- /dev/null +++ b/src/postgrid/types/print_mail/tracker_update_response.py @@ -0,0 +1,50 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = ["TrackerUpdateResponse"] + + +class TrackerUpdateResponse(BaseModel): + id: str + """A unique ID prefixed with tracker\\__""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + object: Literal["tracker"] + """Always `tracker`.""" + + redirect_url_template: str = FieldInfo(alias="redirectURLTemplate") + """The base template for URLs generated by this Tracker.""" + + unique_visit_count: int = FieldInfo(alias="uniqueVisitCount") + """The unique number of interactions the Tracker has had.""" + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + url_expire_after_days: Literal[30, 60, 90, 180, 365] = FieldInfo(alias="urlExpireAfterDays") + """The number of days generated Tracker URLs remain valid.""" + + visit_count: int = FieldInfo(alias="visitCount") + """The total number of interactions the Tracker has had.""" + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" diff --git a/src/postgrid/types/print_mail/virtual_mailbox_create_params.py b/src/postgrid/types/print_mail/virtual_mailbox_create_params.py new file mode 100644 index 0000000..749207c --- /dev/null +++ b/src/postgrid/types/print_mail/virtual_mailbox_create_params.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict + +from ..._utils import PropertyInfo +from .contact_create_with_first_name_param import ContactCreateWithFirstNameParam +from .contact_create_with_company_name_param import ContactCreateWithCompanyNameParam + +__all__ = ["VirtualMailboxCreateParams", "Capabilities", "CapabilitiesForwardMailTo"] + + +class VirtualMailboxCreateParams(TypedDict, total=False): + country_code: Required[Annotated[Literal["US"], PropertyInfo(alias="countryCode")]] + """All of the supported countries for virtual mailboxes.""" + + capabilities: Capabilities + """The capabilities the virtual mailbox should support.""" + + +CapabilitiesForwardMailTo: TypeAlias = Union[ContactCreateWithFirstNameParam, ContactCreateWithCompanyNameParam, str] + + +class Capabilities(TypedDict, total=False): + """The capabilities the virtual mailbox should support.""" + + envelope_scans: Required[Annotated[bool, PropertyInfo(alias="envelopeScans")]] + """If the virtual mailbox should support envelope scans or not.""" + + forward_mail_to: Annotated[CapabilitiesForwardMailTo, PropertyInfo(alias="forwardMailTo")] + """A contact ID or contact object.""" diff --git a/src/postgrid/types/print_mail/virtual_mailbox_create_response.py b/src/postgrid/types/print_mail/virtual_mailbox_create_response.py new file mode 100644 index 0000000..3b75fd6 --- /dev/null +++ b/src/postgrid/types/print_mail/virtual_mailbox_create_response.py @@ -0,0 +1,60 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .contact import Contact +from ..._models import BaseModel + +__all__ = ["VirtualMailboxCreateResponse", "Capabilities"] + + +class Capabilities(BaseModel): + """All of the capabilities a virtual mailbox may have.""" + + envelope_scans: bool = FieldInfo(alias="envelopeScans") + """Indicates if the virtual mailbox can produce scans of envelopes.""" + + forward_mail_to: Optional[Contact] = FieldInfo(alias="forwardMailTo", default=None) + """A contact to forward any returned mail to.""" + + +class VirtualMailboxCreateResponse(BaseModel): + """The virtual mailbox object.""" + + id: str + """A unique ID prefixed with virtual*mailbox*""" + + capabilities: Capabilities + """All of the capabilities a virtual mailbox may have.""" + + country_code: Literal["US"] = FieldInfo(alias="countryCode") + """All of the supported countries for virtual mailboxes.""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + object: Literal["virtual_mailbox"] + """Always "virtual_mailbox".""" + + status: Literal["active", "pending_assignment"] + """The possible statuses of virtual mailboxes.""" + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" diff --git a/src/postgrid/types/print_mail/virtual_mailbox_list_params.py b/src/postgrid/types/print_mail/virtual_mailbox_list_params.py new file mode 100644 index 0000000..1ac4431 --- /dev/null +++ b/src/postgrid/types/print_mail/virtual_mailbox_list_params.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["VirtualMailboxListParams"] + + +class VirtualMailboxListParams(TypedDict, total=False): + limit: int + + search: str + """You can supply any string to help narrow down the list of resources. + + For example, if you pass `"New York"` (quoted), it will return resources that + have that string present somewhere in their response. Alternatively, you can + supply a structured search query. See the documentation on + `StructuredSearchQuery` for more details. + """ + + skip: int diff --git a/src/postgrid/types/print_mail/virtual_mailbox_list_response.py b/src/postgrid/types/print_mail/virtual_mailbox_list_response.py new file mode 100644 index 0000000..eb5b1b7 --- /dev/null +++ b/src/postgrid/types/print_mail/virtual_mailbox_list_response.py @@ -0,0 +1,60 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .contact import Contact +from ..._models import BaseModel + +__all__ = ["VirtualMailboxListResponse", "Capabilities"] + + +class Capabilities(BaseModel): + """All of the capabilities a virtual mailbox may have.""" + + envelope_scans: bool = FieldInfo(alias="envelopeScans") + """Indicates if the virtual mailbox can produce scans of envelopes.""" + + forward_mail_to: Optional[Contact] = FieldInfo(alias="forwardMailTo", default=None) + """A contact to forward any returned mail to.""" + + +class VirtualMailboxListResponse(BaseModel): + """The virtual mailbox object.""" + + id: str + """A unique ID prefixed with virtual*mailbox*""" + + capabilities: Capabilities + """All of the capabilities a virtual mailbox may have.""" + + country_code: Literal["US"] = FieldInfo(alias="countryCode") + """All of the supported countries for virtual mailboxes.""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + object: Literal["virtual_mailbox"] + """Always "virtual_mailbox".""" + + status: Literal["active", "pending_assignment"] + """The possible statuses of virtual mailboxes.""" + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" diff --git a/src/postgrid/types/print_mail/virtual_mailbox_retrieve_address_response.py b/src/postgrid/types/print_mail/virtual_mailbox_retrieve_address_response.py new file mode 100644 index 0000000..e1dd55c --- /dev/null +++ b/src/postgrid/types/print_mail/virtual_mailbox_retrieve_address_response.py @@ -0,0 +1,32 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ..._models import BaseModel + +__all__ = ["VirtualMailboxRetrieveAddressResponse"] + + +class VirtualMailboxRetrieveAddressResponse(BaseModel): + """The address information for a mailbox.""" + + address_line1: str = FieldInfo(alias="addressLine1") + """The address line 1 of the mailbox.""" + + country_code: Literal["US"] = FieldInfo(alias="countryCode") + """All of the supported countries for virtual mailboxes.""" + + address_line2: Optional[str] = FieldInfo(alias="addressLine2", default=None) + """The address line 2 of the mailbox.""" + + city: Optional[str] = None + """The city of the mailbox.""" + + postal_or_zip: Optional[str] = FieldInfo(alias="postalOrZip", default=None) + """The postal or ZIP code of the mailbox.""" + + province_or_state: Optional[str] = FieldInfo(alias="provinceOrState", default=None) + """The province or state of the mailbox.""" diff --git a/src/postgrid/types/print_mail/virtual_mailbox_retrieve_response.py b/src/postgrid/types/print_mail/virtual_mailbox_retrieve_response.py new file mode 100644 index 0000000..7ff0dce --- /dev/null +++ b/src/postgrid/types/print_mail/virtual_mailbox_retrieve_response.py @@ -0,0 +1,60 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from .contact import Contact +from ..._models import BaseModel + +__all__ = ["VirtualMailboxRetrieveResponse", "Capabilities"] + + +class Capabilities(BaseModel): + """All of the capabilities a virtual mailbox may have.""" + + envelope_scans: bool = FieldInfo(alias="envelopeScans") + """Indicates if the virtual mailbox can produce scans of envelopes.""" + + forward_mail_to: Optional[Contact] = FieldInfo(alias="forwardMailTo", default=None) + """A contact to forward any returned mail to.""" + + +class VirtualMailboxRetrieveResponse(BaseModel): + """The virtual mailbox object.""" + + id: str + """A unique ID prefixed with virtual*mailbox*""" + + capabilities: Capabilities + """All of the capabilities a virtual mailbox may have.""" + + country_code: Literal["US"] = FieldInfo(alias="countryCode") + """All of the supported countries for virtual mailboxes.""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + object: Literal["virtual_mailbox"] + """Always "virtual_mailbox".""" + + status: Literal["active", "pending_assignment"] + """The possible statuses of virtual mailboxes.""" + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" diff --git a/src/postgrid/types/print_mail/virtual_mailboxes/__init__.py b/src/postgrid/types/print_mail/virtual_mailboxes/__init__.py new file mode 100644 index 0000000..21f11f2 --- /dev/null +++ b/src/postgrid/types/print_mail/virtual_mailboxes/__init__.py @@ -0,0 +1,9 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .item_list_params import ItemListParams as ItemListParams +from .item_create_params import ItemCreateParams as ItemCreateParams +from .item_list_response import ItemListResponse as ItemListResponse +from .item_create_response import ItemCreateResponse as ItemCreateResponse +from .item_retrieve_response import ItemRetrieveResponse as ItemRetrieveResponse diff --git a/src/postgrid/types/print_mail/virtual_mailboxes/item_create_params.py b/src/postgrid/types/print_mail/virtual_mailboxes/item_create_params.py new file mode 100644 index 0000000..d248a82 --- /dev/null +++ b/src/postgrid/types/print_mail/virtual_mailboxes/item_create_params.py @@ -0,0 +1,21 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict +from typing_extensions import Annotated, TypedDict + +from ...._utils import PropertyInfo + +__all__ = ["ItemCreateParams"] + + +class ItemCreateParams(TypedDict, total=False): + description: str + """The description of the item.""" + + matched_letter: Annotated[str, PropertyInfo(alias="matchedLetter")] + """The ID of a letter to match this test item to.""" + + metadata: Dict[str, object] + """The metadata of the item.""" diff --git a/src/postgrid/types/print_mail/virtual_mailboxes/item_create_response.py b/src/postgrid/types/print_mail/virtual_mailboxes/item_create_response.py new file mode 100644 index 0000000..3e2301e --- /dev/null +++ b/src/postgrid/types/print_mail/virtual_mailboxes/item_create_response.py @@ -0,0 +1,49 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["ItemCreateResponse"] + + +class ItemCreateResponse(BaseModel): + """The virtual mailbox item object.""" + + id: str + """A unique ID prefixed with virtual*mailbox_item*""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + object: Literal["virtual_mailbox_item"] + """Always "virtual_mailbox_item".""" + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + virtual_mailbox: str = FieldInfo(alias="virtualMailbox") + """The ID of the virtual mailbox associated with this item.""" + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + file_url: Optional[str] = FieldInfo(alias="fileURL", default=None) + """A URL of the envelope scan PDF.""" + + matched_letter: Optional[str] = FieldInfo(alias="matchedLetter", default=None) + """The ID of the letter this item was matched to.""" + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" diff --git a/src/postgrid/types/print_mail/virtual_mailboxes/item_list_params.py b/src/postgrid/types/print_mail/virtual_mailboxes/item_list_params.py new file mode 100644 index 0000000..320bc2a --- /dev/null +++ b/src/postgrid/types/print_mail/virtual_mailboxes/item_list_params.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import TypedDict + +__all__ = ["ItemListParams"] + + +class ItemListParams(TypedDict, total=False): + limit: int + + search: str + """You can supply any string to help narrow down the list of resources. + + For example, if you pass `"New York"` (quoted), it will return resources that + have that string present somewhere in their response. Alternatively, you can + supply a structured search query. See the documentation on + `StructuredSearchQuery` for more details. + """ + + skip: int diff --git a/src/postgrid/types/print_mail/virtual_mailboxes/item_list_response.py b/src/postgrid/types/print_mail/virtual_mailboxes/item_list_response.py new file mode 100644 index 0000000..4d4b57b --- /dev/null +++ b/src/postgrid/types/print_mail/virtual_mailboxes/item_list_response.py @@ -0,0 +1,49 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["ItemListResponse"] + + +class ItemListResponse(BaseModel): + """The virtual mailbox item object.""" + + id: str + """A unique ID prefixed with virtual*mailbox_item*""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + object: Literal["virtual_mailbox_item"] + """Always "virtual_mailbox_item".""" + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + virtual_mailbox: str = FieldInfo(alias="virtualMailbox") + """The ID of the virtual mailbox associated with this item.""" + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + file_url: Optional[str] = FieldInfo(alias="fileURL", default=None) + """A URL of the envelope scan PDF.""" + + matched_letter: Optional[str] = FieldInfo(alias="matchedLetter", default=None) + """The ID of the letter this item was matched to.""" + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" diff --git a/src/postgrid/types/print_mail/virtual_mailboxes/item_retrieve_response.py b/src/postgrid/types/print_mail/virtual_mailboxes/item_retrieve_response.py new file mode 100644 index 0000000..44b2031 --- /dev/null +++ b/src/postgrid/types/print_mail/virtual_mailboxes/item_retrieve_response.py @@ -0,0 +1,49 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import builtins +from typing import Dict, Optional +from datetime import datetime +from typing_extensions import Literal + +from pydantic import Field as FieldInfo + +from ...._models import BaseModel + +__all__ = ["ItemRetrieveResponse"] + + +class ItemRetrieveResponse(BaseModel): + """The virtual mailbox item object.""" + + id: str + """A unique ID prefixed with virtual*mailbox_item*""" + + created_at: datetime = FieldInfo(alias="createdAt") + """The UTC time at which this resource was created.""" + + live: bool + """`true` if this is a live mode resource else `false`.""" + + object: Literal["virtual_mailbox_item"] + """Always "virtual_mailbox_item".""" + + updated_at: datetime = FieldInfo(alias="updatedAt") + """The UTC time at which this resource was last updated.""" + + virtual_mailbox: str = FieldInfo(alias="virtualMailbox") + """The ID of the virtual mailbox associated with this item.""" + + description: Optional[str] = None + """An optional string describing this resource. + + Will be visible in the API and the dashboard. + """ + + file_url: Optional[str] = FieldInfo(alias="fileURL", default=None) + """A URL of the envelope scan PDF.""" + + matched_letter: Optional[str] = FieldInfo(alias="matchedLetter", default=None) + """The ID of the letter this item was matched to.""" + + metadata: Optional[Dict[str, builtins.object]] = None + """See the section on Metadata.""" diff --git a/tests/api_resources/print_mail/targeted_list_builds/__init__.py b/tests/api_resources/print_mail/targeted_list_builds/__init__.py new file mode 100644 index 0000000..fd8019a --- /dev/null +++ b/tests/api_resources/print_mail/targeted_list_builds/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/print_mail/targeted_list_builds/test_filters.py b/tests/api_resources/print_mail/targeted_list_builds/test_filters.py new file mode 100644 index 0000000..43e5ab3 --- /dev/null +++ b/tests/api_resources/print_mail/targeted_list_builds/test_filters.py @@ -0,0 +1,112 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from postgrid import PostGrid, AsyncPostGrid +from tests.utils import assert_matches_type +from postgrid.types.print_mail.targeted_list_builds import FilterAutocompleteResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestFilters: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_autocomplete(self, client: PostGrid) -> None: + filter = client.print_mail.targeted_list_builds.filters.autocomplete( + field="industry", + ) + assert_matches_type(FilterAutocompleteResponse, filter, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_autocomplete_with_all_params(self, client: PostGrid) -> None: + filter = client.print_mail.targeted_list_builds.filters.autocomplete( + field="industry", + size=5, + text="soft", + ) + assert_matches_type(FilterAutocompleteResponse, filter, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_autocomplete(self, client: PostGrid) -> None: + response = client.print_mail.targeted_list_builds.filters.with_raw_response.autocomplete( + field="industry", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + filter = response.parse() + assert_matches_type(FilterAutocompleteResponse, filter, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_autocomplete(self, client: PostGrid) -> None: + with client.print_mail.targeted_list_builds.filters.with_streaming_response.autocomplete( + field="industry", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + filter = response.parse() + assert_matches_type(FilterAutocompleteResponse, filter, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncFilters: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_autocomplete(self, async_client: AsyncPostGrid) -> None: + filter = await async_client.print_mail.targeted_list_builds.filters.autocomplete( + field="industry", + ) + assert_matches_type(FilterAutocompleteResponse, filter, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_autocomplete_with_all_params(self, async_client: AsyncPostGrid) -> None: + filter = await async_client.print_mail.targeted_list_builds.filters.autocomplete( + field="industry", + size=5, + text="soft", + ) + assert_matches_type(FilterAutocompleteResponse, filter, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_autocomplete(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.targeted_list_builds.filters.with_raw_response.autocomplete( + field="industry", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + filter = await response.parse() + assert_matches_type(FilterAutocompleteResponse, filter, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_autocomplete(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.targeted_list_builds.filters.with_streaming_response.autocomplete( + field="industry", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + filter = await response.parse() + assert_matches_type(FilterAutocompleteResponse, filter, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/print_mail/test_boxes.py b/tests/api_resources/print_mail/test_boxes.py new file mode 100644 index 0000000..745bf85 --- /dev/null +++ b/tests/api_resources/print_mail/test_boxes.py @@ -0,0 +1,542 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from postgrid import PostGrid, AsyncPostGrid +from tests.utils import assert_matches_type +from postgrid._utils import parse_datetime +from postgrid.pagination import SyncSkipLimit, AsyncSkipLimit +from postgrid.types.print_mail import ( + BoxListResponse, + BoxCreateResponse, + BoxDeleteResponse, + BoxRetrieveResponse, + BoxProgressionsResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestBoxes: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create(self, client: PostGrid) -> None: + box = client.print_mail.boxes.create( + cheques=[ + { + "amount": 5000, + "bank_account": "bank_abc", + "from": "contact_456", + "number": 1042, + "to": "contact_123", + } + ], + from_="contact_456", + to="contact_123", + ) + assert_matches_type(BoxCreateResponse, box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: PostGrid) -> None: + box = client.print_mail.boxes.create( + cheques=[ + { + "amount": 5000, + "bank_account": "bank_abc", + "from": "contact_456", + "number": 1042, + "to": "contact_123", + "logo_url": "https://example.com", + "memo": "memo", + "merge_variables": {"foo": "bar"}, + "message_template": "messageTemplate", + } + ], + from_="contact_456", + to="contact_123", + description="description", + mailing_class="first_class", + merge_variables={"foo": "bar"}, + metadata={"foo": "bar"}, + send_date=parse_datetime("2019-12-27T18:11:19.117Z"), + ) + assert_matches_type(BoxCreateResponse, box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_create(self, client: PostGrid) -> None: + response = client.print_mail.boxes.with_raw_response.create( + cheques=[ + { + "amount": 5000, + "bank_account": "bank_abc", + "from": "contact_456", + "number": 1042, + "to": "contact_123", + } + ], + from_="contact_456", + to="contact_123", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + box = response.parse() + assert_matches_type(BoxCreateResponse, box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_create(self, client: PostGrid) -> None: + with client.print_mail.boxes.with_streaming_response.create( + cheques=[ + { + "amount": 5000, + "bank_account": "bank_abc", + "from": "contact_456", + "number": 1042, + "to": "contact_123", + } + ], + from_="contact_456", + to="contact_123", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + box = response.parse() + assert_matches_type(BoxCreateResponse, box, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve(self, client: PostGrid) -> None: + box = client.print_mail.boxes.retrieve( + "id", + ) + assert_matches_type(BoxRetrieveResponse, box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: PostGrid) -> None: + response = client.print_mail.boxes.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + box = response.parse() + assert_matches_type(BoxRetrieveResponse, box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: PostGrid) -> None: + with client.print_mail.boxes.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + box = response.parse() + assert_matches_type(BoxRetrieveResponse, box, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.boxes.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list(self, client: PostGrid) -> None: + box = client.print_mail.boxes.list() + assert_matches_type(SyncSkipLimit[BoxListResponse], box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: PostGrid) -> None: + box = client.print_mail.boxes.list( + limit=0, + search="search", + skip=0, + ) + assert_matches_type(SyncSkipLimit[BoxListResponse], box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_list(self, client: PostGrid) -> None: + response = client.print_mail.boxes.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + box = response.parse() + assert_matches_type(SyncSkipLimit[BoxListResponse], box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_list(self, client: PostGrid) -> None: + with client.print_mail.boxes.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + box = response.parse() + assert_matches_type(SyncSkipLimit[BoxListResponse], box, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_delete(self, client: PostGrid) -> None: + box = client.print_mail.boxes.delete( + "id", + ) + assert_matches_type(BoxDeleteResponse, box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_delete(self, client: PostGrid) -> None: + response = client.print_mail.boxes.with_raw_response.delete( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + box = response.parse() + assert_matches_type(BoxDeleteResponse, box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: PostGrid) -> None: + with client.print_mail.boxes.with_streaming_response.delete( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + box = response.parse() + assert_matches_type(BoxDeleteResponse, box, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_delete(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.boxes.with_raw_response.delete( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_progressions(self, client: PostGrid) -> None: + box = client.print_mail.boxes.progressions( + "id", + ) + assert_matches_type(BoxProgressionsResponse, box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_progressions(self, client: PostGrid) -> None: + response = client.print_mail.boxes.with_raw_response.progressions( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + box = response.parse() + assert_matches_type(BoxProgressionsResponse, box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_progressions(self, client: PostGrid) -> None: + with client.print_mail.boxes.with_streaming_response.progressions( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + box = response.parse() + assert_matches_type(BoxProgressionsResponse, box, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_progressions(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.boxes.with_raw_response.progressions( + "", + ) + + +class TestAsyncBoxes: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncPostGrid) -> None: + box = await async_client.print_mail.boxes.create( + cheques=[ + { + "amount": 5000, + "bank_account": "bank_abc", + "from": "contact_456", + "number": 1042, + "to": "contact_123", + } + ], + from_="contact_456", + to="contact_123", + ) + assert_matches_type(BoxCreateResponse, box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncPostGrid) -> None: + box = await async_client.print_mail.boxes.create( + cheques=[ + { + "amount": 5000, + "bank_account": "bank_abc", + "from": "contact_456", + "number": 1042, + "to": "contact_123", + "logo_url": "https://example.com", + "memo": "memo", + "merge_variables": {"foo": "bar"}, + "message_template": "messageTemplate", + } + ], + from_="contact_456", + to="contact_123", + description="description", + mailing_class="first_class", + merge_variables={"foo": "bar"}, + metadata={"foo": "bar"}, + send_date=parse_datetime("2019-12-27T18:11:19.117Z"), + ) + assert_matches_type(BoxCreateResponse, box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.boxes.with_raw_response.create( + cheques=[ + { + "amount": 5000, + "bank_account": "bank_abc", + "from": "contact_456", + "number": 1042, + "to": "contact_123", + } + ], + from_="contact_456", + to="contact_123", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + box = await response.parse() + assert_matches_type(BoxCreateResponse, box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.boxes.with_streaming_response.create( + cheques=[ + { + "amount": 5000, + "bank_account": "bank_abc", + "from": "contact_456", + "number": 1042, + "to": "contact_123", + } + ], + from_="contact_456", + to="contact_123", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + box = await response.parse() + assert_matches_type(BoxCreateResponse, box, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncPostGrid) -> None: + box = await async_client.print_mail.boxes.retrieve( + "id", + ) + assert_matches_type(BoxRetrieveResponse, box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.boxes.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + box = await response.parse() + assert_matches_type(BoxRetrieveResponse, box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.boxes.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + box = await response.parse() + assert_matches_type(BoxRetrieveResponse, box, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.boxes.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncPostGrid) -> None: + box = await async_client.print_mail.boxes.list() + assert_matches_type(AsyncSkipLimit[BoxListResponse], box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncPostGrid) -> None: + box = await async_client.print_mail.boxes.list( + limit=0, + search="search", + skip=0, + ) + assert_matches_type(AsyncSkipLimit[BoxListResponse], box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.boxes.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + box = await response.parse() + assert_matches_type(AsyncSkipLimit[BoxListResponse], box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.boxes.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + box = await response.parse() + assert_matches_type(AsyncSkipLimit[BoxListResponse], box, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncPostGrid) -> None: + box = await async_client.print_mail.boxes.delete( + "id", + ) + assert_matches_type(BoxDeleteResponse, box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.boxes.with_raw_response.delete( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + box = await response.parse() + assert_matches_type(BoxDeleteResponse, box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.boxes.with_streaming_response.delete( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + box = await response.parse() + assert_matches_type(BoxDeleteResponse, box, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.boxes.with_raw_response.delete( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_progressions(self, async_client: AsyncPostGrid) -> None: + box = await async_client.print_mail.boxes.progressions( + "id", + ) + assert_matches_type(BoxProgressionsResponse, box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_progressions(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.boxes.with_raw_response.progressions( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + box = await response.parse() + assert_matches_type(BoxProgressionsResponse, box, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_progressions(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.boxes.with_streaming_response.progressions( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + box = await response.parse() + assert_matches_type(BoxProgressionsResponse, box, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_progressions(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.boxes.with_raw_response.progressions( + "", + ) diff --git a/tests/api_resources/print_mail/test_cheques.py b/tests/api_resources/print_mail/test_cheques.py index 0be01a9..a981f5e 100644 --- a/tests/api_resources/print_mail/test_cheques.py +++ b/tests/api_resources/print_mail/test_cheques.py @@ -229,6 +229,94 @@ def test_path_params_delete(self, client: PostGrid) -> None: "", ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_cancel(self, client: PostGrid) -> None: + cheque = client.print_mail.cheques.cancel( + id="id", + note="Cancelling this cheque", + ) + assert_matches_type(Cheque, cheque, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_cancel(self, client: PostGrid) -> None: + response = client.print_mail.cheques.with_raw_response.cancel( + id="id", + note="Cancelling this cheque", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cheque = response.parse() + assert_matches_type(Cheque, cheque, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_cancel(self, client: PostGrid) -> None: + with client.print_mail.cheques.with_streaming_response.cancel( + id="id", + note="Cancelling this cheque", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cheque = response.parse() + assert_matches_type(Cheque, cheque, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_cancel(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.cheques.with_raw_response.cancel( + id="", + note="Cancelling this cheque", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_progress(self, client: PostGrid) -> None: + cheque = client.print_mail.cheques.progress( + "id", + ) + assert_matches_type(Cheque, cheque, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_progress(self, client: PostGrid) -> None: + response = client.print_mail.cheques.with_raw_response.progress( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cheque = response.parse() + assert_matches_type(Cheque, cheque, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_progress(self, client: PostGrid) -> None: + with client.print_mail.cheques.with_streaming_response.progress( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cheque = response.parse() + assert_matches_type(Cheque, cheque, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_progress(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.cheques.with_raw_response.progress( + "", + ) + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_retrieve_url(self, client: PostGrid) -> None: @@ -526,6 +614,94 @@ async def test_path_params_delete(self, async_client: AsyncPostGrid) -> None: "", ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_cancel(self, async_client: AsyncPostGrid) -> None: + cheque = await async_client.print_mail.cheques.cancel( + id="id", + note="Cancelling this cheque", + ) + assert_matches_type(Cheque, cheque, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_cancel(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.cheques.with_raw_response.cancel( + id="id", + note="Cancelling this cheque", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cheque = await response.parse() + assert_matches_type(Cheque, cheque, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_cancel(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.cheques.with_streaming_response.cancel( + id="id", + note="Cancelling this cheque", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cheque = await response.parse() + assert_matches_type(Cheque, cheque, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_cancel(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.cheques.with_raw_response.cancel( + id="", + note="Cancelling this cheque", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_progress(self, async_client: AsyncPostGrid) -> None: + cheque = await async_client.print_mail.cheques.progress( + "id", + ) + assert_matches_type(Cheque, cheque, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_progress(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.cheques.with_raw_response.progress( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + cheque = await response.parse() + assert_matches_type(Cheque, cheque, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_progress(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.cheques.with_streaming_response.progress( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + cheque = await response.parse() + assert_matches_type(Cheque, cheque, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_progress(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.cheques.with_raw_response.progress( + "", + ) + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_retrieve_url(self, async_client: AsyncPostGrid) -> None: diff --git a/tests/api_resources/print_mail/test_letters.py b/tests/api_resources/print_mail/test_letters.py index 1e80308..8e266ce 100644 --- a/tests/api_resources/print_mail/test_letters.py +++ b/tests/api_resources/print_mail/test_letters.py @@ -456,6 +456,94 @@ def test_path_params_delete(self, client: PostGrid) -> None: "", ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_cancel(self, client: PostGrid) -> None: + letter = client.print_mail.letters.cancel( + id="id", + note="Cancelling this letter", + ) + assert_matches_type(Letter, letter, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_cancel(self, client: PostGrid) -> None: + response = client.print_mail.letters.with_raw_response.cancel( + id="id", + note="Cancelling this letter", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + letter = response.parse() + assert_matches_type(Letter, letter, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_cancel(self, client: PostGrid) -> None: + with client.print_mail.letters.with_streaming_response.cancel( + id="id", + note="Cancelling this letter", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + letter = response.parse() + assert_matches_type(Letter, letter, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_cancel(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.letters.with_raw_response.cancel( + id="", + note="Cancelling this letter", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_progress(self, client: PostGrid) -> None: + letter = client.print_mail.letters.progress( + "id", + ) + assert_matches_type(Letter, letter, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_progress(self, client: PostGrid) -> None: + response = client.print_mail.letters.with_raw_response.progress( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + letter = response.parse() + assert_matches_type(Letter, letter, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_progress(self, client: PostGrid) -> None: + with client.print_mail.letters.with_streaming_response.progress( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + letter = response.parse() + assert_matches_type(Letter, letter, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_progress(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.letters.with_raw_response.progress( + "", + ) + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_retrieve_url(self, client: PostGrid) -> None: @@ -938,6 +1026,94 @@ async def test_path_params_delete(self, async_client: AsyncPostGrid) -> None: "", ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_cancel(self, async_client: AsyncPostGrid) -> None: + letter = await async_client.print_mail.letters.cancel( + id="id", + note="Cancelling this letter", + ) + assert_matches_type(Letter, letter, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_cancel(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.letters.with_raw_response.cancel( + id="id", + note="Cancelling this letter", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + letter = await response.parse() + assert_matches_type(Letter, letter, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_cancel(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.letters.with_streaming_response.cancel( + id="id", + note="Cancelling this letter", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + letter = await response.parse() + assert_matches_type(Letter, letter, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_cancel(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.letters.with_raw_response.cancel( + id="", + note="Cancelling this letter", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_progress(self, async_client: AsyncPostGrid) -> None: + letter = await async_client.print_mail.letters.progress( + "id", + ) + assert_matches_type(Letter, letter, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_progress(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.letters.with_raw_response.progress( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + letter = await response.parse() + assert_matches_type(Letter, letter, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_progress(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.letters.with_streaming_response.progress( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + letter = await response.parse() + assert_matches_type(Letter, letter, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_progress(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.letters.with_raw_response.progress( + "", + ) + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_retrieve_url(self, async_client: AsyncPostGrid) -> None: diff --git a/tests/api_resources/print_mail/test_postcards.py b/tests/api_resources/print_mail/test_postcards.py index cb47fc4..fa3b112 100644 --- a/tests/api_resources/print_mail/test_postcards.py +++ b/tests/api_resources/print_mail/test_postcards.py @@ -494,6 +494,94 @@ def test_path_params_delete(self, client: PostGrid) -> None: "", ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_cancel(self, client: PostGrid) -> None: + postcard = client.print_mail.postcards.cancel( + id="id", + note="Cancelling this postcard", + ) + assert_matches_type(Postcard, postcard, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_cancel(self, client: PostGrid) -> None: + response = client.print_mail.postcards.with_raw_response.cancel( + id="id", + note="Cancelling this postcard", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + postcard = response.parse() + assert_matches_type(Postcard, postcard, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_cancel(self, client: PostGrid) -> None: + with client.print_mail.postcards.with_streaming_response.cancel( + id="id", + note="Cancelling this postcard", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + postcard = response.parse() + assert_matches_type(Postcard, postcard, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_cancel(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.postcards.with_raw_response.cancel( + id="", + note="Cancelling this postcard", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_progress(self, client: PostGrid) -> None: + postcard = client.print_mail.postcards.progress( + "id", + ) + assert_matches_type(Postcard, postcard, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_progress(self, client: PostGrid) -> None: + response = client.print_mail.postcards.with_raw_response.progress( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + postcard = response.parse() + assert_matches_type(Postcard, postcard, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_progress(self, client: PostGrid) -> None: + with client.print_mail.postcards.with_streaming_response.progress( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + postcard = response.parse() + assert_matches_type(Postcard, postcard, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_progress(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.postcards.with_raw_response.progress( + "", + ) + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_retrieve_url(self, client: PostGrid) -> None: @@ -1014,6 +1102,94 @@ async def test_path_params_delete(self, async_client: AsyncPostGrid) -> None: "", ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_cancel(self, async_client: AsyncPostGrid) -> None: + postcard = await async_client.print_mail.postcards.cancel( + id="id", + note="Cancelling this postcard", + ) + assert_matches_type(Postcard, postcard, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_cancel(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.postcards.with_raw_response.cancel( + id="id", + note="Cancelling this postcard", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + postcard = await response.parse() + assert_matches_type(Postcard, postcard, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_cancel(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.postcards.with_streaming_response.cancel( + id="id", + note="Cancelling this postcard", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + postcard = await response.parse() + assert_matches_type(Postcard, postcard, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_cancel(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.postcards.with_raw_response.cancel( + id="", + note="Cancelling this postcard", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_progress(self, async_client: AsyncPostGrid) -> None: + postcard = await async_client.print_mail.postcards.progress( + "id", + ) + assert_matches_type(Postcard, postcard, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_progress(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.postcards.with_raw_response.progress( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + postcard = await response.parse() + assert_matches_type(Postcard, postcard, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_progress(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.postcards.with_streaming_response.progress( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + postcard = await response.parse() + assert_matches_type(Postcard, postcard, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_progress(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.postcards.with_raw_response.progress( + "", + ) + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_retrieve_url(self, async_client: AsyncPostGrid) -> None: diff --git a/tests/api_resources/print_mail/test_self_mailers.py b/tests/api_resources/print_mail/test_self_mailers.py index d3ef9cb..f8755da 100644 --- a/tests/api_resources/print_mail/test_self_mailers.py +++ b/tests/api_resources/print_mail/test_self_mailers.py @@ -536,6 +536,48 @@ def test_path_params_delete(self, client: PostGrid) -> None: "", ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_progress(self, client: PostGrid) -> None: + self_mailer = client.print_mail.self_mailers.progress( + "id", + ) + assert_matches_type(SelfMailer, self_mailer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_progress(self, client: PostGrid) -> None: + response = client.print_mail.self_mailers.with_raw_response.progress( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + self_mailer = response.parse() + assert_matches_type(SelfMailer, self_mailer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_progress(self, client: PostGrid) -> None: + with client.print_mail.self_mailers.with_streaming_response.progress( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + self_mailer = response.parse() + assert_matches_type(SelfMailer, self_mailer, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_progress(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.self_mailers.with_raw_response.progress( + "", + ) + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_retrieve_url(self, client: PostGrid) -> None: @@ -1098,6 +1140,48 @@ async def test_path_params_delete(self, async_client: AsyncPostGrid) -> None: "", ) + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_progress(self, async_client: AsyncPostGrid) -> None: + self_mailer = await async_client.print_mail.self_mailers.progress( + "id", + ) + assert_matches_type(SelfMailer, self_mailer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_progress(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.self_mailers.with_raw_response.progress( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + self_mailer = await response.parse() + assert_matches_type(SelfMailer, self_mailer, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_progress(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.self_mailers.with_streaming_response.progress( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + self_mailer = await response.parse() + assert_matches_type(SelfMailer, self_mailer, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_progress(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.self_mailers.with_raw_response.progress( + "", + ) + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_retrieve_url(self, async_client: AsyncPostGrid) -> None: diff --git a/tests/api_resources/print_mail/test_snap_packs.py b/tests/api_resources/print_mail/test_snap_packs.py new file mode 100644 index 0000000..7e849f9 --- /dev/null +++ b/tests/api_resources/print_mail/test_snap_packs.py @@ -0,0 +1,1167 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from postgrid import PostGrid, AsyncPostGrid +from tests.utils import assert_matches_type +from postgrid._utils import parse_datetime +from postgrid.pagination import SyncSkipLimit, AsyncSkipLimit +from postgrid.types.print_mail import ( + SnapPackListResponse, + SnapPackCreateResponse, + SnapPackDeleteResponse, + SnapPackRetrieveResponse, + SnapPackProgressionsResponse, + SnapPackRetrieveCapabilitiesResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSnapPacks: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_overload_1(self, client: PostGrid) -> None: + snap_pack = client.print_mail.snap_packs.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + inside_html="insideHTML", + outside_html="outsideHTML", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + ) + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_with_all_params_overload_1(self, client: PostGrid) -> None: + snap_pack = client.print_mail.snap_packs.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + "address_line2": "addressLine2", + "city": "city", + "company_name": "companyName", + "description": "description", + "email": "email", + "force_verified_status": True, + "job_title": "jobTitle", + "last_name": "lastName", + "metadata": {"foo": "bar"}, + "phone_number": "phoneNumber", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + "skip_verification": True, + }, + inside_html="insideHTML", + outside_html="outsideHTML", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + "address_line2": "addressLine2", + "city": "city", + "company_name": "companyName", + "description": "description", + "email": "email", + "force_verified_status": True, + "job_title": "jobTitle", + "last_name": "lastName", + "metadata": {"foo": "bar"}, + "phone_number": "phoneNumber", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + "skip_verification": True, + }, + description="description", + mailing_class="first_class", + merge_variables={"foo": "bar"}, + metadata={"foo": "bar"}, + send_date=parse_datetime("2019-12-27T18:11:19.117Z"), + ) + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_create_overload_1(self, client: PostGrid) -> None: + response = client.print_mail.snap_packs.with_raw_response.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + inside_html="insideHTML", + outside_html="outsideHTML", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snap_pack = response.parse() + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_create_overload_1(self, client: PostGrid) -> None: + with client.print_mail.snap_packs.with_streaming_response.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + inside_html="insideHTML", + outside_html="outsideHTML", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snap_pack = response.parse() + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_overload_2(self, client: PostGrid) -> None: + snap_pack = client.print_mail.snap_packs.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + inside_template="insideTemplate", + outside_template="outsideTemplate", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + ) + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_with_all_params_overload_2(self, client: PostGrid) -> None: + snap_pack = client.print_mail.snap_packs.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + "address_line2": "addressLine2", + "city": "city", + "company_name": "companyName", + "description": "description", + "email": "email", + "force_verified_status": True, + "job_title": "jobTitle", + "last_name": "lastName", + "metadata": {"foo": "bar"}, + "phone_number": "phoneNumber", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + "skip_verification": True, + }, + inside_template="insideTemplate", + outside_template="outsideTemplate", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + "address_line2": "addressLine2", + "city": "city", + "company_name": "companyName", + "description": "description", + "email": "email", + "force_verified_status": True, + "job_title": "jobTitle", + "last_name": "lastName", + "metadata": {"foo": "bar"}, + "phone_number": "phoneNumber", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + "skip_verification": True, + }, + description="description", + mailing_class="first_class", + merge_variables={"foo": "bar"}, + metadata={"foo": "bar"}, + send_date=parse_datetime("2019-12-27T18:11:19.117Z"), + ) + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_create_overload_2(self, client: PostGrid) -> None: + response = client.print_mail.snap_packs.with_raw_response.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + inside_template="insideTemplate", + outside_template="outsideTemplate", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snap_pack = response.parse() + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_create_overload_2(self, client: PostGrid) -> None: + with client.print_mail.snap_packs.with_streaming_response.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + inside_template="insideTemplate", + outside_template="outsideTemplate", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snap_pack = response.parse() + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_overload_3(self, client: PostGrid) -> None: + snap_pack = client.print_mail.snap_packs.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + pdf="https://example.com", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + ) + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_with_all_params_overload_3(self, client: PostGrid) -> None: + snap_pack = client.print_mail.snap_packs.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + "address_line2": "addressLine2", + "city": "city", + "company_name": "companyName", + "description": "description", + "email": "email", + "force_verified_status": True, + "job_title": "jobTitle", + "last_name": "lastName", + "metadata": {"foo": "bar"}, + "phone_number": "phoneNumber", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + "skip_verification": True, + }, + pdf="https://example.com", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + "address_line2": "addressLine2", + "city": "city", + "company_name": "companyName", + "description": "description", + "email": "email", + "force_verified_status": True, + "job_title": "jobTitle", + "last_name": "lastName", + "metadata": {"foo": "bar"}, + "phone_number": "phoneNumber", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + "skip_verification": True, + }, + description="description", + mailing_class="first_class", + merge_variables={"foo": "bar"}, + metadata={"foo": "bar"}, + send_date=parse_datetime("2019-12-27T18:11:19.117Z"), + ) + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_create_overload_3(self, client: PostGrid) -> None: + response = client.print_mail.snap_packs.with_raw_response.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + pdf="https://example.com", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snap_pack = response.parse() + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_create_overload_3(self, client: PostGrid) -> None: + with client.print_mail.snap_packs.with_streaming_response.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + pdf="https://example.com", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snap_pack = response.parse() + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve(self, client: PostGrid) -> None: + snap_pack = client.print_mail.snap_packs.retrieve( + "id", + ) + assert_matches_type(SnapPackRetrieveResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: PostGrid) -> None: + response = client.print_mail.snap_packs.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snap_pack = response.parse() + assert_matches_type(SnapPackRetrieveResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: PostGrid) -> None: + with client.print_mail.snap_packs.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snap_pack = response.parse() + assert_matches_type(SnapPackRetrieveResponse, snap_pack, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.snap_packs.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list(self, client: PostGrid) -> None: + snap_pack = client.print_mail.snap_packs.list() + assert_matches_type(SyncSkipLimit[SnapPackListResponse], snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: PostGrid) -> None: + snap_pack = client.print_mail.snap_packs.list( + limit=0, + search="search", + skip=0, + ) + assert_matches_type(SyncSkipLimit[SnapPackListResponse], snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_list(self, client: PostGrid) -> None: + response = client.print_mail.snap_packs.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snap_pack = response.parse() + assert_matches_type(SyncSkipLimit[SnapPackListResponse], snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_list(self, client: PostGrid) -> None: + with client.print_mail.snap_packs.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snap_pack = response.parse() + assert_matches_type(SyncSkipLimit[SnapPackListResponse], snap_pack, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_delete(self, client: PostGrid) -> None: + snap_pack = client.print_mail.snap_packs.delete( + "id", + ) + assert_matches_type(SnapPackDeleteResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_delete(self, client: PostGrid) -> None: + response = client.print_mail.snap_packs.with_raw_response.delete( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snap_pack = response.parse() + assert_matches_type(SnapPackDeleteResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: PostGrid) -> None: + with client.print_mail.snap_packs.with_streaming_response.delete( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snap_pack = response.parse() + assert_matches_type(SnapPackDeleteResponse, snap_pack, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_delete(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.snap_packs.with_raw_response.delete( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_progressions(self, client: PostGrid) -> None: + snap_pack = client.print_mail.snap_packs.progressions( + "id", + ) + assert_matches_type(SnapPackProgressionsResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_progressions(self, client: PostGrid) -> None: + response = client.print_mail.snap_packs.with_raw_response.progressions( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snap_pack = response.parse() + assert_matches_type(SnapPackProgressionsResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_progressions(self, client: PostGrid) -> None: + with client.print_mail.snap_packs.with_streaming_response.progressions( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snap_pack = response.parse() + assert_matches_type(SnapPackProgressionsResponse, snap_pack, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_progressions(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.snap_packs.with_raw_response.progressions( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve_capabilities(self, client: PostGrid) -> None: + snap_pack = client.print_mail.snap_packs.retrieve_capabilities( + return_country_code="returnCountryCode", + ) + assert_matches_type(SnapPackRetrieveCapabilitiesResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve_capabilities_with_all_params(self, client: PostGrid) -> None: + snap_pack = client.print_mail.snap_packs.retrieve_capabilities( + return_country_code="returnCountryCode", + destination_country_code="destinationCountryCode", + mailing_list="mailingList", + ) + assert_matches_type(SnapPackRetrieveCapabilitiesResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_retrieve_capabilities(self, client: PostGrid) -> None: + response = client.print_mail.snap_packs.with_raw_response.retrieve_capabilities( + return_country_code="returnCountryCode", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snap_pack = response.parse() + assert_matches_type(SnapPackRetrieveCapabilitiesResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_retrieve_capabilities(self, client: PostGrid) -> None: + with client.print_mail.snap_packs.with_streaming_response.retrieve_capabilities( + return_country_code="returnCountryCode", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snap_pack = response.parse() + assert_matches_type(SnapPackRetrieveCapabilitiesResponse, snap_pack, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncSnapPacks: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_overload_1(self, async_client: AsyncPostGrid) -> None: + snap_pack = await async_client.print_mail.snap_packs.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + inside_html="insideHTML", + outside_html="outsideHTML", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + ) + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_with_all_params_overload_1(self, async_client: AsyncPostGrid) -> None: + snap_pack = await async_client.print_mail.snap_packs.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + "address_line2": "addressLine2", + "city": "city", + "company_name": "companyName", + "description": "description", + "email": "email", + "force_verified_status": True, + "job_title": "jobTitle", + "last_name": "lastName", + "metadata": {"foo": "bar"}, + "phone_number": "phoneNumber", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + "skip_verification": True, + }, + inside_html="insideHTML", + outside_html="outsideHTML", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + "address_line2": "addressLine2", + "city": "city", + "company_name": "companyName", + "description": "description", + "email": "email", + "force_verified_status": True, + "job_title": "jobTitle", + "last_name": "lastName", + "metadata": {"foo": "bar"}, + "phone_number": "phoneNumber", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + "skip_verification": True, + }, + description="description", + mailing_class="first_class", + merge_variables={"foo": "bar"}, + metadata={"foo": "bar"}, + send_date=parse_datetime("2019-12-27T18:11:19.117Z"), + ) + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_create_overload_1(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.snap_packs.with_raw_response.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + inside_html="insideHTML", + outside_html="outsideHTML", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snap_pack = await response.parse() + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_create_overload_1(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.snap_packs.with_streaming_response.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + inside_html="insideHTML", + outside_html="outsideHTML", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snap_pack = await response.parse() + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_overload_2(self, async_client: AsyncPostGrid) -> None: + snap_pack = await async_client.print_mail.snap_packs.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + inside_template="insideTemplate", + outside_template="outsideTemplate", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + ) + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_with_all_params_overload_2(self, async_client: AsyncPostGrid) -> None: + snap_pack = await async_client.print_mail.snap_packs.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + "address_line2": "addressLine2", + "city": "city", + "company_name": "companyName", + "description": "description", + "email": "email", + "force_verified_status": True, + "job_title": "jobTitle", + "last_name": "lastName", + "metadata": {"foo": "bar"}, + "phone_number": "phoneNumber", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + "skip_verification": True, + }, + inside_template="insideTemplate", + outside_template="outsideTemplate", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + "address_line2": "addressLine2", + "city": "city", + "company_name": "companyName", + "description": "description", + "email": "email", + "force_verified_status": True, + "job_title": "jobTitle", + "last_name": "lastName", + "metadata": {"foo": "bar"}, + "phone_number": "phoneNumber", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + "skip_verification": True, + }, + description="description", + mailing_class="first_class", + merge_variables={"foo": "bar"}, + metadata={"foo": "bar"}, + send_date=parse_datetime("2019-12-27T18:11:19.117Z"), + ) + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_create_overload_2(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.snap_packs.with_raw_response.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + inside_template="insideTemplate", + outside_template="outsideTemplate", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snap_pack = await response.parse() + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_create_overload_2(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.snap_packs.with_streaming_response.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + inside_template="insideTemplate", + outside_template="outsideTemplate", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snap_pack = await response.parse() + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_overload_3(self, async_client: AsyncPostGrid) -> None: + snap_pack = await async_client.print_mail.snap_packs.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + pdf="https://example.com", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + ) + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_with_all_params_overload_3(self, async_client: AsyncPostGrid) -> None: + snap_pack = await async_client.print_mail.snap_packs.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + "address_line2": "addressLine2", + "city": "city", + "company_name": "companyName", + "description": "description", + "email": "email", + "force_verified_status": True, + "job_title": "jobTitle", + "last_name": "lastName", + "metadata": {"foo": "bar"}, + "phone_number": "phoneNumber", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + "skip_verification": True, + }, + pdf="https://example.com", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + "address_line2": "addressLine2", + "city": "city", + "company_name": "companyName", + "description": "description", + "email": "email", + "force_verified_status": True, + "job_title": "jobTitle", + "last_name": "lastName", + "metadata": {"foo": "bar"}, + "phone_number": "phoneNumber", + "postal_or_zip": "postalOrZip", + "province_or_state": "provinceOrState", + "skip_verification": True, + }, + description="description", + mailing_class="first_class", + merge_variables={"foo": "bar"}, + metadata={"foo": "bar"}, + send_date=parse_datetime("2019-12-27T18:11:19.117Z"), + ) + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_create_overload_3(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.snap_packs.with_raw_response.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + pdf="https://example.com", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snap_pack = await response.parse() + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_create_overload_3(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.snap_packs.with_streaming_response.create( + from_={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + pdf="https://example.com", + size="8.5x11_bifold_v", + to={ + "address_line1": "addressLine1", + "country_code": "countryCode", + "first_name": "firstName", + }, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snap_pack = await response.parse() + assert_matches_type(SnapPackCreateResponse, snap_pack, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncPostGrid) -> None: + snap_pack = await async_client.print_mail.snap_packs.retrieve( + "id", + ) + assert_matches_type(SnapPackRetrieveResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.snap_packs.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snap_pack = await response.parse() + assert_matches_type(SnapPackRetrieveResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.snap_packs.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snap_pack = await response.parse() + assert_matches_type(SnapPackRetrieveResponse, snap_pack, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.snap_packs.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncPostGrid) -> None: + snap_pack = await async_client.print_mail.snap_packs.list() + assert_matches_type(AsyncSkipLimit[SnapPackListResponse], snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncPostGrid) -> None: + snap_pack = await async_client.print_mail.snap_packs.list( + limit=0, + search="search", + skip=0, + ) + assert_matches_type(AsyncSkipLimit[SnapPackListResponse], snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.snap_packs.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snap_pack = await response.parse() + assert_matches_type(AsyncSkipLimit[SnapPackListResponse], snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.snap_packs.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snap_pack = await response.parse() + assert_matches_type(AsyncSkipLimit[SnapPackListResponse], snap_pack, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncPostGrid) -> None: + snap_pack = await async_client.print_mail.snap_packs.delete( + "id", + ) + assert_matches_type(SnapPackDeleteResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.snap_packs.with_raw_response.delete( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snap_pack = await response.parse() + assert_matches_type(SnapPackDeleteResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.snap_packs.with_streaming_response.delete( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snap_pack = await response.parse() + assert_matches_type(SnapPackDeleteResponse, snap_pack, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.snap_packs.with_raw_response.delete( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_progressions(self, async_client: AsyncPostGrid) -> None: + snap_pack = await async_client.print_mail.snap_packs.progressions( + "id", + ) + assert_matches_type(SnapPackProgressionsResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_progressions(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.snap_packs.with_raw_response.progressions( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snap_pack = await response.parse() + assert_matches_type(SnapPackProgressionsResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_progressions(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.snap_packs.with_streaming_response.progressions( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snap_pack = await response.parse() + assert_matches_type(SnapPackProgressionsResponse, snap_pack, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_progressions(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.snap_packs.with_raw_response.progressions( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve_capabilities(self, async_client: AsyncPostGrid) -> None: + snap_pack = await async_client.print_mail.snap_packs.retrieve_capabilities( + return_country_code="returnCountryCode", + ) + assert_matches_type(SnapPackRetrieveCapabilitiesResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve_capabilities_with_all_params(self, async_client: AsyncPostGrid) -> None: + snap_pack = await async_client.print_mail.snap_packs.retrieve_capabilities( + return_country_code="returnCountryCode", + destination_country_code="destinationCountryCode", + mailing_list="mailingList", + ) + assert_matches_type(SnapPackRetrieveCapabilitiesResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_retrieve_capabilities(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.snap_packs.with_raw_response.retrieve_capabilities( + return_country_code="returnCountryCode", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + snap_pack = await response.parse() + assert_matches_type(SnapPackRetrieveCapabilitiesResponse, snap_pack, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_retrieve_capabilities(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.snap_packs.with_streaming_response.retrieve_capabilities( + return_country_code="returnCountryCode", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + snap_pack = await response.parse() + assert_matches_type(SnapPackRetrieveCapabilitiesResponse, snap_pack, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/print_mail/test_targeted_list_builds.py b/tests/api_resources/print_mail/test_targeted_list_builds.py new file mode 100644 index 0000000..e632bc3 --- /dev/null +++ b/tests/api_resources/print_mail/test_targeted_list_builds.py @@ -0,0 +1,640 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from postgrid import PostGrid, AsyncPostGrid +from tests.utils import assert_matches_type +from postgrid.pagination import SyncSkipLimit, AsyncSkipLimit +from postgrid.types.print_mail import ( + TargetedListBuildListResponse, + TargetedListBuildCreateResponse, + TargetedListBuildDeleteResponse, + TargetedListBuildUpdateResponse, + TargetedListBuildConfirmResponse, + TargetedListBuildRetrieveResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestTargetedListBuilds: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create(self, client: PostGrid) -> None: + targeted_list_build = client.print_mail.targeted_list_builds.create() + assert_matches_type(TargetedListBuildCreateResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: PostGrid) -> None: + targeted_list_build = client.print_mail.targeted_list_builds.create( + description="Q1 prospecting list", + limit=1000, + metadata={"campaign": "bar"}, + us_companies={ + "postal_codes": ["10001", "10002"], + "company_types": ["public"], + "employee_count": [10, 500], + "founded_year": [1600, 1600], + "industries": ["software"], + "naics_codes": ["string"], + "tags": ["string"], + }, + us_consumers={ + "age_range": [18, 18], + "city_states": ["string"], + "education_levels": ["high_school"], + "gender": "male", + "home_value_range": [0, 0], + "income_range": [0, 0], + "num_children_range": [0, 0], + "occupations": ["professional_technical"], + "zip_codes": ["string"], + "zip_codes_around": { + "radius_in_miles": 0.1, + "zip_code": "zipCode", + }, + }, + idempotency_key="idempotency-key", + ) + assert_matches_type(TargetedListBuildCreateResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_create(self, client: PostGrid) -> None: + response = client.print_mail.targeted_list_builds.with_raw_response.create() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + targeted_list_build = response.parse() + assert_matches_type(TargetedListBuildCreateResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_create(self, client: PostGrid) -> None: + with client.print_mail.targeted_list_builds.with_streaming_response.create() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + targeted_list_build = response.parse() + assert_matches_type(TargetedListBuildCreateResponse, targeted_list_build, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve(self, client: PostGrid) -> None: + targeted_list_build = client.print_mail.targeted_list_builds.retrieve( + "id", + ) + assert_matches_type(TargetedListBuildRetrieveResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: PostGrid) -> None: + response = client.print_mail.targeted_list_builds.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + targeted_list_build = response.parse() + assert_matches_type(TargetedListBuildRetrieveResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: PostGrid) -> None: + with client.print_mail.targeted_list_builds.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + targeted_list_build = response.parse() + assert_matches_type(TargetedListBuildRetrieveResponse, targeted_list_build, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.targeted_list_builds.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_update(self, client: PostGrid) -> None: + targeted_list_build = client.print_mail.targeted_list_builds.update( + id="id", + ) + assert_matches_type(TargetedListBuildUpdateResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_update_with_all_params(self, client: PostGrid) -> None: + targeted_list_build = client.print_mail.targeted_list_builds.update( + id="id", + description="description", + limit=2000, + metadata={"foo": "bar"}, + us_companies={ + "postal_codes": ["10001", "10002", "10003"], + "company_types": ["public"], + "employee_count": [50, 1000], + "founded_year": [1600, 1600], + "industries": ["software", "fintech"], + "naics_codes": ["string"], + "tags": ["string"], + }, + us_consumers={ + "age_range": [18, 18], + "city_states": ["string"], + "education_levels": ["high_school"], + "gender": "male", + "home_value_range": [0, 0], + "income_range": [0, 0], + "num_children_range": [0, 0], + "occupations": ["professional_technical"], + "zip_codes": ["string"], + "zip_codes_around": { + "radius_in_miles": 0.1, + "zip_code": "zipCode", + }, + }, + ) + assert_matches_type(TargetedListBuildUpdateResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_update(self, client: PostGrid) -> None: + response = client.print_mail.targeted_list_builds.with_raw_response.update( + id="id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + targeted_list_build = response.parse() + assert_matches_type(TargetedListBuildUpdateResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_update(self, client: PostGrid) -> None: + with client.print_mail.targeted_list_builds.with_streaming_response.update( + id="id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + targeted_list_build = response.parse() + assert_matches_type(TargetedListBuildUpdateResponse, targeted_list_build, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_update(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.targeted_list_builds.with_raw_response.update( + id="", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list(self, client: PostGrid) -> None: + targeted_list_build = client.print_mail.targeted_list_builds.list() + assert_matches_type(SyncSkipLimit[TargetedListBuildListResponse], targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: PostGrid) -> None: + targeted_list_build = client.print_mail.targeted_list_builds.list( + limit=0, + search="search", + skip=0, + ) + assert_matches_type(SyncSkipLimit[TargetedListBuildListResponse], targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_list(self, client: PostGrid) -> None: + response = client.print_mail.targeted_list_builds.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + targeted_list_build = response.parse() + assert_matches_type(SyncSkipLimit[TargetedListBuildListResponse], targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_list(self, client: PostGrid) -> None: + with client.print_mail.targeted_list_builds.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + targeted_list_build = response.parse() + assert_matches_type(SyncSkipLimit[TargetedListBuildListResponse], targeted_list_build, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_delete(self, client: PostGrid) -> None: + targeted_list_build = client.print_mail.targeted_list_builds.delete( + "id", + ) + assert_matches_type(TargetedListBuildDeleteResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_delete(self, client: PostGrid) -> None: + response = client.print_mail.targeted_list_builds.with_raw_response.delete( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + targeted_list_build = response.parse() + assert_matches_type(TargetedListBuildDeleteResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: PostGrid) -> None: + with client.print_mail.targeted_list_builds.with_streaming_response.delete( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + targeted_list_build = response.parse() + assert_matches_type(TargetedListBuildDeleteResponse, targeted_list_build, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_delete(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.targeted_list_builds.with_raw_response.delete( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_confirm(self, client: PostGrid) -> None: + targeted_list_build = client.print_mail.targeted_list_builds.confirm( + "id", + ) + assert_matches_type(TargetedListBuildConfirmResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_confirm(self, client: PostGrid) -> None: + response = client.print_mail.targeted_list_builds.with_raw_response.confirm( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + targeted_list_build = response.parse() + assert_matches_type(TargetedListBuildConfirmResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_confirm(self, client: PostGrid) -> None: + with client.print_mail.targeted_list_builds.with_streaming_response.confirm( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + targeted_list_build = response.parse() + assert_matches_type(TargetedListBuildConfirmResponse, targeted_list_build, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_confirm(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.targeted_list_builds.with_raw_response.confirm( + "", + ) + + +class TestAsyncTargetedListBuilds: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncPostGrid) -> None: + targeted_list_build = await async_client.print_mail.targeted_list_builds.create() + assert_matches_type(TargetedListBuildCreateResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncPostGrid) -> None: + targeted_list_build = await async_client.print_mail.targeted_list_builds.create( + description="Q1 prospecting list", + limit=1000, + metadata={"campaign": "bar"}, + us_companies={ + "postal_codes": ["10001", "10002"], + "company_types": ["public"], + "employee_count": [10, 500], + "founded_year": [1600, 1600], + "industries": ["software"], + "naics_codes": ["string"], + "tags": ["string"], + }, + us_consumers={ + "age_range": [18, 18], + "city_states": ["string"], + "education_levels": ["high_school"], + "gender": "male", + "home_value_range": [0, 0], + "income_range": [0, 0], + "num_children_range": [0, 0], + "occupations": ["professional_technical"], + "zip_codes": ["string"], + "zip_codes_around": { + "radius_in_miles": 0.1, + "zip_code": "zipCode", + }, + }, + idempotency_key="idempotency-key", + ) + assert_matches_type(TargetedListBuildCreateResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.targeted_list_builds.with_raw_response.create() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + targeted_list_build = await response.parse() + assert_matches_type(TargetedListBuildCreateResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.targeted_list_builds.with_streaming_response.create() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + targeted_list_build = await response.parse() + assert_matches_type(TargetedListBuildCreateResponse, targeted_list_build, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncPostGrid) -> None: + targeted_list_build = await async_client.print_mail.targeted_list_builds.retrieve( + "id", + ) + assert_matches_type(TargetedListBuildRetrieveResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.targeted_list_builds.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + targeted_list_build = await response.parse() + assert_matches_type(TargetedListBuildRetrieveResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.targeted_list_builds.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + targeted_list_build = await response.parse() + assert_matches_type(TargetedListBuildRetrieveResponse, targeted_list_build, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.targeted_list_builds.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_update(self, async_client: AsyncPostGrid) -> None: + targeted_list_build = await async_client.print_mail.targeted_list_builds.update( + id="id", + ) + assert_matches_type(TargetedListBuildUpdateResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncPostGrid) -> None: + targeted_list_build = await async_client.print_mail.targeted_list_builds.update( + id="id", + description="description", + limit=2000, + metadata={"foo": "bar"}, + us_companies={ + "postal_codes": ["10001", "10002", "10003"], + "company_types": ["public"], + "employee_count": [50, 1000], + "founded_year": [1600, 1600], + "industries": ["software", "fintech"], + "naics_codes": ["string"], + "tags": ["string"], + }, + us_consumers={ + "age_range": [18, 18], + "city_states": ["string"], + "education_levels": ["high_school"], + "gender": "male", + "home_value_range": [0, 0], + "income_range": [0, 0], + "num_children_range": [0, 0], + "occupations": ["professional_technical"], + "zip_codes": ["string"], + "zip_codes_around": { + "radius_in_miles": 0.1, + "zip_code": "zipCode", + }, + }, + ) + assert_matches_type(TargetedListBuildUpdateResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_update(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.targeted_list_builds.with_raw_response.update( + id="id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + targeted_list_build = await response.parse() + assert_matches_type(TargetedListBuildUpdateResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_update(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.targeted_list_builds.with_streaming_response.update( + id="id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + targeted_list_build = await response.parse() + assert_matches_type(TargetedListBuildUpdateResponse, targeted_list_build, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_update(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.targeted_list_builds.with_raw_response.update( + id="", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncPostGrid) -> None: + targeted_list_build = await async_client.print_mail.targeted_list_builds.list() + assert_matches_type(AsyncSkipLimit[TargetedListBuildListResponse], targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncPostGrid) -> None: + targeted_list_build = await async_client.print_mail.targeted_list_builds.list( + limit=0, + search="search", + skip=0, + ) + assert_matches_type(AsyncSkipLimit[TargetedListBuildListResponse], targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.targeted_list_builds.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + targeted_list_build = await response.parse() + assert_matches_type(AsyncSkipLimit[TargetedListBuildListResponse], targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.targeted_list_builds.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + targeted_list_build = await response.parse() + assert_matches_type(AsyncSkipLimit[TargetedListBuildListResponse], targeted_list_build, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncPostGrid) -> None: + targeted_list_build = await async_client.print_mail.targeted_list_builds.delete( + "id", + ) + assert_matches_type(TargetedListBuildDeleteResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.targeted_list_builds.with_raw_response.delete( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + targeted_list_build = await response.parse() + assert_matches_type(TargetedListBuildDeleteResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.targeted_list_builds.with_streaming_response.delete( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + targeted_list_build = await response.parse() + assert_matches_type(TargetedListBuildDeleteResponse, targeted_list_build, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.targeted_list_builds.with_raw_response.delete( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_confirm(self, async_client: AsyncPostGrid) -> None: + targeted_list_build = await async_client.print_mail.targeted_list_builds.confirm( + "id", + ) + assert_matches_type(TargetedListBuildConfirmResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_confirm(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.targeted_list_builds.with_raw_response.confirm( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + targeted_list_build = await response.parse() + assert_matches_type(TargetedListBuildConfirmResponse, targeted_list_build, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_confirm(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.targeted_list_builds.with_streaming_response.confirm( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + targeted_list_build = await response.parse() + assert_matches_type(TargetedListBuildConfirmResponse, targeted_list_build, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_confirm(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.targeted_list_builds.with_raw_response.confirm( + "", + ) diff --git a/tests/api_resources/print_mail/test_template_editor_sessions.py b/tests/api_resources/print_mail/test_template_editor_sessions.py new file mode 100644 index 0000000..b75891e --- /dev/null +++ b/tests/api_resources/print_mail/test_template_editor_sessions.py @@ -0,0 +1,311 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from postgrid import PostGrid, AsyncPostGrid +from tests.utils import assert_matches_type +from postgrid.pagination import SyncSkipLimit, AsyncSkipLimit +from postgrid.types.print_mail import ( + TemplateEditorSessionListResponse, + TemplateEditorSessionCreateResponse, + TemplateEditorSessionDeleteResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestTemplateEditorSessions: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create(self, client: PostGrid) -> None: + template_editor_session = client.print_mail.template_editor_sessions.create( + template="template_eYxcbMKPZEZPk71ZJPA6Yz", + ) + assert_matches_type(TemplateEditorSessionCreateResponse, template_editor_session, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: PostGrid) -> None: + template_editor_session = client.print_mail.template_editor_sessions.create( + template="template_eYxcbMKPZEZPk71ZJPA6Yz", + back_url="https://postgrid.com", + styles={ + "canvas": {"background_color": "backgroundColor"}, + "panel_text": {"color": "color"}, + "save_button": { + "background_color": "backgroundColor", + "text_color": "textColor", + }, + }, + title="My Editor Session", + trackers=["tracker_123456789abcdefghijklmnopqrstuvwxyz"], + ) + assert_matches_type(TemplateEditorSessionCreateResponse, template_editor_session, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_create(self, client: PostGrid) -> None: + response = client.print_mail.template_editor_sessions.with_raw_response.create( + template="template_eYxcbMKPZEZPk71ZJPA6Yz", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template_editor_session = response.parse() + assert_matches_type(TemplateEditorSessionCreateResponse, template_editor_session, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_create(self, client: PostGrid) -> None: + with client.print_mail.template_editor_sessions.with_streaming_response.create( + template="template_eYxcbMKPZEZPk71ZJPA6Yz", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template_editor_session = response.parse() + assert_matches_type(TemplateEditorSessionCreateResponse, template_editor_session, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list(self, client: PostGrid) -> None: + template_editor_session = client.print_mail.template_editor_sessions.list() + assert_matches_type( + SyncSkipLimit[TemplateEditorSessionListResponse], template_editor_session, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: PostGrid) -> None: + template_editor_session = client.print_mail.template_editor_sessions.list( + limit=0, + search="search", + skip=0, + ) + assert_matches_type( + SyncSkipLimit[TemplateEditorSessionListResponse], template_editor_session, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_list(self, client: PostGrid) -> None: + response = client.print_mail.template_editor_sessions.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template_editor_session = response.parse() + assert_matches_type( + SyncSkipLimit[TemplateEditorSessionListResponse], template_editor_session, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_list(self, client: PostGrid) -> None: + with client.print_mail.template_editor_sessions.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template_editor_session = response.parse() + assert_matches_type( + SyncSkipLimit[TemplateEditorSessionListResponse], template_editor_session, path=["response"] + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_delete(self, client: PostGrid) -> None: + template_editor_session = client.print_mail.template_editor_sessions.delete( + "id", + ) + assert_matches_type(TemplateEditorSessionDeleteResponse, template_editor_session, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_delete(self, client: PostGrid) -> None: + response = client.print_mail.template_editor_sessions.with_raw_response.delete( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template_editor_session = response.parse() + assert_matches_type(TemplateEditorSessionDeleteResponse, template_editor_session, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: PostGrid) -> None: + with client.print_mail.template_editor_sessions.with_streaming_response.delete( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template_editor_session = response.parse() + assert_matches_type(TemplateEditorSessionDeleteResponse, template_editor_session, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_delete(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.template_editor_sessions.with_raw_response.delete( + "", + ) + + +class TestAsyncTemplateEditorSessions: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncPostGrid) -> None: + template_editor_session = await async_client.print_mail.template_editor_sessions.create( + template="template_eYxcbMKPZEZPk71ZJPA6Yz", + ) + assert_matches_type(TemplateEditorSessionCreateResponse, template_editor_session, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncPostGrid) -> None: + template_editor_session = await async_client.print_mail.template_editor_sessions.create( + template="template_eYxcbMKPZEZPk71ZJPA6Yz", + back_url="https://postgrid.com", + styles={ + "canvas": {"background_color": "backgroundColor"}, + "panel_text": {"color": "color"}, + "save_button": { + "background_color": "backgroundColor", + "text_color": "textColor", + }, + }, + title="My Editor Session", + trackers=["tracker_123456789abcdefghijklmnopqrstuvwxyz"], + ) + assert_matches_type(TemplateEditorSessionCreateResponse, template_editor_session, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.template_editor_sessions.with_raw_response.create( + template="template_eYxcbMKPZEZPk71ZJPA6Yz", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template_editor_session = await response.parse() + assert_matches_type(TemplateEditorSessionCreateResponse, template_editor_session, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.template_editor_sessions.with_streaming_response.create( + template="template_eYxcbMKPZEZPk71ZJPA6Yz", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template_editor_session = await response.parse() + assert_matches_type(TemplateEditorSessionCreateResponse, template_editor_session, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncPostGrid) -> None: + template_editor_session = await async_client.print_mail.template_editor_sessions.list() + assert_matches_type( + AsyncSkipLimit[TemplateEditorSessionListResponse], template_editor_session, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncPostGrid) -> None: + template_editor_session = await async_client.print_mail.template_editor_sessions.list( + limit=0, + search="search", + skip=0, + ) + assert_matches_type( + AsyncSkipLimit[TemplateEditorSessionListResponse], template_editor_session, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.template_editor_sessions.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template_editor_session = await response.parse() + assert_matches_type( + AsyncSkipLimit[TemplateEditorSessionListResponse], template_editor_session, path=["response"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.template_editor_sessions.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template_editor_session = await response.parse() + assert_matches_type( + AsyncSkipLimit[TemplateEditorSessionListResponse], template_editor_session, path=["response"] + ) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncPostGrid) -> None: + template_editor_session = await async_client.print_mail.template_editor_sessions.delete( + "id", + ) + assert_matches_type(TemplateEditorSessionDeleteResponse, template_editor_session, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.template_editor_sessions.with_raw_response.delete( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + template_editor_session = await response.parse() + assert_matches_type(TemplateEditorSessionDeleteResponse, template_editor_session, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.template_editor_sessions.with_streaming_response.delete( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + template_editor_session = await response.parse() + assert_matches_type(TemplateEditorSessionDeleteResponse, template_editor_session, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.template_editor_sessions.with_raw_response.delete( + "", + ) diff --git a/tests/api_resources/print_mail/test_trackers.py b/tests/api_resources/print_mail/test_trackers.py new file mode 100644 index 0000000..d3155b7 --- /dev/null +++ b/tests/api_resources/print_mail/test_trackers.py @@ -0,0 +1,602 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from postgrid import PostGrid, AsyncPostGrid +from tests.utils import assert_matches_type +from postgrid.pagination import SyncSkipLimit, AsyncSkipLimit +from postgrid.types.print_mail import ( + TrackerListResponse, + TrackerCreateResponse, + TrackerDeleteResponse, + TrackerUpdateResponse, + TrackerRetrieveResponse, + TrackerRetrieveVisitsResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestTrackers: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create(self, client: PostGrid) -> None: + tracker = client.print_mail.trackers.create( + redirect_url_template="https://postgrid.com?name={{to.firstName}}", + url_expire_after_days=30, + ) + assert_matches_type(TrackerCreateResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: PostGrid) -> None: + tracker = client.print_mail.trackers.create( + redirect_url_template="https://postgrid.com?name={{to.firstName}}", + url_expire_after_days=30, + description="description", + metadata={"foo": "bar"}, + ) + assert_matches_type(TrackerCreateResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_create(self, client: PostGrid) -> None: + response = client.print_mail.trackers.with_raw_response.create( + redirect_url_template="https://postgrid.com?name={{to.firstName}}", + url_expire_after_days=30, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tracker = response.parse() + assert_matches_type(TrackerCreateResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_create(self, client: PostGrid) -> None: + with client.print_mail.trackers.with_streaming_response.create( + redirect_url_template="https://postgrid.com?name={{to.firstName}}", + url_expire_after_days=30, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tracker = response.parse() + assert_matches_type(TrackerCreateResponse, tracker, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve(self, client: PostGrid) -> None: + tracker = client.print_mail.trackers.retrieve( + "id", + ) + assert_matches_type(TrackerRetrieveResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: PostGrid) -> None: + response = client.print_mail.trackers.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tracker = response.parse() + assert_matches_type(TrackerRetrieveResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: PostGrid) -> None: + with client.print_mail.trackers.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tracker = response.parse() + assert_matches_type(TrackerRetrieveResponse, tracker, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.trackers.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_update(self, client: PostGrid) -> None: + tracker = client.print_mail.trackers.update( + id="id", + redirect_url_template="https://postgrid.com?firstName={{to.firstName}}", + url_expire_after_days=90, + ) + assert_matches_type(TrackerUpdateResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_update_with_all_params(self, client: PostGrid) -> None: + tracker = client.print_mail.trackers.update( + id="id", + redirect_url_template="https://postgrid.com?firstName={{to.firstName}}", + url_expire_after_days=90, + description="description", + metadata={"foo": "bar"}, + ) + assert_matches_type(TrackerUpdateResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_update(self, client: PostGrid) -> None: + response = client.print_mail.trackers.with_raw_response.update( + id="id", + redirect_url_template="https://postgrid.com?firstName={{to.firstName}}", + url_expire_after_days=90, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tracker = response.parse() + assert_matches_type(TrackerUpdateResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_update(self, client: PostGrid) -> None: + with client.print_mail.trackers.with_streaming_response.update( + id="id", + redirect_url_template="https://postgrid.com?firstName={{to.firstName}}", + url_expire_after_days=90, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tracker = response.parse() + assert_matches_type(TrackerUpdateResponse, tracker, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_update(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.trackers.with_raw_response.update( + id="", + redirect_url_template="https://postgrid.com?firstName={{to.firstName}}", + url_expire_after_days=90, + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list(self, client: PostGrid) -> None: + tracker = client.print_mail.trackers.list() + assert_matches_type(SyncSkipLimit[TrackerListResponse], tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: PostGrid) -> None: + tracker = client.print_mail.trackers.list( + limit=0, + search="search", + skip=0, + ) + assert_matches_type(SyncSkipLimit[TrackerListResponse], tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_list(self, client: PostGrid) -> None: + response = client.print_mail.trackers.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tracker = response.parse() + assert_matches_type(SyncSkipLimit[TrackerListResponse], tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_list(self, client: PostGrid) -> None: + with client.print_mail.trackers.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tracker = response.parse() + assert_matches_type(SyncSkipLimit[TrackerListResponse], tracker, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_delete(self, client: PostGrid) -> None: + tracker = client.print_mail.trackers.delete( + "id", + ) + assert_matches_type(TrackerDeleteResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_delete(self, client: PostGrid) -> None: + response = client.print_mail.trackers.with_raw_response.delete( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tracker = response.parse() + assert_matches_type(TrackerDeleteResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_delete(self, client: PostGrid) -> None: + with client.print_mail.trackers.with_streaming_response.delete( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tracker = response.parse() + assert_matches_type(TrackerDeleteResponse, tracker, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_delete(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.trackers.with_raw_response.delete( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve_visits(self, client: PostGrid) -> None: + tracker = client.print_mail.trackers.retrieve_visits( + id="id", + ) + assert_matches_type(SyncSkipLimit[TrackerRetrieveVisitsResponse], tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve_visits_with_all_params(self, client: PostGrid) -> None: + tracker = client.print_mail.trackers.retrieve_visits( + id="id", + limit=0, + search="search", + skip=0, + ) + assert_matches_type(SyncSkipLimit[TrackerRetrieveVisitsResponse], tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_retrieve_visits(self, client: PostGrid) -> None: + response = client.print_mail.trackers.with_raw_response.retrieve_visits( + id="id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tracker = response.parse() + assert_matches_type(SyncSkipLimit[TrackerRetrieveVisitsResponse], tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_retrieve_visits(self, client: PostGrid) -> None: + with client.print_mail.trackers.with_streaming_response.retrieve_visits( + id="id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tracker = response.parse() + assert_matches_type(SyncSkipLimit[TrackerRetrieveVisitsResponse], tracker, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_retrieve_visits(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.trackers.with_raw_response.retrieve_visits( + id="", + ) + + +class TestAsyncTrackers: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncPostGrid) -> None: + tracker = await async_client.print_mail.trackers.create( + redirect_url_template="https://postgrid.com?name={{to.firstName}}", + url_expire_after_days=30, + ) + assert_matches_type(TrackerCreateResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncPostGrid) -> None: + tracker = await async_client.print_mail.trackers.create( + redirect_url_template="https://postgrid.com?name={{to.firstName}}", + url_expire_after_days=30, + description="description", + metadata={"foo": "bar"}, + ) + assert_matches_type(TrackerCreateResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.trackers.with_raw_response.create( + redirect_url_template="https://postgrid.com?name={{to.firstName}}", + url_expire_after_days=30, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tracker = await response.parse() + assert_matches_type(TrackerCreateResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.trackers.with_streaming_response.create( + redirect_url_template="https://postgrid.com?name={{to.firstName}}", + url_expire_after_days=30, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tracker = await response.parse() + assert_matches_type(TrackerCreateResponse, tracker, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncPostGrid) -> None: + tracker = await async_client.print_mail.trackers.retrieve( + "id", + ) + assert_matches_type(TrackerRetrieveResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.trackers.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tracker = await response.parse() + assert_matches_type(TrackerRetrieveResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.trackers.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tracker = await response.parse() + assert_matches_type(TrackerRetrieveResponse, tracker, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.trackers.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_update(self, async_client: AsyncPostGrid) -> None: + tracker = await async_client.print_mail.trackers.update( + id="id", + redirect_url_template="https://postgrid.com?firstName={{to.firstName}}", + url_expire_after_days=90, + ) + assert_matches_type(TrackerUpdateResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncPostGrid) -> None: + tracker = await async_client.print_mail.trackers.update( + id="id", + redirect_url_template="https://postgrid.com?firstName={{to.firstName}}", + url_expire_after_days=90, + description="description", + metadata={"foo": "bar"}, + ) + assert_matches_type(TrackerUpdateResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_update(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.trackers.with_raw_response.update( + id="id", + redirect_url_template="https://postgrid.com?firstName={{to.firstName}}", + url_expire_after_days=90, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tracker = await response.parse() + assert_matches_type(TrackerUpdateResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_update(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.trackers.with_streaming_response.update( + id="id", + redirect_url_template="https://postgrid.com?firstName={{to.firstName}}", + url_expire_after_days=90, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tracker = await response.parse() + assert_matches_type(TrackerUpdateResponse, tracker, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_update(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.trackers.with_raw_response.update( + id="", + redirect_url_template="https://postgrid.com?firstName={{to.firstName}}", + url_expire_after_days=90, + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncPostGrid) -> None: + tracker = await async_client.print_mail.trackers.list() + assert_matches_type(AsyncSkipLimit[TrackerListResponse], tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncPostGrid) -> None: + tracker = await async_client.print_mail.trackers.list( + limit=0, + search="search", + skip=0, + ) + assert_matches_type(AsyncSkipLimit[TrackerListResponse], tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.trackers.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tracker = await response.parse() + assert_matches_type(AsyncSkipLimit[TrackerListResponse], tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.trackers.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tracker = await response.parse() + assert_matches_type(AsyncSkipLimit[TrackerListResponse], tracker, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_delete(self, async_client: AsyncPostGrid) -> None: + tracker = await async_client.print_mail.trackers.delete( + "id", + ) + assert_matches_type(TrackerDeleteResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_delete(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.trackers.with_raw_response.delete( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tracker = await response.parse() + assert_matches_type(TrackerDeleteResponse, tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.trackers.with_streaming_response.delete( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tracker = await response.parse() + assert_matches_type(TrackerDeleteResponse, tracker, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_delete(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.trackers.with_raw_response.delete( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve_visits(self, async_client: AsyncPostGrid) -> None: + tracker = await async_client.print_mail.trackers.retrieve_visits( + id="id", + ) + assert_matches_type(AsyncSkipLimit[TrackerRetrieveVisitsResponse], tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve_visits_with_all_params(self, async_client: AsyncPostGrid) -> None: + tracker = await async_client.print_mail.trackers.retrieve_visits( + id="id", + limit=0, + search="search", + skip=0, + ) + assert_matches_type(AsyncSkipLimit[TrackerRetrieveVisitsResponse], tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_retrieve_visits(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.trackers.with_raw_response.retrieve_visits( + id="id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + tracker = await response.parse() + assert_matches_type(AsyncSkipLimit[TrackerRetrieveVisitsResponse], tracker, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_retrieve_visits(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.trackers.with_streaming_response.retrieve_visits( + id="id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + tracker = await response.parse() + assert_matches_type(AsyncSkipLimit[TrackerRetrieveVisitsResponse], tracker, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_retrieve_visits(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.trackers.with_raw_response.retrieve_visits( + id="", + ) diff --git a/tests/api_resources/print_mail/test_virtual_mailboxes.py b/tests/api_resources/print_mail/test_virtual_mailboxes.py new file mode 100644 index 0000000..cea9fcc --- /dev/null +++ b/tests/api_resources/print_mail/test_virtual_mailboxes.py @@ -0,0 +1,366 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from postgrid import PostGrid, AsyncPostGrid +from tests.utils import assert_matches_type +from postgrid.pagination import SyncSkipLimit, AsyncSkipLimit +from postgrid.types.print_mail import ( + VirtualMailboxListResponse, + VirtualMailboxCreateResponse, + VirtualMailboxRetrieveResponse, + VirtualMailboxRetrieveAddressResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestVirtualMailboxes: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create(self, client: PostGrid) -> None: + virtual_mailbox = client.print_mail.virtual_mailboxes.create( + country_code="US", + ) + assert_matches_type(VirtualMailboxCreateResponse, virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: PostGrid) -> None: + virtual_mailbox = client.print_mail.virtual_mailboxes.create( + country_code="US", + capabilities={ + "envelope_scans": True, + "forward_mail_to": "contact_pxd7wnnD1xY6H6etKNvjb4", + }, + ) + assert_matches_type(VirtualMailboxCreateResponse, virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_create(self, client: PostGrid) -> None: + response = client.print_mail.virtual_mailboxes.with_raw_response.create( + country_code="US", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + virtual_mailbox = response.parse() + assert_matches_type(VirtualMailboxCreateResponse, virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_create(self, client: PostGrid) -> None: + with client.print_mail.virtual_mailboxes.with_streaming_response.create( + country_code="US", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + virtual_mailbox = response.parse() + assert_matches_type(VirtualMailboxCreateResponse, virtual_mailbox, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve(self, client: PostGrid) -> None: + virtual_mailbox = client.print_mail.virtual_mailboxes.retrieve( + "id", + ) + assert_matches_type(VirtualMailboxRetrieveResponse, virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: PostGrid) -> None: + response = client.print_mail.virtual_mailboxes.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + virtual_mailbox = response.parse() + assert_matches_type(VirtualMailboxRetrieveResponse, virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: PostGrid) -> None: + with client.print_mail.virtual_mailboxes.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + virtual_mailbox = response.parse() + assert_matches_type(VirtualMailboxRetrieveResponse, virtual_mailbox, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.virtual_mailboxes.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list(self, client: PostGrid) -> None: + virtual_mailbox = client.print_mail.virtual_mailboxes.list() + assert_matches_type(SyncSkipLimit[VirtualMailboxListResponse], virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: PostGrid) -> None: + virtual_mailbox = client.print_mail.virtual_mailboxes.list( + limit=0, + search="search", + skip=0, + ) + assert_matches_type(SyncSkipLimit[VirtualMailboxListResponse], virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_list(self, client: PostGrid) -> None: + response = client.print_mail.virtual_mailboxes.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + virtual_mailbox = response.parse() + assert_matches_type(SyncSkipLimit[VirtualMailboxListResponse], virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_list(self, client: PostGrid) -> None: + with client.print_mail.virtual_mailboxes.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + virtual_mailbox = response.parse() + assert_matches_type(SyncSkipLimit[VirtualMailboxListResponse], virtual_mailbox, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve_address(self, client: PostGrid) -> None: + virtual_mailbox = client.print_mail.virtual_mailboxes.retrieve_address( + "id", + ) + assert_matches_type(VirtualMailboxRetrieveAddressResponse, virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_retrieve_address(self, client: PostGrid) -> None: + response = client.print_mail.virtual_mailboxes.with_raw_response.retrieve_address( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + virtual_mailbox = response.parse() + assert_matches_type(VirtualMailboxRetrieveAddressResponse, virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_retrieve_address(self, client: PostGrid) -> None: + with client.print_mail.virtual_mailboxes.with_streaming_response.retrieve_address( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + virtual_mailbox = response.parse() + assert_matches_type(VirtualMailboxRetrieveAddressResponse, virtual_mailbox, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_retrieve_address(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.virtual_mailboxes.with_raw_response.retrieve_address( + "", + ) + + +class TestAsyncVirtualMailboxes: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncPostGrid) -> None: + virtual_mailbox = await async_client.print_mail.virtual_mailboxes.create( + country_code="US", + ) + assert_matches_type(VirtualMailboxCreateResponse, virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncPostGrid) -> None: + virtual_mailbox = await async_client.print_mail.virtual_mailboxes.create( + country_code="US", + capabilities={ + "envelope_scans": True, + "forward_mail_to": "contact_pxd7wnnD1xY6H6etKNvjb4", + }, + ) + assert_matches_type(VirtualMailboxCreateResponse, virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.virtual_mailboxes.with_raw_response.create( + country_code="US", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + virtual_mailbox = await response.parse() + assert_matches_type(VirtualMailboxCreateResponse, virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.virtual_mailboxes.with_streaming_response.create( + country_code="US", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + virtual_mailbox = await response.parse() + assert_matches_type(VirtualMailboxCreateResponse, virtual_mailbox, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncPostGrid) -> None: + virtual_mailbox = await async_client.print_mail.virtual_mailboxes.retrieve( + "id", + ) + assert_matches_type(VirtualMailboxRetrieveResponse, virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.virtual_mailboxes.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + virtual_mailbox = await response.parse() + assert_matches_type(VirtualMailboxRetrieveResponse, virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.virtual_mailboxes.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + virtual_mailbox = await response.parse() + assert_matches_type(VirtualMailboxRetrieveResponse, virtual_mailbox, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.virtual_mailboxes.with_raw_response.retrieve( + "", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncPostGrid) -> None: + virtual_mailbox = await async_client.print_mail.virtual_mailboxes.list() + assert_matches_type(AsyncSkipLimit[VirtualMailboxListResponse], virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncPostGrid) -> None: + virtual_mailbox = await async_client.print_mail.virtual_mailboxes.list( + limit=0, + search="search", + skip=0, + ) + assert_matches_type(AsyncSkipLimit[VirtualMailboxListResponse], virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.virtual_mailboxes.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + virtual_mailbox = await response.parse() + assert_matches_type(AsyncSkipLimit[VirtualMailboxListResponse], virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.virtual_mailboxes.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + virtual_mailbox = await response.parse() + assert_matches_type(AsyncSkipLimit[VirtualMailboxListResponse], virtual_mailbox, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve_address(self, async_client: AsyncPostGrid) -> None: + virtual_mailbox = await async_client.print_mail.virtual_mailboxes.retrieve_address( + "id", + ) + assert_matches_type(VirtualMailboxRetrieveAddressResponse, virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_retrieve_address(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.virtual_mailboxes.with_raw_response.retrieve_address( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + virtual_mailbox = await response.parse() + assert_matches_type(VirtualMailboxRetrieveAddressResponse, virtual_mailbox, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_retrieve_address(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.virtual_mailboxes.with_streaming_response.retrieve_address( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + virtual_mailbox = await response.parse() + assert_matches_type(VirtualMailboxRetrieveAddressResponse, virtual_mailbox, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_retrieve_address(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.virtual_mailboxes.with_raw_response.retrieve_address( + "", + ) diff --git a/tests/api_resources/print_mail/virtual_mailboxes/__init__.py b/tests/api_resources/print_mail/virtual_mailboxes/__init__.py new file mode 100644 index 0000000..fd8019a --- /dev/null +++ b/tests/api_resources/print_mail/virtual_mailboxes/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/print_mail/virtual_mailboxes/test_items.py b/tests/api_resources/print_mail/virtual_mailboxes/test_items.py new file mode 100644 index 0000000..5eadd94 --- /dev/null +++ b/tests/api_resources/print_mail/virtual_mailboxes/test_items.py @@ -0,0 +1,345 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from postgrid import PostGrid, AsyncPostGrid +from tests.utils import assert_matches_type +from postgrid.pagination import SyncSkipLimit, AsyncSkipLimit +from postgrid.types.print_mail.virtual_mailboxes import ( + ItemListResponse, + ItemCreateResponse, + ItemRetrieveResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestItems: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create(self, client: PostGrid) -> None: + item = client.print_mail.virtual_mailboxes.items.create( + id="id", + ) + assert_matches_type(ItemCreateResponse, item, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_create_with_all_params(self, client: PostGrid) -> None: + item = client.print_mail.virtual_mailboxes.items.create( + id="id", + description="description", + matched_letter="letter_abcdef1234567890", + metadata={"foo": "bar"}, + ) + assert_matches_type(ItemCreateResponse, item, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_create(self, client: PostGrid) -> None: + response = client.print_mail.virtual_mailboxes.items.with_raw_response.create( + id="id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = response.parse() + assert_matches_type(ItemCreateResponse, item, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_create(self, client: PostGrid) -> None: + with client.print_mail.virtual_mailboxes.items.with_streaming_response.create( + id="id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = response.parse() + assert_matches_type(ItemCreateResponse, item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_create(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.virtual_mailboxes.items.with_raw_response.create( + id="", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve(self, client: PostGrid) -> None: + item = client.print_mail.virtual_mailboxes.items.retrieve( + item_id="itemID", + id="id", + ) + assert_matches_type(ItemRetrieveResponse, item, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: PostGrid) -> None: + response = client.print_mail.virtual_mailboxes.items.with_raw_response.retrieve( + item_id="itemID", + id="id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = response.parse() + assert_matches_type(ItemRetrieveResponse, item, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: PostGrid) -> None: + with client.print_mail.virtual_mailboxes.items.with_streaming_response.retrieve( + item_id="itemID", + id="id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = response.parse() + assert_matches_type(ItemRetrieveResponse, item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.virtual_mailboxes.items.with_raw_response.retrieve( + item_id="itemID", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `item_id` but received ''"): + client.print_mail.virtual_mailboxes.items.with_raw_response.retrieve( + item_id="", + id="id", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list(self, client: PostGrid) -> None: + item = client.print_mail.virtual_mailboxes.items.list( + id="id", + ) + assert_matches_type(SyncSkipLimit[ItemListResponse], item, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_list_with_all_params(self, client: PostGrid) -> None: + item = client.print_mail.virtual_mailboxes.items.list( + id="id", + limit=0, + search="search", + skip=0, + ) + assert_matches_type(SyncSkipLimit[ItemListResponse], item, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_list(self, client: PostGrid) -> None: + response = client.print_mail.virtual_mailboxes.items.with_raw_response.list( + id="id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = response.parse() + assert_matches_type(SyncSkipLimit[ItemListResponse], item, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_list(self, client: PostGrid) -> None: + with client.print_mail.virtual_mailboxes.items.with_streaming_response.list( + id="id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = response.parse() + assert_matches_type(SyncSkipLimit[ItemListResponse], item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_list(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.virtual_mailboxes.items.with_raw_response.list( + id="", + ) + + +class TestAsyncItems: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create(self, async_client: AsyncPostGrid) -> None: + item = await async_client.print_mail.virtual_mailboxes.items.create( + id="id", + ) + assert_matches_type(ItemCreateResponse, item, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncPostGrid) -> None: + item = await async_client.print_mail.virtual_mailboxes.items.create( + id="id", + description="description", + matched_letter="letter_abcdef1234567890", + metadata={"foo": "bar"}, + ) + assert_matches_type(ItemCreateResponse, item, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_create(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.virtual_mailboxes.items.with_raw_response.create( + id="id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = await response.parse() + assert_matches_type(ItemCreateResponse, item, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_create(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.virtual_mailboxes.items.with_streaming_response.create( + id="id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = await response.parse() + assert_matches_type(ItemCreateResponse, item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_create(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.virtual_mailboxes.items.with_raw_response.create( + id="", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncPostGrid) -> None: + item = await async_client.print_mail.virtual_mailboxes.items.retrieve( + item_id="itemID", + id="id", + ) + assert_matches_type(ItemRetrieveResponse, item, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.virtual_mailboxes.items.with_raw_response.retrieve( + item_id="itemID", + id="id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = await response.parse() + assert_matches_type(ItemRetrieveResponse, item, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.virtual_mailboxes.items.with_streaming_response.retrieve( + item_id="itemID", + id="id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = await response.parse() + assert_matches_type(ItemRetrieveResponse, item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.virtual_mailboxes.items.with_raw_response.retrieve( + item_id="itemID", + id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `item_id` but received ''"): + await async_client.print_mail.virtual_mailboxes.items.with_raw_response.retrieve( + item_id="", + id="id", + ) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list(self, async_client: AsyncPostGrid) -> None: + item = await async_client.print_mail.virtual_mailboxes.items.list( + id="id", + ) + assert_matches_type(AsyncSkipLimit[ItemListResponse], item, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncPostGrid) -> None: + item = await async_client.print_mail.virtual_mailboxes.items.list( + id="id", + limit=0, + search="search", + skip=0, + ) + assert_matches_type(AsyncSkipLimit[ItemListResponse], item, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_list(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.virtual_mailboxes.items.with_raw_response.list( + id="id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + item = await response.parse() + assert_matches_type(AsyncSkipLimit[ItemListResponse], item, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_list(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.virtual_mailboxes.items.with_streaming_response.list( + id="id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + item = await response.parse() + assert_matches_type(AsyncSkipLimit[ItemListResponse], item, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_list(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.virtual_mailboxes.items.with_raw_response.list( + id="", + ) From 459beb65a1c41126dd02d19cabf529c45c8e531c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 8 May 2026 16:29:39 +0000 Subject: [PATCH 10/14] fix(client): add missing f-string prefix in file type error message --- src/postgrid/_files.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/postgrid/_files.py b/src/postgrid/_files.py index 0fdce17..76da9e0 100644 --- a/src/postgrid/_files.py +++ b/src/postgrid/_files.py @@ -99,7 +99,7 @@ async def async_to_httpx_files(files: RequestFiles | None) -> HttpxRequestFiles elif is_sequence_t(files): files = [(key, await _async_transform_file(file)) for key, file in files] else: - raise TypeError("Unexpected file type input {type(files)}, expected mapping or sequence") + raise TypeError(f"Unexpected file type input {type(files)}, expected mapping or sequence") return files From 2124510f8373868ec16a60ffdccd6f5d47e7ad17 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 11 May 2026 17:37:49 +0000 Subject: [PATCH 11/14] feat(internal/types): support eagerly validating pydantic iterators --- src/postgrid/_models.py | 80 +++++++++++++++++++++++++++++++++++++++++ tests/test_models.py | 60 +++++++++++++++++++++++++++++-- 2 files changed, 137 insertions(+), 3 deletions(-) diff --git a/src/postgrid/_models.py b/src/postgrid/_models.py index 29070e0..8c5ab26 100644 --- a/src/postgrid/_models.py +++ b/src/postgrid/_models.py @@ -25,7 +25,9 @@ ClassVar, Protocol, Required, + Annotated, ParamSpec, + TypeAlias, TypedDict, TypeGuard, final, @@ -79,7 +81,15 @@ from ._constants import RAW_RESPONSE_HEADER if TYPE_CHECKING: + from pydantic import GetCoreSchemaHandler, ValidatorFunctionWrapHandler + from pydantic_core import CoreSchema, core_schema from pydantic_core.core_schema import ModelField, ModelSchema, LiteralSchema, ModelFieldsSchema +else: + try: + from pydantic_core import CoreSchema, core_schema + except ImportError: + CoreSchema = None + core_schema = None __all__ = ["BaseModel", "GenericModel"] @@ -396,6 +406,76 @@ def model_dump_json( ) +class _EagerIterable(list[_T], Generic[_T]): + """ + Accepts any Iterable[T] input (including generators), consumes it + eagerly, and validates all items upfront. + + Validation preserves the original container type where possible + (e.g. a set[T] stays a set[T]). Serialization (model_dump / JSON) + always emits a list — round-tripping through model_dump() will not + restore the original container type. + """ + + @classmethod + def __get_pydantic_core_schema__( + cls, + source_type: Any, + handler: GetCoreSchemaHandler, + ) -> CoreSchema: + (item_type,) = get_args(source_type) or (Any,) + item_schema: CoreSchema = handler.generate_schema(item_type) + list_of_items_schema: CoreSchema = core_schema.list_schema(item_schema) + + return core_schema.no_info_wrap_validator_function( + cls._validate, + list_of_items_schema, + serialization=core_schema.plain_serializer_function_ser_schema( + cls._serialize, + info_arg=False, + ), + ) + + @staticmethod + def _validate(v: Iterable[_T], handler: "ValidatorFunctionWrapHandler") -> Any: + original_type: type[Any] = type(v) + + # Normalize to list so list_schema can validate each item + if isinstance(v, list): + items: list[_T] = v + else: + try: + items = list(v) + except TypeError as e: + raise TypeError("Value is not iterable") from e + + # Validate items against the inner schema + validated: list[_T] = handler(items) + + # Reconstruct original container type + if original_type is list: + return validated + # str(list) produces the list's repr, not a string built from items, + # so skip reconstruction for str and its subclasses. + if issubclass(original_type, str): + return validated + try: + return original_type(validated) + except (TypeError, ValueError): + # If the type cannot be reconstructed, just return the validated list + return validated + + @staticmethod + def _serialize(v: Iterable[_T]) -> list[_T]: + """Always serialize as a list so Pydantic's JSON encoder is happy.""" + if isinstance(v, list): + return v + return list(v) + + +EagerIterable: TypeAlias = Annotated[Iterable[_T], _EagerIterable] + + def _construct_field(value: object, field: FieldInfo, key: str) -> object: if value is None: return field_get_default(field) diff --git a/tests/test_models.py b/tests/test_models.py index a185732..e53f9c1 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,7 +1,8 @@ import json -from typing import TYPE_CHECKING, Any, Dict, List, Union, Optional, cast +from typing import TYPE_CHECKING, Any, Dict, List, Union, Iterable, Optional, cast from datetime import datetime, timezone -from typing_extensions import Literal, Annotated, TypeAliasType +from collections import deque +from typing_extensions import Literal, Annotated, TypedDict, TypeAliasType import pytest import pydantic @@ -9,7 +10,7 @@ from postgrid._utils import PropertyInfo from postgrid._compat import PYDANTIC_V1, parse_obj, model_dump, model_json -from postgrid._models import DISCRIMINATOR_CACHE, BaseModel, construct_type +from postgrid._models import DISCRIMINATOR_CACHE, BaseModel, EagerIterable, construct_type class BasicModel(BaseModel): @@ -961,3 +962,56 @@ def __getattr__(self, attr: str) -> Item: ... assert model.a.prop == 1 assert isinstance(model.a, Item) assert model.other == "foo" + + +# NOTE: Workaround for Pydantic Iterable behavior. +# Iterable fields are replaced with a ValidatorIterator and may be consumed +# during serialization, which can cause subsequent dumps to return empty data. +# See: https://github.com/pydantic/pydantic/issues/9541 +@pytest.mark.parametrize( + "data, expected_validated", + [ + ([1, 2, 3], [1, 2, 3]), + ((1, 2, 3), (1, 2, 3)), + (set([1, 2, 3]), set([1, 2, 3])), + (iter([1, 2, 3]), [1, 2, 3]), + ([], []), + ((x for x in [1, 2, 3]), [1, 2, 3]), + (map(lambda x: x, [1, 2, 3]), [1, 2, 3]), + (frozenset([1, 2, 3]), frozenset([1, 2, 3])), + (deque([1, 2, 3]), deque([1, 2, 3])), + ], + ids=["list", "tuple", "set", "iterator", "empty", "generator", "map", "frozenset", "deque"], +) +@pytest.mark.skipif(PYDANTIC_V1, reason="this is only supported in pydantic v2") +def test_iterable_construction(data: Iterable[int], expected_validated: Iterable[int]) -> None: + class TypeWithIterable(TypedDict): + items: EagerIterable[int] + + class Model(BaseModel): + data: TypeWithIterable + + m = Model.model_validate({"data": {"items": data}}) + assert m.data["items"] == expected_validated + + # Verify repeated dumps don't lose data (the original bug) + assert m.model_dump()["data"]["items"] == list(expected_validated) + assert m.model_dump()["data"]["items"] == list(expected_validated) + + +@pytest.mark.skipif(PYDANTIC_V1, reason="this is only supported in pydantic v2") +def test_iterable_construction_str_falls_back_to_list() -> None: + # str is iterable (over chars), but str(list_of_chars) produces the list's repr + # rather than reconstructing a string from items. We special-case str to fall + # back to list instead of attempting reconstruction. + class TypeWithIterable(TypedDict): + items: EagerIterable[str] + + class Model(BaseModel): + data: TypeWithIterable + + m = Model.model_validate({"data": {"items": "hello"}}) + + # falls back to list of chars rather than calling str(["h", "e", "l", "l", "o"]) + assert m.data["items"] == ["h", "e", "l", "l", "o"] + assert m.model_dump()["data"]["items"] == ["h", "e", "l", "l", "o"] From d929a01596b8a3beda921d8c4c3cbed453bc77cc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 12 May 2026 19:05:31 +0000 Subject: [PATCH 12/14] ci: pin GitHub Actions to commit SHAs Pin all GitHub Actions referenced in generated workflows (both first-party `actions/*` and third-party) to immutable commit SHAs. Updating pinned actions is now a deliberate codegen-side bump rather than implicit on every workflow run. --- .github/workflows/ci.yml | 8 ++++---- .github/workflows/publish-pypi.yml | 2 +- .github/workflows/release-doctor.yml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a198d3..d8d8eba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/postgrid-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} 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 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Install Rye run: | @@ -46,7 +46,7 @@ jobs: id-token: write runs-on: ${{ github.repository == 'stainless-sdks/postgrid-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Install Rye run: | @@ -67,7 +67,7 @@ jobs: github.repository == 'stainless-sdks/postgrid-python' && !startsWith(github.ref, 'refs/heads/stl/') id: github-oidc - uses: actions/github-script@v8 + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 with: script: core.setOutput('github_token', await core.getIDToken()); @@ -87,7 +87,7 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/postgrid-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Install Rye run: | diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index a674d45..808c90f 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Install Rye run: | diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 7d1fa04..cf1d6db 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -12,7 +12,7 @@ jobs: if: github.repository == 'postgrid/postgrid-python' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Check release environment run: | From aa4a42689f6e30a8c6566ef225f198a149ceb3d6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 13 May 2026 19:51:44 +0000 Subject: [PATCH 13/14] feat: Testing new GHA workflow --- .stats.yml | 4 +- api.md | 4 +- .../resources/print_mail/sub_organizations.py | 176 +++++++------- src/postgrid/types/print_mail/__init__.py | 4 +- ...s.py => sub_organization_create_params.py} | 4 +- ...py => sub_organization_create_response.py} | 4 +- .../print_mail/test_sub_organizations.py | 218 +++++++++--------- 7 files changed, 207 insertions(+), 207 deletions(-) rename src/postgrid/types/print_mail/{sub_organization_update_params.py => sub_organization_create_params.py} (90%) rename src/postgrid/types/print_mail/{sub_organization_update_response.py => sub_organization_create_response.py} (95%) diff --git a/.stats.yml b/.stats.yml index 1b3eb7f..3a2bf15 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 119 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/postgrid/postgrid-c0cbc48dd2e521e8bcf17c9e76d60390fd5e797a0c2529e29a382fe629628fb7.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/postgrid/postgrid-f236b45c85d9a03ce8a4aa4c457928e4e3d71a1f73a7dda26ec1a3f90b4881f3.yml openapi_spec_hash: 3562a11137635f5a513f3c1ae8421fda -config_hash: a9de56c02f36eab1b7bc2758f27e5f8c +config_hash: 4429a41bb9161a59679a1a95b1ec7053 diff --git a/api.md b/api.md index a5febf1..020ed5e 100644 --- a/api.md +++ b/api.md @@ -315,15 +315,15 @@ Types: from postgrid.types.print_mail import ( EmailPreferences, SubOrganization, - SubOrganizationUpdateResponse, + SubOrganizationCreateResponse, SubOrganizationRetrieveUsersResponse, ) ``` Methods: +- client.print_mail.sub_organizations.create(\*\*params) -> SubOrganizationCreateResponse - client.print_mail.sub_organizations.retrieve(id) -> SubOrganization -- client.print_mail.sub_organizations.update(\*\*params) -> SubOrganizationUpdateResponse - client.print_mail.sub_organizations.list(\*\*params) -> SyncSkipLimit[SubOrganization] - client.print_mail.sub_organizations.retrieve_users(id, \*\*params) -> SubOrganizationRetrieveUsersResponse diff --git a/src/postgrid/resources/print_mail/sub_organizations.py b/src/postgrid/resources/print_mail/sub_organizations.py index 9ac0561..dee02dc 100644 --- a/src/postgrid/resources/print_mail/sub_organizations.py +++ b/src/postgrid/resources/print_mail/sub_organizations.py @@ -18,11 +18,11 @@ from ..._base_client import AsyncPaginator, make_request_options from ...types.print_mail import ( sub_organization_list_params, - sub_organization_update_params, + sub_organization_create_params, sub_organization_retrieve_users_params, ) from ...types.print_mail.sub_organization import SubOrganization -from ...types.print_mail.sub_organization_update_response import SubOrganizationUpdateResponse +from ...types.print_mail.sub_organization_create_response import SubOrganizationCreateResponse from ...types.print_mail.sub_organization_retrieve_users_response import SubOrganizationRetrieveUsersResponse __all__ = ["SubOrganizationsResource", "AsyncSubOrganizationsResource"] @@ -61,40 +61,7 @@ def with_streaming_response(self) -> SubOrganizationsResourceWithStreamingRespon """ return SubOrganizationsResourceWithStreamingResponse(self) - def retrieve( - self, - id: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SubOrganization: - """ - Get a sub-organization. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return self._get( - path_template("/print-mail/v1/sub_organizations/{id}", id=id), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=SubOrganization, - ) - - def update( + def create( self, *, country_code: str, @@ -109,7 +76,7 @@ def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SubOrganizationUpdateResponse: + ) -> SubOrganizationCreateResponse: """ When creating a user through the API, the verifiedEmail field will automatically be set to true. However, if public signups are used, the email will need to be @@ -147,12 +114,45 @@ def update( "password": password, "phone_number": phone_number, }, - sub_organization_update_params.SubOrganizationUpdateParams, + sub_organization_create_params.SubOrganizationCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=SubOrganizationCreateResponse, + ) + + def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SubOrganization: + """ + Get a sub-organization. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return self._get( + path_template("/print-mail/v1/sub_organizations/{id}", id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=SubOrganizationUpdateResponse, + cast_to=SubOrganization, ) def list( @@ -293,40 +293,7 @@ def with_streaming_response(self) -> AsyncSubOrganizationsResourceWithStreamingR """ return AsyncSubOrganizationsResourceWithStreamingResponse(self) - async def retrieve( - self, - id: str, - *, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SubOrganization: - """ - Get a sub-organization. - - Args: - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not id: - raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") - return await self._get( - path_template("/print-mail/v1/sub_organizations/{id}", id=id), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=SubOrganization, - ) - - async def update( + async def create( self, *, country_code: str, @@ -341,7 +308,7 @@ async def update( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = not_given, - ) -> SubOrganizationUpdateResponse: + ) -> SubOrganizationCreateResponse: """ When creating a user through the API, the verifiedEmail field will automatically be set to true. However, if public signups are used, the email will need to be @@ -379,12 +346,45 @@ async def update( "password": password, "phone_number": phone_number, }, - sub_organization_update_params.SubOrganizationUpdateParams, + sub_organization_create_params.SubOrganizationCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), + cast_to=SubOrganizationCreateResponse, + ) + + async def retrieve( + self, + id: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + ) -> SubOrganization: + """ + Get a sub-organization. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not id: + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") + return await self._get( + path_template("/print-mail/v1/sub_organizations/{id}", id=id), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=SubOrganizationUpdateResponse, + cast_to=SubOrganization, ) def list( @@ -496,12 +496,12 @@ class SubOrganizationsResourceWithRawResponse: def __init__(self, sub_organizations: SubOrganizationsResource) -> None: self._sub_organizations = sub_organizations + self.create = to_raw_response_wrapper( + sub_organizations.create, + ) self.retrieve = to_raw_response_wrapper( sub_organizations.retrieve, ) - self.update = to_raw_response_wrapper( - sub_organizations.update, - ) self.list = to_raw_response_wrapper( sub_organizations.list, ) @@ -514,12 +514,12 @@ class AsyncSubOrganizationsResourceWithRawResponse: def __init__(self, sub_organizations: AsyncSubOrganizationsResource) -> None: self._sub_organizations = sub_organizations + self.create = async_to_raw_response_wrapper( + sub_organizations.create, + ) self.retrieve = async_to_raw_response_wrapper( sub_organizations.retrieve, ) - self.update = async_to_raw_response_wrapper( - sub_organizations.update, - ) self.list = async_to_raw_response_wrapper( sub_organizations.list, ) @@ -532,12 +532,12 @@ class SubOrganizationsResourceWithStreamingResponse: def __init__(self, sub_organizations: SubOrganizationsResource) -> None: self._sub_organizations = sub_organizations + self.create = to_streamed_response_wrapper( + sub_organizations.create, + ) self.retrieve = to_streamed_response_wrapper( sub_organizations.retrieve, ) - self.update = to_streamed_response_wrapper( - sub_organizations.update, - ) self.list = to_streamed_response_wrapper( sub_organizations.list, ) @@ -550,12 +550,12 @@ class AsyncSubOrganizationsResourceWithStreamingResponse: def __init__(self, sub_organizations: AsyncSubOrganizationsResource) -> None: self._sub_organizations = sub_organizations + self.create = async_to_streamed_response_wrapper( + sub_organizations.create, + ) self.retrieve = async_to_streamed_response_wrapper( sub_organizations.retrieve, ) - self.update = async_to_streamed_response_wrapper( - sub_organizations.update, - ) self.list = async_to_streamed_response_wrapper( sub_organizations.list, ) diff --git a/src/postgrid/types/print_mail/__init__.py b/src/postgrid/types/print_mail/__init__.py index 5760aa8..58c4f51 100644 --- a/src/postgrid/types/print_mail/__init__.py +++ b/src/postgrid/types/print_mail/__init__.py @@ -93,13 +93,13 @@ from .virtual_mailbox_create_params import VirtualMailboxCreateParams as VirtualMailboxCreateParams from .virtual_mailbox_list_response import VirtualMailboxListResponse as VirtualMailboxListResponse from .postcard_retrieve_url_response import PostcardRetrieveURLResponse as PostcardRetrieveURLResponse -from .sub_organization_update_params import SubOrganizationUpdateParams as SubOrganizationUpdateParams +from .sub_organization_create_params import SubOrganizationCreateParams as SubOrganizationCreateParams from .tracker_retrieve_visits_params import TrackerRetrieveVisitsParams as TrackerRetrieveVisitsParams from .mailing_list_import_list_params import MailingListImportListParams as MailingListImportListParams from .snap_pack_progressions_response import SnapPackProgressionsResponse as SnapPackProgressionsResponse from .targeted_list_build_list_params import TargetedListBuildListParams as TargetedListBuildListParams from .virtual_mailbox_create_response import VirtualMailboxCreateResponse as VirtualMailboxCreateResponse -from .sub_organization_update_response import SubOrganizationUpdateResponse as SubOrganizationUpdateResponse +from .sub_organization_create_response import SubOrganizationCreateResponse as SubOrganizationCreateResponse from .tracker_retrieve_visits_response import TrackerRetrieveVisitsResponse as TrackerRetrieveVisitsResponse from .mailing_list_import_create_params import MailingListImportCreateParams as MailingListImportCreateParams from .mailing_list_import_update_params import MailingListImportUpdateParams as MailingListImportUpdateParams diff --git a/src/postgrid/types/print_mail/sub_organization_update_params.py b/src/postgrid/types/print_mail/sub_organization_create_params.py similarity index 90% rename from src/postgrid/types/print_mail/sub_organization_update_params.py rename to src/postgrid/types/print_mail/sub_organization_create_params.py index 16a60a1..67ae440 100644 --- a/src/postgrid/types/print_mail/sub_organization_update_params.py +++ b/src/postgrid/types/print_mail/sub_organization_create_params.py @@ -6,10 +6,10 @@ from ..._utils import PropertyInfo -__all__ = ["SubOrganizationUpdateParams"] +__all__ = ["SubOrganizationCreateParams"] -class SubOrganizationUpdateParams(TypedDict, total=False): +class SubOrganizationCreateParams(TypedDict, total=False): country_code: Required[Annotated[str, PropertyInfo(alias="countryCode")]] """The country code of the sub-organization.""" diff --git a/src/postgrid/types/print_mail/sub_organization_update_response.py b/src/postgrid/types/print_mail/sub_organization_create_response.py similarity index 95% rename from src/postgrid/types/print_mail/sub_organization_update_response.py rename to src/postgrid/types/print_mail/sub_organization_create_response.py index bf20be1..24c3608 100644 --- a/src/postgrid/types/print_mail/sub_organization_update_response.py +++ b/src/postgrid/types/print_mail/sub_organization_create_response.py @@ -9,7 +9,7 @@ from .sub_organization import SubOrganization from .email_preferences import EmailPreferences -__all__ = ["SubOrganizationUpdateResponse", "User", "UserAPIKey"] +__all__ = ["SubOrganizationCreateResponse", "User", "UserAPIKey"] class UserAPIKey(BaseModel): @@ -69,7 +69,7 @@ class User(BaseModel): """ -class SubOrganizationUpdateResponse(BaseModel): +class SubOrganizationCreateResponse(BaseModel): sub_organization: SubOrganization = FieldInfo(alias="subOrganization") """The Sub-Organization object.""" diff --git a/tests/api_resources/print_mail/test_sub_organizations.py b/tests/api_resources/print_mail/test_sub_organizations.py index 8f4ef5b..7b165f8 100644 --- a/tests/api_resources/print_mail/test_sub_organizations.py +++ b/tests/api_resources/print_mail/test_sub_organizations.py @@ -12,7 +12,7 @@ from postgrid.pagination import SyncSkipLimit, AsyncSkipLimit from postgrid.types.print_mail import ( SubOrganization, - SubOrganizationUpdateResponse, + SubOrganizationCreateResponse, SubOrganizationRetrieveUsersResponse, ) @@ -24,62 +24,20 @@ class TestSubOrganizations: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - def test_method_retrieve(self, client: PostGrid) -> None: - sub_organization = client.print_mail.sub_organizations.retrieve( - "id", - ) - assert_matches_type(SubOrganization, sub_organization, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_raw_response_retrieve(self, client: PostGrid) -> None: - response = client.print_mail.sub_organizations.with_raw_response.retrieve( - "id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - sub_organization = response.parse() - assert_matches_type(SubOrganization, sub_organization, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_streaming_response_retrieve(self, client: PostGrid) -> None: - with client.print_mail.sub_organizations.with_streaming_response.retrieve( - "id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - sub_organization = response.parse() - assert_matches_type(SubOrganization, sub_organization, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_path_params_retrieve(self, client: PostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - client.print_mail.sub_organizations.with_raw_response.retrieve( - "", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - def test_method_update(self, client: PostGrid) -> None: - sub_organization = client.print_mail.sub_organizations.update( + def test_method_create(self, client: PostGrid) -> None: + sub_organization = client.print_mail.sub_organizations.create( country_code="CA", email="suborg@postgrid.com", name="Calvin", organization_name="PostGrid", password="very-strong-password", ) - assert_matches_type(SubOrganizationUpdateResponse, sub_organization, path=["response"]) + assert_matches_type(SubOrganizationCreateResponse, sub_organization, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - def test_method_update_with_all_params(self, client: PostGrid) -> None: - sub_organization = client.print_mail.sub_organizations.update( + def test_method_create_with_all_params(self, client: PostGrid) -> None: + sub_organization = client.print_mail.sub_organizations.create( country_code="CA", email="suborg@postgrid.com", name="Calvin", @@ -87,12 +45,12 @@ def test_method_update_with_all_params(self, client: PostGrid) -> None: password="very-strong-password", phone_number="9059059059", ) - assert_matches_type(SubOrganizationUpdateResponse, sub_organization, path=["response"]) + assert_matches_type(SubOrganizationCreateResponse, sub_organization, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - def test_raw_response_update(self, client: PostGrid) -> None: - response = client.print_mail.sub_organizations.with_raw_response.update( + def test_raw_response_create(self, client: PostGrid) -> None: + response = client.print_mail.sub_organizations.with_raw_response.create( country_code="CA", email="suborg@postgrid.com", name="Calvin", @@ -103,12 +61,12 @@ def test_raw_response_update(self, client: PostGrid) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" sub_organization = response.parse() - assert_matches_type(SubOrganizationUpdateResponse, sub_organization, path=["response"]) + assert_matches_type(SubOrganizationCreateResponse, sub_organization, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - def test_streaming_response_update(self, client: PostGrid) -> None: - with client.print_mail.sub_organizations.with_streaming_response.update( + def test_streaming_response_create(self, client: PostGrid) -> None: + with client.print_mail.sub_organizations.with_streaming_response.create( country_code="CA", email="suborg@postgrid.com", name="Calvin", @@ -119,10 +77,52 @@ def test_streaming_response_update(self, client: PostGrid) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" sub_organization = response.parse() - assert_matches_type(SubOrganizationUpdateResponse, sub_organization, path=["response"]) + assert_matches_type(SubOrganizationCreateResponse, sub_organization, path=["response"]) assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_method_retrieve(self, client: PostGrid) -> None: + sub_organization = client.print_mail.sub_organizations.retrieve( + "id", + ) + assert_matches_type(SubOrganization, sub_organization, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_raw_response_retrieve(self, client: PostGrid) -> None: + response = client.print_mail.sub_organizations.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + sub_organization = response.parse() + assert_matches_type(SubOrganization, sub_organization, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_streaming_response_retrieve(self, client: PostGrid) -> None: + with client.print_mail.sub_organizations.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + sub_organization = response.parse() + assert_matches_type(SubOrganization, sub_organization, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + def test_path_params_retrieve(self, client: PostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + client.print_mail.sub_organizations.with_raw_response.retrieve( + "", + ) + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize def test_method_list(self, client: PostGrid) -> None: @@ -222,62 +222,20 @@ class TestAsyncSubOrganizations: @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_retrieve(self, async_client: AsyncPostGrid) -> None: - sub_organization = await async_client.print_mail.sub_organizations.retrieve( - "id", - ) - assert_matches_type(SubOrganization, sub_organization, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_raw_response_retrieve(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.sub_organizations.with_raw_response.retrieve( - "id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - sub_organization = await response.parse() - assert_matches_type(SubOrganization, sub_organization, path=["response"]) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_streaming_response_retrieve(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.sub_organizations.with_streaming_response.retrieve( - "id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - sub_organization = await response.parse() - assert_matches_type(SubOrganization, sub_organization, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_path_params_retrieve(self, async_client: AsyncPostGrid) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await async_client.print_mail.sub_organizations.with_raw_response.retrieve( - "", - ) - - @pytest.mark.skip(reason="Mock server tests are disabled") - @parametrize - async def test_method_update(self, async_client: AsyncPostGrid) -> None: - sub_organization = await async_client.print_mail.sub_organizations.update( + async def test_method_create(self, async_client: AsyncPostGrid) -> None: + sub_organization = await async_client.print_mail.sub_organizations.create( country_code="CA", email="suborg@postgrid.com", name="Calvin", organization_name="PostGrid", password="very-strong-password", ) - assert_matches_type(SubOrganizationUpdateResponse, sub_organization, path=["response"]) + assert_matches_type(SubOrganizationCreateResponse, sub_organization, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_method_update_with_all_params(self, async_client: AsyncPostGrid) -> None: - sub_organization = await async_client.print_mail.sub_organizations.update( + async def test_method_create_with_all_params(self, async_client: AsyncPostGrid) -> None: + sub_organization = await async_client.print_mail.sub_organizations.create( country_code="CA", email="suborg@postgrid.com", name="Calvin", @@ -285,12 +243,12 @@ async def test_method_update_with_all_params(self, async_client: AsyncPostGrid) password="very-strong-password", phone_number="9059059059", ) - assert_matches_type(SubOrganizationUpdateResponse, sub_organization, path=["response"]) + assert_matches_type(SubOrganizationCreateResponse, sub_organization, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_raw_response_update(self, async_client: AsyncPostGrid) -> None: - response = await async_client.print_mail.sub_organizations.with_raw_response.update( + async def test_raw_response_create(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.sub_organizations.with_raw_response.create( country_code="CA", email="suborg@postgrid.com", name="Calvin", @@ -301,12 +259,12 @@ async def test_raw_response_update(self, async_client: AsyncPostGrid) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" sub_organization = await response.parse() - assert_matches_type(SubOrganizationUpdateResponse, sub_organization, path=["response"]) + assert_matches_type(SubOrganizationCreateResponse, sub_organization, path=["response"]) @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize - async def test_streaming_response_update(self, async_client: AsyncPostGrid) -> None: - async with async_client.print_mail.sub_organizations.with_streaming_response.update( + async def test_streaming_response_create(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.sub_organizations.with_streaming_response.create( country_code="CA", email="suborg@postgrid.com", name="Calvin", @@ -317,10 +275,52 @@ async def test_streaming_response_update(self, async_client: AsyncPostGrid) -> N assert response.http_request.headers.get("X-Stainless-Lang") == "python" sub_organization = await response.parse() - assert_matches_type(SubOrganizationUpdateResponse, sub_organization, path=["response"]) + assert_matches_type(SubOrganizationCreateResponse, sub_organization, path=["response"]) assert cast(Any, response.is_closed) is True + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_method_retrieve(self, async_client: AsyncPostGrid) -> None: + sub_organization = await async_client.print_mail.sub_organizations.retrieve( + "id", + ) + assert_matches_type(SubOrganization, sub_organization, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncPostGrid) -> None: + response = await async_client.print_mail.sub_organizations.with_raw_response.retrieve( + "id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + sub_organization = await response.parse() + assert_matches_type(SubOrganization, sub_organization, path=["response"]) + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncPostGrid) -> None: + async with async_client.print_mail.sub_organizations.with_streaming_response.retrieve( + "id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + sub_organization = await response.parse() + assert_matches_type(SubOrganization, sub_organization, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip(reason="Mock server tests are disabled") + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncPostGrid) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): + await async_client.print_mail.sub_organizations.with_raw_response.retrieve( + "", + ) + @pytest.mark.skip(reason="Mock server tests are disabled") @parametrize async def test_method_list(self, async_client: AsyncPostGrid) -> None: From b18087e81db7cd0336cc27594e4ec826f182a45b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 13 May 2026 19:52:10 +0000 Subject: [PATCH 14/14] release: 2.2.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 29 +++++++++++++++++++++++++++++ pyproject.toml | 2 +- src/postgrid/_version.py | 2 +- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 19588bd..bfc26f9 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.1.1" + ".": "2.2.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dd0a44..4a9b637 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,34 @@ # Changelog +## 2.2.0 (2026-05-13) + +Full Changelog: [v2.1.1...v2.2.0](https://github.com/postgrid/postgrid-python/compare/v2.1.1...v2.2.0) + +### Features + +* **api:** Generate OpenAPI spec from master, Complete AV endpoints, Deprecate order profiles ([e077d42](https://github.com/postgrid/postgrid-python/commit/e077d42c1fa32be25d6b458d0095c4a94a008ad1)) +* **api:** sheikh's updates ([bdc7fef](https://github.com/postgrid/postgrid-python/commit/bdc7fef6407b6906f7289f302a1281bc76730297)) +* **internal/types:** support eagerly validating pydantic iterators ([2124510](https://github.com/postgrid/postgrid-python/commit/2124510f8373868ec16a60ffdccd6f5d47e7ad17)) +* support setting headers via env ([e690d3e](https://github.com/postgrid/postgrid-python/commit/e690d3eea529e14db8ef172128b126e9c62a0bfa)) +* Testing new GHA workflow ([aa4a426](https://github.com/postgrid/postgrid-python/commit/aa4a42689f6e30a8c6566ef225f198a149ceb3d6)) + + +### Bug Fixes + +* **client:** add missing f-string prefix in file type error message ([459beb6](https://github.com/postgrid/postgrid-python/commit/459beb65a1c41126dd02d19cabf529c45c8e531c)) +* use correct field name format for multipart file arrays ([4662cc7](https://github.com/postgrid/postgrid-python/commit/4662cc7a36251fb808df1ac04ee5bbecfeaf9ebb)) + + +### Performance Improvements + +* **client:** optimize file structure copying in multipart requests ([ad870fb](https://github.com/postgrid/postgrid-python/commit/ad870fb8a30f20b4193f7eed5a96755a9a656228)) + + +### Chores + +* **internal:** more robust bootstrap script ([e3ae215](https://github.com/postgrid/postgrid-python/commit/e3ae21534f0e6048dd59631aa02c04d5c1f3a681)) +* **internal:** reformat pyproject.toml ([872adb3](https://github.com/postgrid/postgrid-python/commit/872adb3468462b205c3619f1de65cf163f982ad3)) + ## 2.1.1 (2026-04-10) Full Changelog: [v2.1.0...v2.1.1](https://github.com/postgrid/postgrid-python/compare/v2.1.0...v2.1.1) diff --git a/pyproject.toml b/pyproject.toml index f7f9f94..f4253ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "postgrid-python" -version = "2.1.1" +version = "2.2.0" description = "The official Python library for the PostGrid API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/postgrid/_version.py b/src/postgrid/_version.py index b4b4503..4752289 100644 --- a/src/postgrid/_version.py +++ b/src/postgrid/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "postgrid" -__version__ = "2.1.1" # x-release-please-version +__version__ = "2.2.0" # x-release-please-version