Skip to content

release: 0.7.0 #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Nov 15, 2023
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
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": ".venv/bin/python",
"python.defaultInterpreterPath": ".venv/bin/python",
"python.typeChecking": "basic",
"terminal.integrated.env.linux": {
"PATH": "/home/vscode/.rye/shims:${env:PATH}"
Expand Down
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.6.0"
".": "0.7.0"
}
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# Changelog

## 0.7.0 (2023-11-15)

Full Changelog: [v0.6.0...v0.7.0](https://github.com/Finch-API/finch-api-python/compare/v0.6.0...v0.7.0)

### Features

* **api:** updates ([#184](https://github.com/Finch-API/finch-api-python/issues/184)) ([1fbf21e](https://github.com/Finch-API/finch-api-python/commit/1fbf21e96dc700db462b619da54897ce156301a9))
* **client:** support passing chunk size for binary responses ([#175](https://github.com/Finch-API/finch-api-python/issues/175)) ([3d02d4b](https://github.com/Finch-API/finch-api-python/commit/3d02d4ba528ad199981a185def69bb80d939d445))
* **client:** support reading the base url from an env variable ([#186](https://github.com/Finch-API/finch-api-python/issues/186)) ([bb2dc38](https://github.com/Finch-API/finch-api-python/commit/bb2dc38e25da74fcbcdc2a34b4706ec304e9657f))


### Bug Fixes

* **client:** retry if SSLWantReadError occurs in the async client ([#181](https://github.com/Finch-API/finch-api-python/issues/181)) ([b2a7d2c](https://github.com/Finch-API/finch-api-python/commit/b2a7d2c0a617f358a12e7556fc53b740880892a4))
* **client:** serialise pydantic v1 default fields correctly in params ([#180](https://github.com/Finch-API/finch-api-python/issues/180)) ([cb69944](https://github.com/Finch-API/finch-api-python/commit/cb6994491d3c2bf4112443018bc7d2d6d2b78fd4))
* **models:** mark unknown fields as set in pydantic v1 ([#179](https://github.com/Finch-API/finch-api-python/issues/179)) ([c8261c9](https://github.com/Finch-API/finch-api-python/commit/c8261c9fb39b0a275dde59a78c67feb15d84c0f9))


### Chores

* **internal:** base client updates ([#178](https://github.com/Finch-API/finch-api-python/issues/178)) ([d06251d](https://github.com/Finch-API/finch-api-python/commit/d06251dfdb660fc7843b55c533f5b59906197160))
* **internal:** fix devcontainer interpeter path ([#183](https://github.com/Finch-API/finch-api-python/issues/183)) ([ca48726](https://github.com/Finch-API/finch-api-python/commit/ca487263a47beab1f4dce8c052e734358d6893ef))
* **internal:** fix typo in NotGiven docstring ([#182](https://github.com/Finch-API/finch-api-python/issues/182)) ([ca198e9](https://github.com/Finch-API/finch-api-python/commit/ca198e9a817cf76eadd912909a4581ef1ad2fd29))


### Documentation

* fix code comment typo ([#185](https://github.com/Finch-API/finch-api-python/issues/185)) ([09df068](https://github.com/Finch-API/finch-api-python/commit/09df068fad1545affb78bb5a982eb4ba4c9ed080))
* reword package description ([#177](https://github.com/Finch-API/finch-api-python/issues/177)) ([ee5340a](https://github.com/Finch-API/finch-api-python/commit/ee5340ae2a36d26e2c9e12add86e8ba0a1603d2e))

## 0.6.0 (2023-11-08)

Full Changelog: [v0.5.0...v0.6.0](https://github.com/Finch-API/finch-api-python/compare/v0.5.0...v0.6.0)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ import httpx
from finch import Finch

client = Finch(
# Or use the `FINCH_BASE_URL` env var
base_url="http://my.test.server.example.com:8083",
http_client=httpx.Client(
proxies="http://my.test.proxy.example.com",
Expand Down
9 changes: 9 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Shared Types

```python
from finch.types import OperationSupport, OperationSupportMatrix
```

# Finch

Methods:
Expand Down Expand Up @@ -96,11 +102,14 @@ Types:
```python
from finch.types.hris import (
BenefitContribution,
BenefitFeaturesAndOperations,
BenefitFrequency,
BenefitType,
BenefitsSupport,
BenfitContribution,
CompanyBenefit,
CreateCompanyBenefitsResponse,
SupportPerBenefitType,
SupportedBenefit,
UpdateCompanyBenefitResponse,
)
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "finch-api"
version = "0.6.0"
description = "Client library for the Finch API"
version = "0.7.0"
description = "The official Python library for the Finch API"
readme = "README.md"
license = "Apache-2.0"
authors = [
Expand Down
24 changes: 14 additions & 10 deletions src/finch/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1320,12 +1320,6 @@ async def _request(
if retries > 0:
return await self._retry_request(options, cast_to, retries, stream=stream, stream_cls=stream_cls)
raise APITimeoutError(request=request) from err
except httpx.ReadTimeout as err:
# We explicitly do not retry on ReadTimeout errors as this means
# that the server processing the request has taken 60 seconds
# (our default timeout). This likely indicates that something
# is not working as expected on the server side.
raise
except httpx.TimeoutException as err:
if retries > 0:
return await self._retry_request(options, cast_to, retries, stream=stream, stream_cls=stream_cls)
Expand Down Expand Up @@ -1727,9 +1721,14 @@ def iter_raw(self, chunk_size: Optional[int] = None) -> Iterator[bytes]:
return self.response.iter_raw(chunk_size)

@override
def stream_to_file(self, file: str | os.PathLike[str]) -> None:
def stream_to_file(
self,
file: str | os.PathLike[str],
*,
chunk_size: int | None = None,
) -> None:
with open(file, mode="wb") as f:
for data in self.response.iter_bytes():
for data in self.response.iter_bytes(chunk_size):
f.write(data)

@override
Expand Down Expand Up @@ -1757,10 +1756,15 @@ async def aiter_raw(self, chunk_size: Optional[int] = None) -> AsyncIterator[byt
return self.response.aiter_raw(chunk_size)

@override
async def astream_to_file(self, file: str | os.PathLike[str]) -> None:
async def astream_to_file(
self,
file: str | os.PathLike[str],
*,
chunk_size: int | None = None,
) -> None:
path = anyio.Path(file)
async with await path.open(mode="wb") as f:
async for data in self.response.aiter_bytes():
async for data in self.response.aiter_bytes(chunk_size):
await f.write(data)

@override
Expand Down
4 changes: 4 additions & 0 deletions src/finch/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ def __init__(
webhook_secret = os.environ.get("FINCH_WEBHOOK_SECRET")
self.webhook_secret = webhook_secret

if base_url is None:
base_url = os.environ.get("FINCH_BASE_URL")
if base_url is None:
base_url = f"https://api.tryfinch.com"

Expand Down Expand Up @@ -414,6 +416,8 @@ def __init__(
webhook_secret = os.environ.get("FINCH_WEBHOOK_SECRET")
self.webhook_secret = webhook_secret

if base_url is None:
base_url = os.environ.get("FINCH_BASE_URL")
if base_url is None:
base_url = f"https://api.tryfinch.com"

Expand Down
3 changes: 2 additions & 1 deletion src/finch/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def construct(
if PYDANTIC_V2:
_extra[key] = value
else:
_fields_set.add(key)
fields_values[key] = value

object.__setattr__(m, "__dict__", fields_values)
Expand Down Expand Up @@ -148,7 +149,7 @@ def construct(
if not PYDANTIC_V2:
# we define aliases for some of the new pydantic v2 methods so
# that we can just document these methods without having to specify
# a specifc pydantic version as some users may not know which
# a specific pydantic version as some users may not know which
# pydantic version they are currently using

@override
Expand Down
14 changes: 12 additions & 2 deletions src/finch/_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ def __stream__(self) -> Iterator[ResponseT]:
cast_to = self._cast_to
response = self.response
process_data = self._client._process_response_data
iterator = self._iter_events()

for sse in self._iter_events():
for sse in iterator:
yield process_data(data=sse.json(), cast_to=cast_to, response=response)

# Ensure the entire stream is consumed
for sse in iterator:
...


class AsyncStream(Generic[ResponseT]):
"""Provides the core interface to iterate over an asynchronous stream response."""
Expand Down Expand Up @@ -83,10 +88,15 @@ async def __stream__(self) -> AsyncIterator[ResponseT]:
cast_to = self._cast_to
response = self.response
process_data = self._client._process_response_data
iterator = self._iter_events()

async for sse in self._iter_events():
async for sse in iterator:
yield process_data(data=sse.json(), cast_to=cast_to, response=response)

# Ensure the entire stream is consumed
async for sse in iterator:
...


class ServerSentEvent:
def __init__(
Expand Down
19 changes: 15 additions & 4 deletions src/finch/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,12 @@ def iter_raw(self, chunk_size: Optional[int] = None) -> Iterator[bytes]:
pass

@abstractmethod
def stream_to_file(self, file: str | PathLike[str]) -> None:
def stream_to_file(
self,
file: str | PathLike[str],
*,
chunk_size: int | None = None,
) -> None:
"""
Stream the output to the given file.
"""
Expand Down Expand Up @@ -172,7 +177,13 @@ async def aiter_raw(self, chunk_size: Optional[int] = None) -> AsyncIterator[byt
"""
pass

async def astream_to_file(self, file: str | PathLike[str]) -> None:
@abstractmethod
async def astream_to_file(
self,
file: str | PathLike[str],
*,
chunk_size: int | None = None,
) -> None:
"""
Stream the output to the given file.
"""
Expand Down Expand Up @@ -268,8 +279,8 @@ class NotGiven:
```py
def get(timeout: Union[int, NotGiven, None] = NotGiven()) -> Response: ...

get(timout=1) # 1s timeout
get(timout=None) # No timeout
get(timeout=1) # 1s timeout
get(timeout=None) # No timeout
get() # Default timeout behavior, which may not be statically known at the method definition.
```
"""
Expand Down
2 changes: 1 addition & 1 deletion src/finch/_utils/_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def _transform_recursive(
return data

if isinstance(data, pydantic.BaseModel):
return model_dump(data, exclude_unset=True, exclude_defaults=True)
return model_dump(data, exclude_unset=True)

return _transform_value(data, annotation)

Expand Down
2 changes: 1 addition & 1 deletion src/finch/_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__ = "finch"
__version__ = "0.6.0" # x-release-please-version
__version__ = "0.7.0" # x-release-please-version
24 changes: 16 additions & 8 deletions src/finch/resources/request_forwarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ def forward(
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> RequestForwardingForwardResponse:
"""
The Forward API allows you to make direct requests to an employment system.
"""The Forward API allows you to make direct requests to an employment system.

If
Finch’s unified API doesn’t have a data model that cleanly fits your needs, then
Forward allows you to push or pull data models directly against an integration’s
API.

Args:
method: The HTTP method for the forwarded request. Valid values include: `GET`, `POST`,
`PUT`, `DELETE`, and `PATCH`.
method: The HTTP method for the forwarded request. Valid values include: `GET` , `POST`
, `PUT` , `DELETE` , and `PATCH`.

route: The URL route path for the forwarded request. This value must begin with a
forward-slash ( / ) and may only contain alphanumeric characters, hyphens, and
Expand Down Expand Up @@ -111,12 +115,16 @@ async def forward(
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> RequestForwardingForwardResponse:
"""
The Forward API allows you to make direct requests to an employment system.
"""The Forward API allows you to make direct requests to an employment system.

If
Finch’s unified API doesn’t have a data model that cleanly fits your needs, then
Forward allows you to push or pull data models directly against an integration’s
API.

Args:
method: The HTTP method for the forwarded request. Valid values include: `GET`, `POST`,
`PUT`, `DELETE`, and `PATCH`.
method: The HTTP method for the forwarded request. Valid values include: `GET` , `POST`
, `PUT` , `DELETE` , and `PATCH`.

route: The URL route path for the forwarded request. This value must begin with a
forward-slash ( / ) and may only contain alphanumeric characters, hyphens, and
Expand Down
2 changes: 2 additions & 0 deletions src/finch/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from .money import Money as Money
from .income import Income as Income
from .paging import Paging as Paging
from .shared import OperationSupport as OperationSupport
from .shared import OperationSupportMatrix as OperationSupportMatrix
from .location import Location as Location
from .provider import Provider as Provider
from .introspection import Introspection as Introspection
Expand Down
5 changes: 5 additions & 0 deletions src/finch/types/hris/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .pay_statement import PayStatement as PayStatement
from .company_benefit import CompanyBenefit as CompanyBenefit
from .employment_data import EmploymentData as EmploymentData
from .benefits_support import BenefitsSupport as BenefitsSupport
from .benefit_frequency import BenefitFrequency as BenefitFrequency
from .supported_benefit import SupportedBenefit as SupportedBenefit
from .benfit_contribution import BenfitContribution as BenfitContribution
Expand All @@ -21,9 +22,13 @@
from .pay_statement_response import PayStatementResponse as PayStatementResponse
from .individual_in_directory import IndividualInDirectory as IndividualInDirectory
from .employment_data_response import EmploymentDataResponse as EmploymentDataResponse
from .support_per_benefit_type import SupportPerBenefitType as SupportPerBenefitType
from .pay_statement_response_body import (
PayStatementResponseBody as PayStatementResponseBody,
)
from .benefit_features_and_operations import (
BenefitFeaturesAndOperations as BenefitFeaturesAndOperations,
)
from .employment_retrieve_many_params import (
EmploymentRetrieveManyParams as EmploymentRetrieveManyParams,
)
Expand Down
51 changes: 51 additions & 0 deletions src/finch/types/hris/benefit_features_and_operations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# File generated from our OpenAPI spec by Stainless.

from typing import List, Optional
from typing_extensions import Literal

from ..._models import BaseModel
from .benefit_frequency import BenefitFrequency
from .support_per_benefit_type import SupportPerBenefitType

__all__ = ["BenefitFeaturesAndOperations", "SupportedFeatures"]


class SupportedFeatures(BaseModel):
annual_maximum: Optional[bool] = None
"""Whether the provider supports an annual maximum for this benefit."""

catch_up: Optional[bool] = None
"""Whether the provider supports catch up for this benefit.

This field will only be true for retirement benefits.
"""

company_contribution: Optional[List[Literal["fixed", "percent"]]] = None
"""Supported contribution types.

An empty array indicates contributions are not supported.
"""

description: Optional[str] = None

employee_deduction: Optional[List[Literal["fixed", "percent"]]] = None
"""Supported deduction types.

An empty array indicates deductions are not supported.
"""

frequencies: Optional[List[Optional[BenefitFrequency]]] = None
"""The list of frequencies supported by the provider for this benefit"""

hsa_contribution_limit: Optional[List[Literal["individual", "family"]]] = None
"""Whether the provider supports HSA contribution limits.

Empty if this feature is not supported for the benefit. This array only has
values for HSA benefits.
"""


class BenefitFeaturesAndOperations(BaseModel):
supported_features: Optional[SupportedFeatures] = None

supported_operations: Optional[SupportPerBenefitType] = None
2 changes: 1 addition & 1 deletion src/finch/types/hris/benefit_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

__all__ = ["BenefitFrequency"]

BenefitFrequency = Optional[Literal["one_time", "every_paycheck"]]
BenefitFrequency = Optional[Literal["one_time", "every_paycheck", "monthly"]]
Loading