diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b865379..40293964 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: lint: name: lint runs-on: ubuntu-latest - if: github.repository == 'orbcorp/orb-python' + steps: - uses: actions/checkout@v4 @@ -33,7 +33,6 @@ jobs: test: name: test runs-on: ubuntu-latest - if: github.repository == 'orbcorp/orb-python' steps: - uses: actions/checkout@v4 diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 65f558e7..656a2ef1 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.0.0" + ".": "2.1.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index f069adb9..16809d9a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 91 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb-83ae433113181f3839cc63db01cc7c815de1fff597a1cbaf8ffda48ba98268c9.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-67c238400cda65d40994581c7d37ad182a7d737e8abf3accfbc5ac5b04f64f07.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index abebbc1a..bfced2c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## 2.1.0 (2024-08-14) + +Full Changelog: [v2.0.0...v2.1.0](https://github.com/orbcorp/orb-python/compare/v2.0.0...v2.1.0) + +### Features + +* **api:** OpenAPI spec update via Stainless API ([#338](https://github.com/orbcorp/orb-python/issues/338)) ([ff005e5](https://github.com/orbcorp/orb-python/commit/ff005e562aeebdc0b4c4a6f91f1dad7af7030d2e)) +* **client:** add `retries_taken` to raw response class ([#334](https://github.com/orbcorp/orb-python/issues/334)) ([99d1df1](https://github.com/orbcorp/orb-python/commit/99d1df1a5da230325d47e8c1cc8bf1da53e74253)) + + +### Chores + +* **internal:** bump pyright ([#333](https://github.com/orbcorp/orb-python/issues/333)) ([7678fca](https://github.com/orbcorp/orb-python/commit/7678fca8726890c52693c1ff9747f81379749245)) +* **internal:** bump ruff version ([#336](https://github.com/orbcorp/orb-python/issues/336)) ([dffe52f](https://github.com/orbcorp/orb-python/commit/dffe52ffdd81cd279b0c789d8c4bfc72493b848a)) +* **internal:** test updates ([#335](https://github.com/orbcorp/orb-python/issues/335)) ([ef3b8d2](https://github.com/orbcorp/orb-python/commit/ef3b8d2fc6ae76a79cf08ddd9f3142c594459aa5)) +* **internal:** update pydantic compat helper function ([#337](https://github.com/orbcorp/orb-python/issues/337)) ([d8a0d01](https://github.com/orbcorp/orb-python/commit/d8a0d01d4b2b43a8b6a7d6e69891d5ec4ff20809)) +* **internal:** use `TypeAlias` marker for type assignments ([#331](https://github.com/orbcorp/orb-python/issues/331)) ([5208144](https://github.com/orbcorp/orb-python/commit/5208144f3767ed7e615ca066c9185b861ca73969)) + ## 2.0.0 (2024-08-02) Full Changelog: [v1.56.0...v2.0.0](https://github.com/orbcorp/orb-python/compare/v1.56.0...v2.0.0) diff --git a/pyproject.toml b/pyproject.toml index 45592108..757f78b5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "orb-billing" -version = "2.0.0" +version = "2.1.0" description = "The official Python library for the orb API" dynamic = ["readme"] license = "Apache-2.0" @@ -76,9 +76,12 @@ format = { chain = [ "lint" = { chain = [ "check:ruff", "typecheck", + "check:importable", ]} -"check:ruff" = "ruff ." -"fix:ruff" = "ruff --fix ." +"check:ruff" = "ruff check ." +"fix:ruff" = "ruff check --fix ." + +"check:importable" = "python -c 'import orb'" typecheck = { chain = [ "typecheck:pyright", @@ -162,6 +165,11 @@ reportPrivateUsage = false line-length = 120 output-format = "grouped" target-version = "py37" + +[tool.ruff.format] +docstring-code-format = true + +[tool.ruff.lint] select = [ # isort "I", @@ -190,10 +198,6 @@ unfixable = [ "T201", "T203", ] -ignore-init-module-imports = true - -[tool.ruff.format] -docstring-code-format = true [tool.ruff.lint.flake8-tidy-imports.banned-api] "functools.lru_cache".msg = "This function does not retain type information for the wrapped function's arguments; The `lru_cache` function from `_utils` should be used instead" @@ -205,7 +209,7 @@ combine-as-imports = true extra-standard-library = ["typing_extensions"] known-first-party = ["orb", "tests"] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "bin/**.py" = ["T201", "T203"] "scripts/**.py" = ["T201", "T203"] "tests/**.py" = ["T201", "T203"] diff --git a/requirements-dev.lock b/requirements-dev.lock index 640a1a72..3eed038a 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -70,7 +70,7 @@ pydantic-core==2.18.2 # via pydantic pygments==2.18.0 # via rich -pyright==1.1.364 +pyright==1.1.374 pytest==7.1.1 # via pytest-asyncio pytest-asyncio==0.21.1 @@ -80,7 +80,7 @@ pytz==2023.3.post1 # via dirty-equals respx==0.20.2 rich==13.7.1 -ruff==0.1.9 +ruff==0.5.6 setuptools==68.2.2 # via nodeenv six==1.16.0 diff --git a/scripts/mock b/scripts/mock index f5861576..d2814ae6 100755 --- a/scripts/mock +++ b/scripts/mock @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}" # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then - npm exec --package=@stainless-api/prism-cli@5.8.4 -- prism mock "$URL" &> .prism.log & + npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" &> .prism.log & # Wait for server to come online echo -n "Waiting for server" @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stainless-api/prism-cli@5.8.4 -- prism mock "$URL" + npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" fi diff --git a/src/orb/_base_client.py b/src/orb/_base_client.py index 859bc01f..adf1a9b2 100644 --- a/src/orb/_base_client.py +++ b/src/orb/_base_client.py @@ -125,16 +125,14 @@ def __init__( self, *, url: URL, - ) -> None: - ... + ) -> None: ... @overload def __init__( self, *, params: Query, - ) -> None: - ... + ) -> None: ... def __init__( self, @@ -167,8 +165,7 @@ def has_next_page(self) -> bool: return False return self.next_page_info() is not None - def next_page_info(self) -> Optional[PageInfo]: - ... + def next_page_info(self) -> Optional[PageInfo]: ... def _get_page_items(self) -> Iterable[_T]: # type: ignore[empty-body] ... @@ -904,8 +901,7 @@ def request( *, stream: Literal[True], stream_cls: Type[_StreamT], - ) -> _StreamT: - ... + ) -> _StreamT: ... @overload def request( @@ -915,8 +911,7 @@ def request( remaining_retries: Optional[int] = None, *, stream: Literal[False] = False, - ) -> ResponseT: - ... + ) -> ResponseT: ... @overload def request( @@ -927,8 +922,7 @@ def request( *, stream: bool = False, stream_cls: Type[_StreamT] | None = None, - ) -> ResponseT | _StreamT: - ... + ) -> ResponseT | _StreamT: ... def request( self, @@ -1050,6 +1044,7 @@ def _request( response=response, stream=stream, stream_cls=stream_cls, + retries_taken=options.get_max_retries(self.max_retries) - retries, ) def _retry_request( @@ -1091,6 +1086,7 @@ def _process_response( response: httpx.Response, stream: bool, stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None, + retries_taken: int = 0, ) -> ResponseT: if response.request.headers.get(RAW_RESPONSE_HEADER) == "true": return cast( @@ -1102,6 +1098,7 @@ def _process_response( stream=stream, stream_cls=stream_cls, options=options, + retries_taken=retries_taken, ), ) @@ -1121,6 +1118,7 @@ def _process_response( stream=stream, stream_cls=stream_cls, options=options, + retries_taken=retries_taken, ), ) @@ -1134,6 +1132,7 @@ def _process_response( stream=stream, stream_cls=stream_cls, options=options, + retries_taken=retries_taken, ) if bool(response.request.headers.get(RAW_RESPONSE_HEADER)): return cast(ResponseT, api_response) @@ -1166,8 +1165,7 @@ def get( cast_to: Type[ResponseT], options: RequestOptions = {}, stream: Literal[False] = False, - ) -> ResponseT: - ... + ) -> ResponseT: ... @overload def get( @@ -1178,8 +1176,7 @@ def get( options: RequestOptions = {}, stream: Literal[True], stream_cls: type[_StreamT], - ) -> _StreamT: - ... + ) -> _StreamT: ... @overload def get( @@ -1190,8 +1187,7 @@ def get( options: RequestOptions = {}, stream: bool, stream_cls: type[_StreamT] | None = None, - ) -> ResponseT | _StreamT: - ... + ) -> ResponseT | _StreamT: ... def get( self, @@ -1217,8 +1213,7 @@ def post( options: RequestOptions = {}, files: RequestFiles | None = None, stream: Literal[False] = False, - ) -> ResponseT: - ... + ) -> ResponseT: ... @overload def post( @@ -1231,8 +1226,7 @@ def post( files: RequestFiles | None = None, stream: Literal[True], stream_cls: type[_StreamT], - ) -> _StreamT: - ... + ) -> _StreamT: ... @overload def post( @@ -1245,8 +1239,7 @@ def post( files: RequestFiles | None = None, stream: bool, stream_cls: type[_StreamT] | None = None, - ) -> ResponseT | _StreamT: - ... + ) -> ResponseT | _StreamT: ... def post( self, @@ -1479,8 +1472,7 @@ async def request( *, stream: Literal[False] = False, remaining_retries: Optional[int] = None, - ) -> ResponseT: - ... + ) -> ResponseT: ... @overload async def request( @@ -1491,8 +1483,7 @@ async def request( stream: Literal[True], stream_cls: type[_AsyncStreamT], remaining_retries: Optional[int] = None, - ) -> _AsyncStreamT: - ... + ) -> _AsyncStreamT: ... @overload async def request( @@ -1503,8 +1494,7 @@ async def request( stream: bool, stream_cls: type[_AsyncStreamT] | None = None, remaining_retries: Optional[int] = None, - ) -> ResponseT | _AsyncStreamT: - ... + ) -> ResponseT | _AsyncStreamT: ... async def request( self, @@ -1624,6 +1614,7 @@ async def _request( response=response, stream=stream, stream_cls=stream_cls, + retries_taken=options.get_max_retries(self.max_retries) - retries, ) async def _retry_request( @@ -1663,6 +1654,7 @@ async def _process_response( response: httpx.Response, stream: bool, stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None, + retries_taken: int = 0, ) -> ResponseT: if response.request.headers.get(RAW_RESPONSE_HEADER) == "true": return cast( @@ -1674,6 +1666,7 @@ async def _process_response( stream=stream, stream_cls=stream_cls, options=options, + retries_taken=retries_taken, ), ) @@ -1693,6 +1686,7 @@ async def _process_response( stream=stream, stream_cls=stream_cls, options=options, + retries_taken=retries_taken, ), ) @@ -1706,6 +1700,7 @@ async def _process_response( stream=stream, stream_cls=stream_cls, options=options, + retries_taken=retries_taken, ) if bool(response.request.headers.get(RAW_RESPONSE_HEADER)): return cast(ResponseT, api_response) @@ -1728,8 +1723,7 @@ async def get( cast_to: Type[ResponseT], options: RequestOptions = {}, stream: Literal[False] = False, - ) -> ResponseT: - ... + ) -> ResponseT: ... @overload async def get( @@ -1740,8 +1734,7 @@ async def get( options: RequestOptions = {}, stream: Literal[True], stream_cls: type[_AsyncStreamT], - ) -> _AsyncStreamT: - ... + ) -> _AsyncStreamT: ... @overload async def get( @@ -1752,8 +1745,7 @@ async def get( options: RequestOptions = {}, stream: bool, stream_cls: type[_AsyncStreamT] | None = None, - ) -> ResponseT | _AsyncStreamT: - ... + ) -> ResponseT | _AsyncStreamT: ... async def get( self, @@ -1777,8 +1769,7 @@ async def post( files: RequestFiles | None = None, options: RequestOptions = {}, stream: Literal[False] = False, - ) -> ResponseT: - ... + ) -> ResponseT: ... @overload async def post( @@ -1791,8 +1782,7 @@ async def post( options: RequestOptions = {}, stream: Literal[True], stream_cls: type[_AsyncStreamT], - ) -> _AsyncStreamT: - ... + ) -> _AsyncStreamT: ... @overload async def post( @@ -1805,8 +1795,7 @@ async def post( options: RequestOptions = {}, stream: bool, stream_cls: type[_AsyncStreamT] | None = None, - ) -> ResponseT | _AsyncStreamT: - ... + ) -> ResponseT | _AsyncStreamT: ... async def post( self, diff --git a/src/orb/_compat.py b/src/orb/_compat.py index c919b5ad..21fe6941 100644 --- a/src/orb/_compat.py +++ b/src/orb/_compat.py @@ -7,7 +7,7 @@ import pydantic from pydantic.fields import FieldInfo -from ._types import StrBytesIntFloat +from ._types import IncEx, StrBytesIntFloat _T = TypeVar("_T") _ModelT = TypeVar("_ModelT", bound=pydantic.BaseModel) @@ -133,17 +133,20 @@ def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str: def model_dump( model: pydantic.BaseModel, *, + exclude: IncEx = None, exclude_unset: bool = False, exclude_defaults: bool = False, ) -> dict[str, Any]: if PYDANTIC_V2: return model.model_dump( + exclude=exclude, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, ) return cast( "dict[str, Any]", model.dict( # pyright: ignore[reportDeprecated, reportUnnecessaryCast] + exclude=exclude, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, ), @@ -159,22 +162,19 @@ def model_parse(model: type[_ModelT], data: Any) -> _ModelT: # generic models if TYPE_CHECKING: - class GenericModel(pydantic.BaseModel): - ... + class GenericModel(pydantic.BaseModel): ... else: if PYDANTIC_V2: # there no longer needs to be a distinction in v2 but # we still have to create our own subclass to avoid # inconsistent MRO ordering errors - class GenericModel(pydantic.BaseModel): - ... + class GenericModel(pydantic.BaseModel): ... else: import pydantic.generics - class GenericModel(pydantic.generics.GenericModel, pydantic.BaseModel): - ... + class GenericModel(pydantic.generics.GenericModel, pydantic.BaseModel): ... # cached properties @@ -193,26 +193,21 @@ class typed_cached_property(Generic[_T]): func: Callable[[Any], _T] attrname: str | None - def __init__(self, func: Callable[[Any], _T]) -> None: - ... + def __init__(self, func: Callable[[Any], _T]) -> None: ... @overload - def __get__(self, instance: None, owner: type[Any] | None = None) -> Self: - ... + def __get__(self, instance: None, owner: type[Any] | None = None) -> Self: ... @overload - def __get__(self, instance: object, owner: type[Any] | None = None) -> _T: - ... + def __get__(self, instance: object, owner: type[Any] | None = None) -> _T: ... def __get__(self, instance: object, owner: type[Any] | None = None) -> _T | Self: raise NotImplementedError() - def __set_name__(self, owner: type[Any], name: str) -> None: - ... + def __set_name__(self, owner: type[Any], name: str) -> None: ... # __set__ is not defined at runtime, but @cached_property is designed to be settable - def __set__(self, instance: object, value: _T) -> None: - ... + def __set__(self, instance: object, value: _T) -> None: ... else: try: from functools import cached_property as cached_property diff --git a/src/orb/_files.py b/src/orb/_files.py index 0d2022ae..715cc207 100644 --- a/src/orb/_files.py +++ b/src/orb/_files.py @@ -39,13 +39,11 @@ def assert_is_file_content(obj: object, *, key: str | None = None) -> None: @overload -def to_httpx_files(files: None) -> None: - ... +def to_httpx_files(files: None) -> None: ... @overload -def to_httpx_files(files: RequestFiles) -> HttpxRequestFiles: - ... +def to_httpx_files(files: RequestFiles) -> HttpxRequestFiles: ... def to_httpx_files(files: RequestFiles | None) -> HttpxRequestFiles | None: @@ -83,13 +81,11 @@ def _read_file_content(file: FileContent) -> HttpxFileContent: @overload -async def async_to_httpx_files(files: None) -> None: - ... +async def async_to_httpx_files(files: None) -> None: ... @overload -async def async_to_httpx_files(files: RequestFiles) -> HttpxRequestFiles: - ... +async def async_to_httpx_files(files: RequestFiles) -> HttpxRequestFiles: ... async def async_to_httpx_files(files: RequestFiles | None) -> HttpxRequestFiles | None: diff --git a/src/orb/_legacy_response.py b/src/orb/_legacy_response.py index 6fb2d7fd..a808044e 100644 --- a/src/orb/_legacy_response.py +++ b/src/orb/_legacy_response.py @@ -5,7 +5,18 @@ import logging import datetime import functools -from typing import TYPE_CHECKING, Any, Union, Generic, TypeVar, Callable, Iterator, AsyncIterator, cast, overload +from typing import ( + TYPE_CHECKING, + Any, + Union, + Generic, + TypeVar, + Callable, + Iterator, + AsyncIterator, + cast, + overload, +) from typing_extensions import Awaitable, ParamSpec, override, deprecated, get_origin import anyio @@ -53,6 +64,9 @@ class LegacyAPIResponse(Generic[R]): http_response: httpx.Response + retries_taken: int + """The number of retries made. If no retries happened this will be `0`""" + def __init__( self, *, @@ -62,6 +76,7 @@ def __init__( stream: bool, stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None, options: FinalRequestOptions, + retries_taken: int = 0, ) -> None: self._cast_to = cast_to self._client = client @@ -70,14 +85,13 @@ def __init__( self._stream_cls = stream_cls self._options = options self.http_response = raw + self.retries_taken = retries_taken @overload - def parse(self, *, to: type[_T]) -> _T: - ... + def parse(self, *, to: type[_T]) -> _T: ... @overload - def parse(self) -> R: - ... + def parse(self) -> R: ... def parse(self, *, to: type[_T] | None = None) -> R | _T: """Returns the rich python representation of this response's data. diff --git a/src/orb/_response.py b/src/orb/_response.py index a3332803..bde0a041 100644 --- a/src/orb/_response.py +++ b/src/orb/_response.py @@ -55,6 +55,9 @@ class BaseAPIResponse(Generic[R]): http_response: httpx.Response + retries_taken: int + """The number of retries made. If no retries happened this will be `0`""" + def __init__( self, *, @@ -64,6 +67,7 @@ def __init__( stream: bool, stream_cls: type[Stream[Any]] | type[AsyncStream[Any]] | None, options: FinalRequestOptions, + retries_taken: int = 0, ) -> None: self._cast_to = cast_to self._client = client @@ -72,6 +76,7 @@ def __init__( self._stream_cls = stream_cls self._options = options self.http_response = raw + self.retries_taken = retries_taken @property def headers(self) -> httpx.Headers: @@ -259,12 +264,10 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T: class APIResponse(BaseAPIResponse[R]): @overload - def parse(self, *, to: type[_T]) -> _T: - ... + def parse(self, *, to: type[_T]) -> _T: ... @overload - def parse(self) -> R: - ... + def parse(self) -> R: ... def parse(self, *, to: type[_T] | None = None) -> R | _T: """Returns the rich python representation of this response's data. @@ -363,12 +366,10 @@ def iter_lines(self) -> Iterator[str]: class AsyncAPIResponse(BaseAPIResponse[R]): @overload - async def parse(self, *, to: type[_T]) -> _T: - ... + async def parse(self, *, to: type[_T]) -> _T: ... @overload - async def parse(self) -> R: - ... + async def parse(self) -> R: ... async def parse(self, *, to: type[_T] | None = None) -> R | _T: """Returns the rich python representation of this response's data. diff --git a/src/orb/_types.py b/src/orb/_types.py index 4e90cff0..a6120d6a 100644 --- a/src/orb/_types.py +++ b/src/orb/_types.py @@ -112,8 +112,7 @@ class NotGiven: For example: ```py - def get(timeout: Union[int, NotGiven, None] = NotGiven()) -> Response: - ... + def get(timeout: Union[int, NotGiven, None] = NotGiven()) -> Response: ... get(timeout=1) # 1s timeout @@ -163,16 +162,14 @@ def build( *, response: Response, data: object, - ) -> _T: - ... + ) -> _T: ... Headers = Mapping[str, Union[str, Omit]] class HeadersLikeProtocol(Protocol): - def get(self, __key: str) -> str | None: - ... + def get(self, __key: str) -> str | None: ... HeadersLike = Union[Headers, HeadersLikeProtocol] diff --git a/src/orb/_utils/_proxy.py b/src/orb/_utils/_proxy.py index c46a62a6..ffd883e9 100644 --- a/src/orb/_utils/_proxy.py +++ b/src/orb/_utils/_proxy.py @@ -59,5 +59,4 @@ def __as_proxied__(self) -> T: return cast(T, self) @abstractmethod - def __load__(self) -> T: - ... + def __load__(self) -> T: ... diff --git a/src/orb/_utils/_reflection.py b/src/orb/_utils/_reflection.py index 9a53c7bd..89aa712a 100644 --- a/src/orb/_utils/_reflection.py +++ b/src/orb/_utils/_reflection.py @@ -34,7 +34,7 @@ def assert_signatures_in_sync( if custom_param.annotation != source_param.annotation: errors.append( - f"types for the `{name}` param are do not match; source={repr(source_param.annotation)} checking={repr(source_param.annotation)}" + f"types for the `{name}` param are do not match; source={repr(source_param.annotation)} checking={repr(custom_param.annotation)}" ) continue diff --git a/src/orb/_utils/_utils.py b/src/orb/_utils/_utils.py index 34797c29..2fc5a1c6 100644 --- a/src/orb/_utils/_utils.py +++ b/src/orb/_utils/_utils.py @@ -211,20 +211,17 @@ def required_args(*variants: Sequence[str]) -> Callable[[CallableT], CallableT]: Example usage: ```py @overload - def foo(*, a: str) -> str: - ... + def foo(*, a: str) -> str: ... @overload - def foo(*, b: bool) -> str: - ... + def foo(*, b: bool) -> str: ... # This enforces the same constraints that a static type checker would # i.e. that either a or b must be passed to the function @required_args(["a"], ["b"]) - def foo(*, a: str | None = None, b: bool | None = None) -> str: - ... + def foo(*, a: str | None = None, b: bool | None = None) -> str: ... ``` """ @@ -286,18 +283,15 @@ def wrapper(*args: object, **kwargs: object) -> object: @overload -def strip_not_given(obj: None) -> None: - ... +def strip_not_given(obj: None) -> None: ... @overload -def strip_not_given(obj: Mapping[_K, _V | NotGiven]) -> dict[_K, _V]: - ... +def strip_not_given(obj: Mapping[_K, _V | NotGiven]) -> dict[_K, _V]: ... @overload -def strip_not_given(obj: object) -> object: - ... +def strip_not_given(obj: object) -> object: ... def strip_not_given(obj: object | None) -> object: diff --git a/src/orb/_version.py b/src/orb/_version.py index 72aa4e1e..8b0aea3d 100644 --- a/src/orb/_version.py +++ b/src/orb/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "orb" -__version__ = "2.0.0" # x-release-please-version +__version__ = "2.1.0" # x-release-please-version diff --git a/src/orb/resources/alerts.py b/src/orb/resources/alerts.py index 99894754..38f5a820 100644 --- a/src/orb/resources/alerts.py +++ b/src/orb/resources/alerts.py @@ -4,6 +4,7 @@ from typing import Union, Iterable, Optional from datetime import datetime +from typing_extensions import Literal import httpx @@ -154,7 +155,13 @@ def create_for_customer( customer_id: str, *, currency: str, - type: str, + type: Literal[ + "usage_exceeded", + "cost_exceeded", + "credit_balance_depleted", + "credit_balance_dropped", + "credit_balance_recovered", + ], thresholds: Optional[Iterable[alert_create_for_customer_params.Threshold]] | NotGiven = NOT_GIVEN, # 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. @@ -179,9 +186,9 @@ def create_for_customer( Args: currency: The case sensitive currency or custom pricing unit to use for this alert. - type: The thresholds that define the values at which the alert will be triggered. + type: The type of alert to create. This must be a valid alert type. - thresholds: The thresholds for the alert. + thresholds: The thresholds that define the values at which the alert will be triggered. extra_headers: Send extra headers @@ -220,7 +227,13 @@ def create_for_external_customer( external_customer_id: str, *, currency: str, - type: str, + type: Literal[ + "usage_exceeded", + "cost_exceeded", + "credit_balance_depleted", + "credit_balance_dropped", + "credit_balance_recovered", + ], thresholds: Optional[Iterable[alert_create_for_external_customer_params.Threshold]] | NotGiven = NOT_GIVEN, # 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. @@ -245,9 +258,9 @@ def create_for_external_customer( Args: currency: The case sensitive currency or custom pricing unit to use for this alert. - type: The thresholds that define the values at which the alert will be triggered. + type: The type of alert to create. This must be a valid alert type. - thresholds: The thresholds for the alert. + thresholds: The thresholds that define the values at which the alert will be triggered. extra_headers: Send extra headers @@ -288,7 +301,13 @@ def create_for_subscription( subscription_id: str, *, thresholds: Iterable[alert_create_for_subscription_params.Threshold], - type: str, + type: Literal[ + "usage_exceeded", + "cost_exceeded", + "credit_balance_depleted", + "credit_balance_dropped", + "credit_balance_recovered", + ], metric_id: Optional[str] | NotGiven = NOT_GIVEN, # 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. @@ -312,9 +331,9 @@ def create_for_subscription( usage or cost conditions met during the current billing cycle. Args: - thresholds: The thresholds for the alert. + thresholds: The thresholds that define the values at which the alert will be triggered. - type: The thresholds that define the values at which the alert will be triggered. + type: The type of alert to create. This must be a valid alert type. metric_id: The metric to track usage for. @@ -560,7 +579,13 @@ async def create_for_customer( customer_id: str, *, currency: str, - type: str, + type: Literal[ + "usage_exceeded", + "cost_exceeded", + "credit_balance_depleted", + "credit_balance_dropped", + "credit_balance_recovered", + ], thresholds: Optional[Iterable[alert_create_for_customer_params.Threshold]] | NotGiven = NOT_GIVEN, # 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. @@ -585,9 +610,9 @@ async def create_for_customer( Args: currency: The case sensitive currency or custom pricing unit to use for this alert. - type: The thresholds that define the values at which the alert will be triggered. + type: The type of alert to create. This must be a valid alert type. - thresholds: The thresholds for the alert. + thresholds: The thresholds that define the values at which the alert will be triggered. extra_headers: Send extra headers @@ -626,7 +651,13 @@ async def create_for_external_customer( external_customer_id: str, *, currency: str, - type: str, + type: Literal[ + "usage_exceeded", + "cost_exceeded", + "credit_balance_depleted", + "credit_balance_dropped", + "credit_balance_recovered", + ], thresholds: Optional[Iterable[alert_create_for_external_customer_params.Threshold]] | NotGiven = NOT_GIVEN, # 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. @@ -651,9 +682,9 @@ async def create_for_external_customer( Args: currency: The case sensitive currency or custom pricing unit to use for this alert. - type: The thresholds that define the values at which the alert will be triggered. + type: The type of alert to create. This must be a valid alert type. - thresholds: The thresholds for the alert. + thresholds: The thresholds that define the values at which the alert will be triggered. extra_headers: Send extra headers @@ -694,7 +725,13 @@ async def create_for_subscription( subscription_id: str, *, thresholds: Iterable[alert_create_for_subscription_params.Threshold], - type: str, + type: Literal[ + "usage_exceeded", + "cost_exceeded", + "credit_balance_depleted", + "credit_balance_dropped", + "credit_balance_recovered", + ], metric_id: Optional[str] | NotGiven = NOT_GIVEN, # 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. @@ -718,9 +755,9 @@ async def create_for_subscription( usage or cost conditions met during the current billing cycle. Args: - thresholds: The thresholds for the alert. + thresholds: The thresholds that define the values at which the alert will be triggered. - type: The thresholds that define the values at which the alert will be triggered. + type: The type of alert to create. This must be a valid alert type. metric_id: The metric to track usage for. diff --git a/src/orb/resources/events/events.py b/src/orb/resources/events/events.py index ae719e3e..0c7edc7b 100644 --- a/src/orb/resources/events/events.py +++ b/src/orb/resources/events/events.py @@ -367,6 +367,10 @@ def ingest( accurately map usage to the correct billing cycle and ensure that all usage is billed for in the corresponding billing period. + In general, Orb does not expect events with future dated timestamps. In cases + where the timestamp is at least 24 hours ahead of the current time, the event + will not be accepted as a valid event, and will throw validation errors. + ## Event validation Orb’s validation ensures that you recognize errors in your events as quickly as @@ -897,6 +901,10 @@ async def ingest( accurately map usage to the correct billing cycle and ensure that all usage is billed for in the corresponding billing period. + In general, Orb does not expect events with future dated timestamps. In cases + where the timestamp is at least 24 hours ahead of the current time, the event + will not be accepted as a valid event, and will throw validation errors. + ## Event validation Orb’s validation ensures that you recognize errors in your events as quickly as diff --git a/src/orb/resources/invoices.py b/src/orb/resources/invoices.py index 85c0ac8c..f522e06f 100644 --- a/src/orb/resources/invoices.py +++ b/src/orb/resources/invoices.py @@ -10,7 +10,6 @@ from .. import _legacy_response from ..types import ( - shared_params, invoice_list_params, invoice_create_params, invoice_update_params, @@ -28,6 +27,7 @@ from ..pagination import SyncPage, AsyncPage from .._base_client import AsyncPaginator, make_request_options from ..types.invoice import Invoice +from ..types.shared_params.discount import Discount from ..types.invoice_fetch_upcoming_response import InvoiceFetchUpcomingResponse __all__ = ["Invoices", "AsyncInvoices"] @@ -50,7 +50,7 @@ def create( line_items: Iterable[invoice_create_params.LineItem], net_terms: int, customer_id: Optional[str] | NotGiven = NOT_GIVEN, - discount: Optional[shared_params.Discount] | NotGiven = NOT_GIVEN, + discount: Optional[Discount] | NotGiven = NOT_GIVEN, external_customer_id: Optional[str] | NotGiven = NOT_GIVEN, memo: Optional[str] | NotGiven = NOT_GIVEN, metadata: Optional[Dict[str, Optional[str]]] | NotGiven = NOT_GIVEN, @@ -516,7 +516,7 @@ async def create( line_items: Iterable[invoice_create_params.LineItem], net_terms: int, customer_id: Optional[str] | NotGiven = NOT_GIVEN, - discount: Optional[shared_params.Discount] | NotGiven = NOT_GIVEN, + discount: Optional[Discount] | NotGiven = NOT_GIVEN, external_customer_id: Optional[str] | NotGiven = NOT_GIVEN, memo: Optional[str] | NotGiven = NOT_GIVEN, metadata: Optional[Dict[str, Optional[str]]] | NotGiven = NOT_GIVEN, diff --git a/src/orb/types/alert_create_for_customer_params.py b/src/orb/types/alert_create_for_customer_params.py index 4cf86a52..5eeec557 100644 --- a/src/orb/types/alert_create_for_customer_params.py +++ b/src/orb/types/alert_create_for_customer_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Iterable, Optional -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict __all__ = ["AlertCreateForCustomerParams", "Threshold"] @@ -12,11 +12,19 @@ class AlertCreateForCustomerParams(TypedDict, total=False): currency: Required[str] """The case sensitive currency or custom pricing unit to use for this alert.""" - type: Required[str] - """The thresholds that define the values at which the alert will be triggered.""" + type: Required[ + Literal[ + "usage_exceeded", + "cost_exceeded", + "credit_balance_depleted", + "credit_balance_dropped", + "credit_balance_recovered", + ] + ] + """The type of alert to create. This must be a valid alert type.""" thresholds: Optional[Iterable[Threshold]] - """The thresholds for the alert.""" + """The thresholds that define the values at which the alert will be triggered.""" class Threshold(TypedDict, total=False): diff --git a/src/orb/types/alert_create_for_external_customer_params.py b/src/orb/types/alert_create_for_external_customer_params.py index b03e287f..6732f61c 100644 --- a/src/orb/types/alert_create_for_external_customer_params.py +++ b/src/orb/types/alert_create_for_external_customer_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Iterable, Optional -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict __all__ = ["AlertCreateForExternalCustomerParams", "Threshold"] @@ -12,11 +12,19 @@ class AlertCreateForExternalCustomerParams(TypedDict, total=False): currency: Required[str] """The case sensitive currency or custom pricing unit to use for this alert.""" - type: Required[str] - """The thresholds that define the values at which the alert will be triggered.""" + type: Required[ + Literal[ + "usage_exceeded", + "cost_exceeded", + "credit_balance_depleted", + "credit_balance_dropped", + "credit_balance_recovered", + ] + ] + """The type of alert to create. This must be a valid alert type.""" thresholds: Optional[Iterable[Threshold]] - """The thresholds for the alert.""" + """The thresholds that define the values at which the alert will be triggered.""" class Threshold(TypedDict, total=False): diff --git a/src/orb/types/alert_create_for_subscription_params.py b/src/orb/types/alert_create_for_subscription_params.py index a84a7bd1..767408dc 100644 --- a/src/orb/types/alert_create_for_subscription_params.py +++ b/src/orb/types/alert_create_for_subscription_params.py @@ -3,18 +3,26 @@ from __future__ import annotations from typing import Iterable, Optional -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict __all__ = ["AlertCreateForSubscriptionParams", "Threshold"] class AlertCreateForSubscriptionParams(TypedDict, total=False): thresholds: Required[Iterable[Threshold]] - """The thresholds for the alert.""" - - type: Required[str] """The thresholds that define the values at which the alert will be triggered.""" + type: Required[ + Literal[ + "usage_exceeded", + "cost_exceeded", + "credit_balance_depleted", + "credit_balance_dropped", + "credit_balance_recovered", + ] + ] + """The type of alert to create. This must be a valid alert type.""" + metric_id: Optional[str] """The metric to track usage for.""" diff --git a/src/orb/types/coupon.py b/src/orb/types/coupon.py index e6260088..5003327d 100644 --- a/src/orb/types/coupon.py +++ b/src/orb/types/coupon.py @@ -2,7 +2,7 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal, Annotated +from typing_extensions import Literal, Annotated, TypeAlias from .._utils import PropertyInfo from .._models import BaseModel @@ -43,7 +43,7 @@ class DiscountAmountDiscount(BaseModel): reason: Optional[str] = None -Discount = Annotated[ +Discount: TypeAlias = Annotated[ Union[DiscountPercentageDiscount, DiscountAmountDiscount], PropertyInfo(discriminator="discount_type") ] diff --git a/src/orb/types/coupon_create_params.py b/src/orb/types/coupon_create_params.py index 284fbb02..50746cd1 100644 --- a/src/orb/types/coupon_create_params.py +++ b/src/orb/types/coupon_create_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Union, Optional -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, Required, TypeAlias, TypedDict __all__ = ["CouponCreateParams", "Discount", "DiscountNewCouponPercentageDiscount", "DiscountNewCouponAmountDiscount"] @@ -39,4 +39,4 @@ class DiscountNewCouponAmountDiscount(TypedDict, total=False): discount_type: Required[Literal["amount"]] -Discount = Union[DiscountNewCouponPercentageDiscount, DiscountNewCouponAmountDiscount] +Discount: TypeAlias = Union[DiscountNewCouponPercentageDiscount, DiscountNewCouponAmountDiscount] diff --git a/src/orb/types/customers/credits/ledger_create_entry_by_external_id_params.py b/src/orb/types/customers/credits/ledger_create_entry_by_external_id_params.py index 3c4ffefa..07e8217c 100644 --- a/src/orb/types/customers/credits/ledger_create_entry_by_external_id_params.py +++ b/src/orb/types/customers/credits/ledger_create_entry_by_external_id_params.py @@ -4,7 +4,7 @@ from typing import Dict, Union, Optional from datetime import date, datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict from ...._utils import PropertyInfo @@ -247,7 +247,7 @@ class AddAmendmentCreditLedgerEntryRequestParams(TypedDict, total=False): """ -LedgerCreateEntryByExternalIDParams = Union[ +LedgerCreateEntryByExternalIDParams: TypeAlias = Union[ AddIncrementCreditLedgerEntryRequestParams, AddDecrementCreditLedgerEntryRequestParams, AddExpirationChangeCreditLedgerEntryRequestParams, diff --git a/src/orb/types/customers/credits/ledger_create_entry_by_external_id_response.py b/src/orb/types/customers/credits/ledger_create_entry_by_external_id_response.py index 54d8733b..82acb578 100644 --- a/src/orb/types/customers/credits/ledger_create_entry_by_external_id_response.py +++ b/src/orb/types/customers/credits/ledger_create_entry_by_external_id_response.py @@ -2,7 +2,7 @@ from typing import Dict, Union, Optional from datetime import datetime -from typing_extensions import Literal, Annotated +from typing_extensions import Literal, Annotated, TypeAlias from ...._utils import PropertyInfo from ...._models import BaseModel @@ -387,7 +387,7 @@ class AmendmentLedgerEntry(BaseModel): starting_balance: float -LedgerCreateEntryByExternalIDResponse = Annotated[ +LedgerCreateEntryByExternalIDResponse: TypeAlias = Annotated[ Union[ IncrementLedgerEntry, DecrementLedgerEntry, diff --git a/src/orb/types/customers/credits/ledger_create_entry_params.py b/src/orb/types/customers/credits/ledger_create_entry_params.py index 5f2d3016..46ce0a9e 100644 --- a/src/orb/types/customers/credits/ledger_create_entry_params.py +++ b/src/orb/types/customers/credits/ledger_create_entry_params.py @@ -4,7 +4,7 @@ from typing import Dict, Union, Optional from datetime import date, datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict from ...._utils import PropertyInfo @@ -247,7 +247,7 @@ class AddAmendmentCreditLedgerEntryRequestParams(TypedDict, total=False): """ -LedgerCreateEntryParams = Union[ +LedgerCreateEntryParams: TypeAlias = Union[ AddIncrementCreditLedgerEntryRequestParams, AddDecrementCreditLedgerEntryRequestParams, AddExpirationChangeCreditLedgerEntryRequestParams, diff --git a/src/orb/types/customers/credits/ledger_create_entry_response.py b/src/orb/types/customers/credits/ledger_create_entry_response.py index 002eb881..17dc5228 100644 --- a/src/orb/types/customers/credits/ledger_create_entry_response.py +++ b/src/orb/types/customers/credits/ledger_create_entry_response.py @@ -2,7 +2,7 @@ from typing import Dict, Union, Optional from datetime import datetime -from typing_extensions import Literal, Annotated +from typing_extensions import Literal, Annotated, TypeAlias from ...._utils import PropertyInfo from ...._models import BaseModel @@ -387,7 +387,7 @@ class AmendmentLedgerEntry(BaseModel): starting_balance: float -LedgerCreateEntryResponse = Annotated[ +LedgerCreateEntryResponse: TypeAlias = Annotated[ Union[ IncrementLedgerEntry, DecrementLedgerEntry, diff --git a/src/orb/types/customers/credits/ledger_list_by_external_id_response.py b/src/orb/types/customers/credits/ledger_list_by_external_id_response.py index 9b6c01f3..fd5d03a2 100644 --- a/src/orb/types/customers/credits/ledger_list_by_external_id_response.py +++ b/src/orb/types/customers/credits/ledger_list_by_external_id_response.py @@ -2,7 +2,7 @@ from typing import Dict, Union, Optional from datetime import datetime -from typing_extensions import Literal, Annotated +from typing_extensions import Literal, Annotated, TypeAlias from ...._utils import PropertyInfo from ...._models import BaseModel @@ -387,7 +387,7 @@ class AmendmentLedgerEntry(BaseModel): starting_balance: float -LedgerListByExternalIDResponse = Annotated[ +LedgerListByExternalIDResponse: TypeAlias = Annotated[ Union[ IncrementLedgerEntry, DecrementLedgerEntry, diff --git a/src/orb/types/customers/credits/ledger_list_response.py b/src/orb/types/customers/credits/ledger_list_response.py index f5141790..c02858de 100644 --- a/src/orb/types/customers/credits/ledger_list_response.py +++ b/src/orb/types/customers/credits/ledger_list_response.py @@ -2,7 +2,7 @@ from typing import Dict, Union, Optional from datetime import datetime -from typing_extensions import Literal, Annotated +from typing_extensions import Literal, Annotated, TypeAlias from ...._utils import PropertyInfo from ...._models import BaseModel @@ -387,7 +387,7 @@ class AmendmentLedgerEntry(BaseModel): starting_balance: float -LedgerListResponse = Annotated[ +LedgerListResponse: TypeAlias = Annotated[ Union[ IncrementLedgerEntry, DecrementLedgerEntry, diff --git a/src/orb/types/invoice.py b/src/orb/types/invoice.py index b1f6fc02..5781f30d 100644 --- a/src/orb/types/invoice.py +++ b/src/orb/types/invoice.py @@ -2,7 +2,7 @@ from typing import Dict, List, Union, Optional from datetime import datetime -from typing_extensions import Literal, Annotated +from typing_extensions import Literal, Annotated, TypeAlias from .price import Price from .._utils import PropertyInfo @@ -416,7 +416,7 @@ class LineItemSubLineItemOtherSubLineItem(BaseModel): type: Literal["'null'"] -LineItemSubLineItem = Annotated[ +LineItemSubLineItem: TypeAlias = Annotated[ Union[ LineItemSubLineItemMatrixSubLineItem, LineItemSubLineItemTierSubLineItem, LineItemSubLineItemOtherSubLineItem ], diff --git a/src/orb/types/invoice_create_params.py b/src/orb/types/invoice_create_params.py index ffe24569..78e22ea8 100644 --- a/src/orb/types/invoice_create_params.py +++ b/src/orb/types/invoice_create_params.py @@ -6,8 +6,8 @@ from datetime import date, datetime from typing_extensions import Literal, Required, Annotated, TypedDict -from ..types import shared_params from .._utils import PropertyInfo +from .shared_params.discount import Discount __all__ = ["InvoiceCreateParams", "LineItem", "LineItemUnitConfig"] @@ -42,7 +42,7 @@ class InvoiceCreateParams(TypedDict, total=False): One of `customer_id` and `external_customer_id` are required. """ - discount: Optional[shared_params.Discount] + discount: Optional[Discount] """An optional discount to attach to the invoice.""" external_customer_id: Optional[str] diff --git a/src/orb/types/invoice_fetch_upcoming_response.py b/src/orb/types/invoice_fetch_upcoming_response.py index bc447274..f1398c16 100644 --- a/src/orb/types/invoice_fetch_upcoming_response.py +++ b/src/orb/types/invoice_fetch_upcoming_response.py @@ -2,7 +2,7 @@ from typing import Dict, List, Union, Optional from datetime import datetime -from typing_extensions import Literal, Annotated +from typing_extensions import Literal, Annotated, TypeAlias from .price import Price from .._utils import PropertyInfo @@ -416,7 +416,7 @@ class LineItemSubLineItemOtherSubLineItem(BaseModel): type: Literal["'null'"] -LineItemSubLineItem = Annotated[ +LineItemSubLineItem: TypeAlias = Annotated[ Union[ LineItemSubLineItemMatrixSubLineItem, LineItemSubLineItemTierSubLineItem, LineItemSubLineItemOtherSubLineItem ], diff --git a/src/orb/types/invoice_line_item_create_response.py b/src/orb/types/invoice_line_item_create_response.py index 68a40f20..7ac86286 100644 --- a/src/orb/types/invoice_line_item_create_response.py +++ b/src/orb/types/invoice_line_item_create_response.py @@ -2,7 +2,7 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal, Annotated +from typing_extensions import Literal, Annotated, TypeAlias from .price import Price from .._utils import PropertyInfo @@ -125,7 +125,7 @@ class SubLineItemOtherSubLineItem(BaseModel): type: Literal["'null'"] -SubLineItem = Annotated[ +SubLineItem: TypeAlias = Annotated[ Union[SubLineItemMatrixSubLineItem, SubLineItemTierSubLineItem, SubLineItemOtherSubLineItem], PropertyInfo(discriminator="type"), ] diff --git a/src/orb/types/plan_create_params.py b/src/orb/types/plan_create_params.py index 6aa80bd3..4a3e49fe 100644 --- a/src/orb/types/plan_create_params.py +++ b/src/orb/types/plan_create_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Dict, List, Union, Iterable, Optional -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, Required, TypeAlias, TypedDict __all__ = [ "PlanCreateParams", @@ -1025,7 +1025,7 @@ class PriceNewPlanUnitWithProrationPrice(TypedDict, total=False): """ -Price = Union[ +Price: TypeAlias = Union[ PriceNewPlanUnitPrice, PriceNewPlanPackagePrice, PriceNewPlanMatrixPrice, diff --git a/src/orb/types/price.py b/src/orb/types/price.py index e3cfe232..ba4d6578 100644 --- a/src/orb/types/price.py +++ b/src/orb/types/price.py @@ -2,7 +2,7 @@ from typing import Dict, List, Union, Optional from datetime import datetime -from typing_extensions import Literal, Annotated +from typing_extensions import Literal, Annotated, TypeAlias from pydantic import Field as FieldInfo @@ -2028,7 +2028,7 @@ class UnitWithProrationPrice(BaseModel): unit_with_proration_config: Dict[str, object] -Price = Annotated[ +Price: TypeAlias = Annotated[ Union[ UnitPrice, PackagePrice, diff --git a/src/orb/types/price_create_params.py b/src/orb/types/price_create_params.py index fd9f4775..9d2162b3 100644 --- a/src/orb/types/price_create_params.py +++ b/src/orb/types/price_create_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Dict, List, Union, Iterable, Optional -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, Required, TypeAlias, TypedDict __all__ = [ "PriceCreateParams", @@ -1123,7 +1123,7 @@ class NewFloatingUnitWithProrationPrice(TypedDict, total=False): """ -PriceCreateParams = Union[ +PriceCreateParams: TypeAlias = Union[ NewFloatingUnitPrice, NewFloatingPackagePrice, NewFloatingMatrixPrice, diff --git a/src/orb/types/shared/billing_cycle_relative_date.py b/src/orb/types/shared/billing_cycle_relative_date.py index f8969b22..b4e6a488 100644 --- a/src/orb/types/shared/billing_cycle_relative_date.py +++ b/src/orb/types/shared/billing_cycle_relative_date.py @@ -1,7 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias __all__ = ["BillingCycleRelativeDate"] -BillingCycleRelativeDate = Literal["start_of_term", "end_of_term"] +BillingCycleRelativeDate: TypeAlias = Literal["start_of_term", "end_of_term"] diff --git a/src/orb/types/shared/discount.py b/src/orb/types/shared/discount.py index 16adf5b6..866b378c 100644 --- a/src/orb/types/shared/discount.py +++ b/src/orb/types/shared/discount.py @@ -1,7 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import List, Union, Optional -from typing_extensions import Literal, Annotated +from typing_extensions import Literal, Annotated, TypeAlias from ..._utils import PropertyInfo from ..._models import BaseModel @@ -78,6 +78,6 @@ class AmountDiscount(BaseModel): reason: Optional[str] = None -Discount = Annotated[ +Discount: TypeAlias = Annotated[ Union[PercentageDiscount, TrialDiscount, UsageDiscount, AmountDiscount], PropertyInfo(discriminator="discount_type") ] diff --git a/src/orb/types/shared_params/billing_cycle_relative_date.py b/src/orb/types/shared_params/billing_cycle_relative_date.py index 24896f54..5ac833ca 100644 --- a/src/orb/types/shared_params/billing_cycle_relative_date.py +++ b/src/orb/types/shared_params/billing_cycle_relative_date.py @@ -2,8 +2,8 @@ from __future__ import annotations -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias __all__ = ["BillingCycleRelativeDate"] -BillingCycleRelativeDate = Literal["start_of_term", "end_of_term"] +BillingCycleRelativeDate: TypeAlias = Literal["start_of_term", "end_of_term"] diff --git a/src/orb/types/shared_params/discount.py b/src/orb/types/shared_params/discount.py index cab49d43..17e76491 100644 --- a/src/orb/types/shared_params/discount.py +++ b/src/orb/types/shared_params/discount.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import List, Union, Optional -from typing_extensions import Literal, Required, TypedDict +from typing_extensions import Literal, Required, TypeAlias, TypedDict __all__ = ["Discount", "PercentageDiscount", "TrialDiscount", "UsageDiscount", "AmountDiscount"] @@ -77,4 +77,4 @@ class AmountDiscount(TypedDict, total=False): reason: Optional[str] -Discount = Union[PercentageDiscount, TrialDiscount, UsageDiscount, AmountDiscount] +Discount: TypeAlias = Union[PercentageDiscount, TrialDiscount, UsageDiscount, AmountDiscount] diff --git a/src/orb/types/subscription.py b/src/orb/types/subscription.py index 9a9cda38..0586dfde 100644 --- a/src/orb/types/subscription.py +++ b/src/orb/types/subscription.py @@ -2,7 +2,7 @@ from typing import Dict, List, Union, Optional from datetime import datetime -from typing_extensions import Literal, Annotated +from typing_extensions import Literal, Annotated, TypeAlias from .plan import Plan from .price import Price @@ -116,7 +116,7 @@ class AdjustmentIntervalAdjustmentMaximumAdjustment(BaseModel): """The reason for the adjustment.""" -AdjustmentIntervalAdjustment = Annotated[ +AdjustmentIntervalAdjustment: TypeAlias = Annotated[ Union[ AdjustmentIntervalAdjustmentAmountDiscountAdjustment, AdjustmentIntervalAdjustmentPercentageDiscountAdjustment, @@ -206,7 +206,7 @@ class DiscountIntervalUsageDiscountInterval(BaseModel): """ -DiscountInterval = Annotated[ +DiscountInterval: TypeAlias = Annotated[ Union[ DiscountIntervalAmountDiscountInterval, DiscountIntervalPercentageDiscountInterval, diff --git a/src/orb/types/subscription_create_params.py b/src/orb/types/subscription_create_params.py index f9120658..391685d9 100644 --- a/src/orb/types/subscription_create_params.py +++ b/src/orb/types/subscription_create_params.py @@ -4,7 +4,7 @@ from typing import Dict, List, Union, Iterable, Optional from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict from .._utils import PropertyInfo @@ -968,7 +968,7 @@ class PriceOverrideOverrideUnitWithPercentPrice(TypedDict, total=False): """The subscription's override minimum amount for the plan.""" -PriceOverride = Union[ +PriceOverride: TypeAlias = Union[ PriceOverrideOverrideUnitPrice, PriceOverrideOverridePackagePrice, PriceOverrideOverrideMatrixPrice, diff --git a/src/orb/types/subscription_price_intervals_params.py b/src/orb/types/subscription_price_intervals_params.py index b3a746df..6754171e 100644 --- a/src/orb/types/subscription_price_intervals_params.py +++ b/src/orb/types/subscription_price_intervals_params.py @@ -4,7 +4,7 @@ from typing import Dict, List, Union, Iterable, Optional from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict from .._utils import PropertyInfo from .shared.billing_cycle_relative_date import BillingCycleRelativeDate @@ -125,7 +125,7 @@ class AddDiscountUsageDiscountCreationParams(TypedDict, total=False): """ -AddDiscount = Union[ +AddDiscount: TypeAlias = Union[ AddDiscountAmountDiscountCreationParams, AddDiscountPercentageDiscountCreationParams, AddDiscountUsageDiscountCreationParams, @@ -1220,7 +1220,7 @@ class AddPriceNewFloatingUnitWithProrationPrice(TypedDict, total=False): """ -AddPrice = Union[ +AddPrice: TypeAlias = Union[ AddPriceNewFloatingUnitPrice, AddPriceNewFloatingPackagePrice, AddPriceNewFloatingMatrixPrice, @@ -1327,7 +1327,7 @@ class AddAdjustmentAdjustmentNewMaximum(TypedDict, total=False): maximum_amount: Required[str] -AddAdjustmentAdjustment = Union[ +AddAdjustmentAdjustment: TypeAlias = Union[ AddAdjustmentAdjustmentNewPercentageDiscount, AddAdjustmentAdjustmentNewAmountDiscount, AddAdjustmentAdjustmentNewMinimum, diff --git a/src/orb/types/subscription_schedule_plan_change_params.py b/src/orb/types/subscription_schedule_plan_change_params.py index 4e9daa26..7f0d3d10 100644 --- a/src/orb/types/subscription_schedule_plan_change_params.py +++ b/src/orb/types/subscription_schedule_plan_change_params.py @@ -4,7 +4,7 @@ from typing import Dict, List, Union, Iterable, Optional from datetime import datetime -from typing_extensions import Literal, Required, Annotated, TypedDict +from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict from .._utils import PropertyInfo @@ -971,7 +971,7 @@ class PriceOverrideOverrideUnitWithPercentPrice(TypedDict, total=False): """The subscription's override minimum amount for the plan.""" -PriceOverride = Union[ +PriceOverride: TypeAlias = Union[ PriceOverrideOverrideUnitPrice, PriceOverrideOverridePackagePrice, PriceOverrideOverrideMatrixPrice, diff --git a/src/orb/types/subscription_usage.py b/src/orb/types/subscription_usage.py index 66c62c37..4a5c4f2e 100644 --- a/src/orb/types/subscription_usage.py +++ b/src/orb/types/subscription_usage.py @@ -2,7 +2,7 @@ from typing import List, Union, Optional from datetime import datetime -from typing_extensions import Literal +from typing_extensions import Literal, TypeAlias from .._models import BaseModel from .shared.pagination_metadata import PaginationMetadata @@ -83,4 +83,4 @@ class GroupedSubscriptionUsage(BaseModel): pagination_metadata: Optional[PaginationMetadata] = None -SubscriptionUsage = Union[UngroupedSubscriptionUsage, GroupedSubscriptionUsage] +SubscriptionUsage: TypeAlias = Union[UngroupedSubscriptionUsage, GroupedSubscriptionUsage] diff --git a/tests/api_resources/test_alerts.py b/tests/api_resources/test_alerts.py index a96b00b0..d1caa338 100644 --- a/tests/api_resources/test_alerts.py +++ b/tests/api_resources/test_alerts.py @@ -108,7 +108,7 @@ def test_method_create_for_customer(self, client: Orb) -> None: alert = client.alerts.create_for_customer( customer_id="customer_id", currency="currency", - type="type", + type="usage_exceeded", ) assert_matches_type(Alert, alert, path=["response"]) @@ -117,7 +117,7 @@ def test_method_create_for_customer_with_all_params(self, client: Orb) -> None: alert = client.alerts.create_for_customer( customer_id="customer_id", currency="currency", - type="type", + type="usage_exceeded", thresholds=[{"value": 0}, {"value": 0}, {"value": 0}], ) assert_matches_type(Alert, alert, path=["response"]) @@ -127,7 +127,7 @@ def test_raw_response_create_for_customer(self, client: Orb) -> None: response = client.alerts.with_raw_response.create_for_customer( customer_id="customer_id", currency="currency", - type="type", + type="usage_exceeded", ) assert response.is_closed is True @@ -140,7 +140,7 @@ def test_streaming_response_create_for_customer(self, client: Orb) -> None: with client.alerts.with_streaming_response.create_for_customer( customer_id="customer_id", currency="currency", - type="type", + type="usage_exceeded", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -156,7 +156,7 @@ def test_path_params_create_for_customer(self, client: Orb) -> None: client.alerts.with_raw_response.create_for_customer( customer_id="", currency="currency", - type="type", + type="usage_exceeded", ) @parametrize @@ -164,7 +164,7 @@ def test_method_create_for_external_customer(self, client: Orb) -> None: alert = client.alerts.create_for_external_customer( external_customer_id="external_customer_id", currency="currency", - type="type", + type="usage_exceeded", ) assert_matches_type(Alert, alert, path=["response"]) @@ -173,7 +173,7 @@ def test_method_create_for_external_customer_with_all_params(self, client: Orb) alert = client.alerts.create_for_external_customer( external_customer_id="external_customer_id", currency="currency", - type="type", + type="usage_exceeded", thresholds=[{"value": 0}, {"value": 0}, {"value": 0}], ) assert_matches_type(Alert, alert, path=["response"]) @@ -183,7 +183,7 @@ def test_raw_response_create_for_external_customer(self, client: Orb) -> None: response = client.alerts.with_raw_response.create_for_external_customer( external_customer_id="external_customer_id", currency="currency", - type="type", + type="usage_exceeded", ) assert response.is_closed is True @@ -196,7 +196,7 @@ def test_streaming_response_create_for_external_customer(self, client: Orb) -> N with client.alerts.with_streaming_response.create_for_external_customer( external_customer_id="external_customer_id", currency="currency", - type="type", + type="usage_exceeded", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -212,7 +212,7 @@ def test_path_params_create_for_external_customer(self, client: Orb) -> None: client.alerts.with_raw_response.create_for_external_customer( external_customer_id="", currency="currency", - type="type", + type="usage_exceeded", ) @parametrize @@ -220,7 +220,7 @@ def test_method_create_for_subscription(self, client: Orb) -> None: alert = client.alerts.create_for_subscription( subscription_id="subscription_id", thresholds=[{"value": 0}, {"value": 0}, {"value": 0}], - type="type", + type="usage_exceeded", ) assert_matches_type(Alert, alert, path=["response"]) @@ -229,7 +229,7 @@ def test_method_create_for_subscription_with_all_params(self, client: Orb) -> No alert = client.alerts.create_for_subscription( subscription_id="subscription_id", thresholds=[{"value": 0}, {"value": 0}, {"value": 0}], - type="type", + type="usage_exceeded", metric_id="metric_id", ) assert_matches_type(Alert, alert, path=["response"]) @@ -239,7 +239,7 @@ def test_raw_response_create_for_subscription(self, client: Orb) -> None: response = client.alerts.with_raw_response.create_for_subscription( subscription_id="subscription_id", thresholds=[{"value": 0}, {"value": 0}, {"value": 0}], - type="type", + type="usage_exceeded", ) assert response.is_closed is True @@ -252,7 +252,7 @@ def test_streaming_response_create_for_subscription(self, client: Orb) -> None: with client.alerts.with_streaming_response.create_for_subscription( subscription_id="subscription_id", thresholds=[{"value": 0}, {"value": 0}, {"value": 0}], - type="type", + type="usage_exceeded", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -268,7 +268,7 @@ def test_path_params_create_for_subscription(self, client: Orb) -> None: client.alerts.with_raw_response.create_for_subscription( subscription_id="", thresholds=[{"value": 0}, {"value": 0}, {"value": 0}], - type="type", + type="usage_exceeded", ) @parametrize @@ -442,7 +442,7 @@ async def test_method_create_for_customer(self, async_client: AsyncOrb) -> None: alert = await async_client.alerts.create_for_customer( customer_id="customer_id", currency="currency", - type="type", + type="usage_exceeded", ) assert_matches_type(Alert, alert, path=["response"]) @@ -451,7 +451,7 @@ async def test_method_create_for_customer_with_all_params(self, async_client: As alert = await async_client.alerts.create_for_customer( customer_id="customer_id", currency="currency", - type="type", + type="usage_exceeded", thresholds=[{"value": 0}, {"value": 0}, {"value": 0}], ) assert_matches_type(Alert, alert, path=["response"]) @@ -461,7 +461,7 @@ async def test_raw_response_create_for_customer(self, async_client: AsyncOrb) -> response = await async_client.alerts.with_raw_response.create_for_customer( customer_id="customer_id", currency="currency", - type="type", + type="usage_exceeded", ) assert response.is_closed is True @@ -474,7 +474,7 @@ async def test_streaming_response_create_for_customer(self, async_client: AsyncO async with async_client.alerts.with_streaming_response.create_for_customer( customer_id="customer_id", currency="currency", - type="type", + type="usage_exceeded", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -490,7 +490,7 @@ async def test_path_params_create_for_customer(self, async_client: AsyncOrb) -> await async_client.alerts.with_raw_response.create_for_customer( customer_id="", currency="currency", - type="type", + type="usage_exceeded", ) @parametrize @@ -498,7 +498,7 @@ async def test_method_create_for_external_customer(self, async_client: AsyncOrb) alert = await async_client.alerts.create_for_external_customer( external_customer_id="external_customer_id", currency="currency", - type="type", + type="usage_exceeded", ) assert_matches_type(Alert, alert, path=["response"]) @@ -507,7 +507,7 @@ async def test_method_create_for_external_customer_with_all_params(self, async_c alert = await async_client.alerts.create_for_external_customer( external_customer_id="external_customer_id", currency="currency", - type="type", + type="usage_exceeded", thresholds=[{"value": 0}, {"value": 0}, {"value": 0}], ) assert_matches_type(Alert, alert, path=["response"]) @@ -517,7 +517,7 @@ async def test_raw_response_create_for_external_customer(self, async_client: Asy response = await async_client.alerts.with_raw_response.create_for_external_customer( external_customer_id="external_customer_id", currency="currency", - type="type", + type="usage_exceeded", ) assert response.is_closed is True @@ -530,7 +530,7 @@ async def test_streaming_response_create_for_external_customer(self, async_clien async with async_client.alerts.with_streaming_response.create_for_external_customer( external_customer_id="external_customer_id", currency="currency", - type="type", + type="usage_exceeded", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -546,7 +546,7 @@ async def test_path_params_create_for_external_customer(self, async_client: Asyn await async_client.alerts.with_raw_response.create_for_external_customer( external_customer_id="", currency="currency", - type="type", + type="usage_exceeded", ) @parametrize @@ -554,7 +554,7 @@ async def test_method_create_for_subscription(self, async_client: AsyncOrb) -> N alert = await async_client.alerts.create_for_subscription( subscription_id="subscription_id", thresholds=[{"value": 0}, {"value": 0}, {"value": 0}], - type="type", + type="usage_exceeded", ) assert_matches_type(Alert, alert, path=["response"]) @@ -563,7 +563,7 @@ async def test_method_create_for_subscription_with_all_params(self, async_client alert = await async_client.alerts.create_for_subscription( subscription_id="subscription_id", thresholds=[{"value": 0}, {"value": 0}, {"value": 0}], - type="type", + type="usage_exceeded", metric_id="metric_id", ) assert_matches_type(Alert, alert, path=["response"]) @@ -573,7 +573,7 @@ async def test_raw_response_create_for_subscription(self, async_client: AsyncOrb response = await async_client.alerts.with_raw_response.create_for_subscription( subscription_id="subscription_id", thresholds=[{"value": 0}, {"value": 0}, {"value": 0}], - type="type", + type="usage_exceeded", ) assert response.is_closed is True @@ -586,7 +586,7 @@ async def test_streaming_response_create_for_subscription(self, async_client: As async with async_client.alerts.with_streaming_response.create_for_subscription( subscription_id="subscription_id", thresholds=[{"value": 0}, {"value": 0}, {"value": 0}], - type="type", + type="usage_exceeded", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -602,7 +602,7 @@ async def test_path_params_create_for_subscription(self, async_client: AsyncOrb) await async_client.alerts.with_raw_response.create_for_subscription( subscription_id="", thresholds=[{"value": 0}, {"value": 0}, {"value": 0}], - type="type", + type="usage_exceeded", ) @parametrize diff --git a/tests/api_resources/test_customers.py b/tests/api_resources/test_customers.py index 89174717..11ab9253 100644 --- a/tests/api_resources/test_customers.py +++ b/tests/api_resources/test_customers.py @@ -35,31 +35,31 @@ def test_method_create_with_all_params(self, client: Orb) -> None: email="email", name="name", accounting_sync_configuration={ - "excluded": True, "accounting_providers": [ { - "provider_type": "provider_type", "external_provider_id": "external_provider_id", + "provider_type": "provider_type", }, { - "provider_type": "provider_type", "external_provider_id": "external_provider_id", + "provider_type": "provider_type", }, { - "provider_type": "provider_type", "external_provider_id": "external_provider_id", + "provider_type": "provider_type", }, ], + "excluded": True, }, additional_emails=["string", "string", "string"], auto_collection=True, billing_address={ + "city": "city", + "country": "country", "line1": "line1", "line2": "line2", - "city": "city", - "state": "state", "postal_code": "postal_code", - "country": "country", + "state": "state", }, currency="currency", email_delivery=True, @@ -69,12 +69,12 @@ def test_method_create_with_all_params(self, client: Orb) -> None: payment_provider_id="payment_provider_id", reporting_configuration={"exempt": True}, shipping_address={ + "city": "city", + "country": "country", "line1": "line1", "line2": "line2", - "city": "city", - "state": "state", "postal_code": "postal_code", - "country": "country", + "state": "state", }, tax_id={ "country": "AD", @@ -123,31 +123,31 @@ def test_method_update_with_all_params(self, client: Orb) -> None: customer = client.customers.update( customer_id="customer_id", accounting_sync_configuration={ - "excluded": True, "accounting_providers": [ { - "provider_type": "provider_type", "external_provider_id": "external_provider_id", + "provider_type": "provider_type", }, { - "provider_type": "provider_type", "external_provider_id": "external_provider_id", + "provider_type": "provider_type", }, { - "provider_type": "provider_type", "external_provider_id": "external_provider_id", + "provider_type": "provider_type", }, ], + "excluded": True, }, additional_emails=["string"], auto_collection=True, billing_address={ + "city": "city", + "country": "country", "line1": "line1", "line2": "line2", - "city": "city", - "state": "state", "postal_code": "postal_code", - "country": "country", + "state": "state", }, currency="currency", email="email", @@ -159,12 +159,12 @@ def test_method_update_with_all_params(self, client: Orb) -> None: payment_provider_id="payment_provider_id", reporting_configuration={"exempt": True}, shipping_address={ + "city": "city", + "country": "country", "line1": "line1", "line2": "line2", - "city": "city", - "state": "state", "postal_code": "postal_code", - "country": "country", + "state": "state", }, tax_id={ "country": "AD", @@ -368,31 +368,31 @@ def test_method_update_by_external_id_with_all_params(self, client: Orb) -> None customer = client.customers.update_by_external_id( id="external_customer_id", accounting_sync_configuration={ - "excluded": True, "accounting_providers": [ { - "provider_type": "provider_type", "external_provider_id": "external_provider_id", + "provider_type": "provider_type", }, { - "provider_type": "provider_type", "external_provider_id": "external_provider_id", + "provider_type": "provider_type", }, { - "provider_type": "provider_type", "external_provider_id": "external_provider_id", + "provider_type": "provider_type", }, ], + "excluded": True, }, additional_emails=["string"], auto_collection=True, billing_address={ + "city": "city", + "country": "country", "line1": "line1", "line2": "line2", - "city": "city", - "state": "state", "postal_code": "postal_code", - "country": "country", + "state": "state", }, currency="currency", email="email", @@ -404,12 +404,12 @@ def test_method_update_by_external_id_with_all_params(self, client: Orb) -> None payment_provider_id="payment_provider_id", reporting_configuration={"exempt": True}, shipping_address={ + "city": "city", + "country": "country", "line1": "line1", "line2": "line2", - "city": "city", - "state": "state", "postal_code": "postal_code", - "country": "country", + "state": "state", }, tax_id={ "country": "AD", @@ -469,31 +469,31 @@ async def test_method_create_with_all_params(self, async_client: AsyncOrb) -> No email="email", name="name", accounting_sync_configuration={ - "excluded": True, "accounting_providers": [ { - "provider_type": "provider_type", "external_provider_id": "external_provider_id", + "provider_type": "provider_type", }, { - "provider_type": "provider_type", "external_provider_id": "external_provider_id", + "provider_type": "provider_type", }, { - "provider_type": "provider_type", "external_provider_id": "external_provider_id", + "provider_type": "provider_type", }, ], + "excluded": True, }, additional_emails=["string", "string", "string"], auto_collection=True, billing_address={ + "city": "city", + "country": "country", "line1": "line1", "line2": "line2", - "city": "city", - "state": "state", "postal_code": "postal_code", - "country": "country", + "state": "state", }, currency="currency", email_delivery=True, @@ -503,12 +503,12 @@ async def test_method_create_with_all_params(self, async_client: AsyncOrb) -> No payment_provider_id="payment_provider_id", reporting_configuration={"exempt": True}, shipping_address={ + "city": "city", + "country": "country", "line1": "line1", "line2": "line2", - "city": "city", - "state": "state", "postal_code": "postal_code", - "country": "country", + "state": "state", }, tax_id={ "country": "AD", @@ -557,31 +557,31 @@ async def test_method_update_with_all_params(self, async_client: AsyncOrb) -> No customer = await async_client.customers.update( customer_id="customer_id", accounting_sync_configuration={ - "excluded": True, "accounting_providers": [ { - "provider_type": "provider_type", "external_provider_id": "external_provider_id", + "provider_type": "provider_type", }, { - "provider_type": "provider_type", "external_provider_id": "external_provider_id", + "provider_type": "provider_type", }, { - "provider_type": "provider_type", "external_provider_id": "external_provider_id", + "provider_type": "provider_type", }, ], + "excluded": True, }, additional_emails=["string"], auto_collection=True, billing_address={ + "city": "city", + "country": "country", "line1": "line1", "line2": "line2", - "city": "city", - "state": "state", "postal_code": "postal_code", - "country": "country", + "state": "state", }, currency="currency", email="email", @@ -593,12 +593,12 @@ async def test_method_update_with_all_params(self, async_client: AsyncOrb) -> No payment_provider_id="payment_provider_id", reporting_configuration={"exempt": True}, shipping_address={ + "city": "city", + "country": "country", "line1": "line1", "line2": "line2", - "city": "city", - "state": "state", "postal_code": "postal_code", - "country": "country", + "state": "state", }, tax_id={ "country": "AD", @@ -802,31 +802,31 @@ async def test_method_update_by_external_id_with_all_params(self, async_client: customer = await async_client.customers.update_by_external_id( id="external_customer_id", accounting_sync_configuration={ - "excluded": True, "accounting_providers": [ { - "provider_type": "provider_type", "external_provider_id": "external_provider_id", + "provider_type": "provider_type", }, { - "provider_type": "provider_type", "external_provider_id": "external_provider_id", + "provider_type": "provider_type", }, { - "provider_type": "provider_type", "external_provider_id": "external_provider_id", + "provider_type": "provider_type", }, ], + "excluded": True, }, additional_emails=["string"], auto_collection=True, billing_address={ + "city": "city", + "country": "country", "line1": "line1", "line2": "line2", - "city": "city", - "state": "state", "postal_code": "postal_code", - "country": "country", + "state": "state", }, currency="currency", email="email", @@ -838,12 +838,12 @@ async def test_method_update_by_external_id_with_all_params(self, async_client: payment_provider_id="payment_provider_id", reporting_configuration={"exempt": True}, shipping_address={ + "city": "city", + "country": "country", "line1": "line1", "line2": "line2", - "city": "city", - "state": "state", "postal_code": "postal_code", - "country": "country", + "state": "state", }, tax_id={ "country": "AD", diff --git a/tests/api_resources/test_events.py b/tests/api_resources/test_events.py index d179e3bf..7e77f4b4 100644 --- a/tests/api_resources/test_events.py +++ b/tests/api_resources/test_events.py @@ -129,21 +129,21 @@ def test_method_ingest(self, client: Orb) -> None: events=[ { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), }, { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), }, { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), }, ], ) @@ -154,28 +154,28 @@ def test_method_ingest_with_all_params(self, client: Orb) -> None: event = client.events.ingest( events=[ { - "customer_id": "customer_id", - "external_customer_id": "external_customer_id", "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", - }, - { + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), "customer_id": "customer_id", "external_customer_id": "external_customer_id", - "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, - "idempotency_key": "idempotency_key", }, { + "event_name": "event_name", + "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), "customer_id": "customer_id", "external_customer_id": "external_customer_id", + }, + { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), + "customer_id": "customer_id", + "external_customer_id": "external_customer_id", }, ], backfill_id="backfill_id", @@ -189,21 +189,21 @@ def test_raw_response_ingest(self, client: Orb) -> None: events=[ { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), }, { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), }, { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), }, ], ) @@ -219,21 +219,21 @@ def test_streaming_response_ingest(self, client: Orb) -> None: events=[ { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), }, { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), }, { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), }, ], ) as response: @@ -395,21 +395,21 @@ async def test_method_ingest(self, async_client: AsyncOrb) -> None: events=[ { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), }, { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), }, { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), }, ], ) @@ -420,28 +420,28 @@ async def test_method_ingest_with_all_params(self, async_client: AsyncOrb) -> No event = await async_client.events.ingest( events=[ { - "customer_id": "customer_id", - "external_customer_id": "external_customer_id", "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", - }, - { + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), "customer_id": "customer_id", "external_customer_id": "external_customer_id", - "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, - "idempotency_key": "idempotency_key", }, { + "event_name": "event_name", + "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), "customer_id": "customer_id", "external_customer_id": "external_customer_id", + }, + { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), + "customer_id": "customer_id", + "external_customer_id": "external_customer_id", }, ], backfill_id="backfill_id", @@ -455,21 +455,21 @@ async def test_raw_response_ingest(self, async_client: AsyncOrb) -> None: events=[ { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), }, { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), }, { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), }, ], ) @@ -485,21 +485,21 @@ async def test_streaming_response_ingest(self, async_client: AsyncOrb) -> None: events=[ { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), }, { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), }, { "event_name": "event_name", - "timestamp": parse_datetime("2020-12-09T16:09:53Z"), - "properties": {}, "idempotency_key": "idempotency_key", + "properties": {}, + "timestamp": parse_datetime("2020-12-09T16:09:53Z"), }, ], ) as response: diff --git a/tests/api_resources/test_invoices.py b/tests/api_resources/test_invoices.py index 01747b5f..c4394fce 100644 --- a/tests/api_resources/test_invoices.py +++ b/tests/api_resources/test_invoices.py @@ -29,30 +29,30 @@ def test_method_create(self, client: Orb) -> None: invoice_date=parse_datetime("2019-12-27T18:11:19.117Z"), line_items=[ { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, ], @@ -67,40 +67,40 @@ def test_method_create_with_all_params(self, client: Orb) -> None: invoice_date=parse_datetime("2019-12-27T18:11:19.117Z"), line_items=[ { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, ], net_terms=0, customer_id="4khy3nwzktxv7", discount={ - "discount_type": "percentage", "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - "reason": "reason", + "discount_type": "percentage", "percentage_discount": 0.15, + "reason": "reason", }, external_customer_id="external-customer-id", memo="An optional memo for my invoice.", @@ -116,30 +116,30 @@ def test_raw_response_create(self, client: Orb) -> None: invoice_date=parse_datetime("2019-12-27T18:11:19.117Z"), line_items=[ { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, ], @@ -158,30 +158,30 @@ def test_streaming_response_create(self, client: Orb) -> None: invoice_date=parse_datetime("2019-12-27T18:11:19.117Z"), line_items=[ { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, ], @@ -500,30 +500,30 @@ async def test_method_create(self, async_client: AsyncOrb) -> None: invoice_date=parse_datetime("2019-12-27T18:11:19.117Z"), line_items=[ { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, ], @@ -538,40 +538,40 @@ async def test_method_create_with_all_params(self, async_client: AsyncOrb) -> No invoice_date=parse_datetime("2019-12-27T18:11:19.117Z"), line_items=[ { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, ], net_terms=0, customer_id="4khy3nwzktxv7", discount={ - "discount_type": "percentage", "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - "reason": "reason", + "discount_type": "percentage", "percentage_discount": 0.15, + "reason": "reason", }, external_customer_id="external-customer-id", memo="An optional memo for my invoice.", @@ -587,30 +587,30 @@ async def test_raw_response_create(self, async_client: AsyncOrb) -> None: invoice_date=parse_datetime("2019-12-27T18:11:19.117Z"), line_items=[ { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, ], @@ -629,30 +629,30 @@ async def test_streaming_response_create(self, async_client: AsyncOrb) -> None: invoice_date=parse_datetime("2019-12-27T18:11:19.117Z"), line_items=[ { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, { - "start_date": parse_date("2023-09-22"), "end_date": parse_date("2023-09-22"), - "quantity": 1, - "name": "Line Item Name", "item_id": "4khy3nwzktxv7", "model_type": "unit", + "name": "Line Item Name", + "quantity": 1, + "start_date": parse_date("2023-09-22"), "unit_config": {"unit_amount": "unit_amount"}, }, ], diff --git a/tests/api_resources/test_plans.py b/tests/api_resources/test_plans.py index 5588af1e..d0dec0a4 100644 --- a/tests/api_resources/test_plans.py +++ b/tests/api_resources/test_plans.py @@ -26,10 +26,10 @@ def test_method_create(self, client: Orb) -> None: name="name", prices=[ { - "name": "Annual fee", - "item_id": "item_id", "cadence": "annual", + "item_id": "item_id", "model_type": "unit", + "name": "Annual fee", "unit_config": {"unit_amount": "unit_amount"}, } ], @@ -43,19 +43,19 @@ def test_method_create_with_all_params(self, client: Orb) -> None: name="name", prices=[ { - "metadata": {"foo": "string"}, - "external_price_id": "external_price_id", + "cadence": "annual", + "item_id": "item_id", + "model_type": "unit", "name": "Annual fee", + "unit_config": {"unit_amount": "unit_amount"}, "billable_metric_id": "billable_metric_id", - "item_id": "item_id", "billed_in_advance": True, - "fixed_price_quantity": 0, - "invoice_grouping_key": "invoice_grouping_key", - "cadence": "annual", "conversion_rate": 0, - "model_type": "unit", - "unit_config": {"unit_amount": "unit_amount"}, "currency": "currency", + "external_price_id": "external_price_id", + "fixed_price_quantity": 0, + "invoice_grouping_key": "invoice_grouping_key", + "metadata": {"foo": "string"}, } ], default_invoice_memo="default_invoice_memo", @@ -73,10 +73,10 @@ def test_raw_response_create(self, client: Orb) -> None: name="name", prices=[ { - "name": "Annual fee", - "item_id": "item_id", "cadence": "annual", + "item_id": "item_id", "model_type": "unit", + "name": "Annual fee", "unit_config": {"unit_amount": "unit_amount"}, } ], @@ -94,10 +94,10 @@ def test_streaming_response_create(self, client: Orb) -> None: name="name", prices=[ { - "name": "Annual fee", - "item_id": "item_id", "cadence": "annual", + "item_id": "item_id", "model_type": "unit", + "name": "Annual fee", "unit_config": {"unit_amount": "unit_amount"}, } ], @@ -244,10 +244,10 @@ async def test_method_create(self, async_client: AsyncOrb) -> None: name="name", prices=[ { - "name": "Annual fee", - "item_id": "item_id", "cadence": "annual", + "item_id": "item_id", "model_type": "unit", + "name": "Annual fee", "unit_config": {"unit_amount": "unit_amount"}, } ], @@ -261,19 +261,19 @@ async def test_method_create_with_all_params(self, async_client: AsyncOrb) -> No name="name", prices=[ { - "metadata": {"foo": "string"}, - "external_price_id": "external_price_id", + "cadence": "annual", + "item_id": "item_id", + "model_type": "unit", "name": "Annual fee", + "unit_config": {"unit_amount": "unit_amount"}, "billable_metric_id": "billable_metric_id", - "item_id": "item_id", "billed_in_advance": True, - "fixed_price_quantity": 0, - "invoice_grouping_key": "invoice_grouping_key", - "cadence": "annual", "conversion_rate": 0, - "model_type": "unit", - "unit_config": {"unit_amount": "unit_amount"}, "currency": "currency", + "external_price_id": "external_price_id", + "fixed_price_quantity": 0, + "invoice_grouping_key": "invoice_grouping_key", + "metadata": {"foo": "string"}, } ], default_invoice_memo="default_invoice_memo", @@ -291,10 +291,10 @@ async def test_raw_response_create(self, async_client: AsyncOrb) -> None: name="name", prices=[ { - "name": "Annual fee", - "item_id": "item_id", "cadence": "annual", + "item_id": "item_id", "model_type": "unit", + "name": "Annual fee", "unit_config": {"unit_amount": "unit_amount"}, } ], @@ -312,10 +312,10 @@ async def test_streaming_response_create(self, async_client: AsyncOrb) -> None: name="name", prices=[ { - "name": "Annual fee", - "item_id": "item_id", "cadence": "annual", + "item_id": "item_id", "model_type": "unit", + "name": "Annual fee", "unit_config": {"unit_amount": "unit_amount"}, } ], diff --git a/tests/api_resources/test_prices.py b/tests/api_resources/test_prices.py index 3605de89..0999b97f 100644 --- a/tests/api_resources/test_prices.py +++ b/tests/api_resources/test_prices.py @@ -171,20 +171,20 @@ def test_method_create_overload_3(self, client: Orb) -> None: currency="currency", item_id="item_id", matrix_config={ - "dimensions": ["string", "string", "string"], "default_unit_amount": "default_unit_amount", + "dimensions": ["string", "string", "string"], "matrix_values": [ { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, ], }, @@ -200,20 +200,20 @@ def test_method_create_with_all_params_overload_3(self, client: Orb) -> None: currency="currency", item_id="item_id", matrix_config={ - "dimensions": ["string", "string", "string"], "default_unit_amount": "default_unit_amount", + "dimensions": ["string", "string", "string"], "matrix_values": [ { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, ], }, @@ -236,20 +236,20 @@ def test_raw_response_create_overload_3(self, client: Orb) -> None: currency="currency", item_id="item_id", matrix_config={ - "dimensions": ["string", "string", "string"], "default_unit_amount": "default_unit_amount", + "dimensions": ["string", "string", "string"], "matrix_values": [ { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, ], }, @@ -269,20 +269,20 @@ def test_streaming_response_create_overload_3(self, client: Orb) -> None: currency="currency", item_id="item_id", matrix_config={ - "dimensions": ["string", "string", "string"], "default_unit_amount": "default_unit_amount", + "dimensions": ["string", "string", "string"], "matrix_values": [ { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, ], }, @@ -304,23 +304,23 @@ def test_method_create_overload_4(self, client: Orb) -> None: currency="currency", item_id="item_id", matrix_with_allocation_config={ - "dimensions": ["string", "string", "string"], + "allocation": 0, "default_unit_amount": "default_unit_amount", + "dimensions": ["string", "string", "string"], "matrix_values": [ { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, ], - "allocation": 0, }, model_type="matrix_with_allocation", name="Annual fee", @@ -334,23 +334,23 @@ def test_method_create_with_all_params_overload_4(self, client: Orb) -> None: currency="currency", item_id="item_id", matrix_with_allocation_config={ - "dimensions": ["string", "string", "string"], + "allocation": 0, "default_unit_amount": "default_unit_amount", + "dimensions": ["string", "string", "string"], "matrix_values": [ { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, ], - "allocation": 0, }, model_type="matrix_with_allocation", name="Annual fee", @@ -371,23 +371,23 @@ def test_raw_response_create_overload_4(self, client: Orb) -> None: currency="currency", item_id="item_id", matrix_with_allocation_config={ - "dimensions": ["string", "string", "string"], + "allocation": 0, "default_unit_amount": "default_unit_amount", + "dimensions": ["string", "string", "string"], "matrix_values": [ { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, ], - "allocation": 0, }, model_type="matrix_with_allocation", name="Annual fee", @@ -405,23 +405,23 @@ def test_streaming_response_create_overload_4(self, client: Orb) -> None: currency="currency", item_id="item_id", matrix_with_allocation_config={ - "dimensions": ["string", "string", "string"], + "allocation": 0, "default_unit_amount": "default_unit_amount", + "dimensions": ["string", "string", "string"], "matrix_values": [ { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, ], - "allocation": 0, }, model_type="matrix_with_allocation", name="Annual fee", @@ -473,18 +473,18 @@ def test_method_create_with_all_params_overload_5(self, client: Orb) -> None: "tiers": [ { "first_unit": 0, - "last_unit": 0, "unit_amount": "unit_amount", + "last_unit": 0, }, { "first_unit": 0, - "last_unit": 0, "unit_amount": "unit_amount", + "last_unit": 0, }, { "first_unit": 0, - "last_unit": 0, "unit_amount": "unit_amount", + "last_unit": 0, }, ] }, @@ -573,16 +573,16 @@ def test_method_create_overload_6(self, client: Orb) -> None: tiered_bps_config={ "tiers": [ { - "minimum_amount": "minimum_amount", "bps": 0, + "minimum_amount": "minimum_amount", }, { - "minimum_amount": "minimum_amount", "bps": 0, + "minimum_amount": "minimum_amount", }, { - "minimum_amount": "minimum_amount", "bps": 0, + "minimum_amount": "minimum_amount", }, ] }, @@ -600,21 +600,21 @@ def test_method_create_with_all_params_overload_6(self, client: Orb) -> None: tiered_bps_config={ "tiers": [ { + "bps": 0, "minimum_amount": "minimum_amount", "maximum_amount": "maximum_amount", - "bps": 0, "per_unit_maximum": "per_unit_maximum", }, { + "bps": 0, "minimum_amount": "minimum_amount", "maximum_amount": "maximum_amount", - "bps": 0, "per_unit_maximum": "per_unit_maximum", }, { + "bps": 0, "minimum_amount": "minimum_amount", "maximum_amount": "maximum_amount", - "bps": 0, "per_unit_maximum": "per_unit_maximum", }, ] @@ -640,16 +640,16 @@ def test_raw_response_create_overload_6(self, client: Orb) -> None: tiered_bps_config={ "tiers": [ { - "minimum_amount": "minimum_amount", "bps": 0, + "minimum_amount": "minimum_amount", }, { - "minimum_amount": "minimum_amount", "bps": 0, + "minimum_amount": "minimum_amount", }, { - "minimum_amount": "minimum_amount", "bps": 0, + "minimum_amount": "minimum_amount", }, ] }, @@ -671,16 +671,16 @@ def test_streaming_response_create_overload_6(self, client: Orb) -> None: tiered_bps_config={ "tiers": [ { - "minimum_amount": "minimum_amount", "bps": 0, + "minimum_amount": "minimum_amount", }, { - "minimum_amount": "minimum_amount", "bps": 0, + "minimum_amount": "minimum_amount", }, { - "minimum_amount": "minimum_amount", "bps": 0, + "minimum_amount": "minimum_amount", }, ] }, @@ -779,18 +779,18 @@ def test_method_create_with_all_params_overload_8(self, client: Orb) -> None: bulk_bps_config={ "tiers": [ { - "maximum_amount": "maximum_amount", "bps": 0, + "maximum_amount": "maximum_amount", "per_unit_maximum": "per_unit_maximum", }, { - "maximum_amount": "maximum_amount", "bps": 0, + "maximum_amount": "maximum_amount", "per_unit_maximum": "per_unit_maximum", }, { - "maximum_amount": "maximum_amount", "bps": 0, + "maximum_amount": "maximum_amount", "per_unit_maximum": "per_unit_maximum", }, ] @@ -868,16 +868,16 @@ def test_method_create_with_all_params_overload_9(self, client: Orb) -> None: bulk_config={ "tiers": [ { - "maximum_units": 0, "unit_amount": "unit_amount", + "maximum_units": 0, }, { - "maximum_units": 0, "unit_amount": "unit_amount", + "maximum_units": 0, }, { - "maximum_units": 0, "unit_amount": "unit_amount", + "maximum_units": 0, }, ] }, @@ -1856,20 +1856,20 @@ async def test_method_create_overload_3(self, async_client: AsyncOrb) -> None: currency="currency", item_id="item_id", matrix_config={ - "dimensions": ["string", "string", "string"], "default_unit_amount": "default_unit_amount", + "dimensions": ["string", "string", "string"], "matrix_values": [ { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, ], }, @@ -1885,20 +1885,20 @@ async def test_method_create_with_all_params_overload_3(self, async_client: Asyn currency="currency", item_id="item_id", matrix_config={ - "dimensions": ["string", "string", "string"], "default_unit_amount": "default_unit_amount", + "dimensions": ["string", "string", "string"], "matrix_values": [ { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, ], }, @@ -1921,20 +1921,20 @@ async def test_raw_response_create_overload_3(self, async_client: AsyncOrb) -> N currency="currency", item_id="item_id", matrix_config={ - "dimensions": ["string", "string", "string"], "default_unit_amount": "default_unit_amount", + "dimensions": ["string", "string", "string"], "matrix_values": [ { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, ], }, @@ -1954,20 +1954,20 @@ async def test_streaming_response_create_overload_3(self, async_client: AsyncOrb currency="currency", item_id="item_id", matrix_config={ - "dimensions": ["string", "string", "string"], "default_unit_amount": "default_unit_amount", + "dimensions": ["string", "string", "string"], "matrix_values": [ { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, ], }, @@ -1989,23 +1989,23 @@ async def test_method_create_overload_4(self, async_client: AsyncOrb) -> None: currency="currency", item_id="item_id", matrix_with_allocation_config={ - "dimensions": ["string", "string", "string"], + "allocation": 0, "default_unit_amount": "default_unit_amount", + "dimensions": ["string", "string", "string"], "matrix_values": [ { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, ], - "allocation": 0, }, model_type="matrix_with_allocation", name="Annual fee", @@ -2019,23 +2019,23 @@ async def test_method_create_with_all_params_overload_4(self, async_client: Asyn currency="currency", item_id="item_id", matrix_with_allocation_config={ - "dimensions": ["string", "string", "string"], + "allocation": 0, "default_unit_amount": "default_unit_amount", + "dimensions": ["string", "string", "string"], "matrix_values": [ { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, ], - "allocation": 0, }, model_type="matrix_with_allocation", name="Annual fee", @@ -2056,23 +2056,23 @@ async def test_raw_response_create_overload_4(self, async_client: AsyncOrb) -> N currency="currency", item_id="item_id", matrix_with_allocation_config={ - "dimensions": ["string", "string", "string"], + "allocation": 0, "default_unit_amount": "default_unit_amount", + "dimensions": ["string", "string", "string"], "matrix_values": [ { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, ], - "allocation": 0, }, model_type="matrix_with_allocation", name="Annual fee", @@ -2090,23 +2090,23 @@ async def test_streaming_response_create_overload_4(self, async_client: AsyncOrb currency="currency", item_id="item_id", matrix_with_allocation_config={ - "dimensions": ["string", "string", "string"], + "allocation": 0, "default_unit_amount": "default_unit_amount", + "dimensions": ["string", "string", "string"], "matrix_values": [ { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, { - "unit_amount": "unit_amount", "dimension_values": ["string", "string", "string"], + "unit_amount": "unit_amount", }, ], - "allocation": 0, }, model_type="matrix_with_allocation", name="Annual fee", @@ -2158,18 +2158,18 @@ async def test_method_create_with_all_params_overload_5(self, async_client: Asyn "tiers": [ { "first_unit": 0, - "last_unit": 0, "unit_amount": "unit_amount", + "last_unit": 0, }, { "first_unit": 0, - "last_unit": 0, "unit_amount": "unit_amount", + "last_unit": 0, }, { "first_unit": 0, - "last_unit": 0, "unit_amount": "unit_amount", + "last_unit": 0, }, ] }, @@ -2258,16 +2258,16 @@ async def test_method_create_overload_6(self, async_client: AsyncOrb) -> None: tiered_bps_config={ "tiers": [ { - "minimum_amount": "minimum_amount", "bps": 0, + "minimum_amount": "minimum_amount", }, { - "minimum_amount": "minimum_amount", "bps": 0, + "minimum_amount": "minimum_amount", }, { - "minimum_amount": "minimum_amount", "bps": 0, + "minimum_amount": "minimum_amount", }, ] }, @@ -2285,21 +2285,21 @@ async def test_method_create_with_all_params_overload_6(self, async_client: Asyn tiered_bps_config={ "tiers": [ { + "bps": 0, "minimum_amount": "minimum_amount", "maximum_amount": "maximum_amount", - "bps": 0, "per_unit_maximum": "per_unit_maximum", }, { + "bps": 0, "minimum_amount": "minimum_amount", "maximum_amount": "maximum_amount", - "bps": 0, "per_unit_maximum": "per_unit_maximum", }, { + "bps": 0, "minimum_amount": "minimum_amount", "maximum_amount": "maximum_amount", - "bps": 0, "per_unit_maximum": "per_unit_maximum", }, ] @@ -2325,16 +2325,16 @@ async def test_raw_response_create_overload_6(self, async_client: AsyncOrb) -> N tiered_bps_config={ "tiers": [ { - "minimum_amount": "minimum_amount", "bps": 0, + "minimum_amount": "minimum_amount", }, { - "minimum_amount": "minimum_amount", "bps": 0, + "minimum_amount": "minimum_amount", }, { - "minimum_amount": "minimum_amount", "bps": 0, + "minimum_amount": "minimum_amount", }, ] }, @@ -2356,16 +2356,16 @@ async def test_streaming_response_create_overload_6(self, async_client: AsyncOrb tiered_bps_config={ "tiers": [ { - "minimum_amount": "minimum_amount", "bps": 0, + "minimum_amount": "minimum_amount", }, { - "minimum_amount": "minimum_amount", "bps": 0, + "minimum_amount": "minimum_amount", }, { - "minimum_amount": "minimum_amount", "bps": 0, + "minimum_amount": "minimum_amount", }, ] }, @@ -2464,18 +2464,18 @@ async def test_method_create_with_all_params_overload_8(self, async_client: Asyn bulk_bps_config={ "tiers": [ { - "maximum_amount": "maximum_amount", "bps": 0, + "maximum_amount": "maximum_amount", "per_unit_maximum": "per_unit_maximum", }, { - "maximum_amount": "maximum_amount", "bps": 0, + "maximum_amount": "maximum_amount", "per_unit_maximum": "per_unit_maximum", }, { - "maximum_amount": "maximum_amount", "bps": 0, + "maximum_amount": "maximum_amount", "per_unit_maximum": "per_unit_maximum", }, ] @@ -2553,16 +2553,16 @@ async def test_method_create_with_all_params_overload_9(self, async_client: Asyn bulk_config={ "tiers": [ { - "maximum_units": 0, "unit_amount": "unit_amount", + "maximum_units": 0, }, { - "maximum_units": 0, "unit_amount": "unit_amount", + "maximum_units": 0, }, { - "maximum_units": 0, "unit_amount": "unit_amount", + "maximum_units": 0, }, ] }, diff --git a/tests/api_resources/test_subscriptions.py b/tests/api_resources/test_subscriptions.py index 51b93500..2e7e9a7d 100644 --- a/tests/api_resources/test_subscriptions.py +++ b/tests/api_resources/test_subscriptions.py @@ -54,56 +54,56 @@ def test_method_create_with_all_params(self, client: Orb) -> None: { "id": "id", "model_type": "unit", - "minimum_amount": "1.23", - "maximum_amount": "1.23", - "currency": "currency", + "unit_config": {"unit_amount": "unit_amount"}, "conversion_rate": 0, + "currency": "currency", "discount": { "discount_type": "percentage", + "amount_discount": "amount_discount", + "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], "percentage_discount": 0.15, "trial_amount_discount": "trial_amount_discount", "usage_discount": 0, - "amount_discount": "amount_discount", - "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], }, "fixed_price_quantity": 2, - "unit_config": {"unit_amount": "unit_amount"}, + "maximum_amount": "1.23", + "minimum_amount": "1.23", }, { "id": "id", "model_type": "unit", - "minimum_amount": "1.23", - "maximum_amount": "1.23", - "currency": "currency", + "unit_config": {"unit_amount": "unit_amount"}, "conversion_rate": 0, + "currency": "currency", "discount": { "discount_type": "percentage", + "amount_discount": "amount_discount", + "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], "percentage_discount": 0.15, "trial_amount_discount": "trial_amount_discount", "usage_discount": 0, - "amount_discount": "amount_discount", - "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], }, "fixed_price_quantity": 2, - "unit_config": {"unit_amount": "unit_amount"}, + "maximum_amount": "1.23", + "minimum_amount": "1.23", }, { "id": "id", "model_type": "unit", - "minimum_amount": "1.23", - "maximum_amount": "1.23", - "currency": "currency", + "unit_config": {"unit_amount": "unit_amount"}, "conversion_rate": 0, + "currency": "currency", "discount": { "discount_type": "percentage", + "amount_discount": "amount_discount", + "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], "percentage_discount": 0.15, "trial_amount_discount": "trial_amount_discount", "usage_discount": 0, - "amount_discount": "amount_discount", - "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], }, "fixed_price_quantity": 2, - "unit_config": {"unit_amount": "unit_amount"}, + "maximum_amount": "1.23", + "minimum_amount": "1.23", }, ], start_date=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -483,182 +483,182 @@ def test_method_price_intervals_with_all_params(self, client: Orb) -> None: subscription_id="subscription_id", add=[ { - "price_id": "h74gfhdjvn7ujokd", - "external_price_id": "external_price_id", - "price": { - "metadata": {"foo": "string"}, - "external_price_id": "external_price_id", - "name": "Annual fee", - "billable_metric_id": "billable_metric_id", - "item_id": "item_id", - "billed_in_advance": True, - "fixed_price_quantity": 0, - "invoice_grouping_key": "invoice_grouping_key", - "cadence": "annual", - "conversion_rate": 0, - "model_type": "unit", - "unit_config": {"unit_amount": "unit_amount"}, - "currency": "currency", - }, + "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), "allocation_price": { - "currency": "USD", "amount": "10.00", - "cadence": "monthly", + "cadence": "one_time", + "currency": "USD", "expires_at_end_of_cadence": True, }, - "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), - "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), - "fixed_fee_quantity_transitions": [ + "discounts": [ { - "quantity": 5, - "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "amount_discount": 0, + "discount_type": "amount", }, { - "quantity": 5, - "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "amount_discount": 0, + "discount_type": "amount", }, { - "quantity": 5, - "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "amount_discount": 0, + "discount_type": "amount", }, ], - "discounts": [ + "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "external_price_id": "external_price_id", + "fixed_fee_quantity_transitions": [ { - "discount_type": "amount", - "amount_discount": 0, + "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "discount_type": "amount", - "amount_discount": 0, + "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "discount_type": "amount", - "amount_discount": 0, + "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, ], - "minimum_amount": 0, "maximum_amount": 0, - }, - { - "price_id": "h74gfhdjvn7ujokd", - "external_price_id": "external_price_id", + "minimum_amount": 0, "price": { - "metadata": {"foo": "string"}, - "external_price_id": "external_price_id", + "cadence": "annual", + "currency": "currency", + "item_id": "item_id", + "model_type": "unit", "name": "Annual fee", + "unit_config": {"unit_amount": "unit_amount"}, "billable_metric_id": "billable_metric_id", - "item_id": "item_id", "billed_in_advance": True, + "conversion_rate": 0, + "external_price_id": "external_price_id", "fixed_price_quantity": 0, "invoice_grouping_key": "invoice_grouping_key", - "cadence": "annual", - "conversion_rate": 0, - "model_type": "unit", - "unit_config": {"unit_amount": "unit_amount"}, - "currency": "currency", + "metadata": {"foo": "string"}, }, + "price_id": "h74gfhdjvn7ujokd", + }, + { + "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), "allocation_price": { - "currency": "USD", "amount": "10.00", - "cadence": "monthly", + "cadence": "one_time", + "currency": "USD", "expires_at_end_of_cadence": True, }, - "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), - "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), - "fixed_fee_quantity_transitions": [ + "discounts": [ { - "quantity": 5, - "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "amount_discount": 0, + "discount_type": "amount", }, { - "quantity": 5, - "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "amount_discount": 0, + "discount_type": "amount", }, { - "quantity": 5, - "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "amount_discount": 0, + "discount_type": "amount", }, ], - "discounts": [ + "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "external_price_id": "external_price_id", + "fixed_fee_quantity_transitions": [ { - "discount_type": "amount", - "amount_discount": 0, + "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "discount_type": "amount", - "amount_discount": 0, + "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "discount_type": "amount", - "amount_discount": 0, + "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, ], - "minimum_amount": 0, "maximum_amount": 0, - }, - { - "price_id": "h74gfhdjvn7ujokd", - "external_price_id": "external_price_id", + "minimum_amount": 0, "price": { - "metadata": {"foo": "string"}, - "external_price_id": "external_price_id", + "cadence": "annual", + "currency": "currency", + "item_id": "item_id", + "model_type": "unit", "name": "Annual fee", + "unit_config": {"unit_amount": "unit_amount"}, "billable_metric_id": "billable_metric_id", - "item_id": "item_id", "billed_in_advance": True, + "conversion_rate": 0, + "external_price_id": "external_price_id", "fixed_price_quantity": 0, "invoice_grouping_key": "invoice_grouping_key", - "cadence": "annual", - "conversion_rate": 0, - "model_type": "unit", - "unit_config": {"unit_amount": "unit_amount"}, - "currency": "currency", + "metadata": {"foo": "string"}, }, + "price_id": "h74gfhdjvn7ujokd", + }, + { + "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), "allocation_price": { - "currency": "USD", "amount": "10.00", - "cadence": "monthly", + "cadence": "one_time", + "currency": "USD", "expires_at_end_of_cadence": True, }, - "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), - "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), - "fixed_fee_quantity_transitions": [ + "discounts": [ { - "quantity": 5, - "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "amount_discount": 0, + "discount_type": "amount", }, { - "quantity": 5, - "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "amount_discount": 0, + "discount_type": "amount", }, { - "quantity": 5, - "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "amount_discount": 0, + "discount_type": "amount", }, ], - "discounts": [ + "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "external_price_id": "external_price_id", + "fixed_fee_quantity_transitions": [ { - "discount_type": "amount", - "amount_discount": 0, + "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "discount_type": "amount", - "amount_discount": 0, + "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "discount_type": "amount", - "amount_discount": 0, + "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, ], - "minimum_amount": 0, "maximum_amount": 0, + "minimum_amount": 0, + "price": { + "cadence": "annual", + "currency": "currency", + "item_id": "item_id", + "model_type": "unit", + "name": "Annual fee", + "unit_config": {"unit_amount": "unit_amount"}, + "billable_metric_id": "billable_metric_id", + "billed_in_advance": True, + "conversion_rate": 0, + "external_price_id": "external_price_id", + "fixed_price_quantity": 0, + "invoice_grouping_key": "invoice_grouping_key", + "metadata": {"foo": "string"}, + }, + "price_id": "h74gfhdjvn7ujokd", }, ], add_adjustments=[ { "adjustment": { - "applies_to_price_ids": ["price_1", "price_2"], "adjustment_type": "percentage_discount", + "applies_to_price_ids": ["price_1", "price_2"], "percentage_discount": 0, }, "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), @@ -666,8 +666,8 @@ def test_method_price_intervals_with_all_params(self, client: Orb) -> None: }, { "adjustment": { - "applies_to_price_ids": ["price_1", "price_2"], "adjustment_type": "percentage_discount", + "applies_to_price_ids": ["price_1", "price_2"], "percentage_discount": 0, }, "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), @@ -675,8 +675,8 @@ def test_method_price_intervals_with_all_params(self, client: Orb) -> None: }, { "adjustment": { - "applies_to_price_ids": ["price_1", "price_2"], "adjustment_type": "percentage_discount", + "applies_to_price_ids": ["price_1", "price_2"], "percentage_discount": 0, }, "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), @@ -686,80 +686,80 @@ def test_method_price_intervals_with_all_params(self, client: Orb) -> None: edit=[ { "price_interval_id": "sdfs6wdjvn7ujokd", - "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "billing_cycle_day": 0, "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), "fixed_fee_quantity_transitions": [ { - "quantity": 5, "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "quantity": 5, "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "quantity": 5, "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, ], - "billing_cycle_day": 0, + "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), }, { "price_interval_id": "sdfs6wdjvn7ujokd", - "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "billing_cycle_day": 0, "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), "fixed_fee_quantity_transitions": [ { - "quantity": 5, "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "quantity": 5, "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "quantity": 5, "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, ], - "billing_cycle_day": 0, + "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), }, { "price_interval_id": "sdfs6wdjvn7ujokd", - "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "billing_cycle_day": 0, "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), "fixed_fee_quantity_transitions": [ { - "quantity": 5, "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "quantity": 5, "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "quantity": 5, "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, ], - "billing_cycle_day": 0, + "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), }, ], edit_adjustments=[ { "adjustment_interval_id": "sdfs6wdjvn7ujokd", - "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), }, { "adjustment_interval_id": "sdfs6wdjvn7ujokd", - "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), }, { "adjustment_interval_id": "sdfs6wdjvn7ujokd", - "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), }, ], ) @@ -826,56 +826,56 @@ def test_method_schedule_plan_change_with_all_params(self, client: Orb) -> None: { "id": "id", "model_type": "unit", - "minimum_amount": "1.23", - "maximum_amount": "1.23", - "currency": "currency", + "unit_config": {"unit_amount": "unit_amount"}, "conversion_rate": 0, + "currency": "currency", "discount": { "discount_type": "percentage", + "amount_discount": "amount_discount", + "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], "percentage_discount": 0.15, "trial_amount_discount": "trial_amount_discount", "usage_discount": 0, - "amount_discount": "amount_discount", - "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], }, "fixed_price_quantity": 2, - "unit_config": {"unit_amount": "unit_amount"}, + "maximum_amount": "1.23", + "minimum_amount": "1.23", }, { "id": "id", "model_type": "unit", - "minimum_amount": "1.23", - "maximum_amount": "1.23", - "currency": "currency", + "unit_config": {"unit_amount": "unit_amount"}, "conversion_rate": 0, + "currency": "currency", "discount": { "discount_type": "percentage", + "amount_discount": "amount_discount", + "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], "percentage_discount": 0.15, "trial_amount_discount": "trial_amount_discount", "usage_discount": 0, - "amount_discount": "amount_discount", - "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], }, "fixed_price_quantity": 2, - "unit_config": {"unit_amount": "unit_amount"}, + "maximum_amount": "1.23", + "minimum_amount": "1.23", }, { "id": "id", "model_type": "unit", - "minimum_amount": "1.23", - "maximum_amount": "1.23", - "currency": "currency", + "unit_config": {"unit_amount": "unit_amount"}, "conversion_rate": 0, + "currency": "currency", "discount": { "discount_type": "percentage", + "amount_discount": "amount_discount", + "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], "percentage_discount": 0.15, "trial_amount_discount": "trial_amount_discount", "usage_discount": 0, - "amount_discount": "amount_discount", - "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], }, "fixed_price_quantity": 2, - "unit_config": {"unit_amount": "unit_amount"}, + "maximum_amount": "1.23", + "minimum_amount": "1.23", }, ], ) @@ -1170,56 +1170,56 @@ async def test_method_create_with_all_params(self, async_client: AsyncOrb) -> No { "id": "id", "model_type": "unit", - "minimum_amount": "1.23", - "maximum_amount": "1.23", - "currency": "currency", + "unit_config": {"unit_amount": "unit_amount"}, "conversion_rate": 0, + "currency": "currency", "discount": { "discount_type": "percentage", + "amount_discount": "amount_discount", + "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], "percentage_discount": 0.15, "trial_amount_discount": "trial_amount_discount", "usage_discount": 0, - "amount_discount": "amount_discount", - "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], }, "fixed_price_quantity": 2, - "unit_config": {"unit_amount": "unit_amount"}, + "maximum_amount": "1.23", + "minimum_amount": "1.23", }, { "id": "id", "model_type": "unit", - "minimum_amount": "1.23", - "maximum_amount": "1.23", - "currency": "currency", + "unit_config": {"unit_amount": "unit_amount"}, "conversion_rate": 0, + "currency": "currency", "discount": { "discount_type": "percentage", + "amount_discount": "amount_discount", + "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], "percentage_discount": 0.15, "trial_amount_discount": "trial_amount_discount", "usage_discount": 0, - "amount_discount": "amount_discount", - "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], }, "fixed_price_quantity": 2, - "unit_config": {"unit_amount": "unit_amount"}, + "maximum_amount": "1.23", + "minimum_amount": "1.23", }, { "id": "id", "model_type": "unit", - "minimum_amount": "1.23", - "maximum_amount": "1.23", - "currency": "currency", + "unit_config": {"unit_amount": "unit_amount"}, "conversion_rate": 0, + "currency": "currency", "discount": { "discount_type": "percentage", + "amount_discount": "amount_discount", + "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], "percentage_discount": 0.15, "trial_amount_discount": "trial_amount_discount", "usage_discount": 0, - "amount_discount": "amount_discount", - "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], }, "fixed_price_quantity": 2, - "unit_config": {"unit_amount": "unit_amount"}, + "maximum_amount": "1.23", + "minimum_amount": "1.23", }, ], start_date=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -1599,182 +1599,182 @@ async def test_method_price_intervals_with_all_params(self, async_client: AsyncO subscription_id="subscription_id", add=[ { - "price_id": "h74gfhdjvn7ujokd", - "external_price_id": "external_price_id", - "price": { - "metadata": {"foo": "string"}, - "external_price_id": "external_price_id", - "name": "Annual fee", - "billable_metric_id": "billable_metric_id", - "item_id": "item_id", - "billed_in_advance": True, - "fixed_price_quantity": 0, - "invoice_grouping_key": "invoice_grouping_key", - "cadence": "annual", - "conversion_rate": 0, - "model_type": "unit", - "unit_config": {"unit_amount": "unit_amount"}, - "currency": "currency", - }, + "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), "allocation_price": { - "currency": "USD", "amount": "10.00", - "cadence": "monthly", + "cadence": "one_time", + "currency": "USD", "expires_at_end_of_cadence": True, }, - "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), - "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), - "fixed_fee_quantity_transitions": [ + "discounts": [ { - "quantity": 5, - "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "amount_discount": 0, + "discount_type": "amount", }, { - "quantity": 5, - "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "amount_discount": 0, + "discount_type": "amount", }, { - "quantity": 5, - "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "amount_discount": 0, + "discount_type": "amount", }, ], - "discounts": [ + "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "external_price_id": "external_price_id", + "fixed_fee_quantity_transitions": [ { - "discount_type": "amount", - "amount_discount": 0, + "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "discount_type": "amount", - "amount_discount": 0, + "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "discount_type": "amount", - "amount_discount": 0, + "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, ], - "minimum_amount": 0, "maximum_amount": 0, - }, - { - "price_id": "h74gfhdjvn7ujokd", - "external_price_id": "external_price_id", + "minimum_amount": 0, "price": { - "metadata": {"foo": "string"}, - "external_price_id": "external_price_id", + "cadence": "annual", + "currency": "currency", + "item_id": "item_id", + "model_type": "unit", "name": "Annual fee", + "unit_config": {"unit_amount": "unit_amount"}, "billable_metric_id": "billable_metric_id", - "item_id": "item_id", "billed_in_advance": True, + "conversion_rate": 0, + "external_price_id": "external_price_id", "fixed_price_quantity": 0, "invoice_grouping_key": "invoice_grouping_key", - "cadence": "annual", - "conversion_rate": 0, - "model_type": "unit", - "unit_config": {"unit_amount": "unit_amount"}, - "currency": "currency", + "metadata": {"foo": "string"}, }, + "price_id": "h74gfhdjvn7ujokd", + }, + { + "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), "allocation_price": { - "currency": "USD", "amount": "10.00", - "cadence": "monthly", + "cadence": "one_time", + "currency": "USD", "expires_at_end_of_cadence": True, }, - "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), - "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), - "fixed_fee_quantity_transitions": [ + "discounts": [ { - "quantity": 5, - "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "amount_discount": 0, + "discount_type": "amount", }, { - "quantity": 5, - "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "amount_discount": 0, + "discount_type": "amount", }, { - "quantity": 5, - "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "amount_discount": 0, + "discount_type": "amount", }, ], - "discounts": [ + "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "external_price_id": "external_price_id", + "fixed_fee_quantity_transitions": [ { - "discount_type": "amount", - "amount_discount": 0, + "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "discount_type": "amount", - "amount_discount": 0, + "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "discount_type": "amount", - "amount_discount": 0, + "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, ], - "minimum_amount": 0, "maximum_amount": 0, - }, - { - "price_id": "h74gfhdjvn7ujokd", - "external_price_id": "external_price_id", + "minimum_amount": 0, "price": { - "metadata": {"foo": "string"}, - "external_price_id": "external_price_id", + "cadence": "annual", + "currency": "currency", + "item_id": "item_id", + "model_type": "unit", "name": "Annual fee", + "unit_config": {"unit_amount": "unit_amount"}, "billable_metric_id": "billable_metric_id", - "item_id": "item_id", "billed_in_advance": True, + "conversion_rate": 0, + "external_price_id": "external_price_id", "fixed_price_quantity": 0, "invoice_grouping_key": "invoice_grouping_key", - "cadence": "annual", - "conversion_rate": 0, - "model_type": "unit", - "unit_config": {"unit_amount": "unit_amount"}, - "currency": "currency", + "metadata": {"foo": "string"}, }, + "price_id": "h74gfhdjvn7ujokd", + }, + { + "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), "allocation_price": { - "currency": "USD", "amount": "10.00", - "cadence": "monthly", + "cadence": "one_time", + "currency": "USD", "expires_at_end_of_cadence": True, }, - "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), - "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), - "fixed_fee_quantity_transitions": [ + "discounts": [ { - "quantity": 5, - "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "amount_discount": 0, + "discount_type": "amount", }, { - "quantity": 5, - "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "amount_discount": 0, + "discount_type": "amount", }, { - "quantity": 5, - "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "amount_discount": 0, + "discount_type": "amount", }, ], - "discounts": [ + "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "external_price_id": "external_price_id", + "fixed_fee_quantity_transitions": [ { - "discount_type": "amount", - "amount_discount": 0, + "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "discount_type": "amount", - "amount_discount": 0, + "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "discount_type": "amount", - "amount_discount": 0, + "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, ], - "minimum_amount": 0, "maximum_amount": 0, + "minimum_amount": 0, + "price": { + "cadence": "annual", + "currency": "currency", + "item_id": "item_id", + "model_type": "unit", + "name": "Annual fee", + "unit_config": {"unit_amount": "unit_amount"}, + "billable_metric_id": "billable_metric_id", + "billed_in_advance": True, + "conversion_rate": 0, + "external_price_id": "external_price_id", + "fixed_price_quantity": 0, + "invoice_grouping_key": "invoice_grouping_key", + "metadata": {"foo": "string"}, + }, + "price_id": "h74gfhdjvn7ujokd", }, ], add_adjustments=[ { "adjustment": { - "applies_to_price_ids": ["price_1", "price_2"], "adjustment_type": "percentage_discount", + "applies_to_price_ids": ["price_1", "price_2"], "percentage_discount": 0, }, "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), @@ -1782,8 +1782,8 @@ async def test_method_price_intervals_with_all_params(self, async_client: AsyncO }, { "adjustment": { - "applies_to_price_ids": ["price_1", "price_2"], "adjustment_type": "percentage_discount", + "applies_to_price_ids": ["price_1", "price_2"], "percentage_discount": 0, }, "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), @@ -1791,8 +1791,8 @@ async def test_method_price_intervals_with_all_params(self, async_client: AsyncO }, { "adjustment": { - "applies_to_price_ids": ["price_1", "price_2"], "adjustment_type": "percentage_discount", + "applies_to_price_ids": ["price_1", "price_2"], "percentage_discount": 0, }, "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), @@ -1802,80 +1802,80 @@ async def test_method_price_intervals_with_all_params(self, async_client: AsyncO edit=[ { "price_interval_id": "sdfs6wdjvn7ujokd", - "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "billing_cycle_day": 0, "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), "fixed_fee_quantity_transitions": [ { - "quantity": 5, "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "quantity": 5, "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "quantity": 5, "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, ], - "billing_cycle_day": 0, + "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), }, { "price_interval_id": "sdfs6wdjvn7ujokd", - "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "billing_cycle_day": 0, "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), "fixed_fee_quantity_transitions": [ { - "quantity": 5, "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "quantity": 5, "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "quantity": 5, "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, ], - "billing_cycle_day": 0, + "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), }, { "price_interval_id": "sdfs6wdjvn7ujokd", - "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "billing_cycle_day": 0, "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), "fixed_fee_quantity_transitions": [ { - "quantity": 5, "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "quantity": 5, "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, { - "quantity": 5, "effective_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "quantity": 5, }, ], - "billing_cycle_day": 0, + "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), }, ], edit_adjustments=[ { "adjustment_interval_id": "sdfs6wdjvn7ujokd", - "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), }, { "adjustment_interval_id": "sdfs6wdjvn7ujokd", - "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), }, { "adjustment_interval_id": "sdfs6wdjvn7ujokd", - "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), "end_date": parse_datetime("2019-12-27T18:11:19.117Z"), + "start_date": parse_datetime("2019-12-27T18:11:19.117Z"), }, ], ) @@ -1942,56 +1942,56 @@ async def test_method_schedule_plan_change_with_all_params(self, async_client: A { "id": "id", "model_type": "unit", - "minimum_amount": "1.23", - "maximum_amount": "1.23", - "currency": "currency", + "unit_config": {"unit_amount": "unit_amount"}, "conversion_rate": 0, + "currency": "currency", "discount": { "discount_type": "percentage", + "amount_discount": "amount_discount", + "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], "percentage_discount": 0.15, "trial_amount_discount": "trial_amount_discount", "usage_discount": 0, - "amount_discount": "amount_discount", - "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], }, "fixed_price_quantity": 2, - "unit_config": {"unit_amount": "unit_amount"}, + "maximum_amount": "1.23", + "minimum_amount": "1.23", }, { "id": "id", "model_type": "unit", - "minimum_amount": "1.23", - "maximum_amount": "1.23", - "currency": "currency", + "unit_config": {"unit_amount": "unit_amount"}, "conversion_rate": 0, + "currency": "currency", "discount": { "discount_type": "percentage", + "amount_discount": "amount_discount", + "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], "percentage_discount": 0.15, "trial_amount_discount": "trial_amount_discount", "usage_discount": 0, - "amount_discount": "amount_discount", - "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], }, "fixed_price_quantity": 2, - "unit_config": {"unit_amount": "unit_amount"}, + "maximum_amount": "1.23", + "minimum_amount": "1.23", }, { "id": "id", "model_type": "unit", - "minimum_amount": "1.23", - "maximum_amount": "1.23", - "currency": "currency", + "unit_config": {"unit_amount": "unit_amount"}, "conversion_rate": 0, + "currency": "currency", "discount": { "discount_type": "percentage", + "amount_discount": "amount_discount", + "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], "percentage_discount": 0.15, "trial_amount_discount": "trial_amount_discount", "usage_discount": 0, - "amount_discount": "amount_discount", - "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], }, "fixed_price_quantity": 2, - "unit_config": {"unit_amount": "unit_amount"}, + "maximum_amount": "1.23", + "minimum_amount": "1.23", }, ], ) diff --git a/tests/test_client.py b/tests/test_client.py index 7358beb0..8b038c1d 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -17,6 +17,7 @@ from pydantic import ValidationError from orb import Orb, AsyncOrb, APIResponseValidationError +from orb._types import Omit from orb._models import BaseModel, FinalRequestOptions from orb._constants import RAW_RESPONSE_HEADER from orb._exceptions import OrbError, APIStatusError, APITimeoutError, APIResponseValidationError @@ -319,7 +320,8 @@ def test_validate_headers(self) -> None: assert request.headers.get("Authorization") == f"Bearer {api_key}" with pytest.raises(OrbError): - client2 = Orb(base_url=base_url, api_key=None, _strict_response_validation=True) + with update_env(**{"ORB_API_KEY": Omit()}): + client2 = Orb(base_url=base_url, api_key=None, _strict_response_validation=True) _ = client2 def test_default_query_option(self) -> None: @@ -747,6 +749,49 @@ def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> Non assert _get_open_connections(self.client) == 0 + @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) + @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @pytest.mark.respx(base_url=base_url) + def test_retries_taken(self, client: Orb, failures_before_success: int, respx_mock: MockRouter) -> None: + client = client.with_options(max_retries=4) + + nb_retries = 0 + + def retry_handler(_request: httpx.Request) -> httpx.Response: + nonlocal nb_retries + if nb_retries < failures_before_success: + nb_retries += 1 + return httpx.Response(500) + return httpx.Response(200) + + respx_mock.post("/customers").mock(side_effect=retry_handler) + + response = client.customers.with_raw_response.create(email="email", name="name") + + assert response.retries_taken == failures_before_success + + @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) + @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @pytest.mark.respx(base_url=base_url) + def test_retries_taken_new_response_class( + self, client: Orb, failures_before_success: int, respx_mock: MockRouter + ) -> None: + client = client.with_options(max_retries=4) + + nb_retries = 0 + + def retry_handler(_request: httpx.Request) -> httpx.Response: + nonlocal nb_retries + if nb_retries < failures_before_success: + nb_retries += 1 + return httpx.Response(500) + return httpx.Response(200) + + respx_mock.post("/customers").mock(side_effect=retry_handler) + + with client.customers.with_streaming_response.create(email="email", name="name") as response: + assert response.retries_taken == failures_before_success + class TestAsyncOrb: client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) @@ -1033,7 +1078,8 @@ def test_validate_headers(self) -> None: assert request.headers.get("Authorization") == f"Bearer {api_key}" with pytest.raises(OrbError): - client2 = AsyncOrb(base_url=base_url, api_key=None, _strict_response_validation=True) + with update_env(**{"ORB_API_KEY": Omit()}): + client2 = AsyncOrb(base_url=base_url, api_key=None, _strict_response_validation=True) _ = client2 def test_default_query_option(self) -> None: @@ -1464,3 +1510,50 @@ async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) ) assert _get_open_connections(self.client) == 0 + + @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) + @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @pytest.mark.respx(base_url=base_url) + @pytest.mark.asyncio + async def test_retries_taken( + self, async_client: AsyncOrb, failures_before_success: int, respx_mock: MockRouter + ) -> None: + client = async_client.with_options(max_retries=4) + + nb_retries = 0 + + def retry_handler(_request: httpx.Request) -> httpx.Response: + nonlocal nb_retries + if nb_retries < failures_before_success: + nb_retries += 1 + return httpx.Response(500) + return httpx.Response(200) + + respx_mock.post("/customers").mock(side_effect=retry_handler) + + response = await client.customers.with_raw_response.create(email="email", name="name") + + assert response.retries_taken == failures_before_success + + @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) + @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @pytest.mark.respx(base_url=base_url) + @pytest.mark.asyncio + async def test_retries_taken_new_response_class( + self, async_client: AsyncOrb, failures_before_success: int, respx_mock: MockRouter + ) -> None: + client = async_client.with_options(max_retries=4) + + nb_retries = 0 + + def retry_handler(_request: httpx.Request) -> httpx.Response: + nonlocal nb_retries + if nb_retries < failures_before_success: + nb_retries += 1 + return httpx.Response(500) + return httpx.Response(200) + + respx_mock.post("/customers").mock(side_effect=retry_handler) + + async with client.customers.with_streaming_response.create(email="email", name="name") as response: + assert response.retries_taken == failures_before_success diff --git a/tests/test_deepcopy.py b/tests/test_deepcopy.py index 1a6048b8..c05f70c0 100644 --- a/tests/test_deepcopy.py +++ b/tests/test_deepcopy.py @@ -41,8 +41,7 @@ def test_nested_list() -> None: assert_different_identities(obj1[1], obj2[1]) -class MyObject: - ... +class MyObject: ... def test_ignores_other_types() -> None: diff --git a/tests/test_legacy_response.py b/tests/test_legacy_response.py index fe9c205a..2f5d0578 100644 --- a/tests/test_legacy_response.py +++ b/tests/test_legacy_response.py @@ -12,8 +12,7 @@ from orb._legacy_response import LegacyAPIResponse -class PydanticModel(pydantic.BaseModel): - ... +class PydanticModel(pydantic.BaseModel): ... def test_response_parse_mismatched_basemodel(client: Orb) -> None: diff --git a/tests/test_response.py b/tests/test_response.py index e90e201b..7c05c327 100644 --- a/tests/test_response.py +++ b/tests/test_response.py @@ -19,16 +19,13 @@ from orb._base_client import FinalRequestOptions -class ConcreteBaseAPIResponse(APIResponse[bytes]): - ... +class ConcreteBaseAPIResponse(APIResponse[bytes]): ... -class ConcreteAPIResponse(APIResponse[List[str]]): - ... +class ConcreteAPIResponse(APIResponse[List[str]]): ... -class ConcreteAsyncAPIResponse(APIResponse[httpx.Response]): - ... +class ConcreteAsyncAPIResponse(APIResponse[httpx.Response]): ... def test_extract_response_type_direct_classes() -> None: @@ -56,8 +53,7 @@ def test_extract_response_type_binary_response() -> None: assert extract_response_type(AsyncBinaryAPIResponse) == bytes -class PydanticModel(pydantic.BaseModel): - ... +class PydanticModel(pydantic.BaseModel): ... def test_response_parse_mismatched_basemodel(client: Orb) -> None: diff --git a/tests/test_utils/test_typing.py b/tests/test_utils/test_typing.py index c3e42410..3826b105 100644 --- a/tests/test_utils/test_typing.py +++ b/tests/test_utils/test_typing.py @@ -9,24 +9,19 @@ _T3 = TypeVar("_T3") -class BaseGeneric(Generic[_T]): - ... +class BaseGeneric(Generic[_T]): ... -class SubclassGeneric(BaseGeneric[_T]): - ... +class SubclassGeneric(BaseGeneric[_T]): ... -class BaseGenericMultipleTypeArgs(Generic[_T, _T2, _T3]): - ... +class BaseGenericMultipleTypeArgs(Generic[_T, _T2, _T3]): ... -class SubclassGenericMultipleTypeArgs(BaseGenericMultipleTypeArgs[_T, _T2, _T3]): - ... +class SubclassGenericMultipleTypeArgs(BaseGenericMultipleTypeArgs[_T, _T2, _T3]): ... -class SubclassDifferentOrderGenericMultipleTypeArgs(BaseGenericMultipleTypeArgs[_T2, _T, _T3]): - ... +class SubclassDifferentOrderGenericMultipleTypeArgs(BaseGenericMultipleTypeArgs[_T2, _T, _T3]): ... def test_extract_type_var() -> None: diff --git a/tests/utils.py b/tests/utils.py index 4aa683f2..1fa786ba 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -8,7 +8,7 @@ from datetime import date, datetime from typing_extensions import Literal, get_args, get_origin, assert_type -from orb._types import NoneType +from orb._types import Omit, NoneType from orb._utils import ( is_dict, is_list, @@ -139,11 +139,15 @@ def _assert_list_type(type_: type[object], value: object) -> None: @contextlib.contextmanager -def update_env(**new_env: str) -> Iterator[None]: +def update_env(**new_env: str | Omit) -> Iterator[None]: old = os.environ.copy() try: - os.environ.update(new_env) + for name, value in new_env.items(): + if isinstance(value, Omit): + os.environ.pop(name, None) + else: + os.environ[name] = value yield None finally: