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 @@
{
".": "0.22.1"
".": "0.22.2"
}
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## 0.22.2 (2023-11-06)

Full Changelog: [v0.22.1...v0.22.2](https://github.com/lithic-com/lithic-python/compare/v0.22.1...v0.22.2)

### Bug Fixes

* prevent TypeError in Python 3.8 (ABC is not subscriptable) ([#233](https://github.com/lithic-com/lithic-python/issues/233)) ([55fd8a3](https://github.com/lithic-com/lithic-python/commit/55fd8a3315c546a4c83ff8e72b36aff78d7c7209))


### Chores

* **internal:** remove unused int/float conversion ([#231](https://github.com/lithic-com/lithic-python/issues/231)) ([1256055](https://github.com/lithic-com/lithic-python/commit/125605517acc43343c15a382c10ce535304c22d6))


### Documentation

* **api:** improve method signatures for named path params ([#228](https://github.com/lithic-com/lithic-python/issues/228)) ([476d296](https://github.com/lithic-com/lithic-python/commit/476d2960e890068e851c4d443533704178912431))
* improve account holder control person documentation ([#230](https://github.com/lithic-com/lithic-python/issues/230)) ([36abfb0](https://github.com/lithic-com/lithic-python/commit/36abfb09f32eb367c6f4bba24c737bcf585defea))
* **readme:** improve example snippets ([#232](https://github.com/lithic-com/lithic-python/issues/232)) ([ace36a4](https://github.com/lithic-com/lithic-python/commit/ace36a44b8f7fc05ebec0842d6be702150a71a3c))

## 0.22.1 (2023-11-03)

Full Changelog: [v0.22.0...v0.22.1](https://github.com/lithic-com/lithic-python/compare/v0.22.0...v0.22.1)
Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ so that your API Key is not stored in source control.
Simply import `AsyncLithic` instead of `Lithic` and use `await` with each API call:

```python
import asyncio
from lithic import AsyncLithic

client = AsyncLithic(
Expand All @@ -56,7 +57,7 @@ client = AsyncLithic(
)


async def main():
async def main() -> None:
card = await client.cards.create(
type="SINGLE_USE",
)
Expand Down Expand Up @@ -146,11 +147,10 @@ from lithic import Lithic

client = Lithic()

client.cards.create(
foo={
"bar": True,
},
card = client.cards.create(
type="VIRTUAL",
)
print(card.token)
```

## Webhook Verification
Expand Down Expand Up @@ -318,9 +318,8 @@ from lithic import Lithic

client = Lithic()
response = client.cards.with_raw_response.create(
type="VIRTUAL",
type="SINGLE_USE",
)

print(response.headers.get('X-My-Header'))

card = response.parse() # get the object that `cards.create()` would have returned
Expand Down
14 changes: 7 additions & 7 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Methods:
- <code title="patch /account_holders/{account_holder_token}">client.account_holders.<a href="./src/lithic/resources/account_holders.py">update</a>(account_holder_token, \*\*<a href="src/lithic/types/account_holder_update_params.py">params</a>) -> <a href="./src/lithic/types/account_holder_update_response.py">AccountHolderUpdateResponse</a></code>
- <code title="get /account_holders/{account_holder_token}/documents">client.account_holders.<a href="./src/lithic/resources/account_holders.py">list_documents</a>(account_holder_token) -> <a href="./src/lithic/types/account_holder_list_documents_response.py">AccountHolderListDocumentsResponse</a></code>
- <code title="post /account_holders/{account_holder_token}/resubmit">client.account_holders.<a href="./src/lithic/resources/account_holders.py">resubmit</a>(account_holder_token, \*\*<a href="src/lithic/types/account_holder_resubmit_params.py">params</a>) -> <a href="./src/lithic/types/account_holder.py">AccountHolder</a></code>
- <code title="get /account_holders/{account_holder_token}/documents/{document_token}">client.account_holders.<a href="./src/lithic/resources/account_holders.py">retrieve_document</a>(account_holder_token, document_token) -> <a href="./src/lithic/types/account_holder_document.py">AccountHolderDocument</a></code>
- <code title="get /account_holders/{account_holder_token}/documents/{document_token}">client.account_holders.<a href="./src/lithic/resources/account_holders.py">retrieve_document</a>(document_token, \*, account_holder_token) -> <a href="./src/lithic/types/account_holder_document.py">AccountHolderDocument</a></code>
- <code title="post /account_holders/{account_holder_token}/documents">client.account_holders.<a href="./src/lithic/resources/account_holders.py">upload_document</a>(account_holder_token, \*\*<a href="src/lithic/types/account_holder_upload_document_params.py">params</a>) -> <a href="./src/lithic/types/account_holder_document.py">AccountHolderDocument</a></code>

# AuthRules
Expand Down Expand Up @@ -169,7 +169,7 @@ Methods:

Methods:

- <code title="get /cards/{card_token}/financial_transactions/{financial_transaction_token}">client.cards.financial_transactions.<a href="./src/lithic/resources/cards/financial_transactions.py">retrieve</a>(card_token, financial_transaction_token) -> <a href="./src/lithic/types/financial_transaction.py">FinancialTransaction</a></code>
- <code title="get /cards/{card_token}/financial_transactions/{financial_transaction_token}">client.cards.financial_transactions.<a href="./src/lithic/resources/cards/financial_transactions.py">retrieve</a>(financial_transaction_token, \*, card_token) -> <a href="./src/lithic/types/financial_transaction.py">FinancialTransaction</a></code>
- <code title="get /cards/{card_token}/financial_transactions">client.cards.financial_transactions.<a href="./src/lithic/resources/cards/financial_transactions.py">list</a>(card_token, \*\*<a href="src/lithic/types/cards/financial_transaction_list_params.py">params</a>) -> <a href="./src/lithic/types/financial_transaction.py">SyncSinglePage[FinancialTransaction]</a></code>

# Balances
Expand Down Expand Up @@ -211,10 +211,10 @@ Methods:
- <code title="patch /disputes/{dispute_token}">client.disputes.<a href="./src/lithic/resources/disputes.py">update</a>(dispute_token, \*\*<a href="src/lithic/types/dispute_update_params.py">params</a>) -> <a href="./src/lithic/types/dispute.py">Dispute</a></code>
- <code title="get /disputes">client.disputes.<a href="./src/lithic/resources/disputes.py">list</a>(\*\*<a href="src/lithic/types/dispute_list_params.py">params</a>) -> <a href="./src/lithic/types/dispute.py">SyncCursorPage[Dispute]</a></code>
- <code title="delete /disputes/{dispute_token}">client.disputes.<a href="./src/lithic/resources/disputes.py">delete</a>(dispute_token) -> <a href="./src/lithic/types/dispute.py">Dispute</a></code>
- <code title="delete /disputes/{dispute_token}/evidences/{evidence_token}">client.disputes.<a href="./src/lithic/resources/disputes.py">delete_evidence</a>(dispute_token, evidence_token) -> <a href="./src/lithic/types/dispute_evidence.py">DisputeEvidence</a></code>
- <code title="delete /disputes/{dispute_token}/evidences/{evidence_token}">client.disputes.<a href="./src/lithic/resources/disputes.py">delete_evidence</a>(evidence_token, \*, dispute_token) -> <a href="./src/lithic/types/dispute_evidence.py">DisputeEvidence</a></code>
- <code title="post /disputes/{dispute_token}/evidences">client.disputes.<a href="./src/lithic/resources/disputes.py">initiate_evidence_upload</a>(dispute_token, \*\*<a href="src/lithic/types/dispute_initiate_evidence_upload_params.py">params</a>) -> <a href="./src/lithic/types/dispute_evidence.py">DisputeEvidence</a></code>
- <code title="get /disputes/{dispute_token}/evidences">client.disputes.<a href="./src/lithic/resources/disputes.py">list_evidences</a>(dispute_token, \*\*<a href="src/lithic/types/dispute_list_evidences_params.py">params</a>) -> <a href="./src/lithic/types/dispute_evidence.py">SyncCursorPage[DisputeEvidence]</a></code>
- <code title="get /disputes/{dispute_token}/evidences/{evidence_token}">client.disputes.<a href="./src/lithic/resources/disputes.py">retrieve_evidence</a>(dispute_token, evidence_token) -> <a href="./src/lithic/types/dispute_evidence.py">DisputeEvidence</a></code>
- <code title="get /disputes/{dispute_token}/evidences/{evidence_token}">client.disputes.<a href="./src/lithic/resources/disputes.py">retrieve_evidence</a>(evidence_token, \*, dispute_token) -> <a href="./src/lithic/types/dispute_evidence.py">DisputeEvidence</a></code>
- <code>client.disputes.<a href="./src/lithic/resources/disputes.py">upload_evidence</a>(\*args) -> None</code>

# Events
Expand Down Expand Up @@ -276,7 +276,7 @@ Methods:

Methods:

- <code title="get /financial_accounts/{financial_account_token}/financial_transactions/{financial_transaction_token}">client.financial_accounts.financial_transactions.<a href="./src/lithic/resources/financial_accounts/financial_transactions.py">retrieve</a>(financial_account_token, financial_transaction_token) -> <a href="./src/lithic/types/financial_transaction.py">FinancialTransaction</a></code>
- <code title="get /financial_accounts/{financial_account_token}/financial_transactions/{financial_transaction_token}">client.financial_accounts.financial_transactions.<a href="./src/lithic/resources/financial_accounts/financial_transactions.py">retrieve</a>(financial_transaction_token, \*, financial_account_token) -> <a href="./src/lithic/types/financial_transaction.py">FinancialTransaction</a></code>
- <code title="get /financial_accounts/{financial_account_token}/financial_transactions">client.financial_accounts.financial_transactions.<a href="./src/lithic/resources/financial_accounts/financial_transactions.py">list</a>(financial_account_token, \*\*<a href="src/lithic/types/financial_accounts/financial_transaction_list_params.py">params</a>) -> <a href="./src/lithic/types/financial_transaction.py">SyncSinglePage[FinancialTransaction]</a></code>

## Statements
Expand All @@ -289,7 +289,7 @@ from lithic.types.financial_accounts import Statement

Methods:

- <code title="get /financial_accounts/{financial_account_token}/statements/{statement_token}">client.financial_accounts.statements.<a href="./src/lithic/resources/financial_accounts/statements/statements.py">retrieve</a>(financial_account_token, statement_token) -> <a href="./src/lithic/types/financial_accounts/statement.py">Statement</a></code>
- <code title="get /financial_accounts/{financial_account_token}/statements/{statement_token}">client.financial_accounts.statements.<a href="./src/lithic/resources/financial_accounts/statements/statements.py">retrieve</a>(statement_token, \*, financial_account_token) -> <a href="./src/lithic/types/financial_accounts/statement.py">Statement</a></code>
- <code title="get /financial_accounts/{financial_account_token}/statements">client.financial_accounts.statements.<a href="./src/lithic/resources/financial_accounts/statements/statements.py">list</a>(financial_account_token, \*\*<a href="src/lithic/types/financial_accounts/statement_list_params.py">params</a>) -> <a href="./src/lithic/types/financial_accounts/statement.py">SyncCursorPage[Statement]</a></code>

### LineItems
Expand All @@ -302,7 +302,7 @@ from lithic.types.financial_accounts.statements import LineItemListResponse

Methods:

- <code title="get /financial_accounts/{financial_account_token}/statements/{statement_token}/line_items">client.financial_accounts.statements.line_items.<a href="./src/lithic/resources/financial_accounts/statements/line_items.py">list</a>(financial_account_token, statement_token, \*\*<a href="src/lithic/types/financial_accounts/statements/line_item_list_params.py">params</a>) -> <a href="./src/lithic/types/financial_accounts/statements/line_item_list_response.py">SyncCursorPage[LineItemListResponse]</a></code>
- <code title="get /financial_accounts/{financial_account_token}/statements/{statement_token}/line_items">client.financial_accounts.statements.line_items.<a href="./src/lithic/resources/financial_accounts/statements/line_items.py">list</a>(statement_token, \*, financial_account_token, \*\*<a href="src/lithic/types/financial_accounts/statements/line_item_list_params.py">params</a>) -> <a href="./src/lithic/types/financial_accounts/statements/line_item_list_response.py">SyncCursorPage[LineItemListResponse]</a></code>

# Transactions

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 = "lithic"
version = "0.22.1"
version = "0.22.2"
description = "Client library for the lithic API"
readme = "README.md"
license = "Apache-2.0"
Expand Down
15 changes: 6 additions & 9 deletions src/lithic/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,16 +313,13 @@ def construct_type(*, value: object, type_: type) -> object:
return [construct_type(value=entry, type_=inner_type) for entry in value]

if origin == float:
try:
return float(cast(Any, value))
except Exception:
return value
if isinstance(value, int):
coerced = float(value)
if coerced != value:
return value
return coerced

if origin == int:
try:
return int(cast(Any, value))
except Exception:
return value
return value

if type_ == datetime:
try:
Expand Down
5 changes: 4 additions & 1 deletion src/lithic/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ async def aclose(self) -> None:
# while adding support for `PathLike` instances
ProxiesDict = Dict["str | URL", Union[None, str, URL, Proxy]]
ProxiesTypes = Union[str, Proxy, ProxiesDict]
FileContent = Union[IO[bytes], bytes, PathLike[str]]
if TYPE_CHECKING:
FileContent = Union[IO[bytes], bytes, PathLike[str]]
else:
FileContent = Union[IO[bytes], bytes, PathLike] # PathLike is not subscriptable in Python 3.8.
FileTypes = Union[
# file (or bytes)
FileContent,
Expand Down
2 changes: 1 addition & 1 deletion src/lithic/_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__ = "lithic"
__version__ = "0.22.1" # x-release-please-version
__version__ = "0.22.2" # x-release-please-version
11 changes: 7 additions & 4 deletions src/lithic/types/account_holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,13 @@ class AccountHolder(BaseModel):
"""

control_person: Optional[ControlPerson] = None
"""Information about an individual associated with an account holder.

A subset of the information provided via KYC. For example, we do not return the
government id.
"""
Only present when user_type == "BUSINESS". An individual with significant
responsibility for managing the legal entity (e.g., a Chief Executive Officer,
Chief Financial Officer, Chief Operating Officer, Managing Member, General
Partner, President, Vice President, or Treasurer). This can be an executive, or
someone who will have program-wide access to the cards that Lithic will provide.
In some cases, this individual could also be a beneficial owner listed above.
"""

created: Optional[datetime] = None
Expand Down
29 changes: 20 additions & 9 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,21 +439,32 @@ class Model(BaseModel):
assert model_json(model) == expected_json


def test_coerces_int() -> None:
def test_does_not_coerce_int() -> None:
class Model(BaseModel):
bar: int

assert Model.construct(bar=1).bar == 1
assert Model.construct(bar=10.9).bar == 10
assert Model.construct(bar="19").bar == 19
assert Model.construct(bar=False).bar == 0
assert Model.construct(bar=10.9).bar == 10.9
assert Model.construct(bar="19").bar == "19" # type: ignore[comparison-overlap]
assert Model.construct(bar=False).bar is False

# TODO: support this
# assert Model.construct(bar="True").bar == 1

# mismatched types are left as-is
m = Model.construct(bar={"foo": "bar"})
assert m.bar == {"foo": "bar"} # type: ignore[comparison-overlap]
def test_int_to_float_safe_conversion() -> None:
class Model(BaseModel):
float_field: float

m = Model.construct(float_field=10)
assert m.float_field == 10.0
assert isinstance(m.float_field, float)

m = Model.construct(float_field=10.12)
assert m.float_field == 10.12
assert isinstance(m.float_field, float)

# number too big
m = Model.construct(float_field=2**53 + 1)
assert m.float_field == 2**53 + 1
assert isinstance(m.float_field, int)


def test_deprecated_alias() -> None:
Expand Down