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
21 changes: 0 additions & 21 deletions .github/workflows/open-release-prs.yml

This file was deleted.

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.12.3"
".": "0.12.4"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 141
configured_endpoints: 144
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# Changelog

## 0.12.4 (2023-09-11)

Full Changelog: [v0.12.3...v0.12.4](https://github.com/increase/increase-python/compare/v0.12.3...v0.12.4)

### Features

* **api:** add bank_of_first_deposit_routing_number and transfer_id properties ([#103](https://github.com/increase/increase-python/issues/103)) ([9409881](https://github.com/increase/increase-python/commit/9409881165df777f9ad62edb2765632c3d710f12))
* **api:** add Update Address and Create Notification Change endpoints ([#109](https://github.com/increase/increase-python/issues/109)) ([feea47b](https://github.com/increase/increase-python/commit/feea47b868d7aec4defe0877bb57de1b0540db83))
* fixes tests where an array has to have unique enum values ([#111](https://github.com/increase/increase-python/issues/111)) ([b80e33c](https://github.com/increase/increase-python/commit/b80e33c401127eaab5fd17385da21d3875577a66))


### Bug Fixes

* **client:** properly handle optional file params ([#110](https://github.com/increase/increase-python/issues/110)) ([f6ccd02](https://github.com/increase/increase-python/commit/f6ccd0252554f20f57ce68a92b055350907875ac))


### Chores

* **internal:** add `pydantic.generics` import for compatibility ([#105](https://github.com/increase/increase-python/issues/105)) ([1ab67a5](https://github.com/increase/increase-python/commit/1ab67a51b1710075bd940f69ebd6a844bb92d676))
* **internal:** minor formatting changes ([#108](https://github.com/increase/increase-python/issues/108)) ([210a1b1](https://github.com/increase/increase-python/commit/210a1b124e56dbc586600feff12ce4de4904e4d7))
* **internal:** minor update ([#113](https://github.com/increase/increase-python/issues/113)) ([7adf2f7](https://github.com/increase/increase-python/commit/7adf2f73f7f1fbc4c52463120ea2895e0ea809d2))
* **internal:** update base client ([#112](https://github.com/increase/increase-python/issues/112)) ([cf9ce31](https://github.com/increase/increase-python/commit/cf9ce31ad44747295ca2627b194ad0acac26a1a6))
* **internal:** update pyright ([#117](https://github.com/increase/increase-python/issues/117)) ([75f249e](https://github.com/increase/increase-python/commit/75f249e2a389b45a7b6e2d120344d0897525129a))
* **internal:** updates ([#116](https://github.com/increase/increase-python/issues/116)) ([e940de3](https://github.com/increase/increase-python/commit/e940de30aa7eedf5ff01c4e2df35258432b58b23))


### Documentation

* **api:** add docstrings and refine enum types ([#115](https://github.com/increase/increase-python/issues/115)) ([d44b0e2](https://github.com/increase/increase-python/commit/d44b0e211dbeecb349c7ac8b21d24bd66359db5c))
* **readme:** add link to api.md ([#114](https://github.com/increase/increase-python/issues/114)) ([e435324](https://github.com/increase/increase-python/commit/e43532404639f86c706d8adf0300ee4bdc49bd4b))
* **readme:** reference pydantic helpers ([#107](https://github.com/increase/increase-python/issues/107)) ([72ef120](https://github.com/increase/increase-python/commit/72ef120f8297770a71c2a87663cf5108316d0f9e))

## 0.12.3 (2023-08-29)

Full Changelog: [v0.12.2...v0.12.3](https://github.com/Increase/increase-python/compare/v0.12.2...v0.12.3)
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pip install increase

## Usage

The full API of this library can be found in [api.md](https://www.github.com/increase/increase-python/blob/main/api.md).

```python
from increase import Increase

Expand Down Expand Up @@ -66,9 +68,9 @@ Functionality between the synchronous and asynchronous clients is otherwise iden

## Using Types

Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict), while responses are [Pydantic](https://pydantic-docs.helpmanual.io/) models. This helps provide autocomplete and documentation within your editor.
Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev), which provide helper methods for things like serializing back into json ([v1](https://docs.pydantic.dev/1.10/usage/models/), [v2](https://docs.pydantic.dev/latest/usage/serialization/)). To get a dictionary, you can call `dict(model)`.

If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `"basic"`.
This helps provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `"basic"`.

## Pagination

Expand Down
3 changes: 3 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,13 +380,15 @@ Methods:
- <code title="get /entities/{entity_id}">client.entities.<a href="./src/increase/resources/entities/entities.py">retrieve</a>(entity_id) -> <a href="./src/increase/types/entity.py">Entity</a></code>
- <code title="get /entities">client.entities.<a href="./src/increase/resources/entities/entities.py">list</a>(\*\*<a href="src/increase/types/entity_list_params.py">params</a>) -> <a href="./src/increase/types/entity.py">SyncPage[Entity]</a></code>
- <code title="post /entities/{entity_id}/archive">client.entities.<a href="./src/increase/resources/entities/entities.py">archive</a>(entity_id) -> <a href="./src/increase/types/entity.py">Entity</a></code>
- <code title="post /entities/{entity_id}/address">client.entities.<a href="./src/increase/resources/entities/entities.py">update_address</a>(entity_id, \*\*<a href="src/increase/types/entity_update_address_params.py">params</a>) -> <a href="./src/increase/types/entity.py">Entity</a></code>

## BeneficialOwners

Methods:

- <code title="post /entity_beneficial_owners">client.entities.beneficial_owners.<a href="./src/increase/resources/entities/beneficial_owners.py">create</a>(\*\*<a href="src/increase/types/entities/beneficial_owner_create_params.py">params</a>) -> <a href="./src/increase/types/entity.py">Entity</a></code>
- <code title="post /entity_beneficial_owners/archive">client.entities.beneficial_owners.<a href="./src/increase/resources/entities/beneficial_owners.py">archive</a>(\*\*<a href="src/increase/types/entities/beneficial_owner_archive_params.py">params</a>) -> <a href="./src/increase/types/entity.py">Entity</a></code>
- <code title="post /entity_beneficial_owners/address">client.entities.beneficial_owners.<a href="./src/increase/resources/entities/beneficial_owners.py">update_address</a>(\*\*<a href="src/increase/types/entities/beneficial_owner_update_address_params.py">params</a>) -> <a href="./src/increase/types/entity.py">Entity</a></code>

## SupplementalDocuments

Expand Down Expand Up @@ -414,6 +416,7 @@ Methods:
- <code title="get /inbound_ach_transfers/{inbound_ach_transfer_id}">client.inbound_ach_transfers.<a href="./src/increase/resources/inbound_ach_transfers.py">retrieve</a>(inbound_ach_transfer_id) -> <a href="./src/increase/types/inbound_ach_transfer.py">InboundACHTransfer</a></code>
- <code title="get /inbound_ach_transfers">client.inbound_ach_transfers.<a href="./src/increase/resources/inbound_ach_transfers.py">list</a>(\*\*<a href="src/increase/types/inbound_ach_transfer_list_params.py">params</a>) -> <a href="./src/increase/types/inbound_ach_transfer.py">SyncPage[InboundACHTransfer]</a></code>
- <code title="post /inbound_ach_transfers/{inbound_ach_transfer_id}/decline">client.inbound_ach_transfers.<a href="./src/increase/resources/inbound_ach_transfers.py">decline</a>(inbound_ach_transfer_id) -> <a href="./src/increase/types/inbound_ach_transfer.py">InboundACHTransfer</a></code>
- <code title="post /inbound_ach_transfers/{inbound_ach_transfer_id}/notification_of_change">client.inbound_ach_transfers.<a href="./src/increase/resources/inbound_ach_transfers.py">notification_of_change</a>(inbound_ach_transfer_id, \*\*<a href="src/increase/types/inbound_ach_transfer_notification_of_change_params.py">params</a>) -> <a href="./src/increase/types/inbound_ach_transfer.py">InboundACHTransfer</a></code>
- <code title="post /inbound_ach_transfers/{inbound_ach_transfer_id}/transfer_return">client.inbound_ach_transfers.<a href="./src/increase/resources/inbound_ach_transfers.py">transfer_return</a>(inbound_ach_transfer_id, \*\*<a href="src/increase/types/inbound_ach_transfer_transfer_return_params.py">params</a>) -> <a href="./src/increase/types/inbound_ach_transfer.py">InboundACHTransfer</a></code>

# InboundWireDrawdownRequests
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "increase"
version = "0.12.3"
version = "0.12.4"
description = "Client library for the increase API"
readme = "README.md"
authors = ["Increase <dev-feedback@increase.com>"]
Expand All @@ -21,7 +21,7 @@ distro = ">= 1.7.0, < 2"


[tool.poetry.group.dev.dependencies]
pyright = "1.1.318"
pyright = "1.1.326"
mypy = "1.4.1"
black = "23.3.0"
respx = "0.19.2"
Expand All @@ -34,6 +34,7 @@ nox = "^2023.4.22"
nox-poetry = "^1.0.3"



[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Expand Down
20 changes: 17 additions & 3 deletions src/increase/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
overload,
)
from functools import lru_cache
from typing_extensions import Literal, get_origin
from typing_extensions import Literal, get_args, get_origin

import anyio
import httpx
Expand Down Expand Up @@ -458,6 +458,14 @@ def _serialize_multipartform(self, data: Mapping[object, object]) -> dict[str, o
serialized[key] = value
return serialized

def _extract_stream_chunk_type(self, stream_cls: type) -> type:
args = get_args(stream_cls)
if not args:
raise TypeError(
f"Expected stream_cls to have been given a generic type argument, e.g. Stream[Foo] but received {stream_cls}",
)
return cast(type, args[0])

def _process_response(
self,
*,
Expand Down Expand Up @@ -793,7 +801,10 @@ def _request(
raise APIConnectionError(request=request) from err

if stream:
stream_cls = stream_cls or cast("type[_StreamT] | None", self._default_stream_cls)
if stream_cls:
return stream_cls(cast_to=self._extract_stream_chunk_type(stream_cls), response=response, client=self)

stream_cls = cast("type[_StreamT] | None", self._default_stream_cls)
if stream_cls is None:
raise MissingStreamClassError()
return stream_cls(cast_to=cast_to, response=response, client=self)
Expand Down Expand Up @@ -1156,7 +1167,10 @@ async def _request(
raise APIConnectionError(request=request) from err

if stream:
stream_cls = stream_cls or cast("type[_AsyncStreamT] | None", self._default_stream_cls)
if stream_cls:
return stream_cls(cast_to=self._extract_stream_chunk_type(stream_cls), response=response, client=self)

stream_cls = cast("type[_AsyncStreamT] | None", self._default_stream_cls)
if stream_cls is None:
raise MissingStreamClassError()
return stream_cls(cast_to=cast_to, response=response, client=self)
Expand Down
13 changes: 10 additions & 3 deletions src/increase/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ def model_copy(model: _ModelT) -> _ModelT:
return model.copy() # type: ignore


def model_json(model: pydantic.BaseModel) -> str:
def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str:
if PYDANTIC_V2:
return model.model_dump_json()
return model.json() # type: ignore
return model.model_dump_json(indent=indent)
return model.json(indent=indent) # type: ignore


def model_dump(model: pydantic.BaseModel) -> dict[str, Any]:
Expand All @@ -132,6 +132,12 @@ def model_dump(model: pydantic.BaseModel) -> dict[str, Any]:
return cast("dict[str, Any]", model.dict()) # pyright: ignore[reportDeprecated, reportUnnecessaryCast]


def model_parse(model: type[_ModelT], data: Any) -> _ModelT:
if PYDANTIC_V2:
return model.model_validate(data)
return model.parse_obj(data) # pyright: ignore[reportDeprecated]


# generic models
if TYPE_CHECKING:

Expand All @@ -147,6 +153,7 @@ class GenericModel(pydantic.BaseModel):
...

else:
import pydantic.generics

class GenericModel(pydantic.generics.GenericModel, pydantic.BaseModel):
...
2 changes: 1 addition & 1 deletion src/increase/_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ def __init__(self, message: str, *, body: object, request: httpx.Request, respon
title = cast(Any, data.get("title"))
super().__init__(title or message, request=request, response=response, body=body)

self.title = title
self.detail = cast(Any, data.get("detail"))
self.errors = cast(Any, data.get("errors"))
self.status = cast(Any, data.get("status"))
self.title = cast(Any, data.get("title"))
self.type = cast(Any, data.get("type"))


Expand Down
2 changes: 1 addition & 1 deletion src/increase/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def validate_type(*, type_: type[_T], value: object) -> _T:
if inspect.isclass(type_) and issubclass(type_, pydantic.BaseModel):
return cast(_T, parse_obj(type_, value))

return _validate_non_model_type(type_=type_, value=value)
return cast(_T, _validate_non_model_type(type_=type_, value=value))


# our use of subclasssing here causes weirdness for type checkers,
Expand Down
8 changes: 8 additions & 0 deletions src/increase/_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import annotations

import time
import asyncio
from typing import TYPE_CHECKING

if TYPE_CHECKING:
Expand All @@ -20,6 +22,9 @@ def __init__(self, client: Increase) -> None:
self._delete = client.delete
self._get_api_list = client.get_api_list

def _sleep(self, seconds: float) -> None:
time.sleep(seconds)


class AsyncAPIResource:
_client: AsyncIncrease
Expand All @@ -32,3 +37,6 @@ def __init__(self, client: AsyncIncrease) -> None:
self._put = client.put
self._delete = client.delete
self._get_api_list = client.get_api_list

async def _sleep(self, seconds: float) -> None:
await asyncio.sleep(seconds)
3 changes: 2 additions & 1 deletion src/increase/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
_T = TypeVar("_T")

# Approximates httpx internal ProxiesTypes and RequestFiles types
ProxiesTypes = Union[str, Proxy, Dict[str, Union[None, str, Proxy]]]
ProxiesDict = Dict[str, Union[None, str, Proxy]]
ProxiesTypes = Union[str, Proxy, ProxiesDict]
FileContent = Union[IO[bytes], bytes]
FileTypes = Union[
# file (or bytes)
Expand Down
1 change: 1 addition & 0 deletions src/increase/_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from ._utils import flatten as flatten
from ._utils import is_dict as is_dict
from ._utils import is_list as is_list
from ._utils import is_given as is_given
from ._utils import is_mapping as is_mapping
from ._utils import parse_date as parse_date
from ._utils import coerce_float as coerce_float
Expand Down
11 changes: 9 additions & 2 deletions src/increase/_utils/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pathlib import Path
from typing_extensions import Required, Annotated, TypeGuard, get_args, get_origin

from .._types import NotGiven, FileTypes
from .._types import NotGiven, FileTypes, NotGivenOr
from .._compat import is_union as _is_union
from .._compat import parse_date as parse_date
from .._compat import parse_datetime as parse_datetime
Expand Down Expand Up @@ -38,12 +38,15 @@ def _extract_items(
path: Sequence[str],
*,
index: int,
# TODO: rename
flattened_key: str | None,
) -> list[tuple[str, FileTypes]]:
try:
key = path[index]
except IndexError:
if isinstance(obj, NotGiven):
# no value was provided - we can safely ignore
return []

# We have exhausted the path, return the entry we found.
if not isinstance(obj, bytes) and not isinstance(obj, tuple):
raise RuntimeError(
Expand Down Expand Up @@ -97,6 +100,10 @@ def _extract_items(
return []


def is_given(obj: NotGivenOr[_T]) -> TypeGuard[_T]:
return not isinstance(obj, NotGiven)


# Type safe methods for narrowing types with TypeVars.
# The default narrowing for isinstance(obj, dict) is dict[unknown, unknown],
# however this cause Pyright to rightfully report errors. As we know we don't
Expand Down
2 changes: 1 addition & 1 deletion src/increase/_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__ = "increase"
__version__ = "0.12.3" # x-release-please-version
__version__ = "0.12.4" # x-release-please-version
Loading