Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.38.1"
".": "1.39.0"
}
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 1.39.0 (2024-01-17)

Full Changelog: [v1.38.1...v1.39.0](https://github.com/orbcorp/orb-python/compare/v1.38.1...v1.39.0)

### Features

* **api:** updates ([#139](https://github.com/orbcorp/orb-python/issues/139)) ([ab7998f](https://github.com/orbcorp/orb-python/commit/ab7998fa311038357c124fe556b9cd1a664d826b))


### Chores

* add write_to_file binary helper method ([#138](https://github.com/orbcorp/orb-python/issues/138)) ([f48014d](https://github.com/orbcorp/orb-python/commit/f48014d0792e01dde7206088ab672c6012d00deb))
* **internal:** updates to proxy helper ([#136](https://github.com/orbcorp/orb-python/issues/136)) ([15d29d5](https://github.com/orbcorp/orb-python/commit/15d29d513cd6b58fee06b6165bc2ce16fba7e096))

## 1.38.1 (2024-01-16)

Full Changelog: [v1.38.0...v1.38.1](https://github.com/orbcorp/orb-python/compare/v1.38.0...v1.38.1)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "orb-billing"
version = "1.38.1"
version = "1.39.0"
description = "The official Python library for the orb API"
readme = "README.md"
license = "Apache-2.0"
Expand Down
16 changes: 16 additions & 0 deletions src/orb/_legacy_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,22 @@ def iter_lines(self) -> Iterator[str]:
def iter_raw(self, chunk_size: int | None = None) -> Iterator[bytes]:
return self.response.iter_raw(chunk_size)

def write_to_file(
self,
file: str | os.PathLike[str],
) -> None:
"""Write the output to the given file.

Accepts a filename or any path-like object, e.g. pathlib.Path

Note: if you want to stream the data to the file instead of writing
all at once then you should use `.with_streaming_response` when making
the API request, e.g. `client.with_streaming_response.foo().stream_to_file('my_filename.txt')`
"""
with open(file, mode="wb") as f:
for data in self.response.iter_bytes():
f.write(data)

@deprecated(
"Due to a bug, this method doesn't actually stream the response content, `.with_streaming_response.method()` should be used instead"
)
Expand Down
20 changes: 2 additions & 18 deletions src/orb/_utils/_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from abc import ABC, abstractmethod
from typing import Generic, TypeVar, Iterable, cast
from typing_extensions import ClassVar, override
from typing_extensions import override

T = TypeVar("T")

Expand All @@ -13,11 +13,6 @@ class LazyProxy(Generic[T], ABC):
This includes forwarding attribute access and othe methods.
"""

should_cache: ClassVar[bool] = False

def __init__(self) -> None:
self.__proxied: T | None = None

# Note: we have to special case proxies that themselves return proxies
# to support using a proxy as a catch-all for any random access, e.g. `proxy.foo.bar.baz`

Expand Down Expand Up @@ -57,18 +52,7 @@ def __class__(self) -> type:
return proxied.__class__

def __get_proxied__(self) -> T:
if not self.should_cache:
return self.__load__()

proxied = self.__proxied
if proxied is not None:
return proxied

self.__proxied = proxied = self.__load__()
return proxied

def __set_proxied__(self, value: T) -> None:
self.__proxied = value
return self.__load__()

def __as_proxied__(self) -> T:
"""Helper method that returns the current proxy, typed as the loaded object"""
Expand Down
2 changes: 1 addition & 1 deletion src/orb/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless.

__title__ = "orb"
__version__ = "1.38.1" # x-release-please-version
__version__ = "1.39.0" # x-release-please-version
80 changes: 36 additions & 44 deletions src/orb/resources/customers/credits/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ def create_entry(
entry_type: Literal["increment"],
currency: Optional[str] | NotGiven = NOT_GIVEN,
description: Optional[str] | NotGiven = NOT_GIVEN,
effective_date: Union[str, date, None] | NotGiven = NOT_GIVEN,
expiry_date: Union[str, date, None] | NotGiven = NOT_GIVEN,
effective_date: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
expiry_date: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
invoice_settings: Optional[ledger_create_entry_params.AddIncrementCreditLedgerEntryRequestParamsInvoiceSettings]
| NotGiven = NOT_GIVEN,
metadata: Optional[Dict[str, Optional[str]]] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -347,11 +347,10 @@ def create_entry(
For example, this can be used to note an increment refers to trial credits, or
for noting corrections as a result of an incident, etc.

effective_date: A future date (specified in YYYY-MM-DD format) that denotes when this credit
balance should become available for use.
effective_date: An ISO 8601 format date that denotes when this credit balance should become
available for use.

expiry_date: A future date (specified in YYYY-MM-DD format) that denotes when this credit
balance should expire.
expiry_date: An ISO 8601 format date that denotes when this credit balance should expire.

invoice_settings: Passing `invoice_settings` automatically generates an invoice for the newly
added credits. If `invoice_settings` is passed, you must specify
Expand Down Expand Up @@ -539,7 +538,7 @@ def create_entry(
customer_id: Optional[str],
*,
entry_type: Literal["expiration_change"],
expiry_date: Union[str, date, None],
expiry_date: Union[str, datetime, None],
target_expiry_date: Union[str, date],
amount: Optional[float] | NotGiven = NOT_GIVEN,
block_id: Optional[str] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -666,8 +665,7 @@ def create_entry(
return to the customer, up to the block's initial balance.

Args:
expiry_date: A future date (specified in YYYY-MM-DD format) that identifies the origination
credit block to expire
expiry_date: An ISO 8601 format date that identifies the origination credit block to expire

target_expiry_date: A future date (specified in YYYY-MM-DD format) used for expiration change,
denoting when credits transferred (as part of a partial block expiration) should
Expand Down Expand Up @@ -1042,8 +1040,8 @@ def create_entry(
| Literal["amendment"],
currency: Optional[str] | NotGiven = NOT_GIVEN,
description: Optional[str] | NotGiven = NOT_GIVEN,
effective_date: Union[str, date, None] | NotGiven = NOT_GIVEN,
expiry_date: Union[str, date, None] | NotGiven = NOT_GIVEN,
effective_date: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
expiry_date: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
invoice_settings: Optional[ledger_create_entry_params.AddIncrementCreditLedgerEntryRequestParamsInvoiceSettings]
| NotGiven = NOT_GIVEN,
metadata: Optional[Dict[str, Optional[str]]] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -1104,8 +1102,8 @@ def create_entry_by_external_id(
entry_type: Literal["increment"],
currency: Optional[str] | NotGiven = NOT_GIVEN,
description: Optional[str] | NotGiven = NOT_GIVEN,
effective_date: Union[str, date, None] | NotGiven = NOT_GIVEN,
expiry_date: Union[str, date, None] | NotGiven = NOT_GIVEN,
effective_date: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
expiry_date: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
invoice_settings: Optional[
ledger_create_entry_by_external_id_params.AddIncrementCreditLedgerEntryRequestParamsInvoiceSettings
]
Expand Down Expand Up @@ -1242,11 +1240,10 @@ def create_entry_by_external_id(
For example, this can be used to note an increment refers to trial credits, or
for noting corrections as a result of an incident, etc.

effective_date: A future date (specified in YYYY-MM-DD format) that denotes when this credit
balance should become available for use.
effective_date: An ISO 8601 format date that denotes when this credit balance should become
available for use.

expiry_date: A future date (specified in YYYY-MM-DD format) that denotes when this credit
balance should expire.
expiry_date: An ISO 8601 format date that denotes when this credit balance should expire.

invoice_settings: Passing `invoice_settings` automatically generates an invoice for the newly
added credits. If `invoice_settings` is passed, you must specify
Expand Down Expand Up @@ -1434,7 +1431,7 @@ def create_entry_by_external_id(
external_customer_id: Optional[str],
*,
entry_type: Literal["expiration_change"],
expiry_date: Union[str, date, None],
expiry_date: Union[str, datetime, None],
target_expiry_date: Union[str, date],
amount: Optional[float] | NotGiven = NOT_GIVEN,
block_id: Optional[str] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -1561,8 +1558,7 @@ def create_entry_by_external_id(
return to the customer, up to the block's initial balance.

Args:
expiry_date: A future date (specified in YYYY-MM-DD format) that identifies the origination
credit block to expire
expiry_date: An ISO 8601 format date that identifies the origination credit block to expire

target_expiry_date: A future date (specified in YYYY-MM-DD format) used for expiration change,
denoting when credits transferred (as part of a partial block expiration) should
Expand Down Expand Up @@ -1937,8 +1933,8 @@ def create_entry_by_external_id(
| Literal["amendment"],
currency: Optional[str] | NotGiven = NOT_GIVEN,
description: Optional[str] | NotGiven = NOT_GIVEN,
effective_date: Union[str, date, None] | NotGiven = NOT_GIVEN,
expiry_date: Union[str, date, None] | NotGiven = NOT_GIVEN,
effective_date: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
expiry_date: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
invoice_settings: Optional[
ledger_create_entry_by_external_id_params.AddIncrementCreditLedgerEntryRequestParamsInvoiceSettings
]
Expand Down Expand Up @@ -2337,8 +2333,8 @@ async def create_entry(
entry_type: Literal["increment"],
currency: Optional[str] | NotGiven = NOT_GIVEN,
description: Optional[str] | NotGiven = NOT_GIVEN,
effective_date: Union[str, date, None] | NotGiven = NOT_GIVEN,
expiry_date: Union[str, date, None] | NotGiven = NOT_GIVEN,
effective_date: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
expiry_date: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
invoice_settings: Optional[ledger_create_entry_params.AddIncrementCreditLedgerEntryRequestParamsInvoiceSettings]
| NotGiven = NOT_GIVEN,
metadata: Optional[Dict[str, Optional[str]]] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -2473,11 +2469,10 @@ async def create_entry(
For example, this can be used to note an increment refers to trial credits, or
for noting corrections as a result of an incident, etc.

effective_date: A future date (specified in YYYY-MM-DD format) that denotes when this credit
balance should become available for use.
effective_date: An ISO 8601 format date that denotes when this credit balance should become
available for use.

expiry_date: A future date (specified in YYYY-MM-DD format) that denotes when this credit
balance should expire.
expiry_date: An ISO 8601 format date that denotes when this credit balance should expire.

invoice_settings: Passing `invoice_settings` automatically generates an invoice for the newly
added credits. If `invoice_settings` is passed, you must specify
Expand Down Expand Up @@ -2665,7 +2660,7 @@ async def create_entry(
customer_id: Optional[str],
*,
entry_type: Literal["expiration_change"],
expiry_date: Union[str, date, None],
expiry_date: Union[str, datetime, None],
target_expiry_date: Union[str, date],
amount: Optional[float] | NotGiven = NOT_GIVEN,
block_id: Optional[str] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -2792,8 +2787,7 @@ async def create_entry(
return to the customer, up to the block's initial balance.

Args:
expiry_date: A future date (specified in YYYY-MM-DD format) that identifies the origination
credit block to expire
expiry_date: An ISO 8601 format date that identifies the origination credit block to expire

target_expiry_date: A future date (specified in YYYY-MM-DD format) used for expiration change,
denoting when credits transferred (as part of a partial block expiration) should
Expand Down Expand Up @@ -3168,8 +3162,8 @@ async def create_entry(
| Literal["amendment"],
currency: Optional[str] | NotGiven = NOT_GIVEN,
description: Optional[str] | NotGiven = NOT_GIVEN,
effective_date: Union[str, date, None] | NotGiven = NOT_GIVEN,
expiry_date: Union[str, date, None] | NotGiven = NOT_GIVEN,
effective_date: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
expiry_date: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
invoice_settings: Optional[ledger_create_entry_params.AddIncrementCreditLedgerEntryRequestParamsInvoiceSettings]
| NotGiven = NOT_GIVEN,
metadata: Optional[Dict[str, Optional[str]]] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -3230,8 +3224,8 @@ async def create_entry_by_external_id(
entry_type: Literal["increment"],
currency: Optional[str] | NotGiven = NOT_GIVEN,
description: Optional[str] | NotGiven = NOT_GIVEN,
effective_date: Union[str, date, None] | NotGiven = NOT_GIVEN,
expiry_date: Union[str, date, None] | NotGiven = NOT_GIVEN,
effective_date: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
expiry_date: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
invoice_settings: Optional[
ledger_create_entry_by_external_id_params.AddIncrementCreditLedgerEntryRequestParamsInvoiceSettings
]
Expand Down Expand Up @@ -3368,11 +3362,10 @@ async def create_entry_by_external_id(
For example, this can be used to note an increment refers to trial credits, or
for noting corrections as a result of an incident, etc.

effective_date: A future date (specified in YYYY-MM-DD format) that denotes when this credit
balance should become available for use.
effective_date: An ISO 8601 format date that denotes when this credit balance should become
available for use.

expiry_date: A future date (specified in YYYY-MM-DD format) that denotes when this credit
balance should expire.
expiry_date: An ISO 8601 format date that denotes when this credit balance should expire.

invoice_settings: Passing `invoice_settings` automatically generates an invoice for the newly
added credits. If `invoice_settings` is passed, you must specify
Expand Down Expand Up @@ -3560,7 +3553,7 @@ async def create_entry_by_external_id(
external_customer_id: Optional[str],
*,
entry_type: Literal["expiration_change"],
expiry_date: Union[str, date, None],
expiry_date: Union[str, datetime, None],
target_expiry_date: Union[str, date],
amount: Optional[float] | NotGiven = NOT_GIVEN,
block_id: Optional[str] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -3687,8 +3680,7 @@ async def create_entry_by_external_id(
return to the customer, up to the block's initial balance.

Args:
expiry_date: A future date (specified in YYYY-MM-DD format) that identifies the origination
credit block to expire
expiry_date: An ISO 8601 format date that identifies the origination credit block to expire

target_expiry_date: A future date (specified in YYYY-MM-DD format) used for expiration change,
denoting when credits transferred (as part of a partial block expiration) should
Expand Down Expand Up @@ -4063,8 +4055,8 @@ async def create_entry_by_external_id(
| Literal["amendment"],
currency: Optional[str] | NotGiven = NOT_GIVEN,
description: Optional[str] | NotGiven = NOT_GIVEN,
effective_date: Union[str, date, None] | NotGiven = NOT_GIVEN,
expiry_date: Union[str, date, None] | NotGiven = NOT_GIVEN,
effective_date: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
expiry_date: Union[str, datetime, None] | NotGiven = NOT_GIVEN,
invoice_settings: Optional[
ledger_create_entry_by_external_id_params.AddIncrementCreditLedgerEntryRequestParamsInvoiceSettings
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from typing import Dict, Union, Optional
from datetime import date
from datetime import date, datetime
from typing_extensions import Literal, Required, Annotated, TypedDict

from ...._utils import PropertyInfo
Expand Down Expand Up @@ -42,17 +42,14 @@ class AddIncrementCreditLedgerEntryRequestParams(TypedDict, total=False):
for noting corrections as a result of an incident, etc.
"""

effective_date: Annotated[Union[str, date, None], PropertyInfo(format="iso8601")]
effective_date: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
"""
A future date (specified in YYYY-MM-DD format) that denotes when this credit
balance should become available for use.
An ISO 8601 format date that denotes when this credit balance should become
available for use.
"""

expiry_date: Annotated[Union[str, date, None], PropertyInfo(format="iso8601")]
"""
A future date (specified in YYYY-MM-DD format) that denotes when this credit
balance should expire.
"""
expiry_date: Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]
"""An ISO 8601 format date that denotes when this credit balance should expire."""

invoice_settings: Optional[AddIncrementCreditLedgerEntryRequestParamsInvoiceSettings]
"""
Expand Down Expand Up @@ -128,11 +125,8 @@ class AddDecrementCreditLedgerEntryRequestParams(TypedDict, total=False):
class AddExpirationChangeCreditLedgerEntryRequestParams(TypedDict, total=False):
entry_type: Required[Literal["expiration_change"]]

expiry_date: Required[Annotated[Union[str, date, None], PropertyInfo(format="iso8601")]]
"""
A future date (specified in YYYY-MM-DD format) that identifies the origination
credit block to expire
"""
expiry_date: Required[Annotated[Union[str, datetime, None], PropertyInfo(format="iso8601")]]
"""An ISO 8601 format date that identifies the origination credit block to expire"""

target_expiry_date: Required[Annotated[Union[str, date], PropertyInfo(format="iso8601")]]
"""
Expand Down
Loading