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
18 changes: 16 additions & 2 deletions src/increase/resources/exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class Exports(SyncAPIResource):
def create(
self,
*,
category: Literal["transaction_csv", "balance_csv"],
category: Literal["account_statement_ofx", "transaction_csv", "balance_csv"],
account_statement_ofx: export_create_params.AccountStatementOfx | NotGiven = NOT_GIVEN,
balance_csv: export_create_params.BalanceCsv | NotGiven = NOT_GIVEN,
transaction_csv: export_create_params.TransactionCsv | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand All @@ -35,10 +36,15 @@ def create(
Args:
category: The type of Export to create.

- `account_statement_ofx` - Export an Open Financial Exchange (OFX) file of
transactions and balances for a given time range and Account.
- `transaction_csv` - Export a CSV of all transactions for a given time range.
- `balance_csv` - Export a CSV of account balances for the dates in a given
range.

account_statement_ofx: Options for the created export. Required if `category` is equal to
`account_statement_ofx`.

balance_csv: Options for the created export. Required if `category` is equal to
`balance_csv`.

Expand All @@ -60,6 +66,7 @@ def create(
body=maybe_transform(
{
"category": category,
"account_statement_ofx": account_statement_ofx,
"balance_csv": balance_csv,
"transaction_csv": transaction_csv,
},
Expand Down Expand Up @@ -161,7 +168,8 @@ class AsyncExports(AsyncAPIResource):
async def create(
self,
*,
category: Literal["transaction_csv", "balance_csv"],
category: Literal["account_statement_ofx", "transaction_csv", "balance_csv"],
account_statement_ofx: export_create_params.AccountStatementOfx | NotGiven = NOT_GIVEN,
balance_csv: export_create_params.BalanceCsv | NotGiven = NOT_GIVEN,
transaction_csv: export_create_params.TransactionCsv | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand All @@ -178,10 +186,15 @@ async def create(
Args:
category: The type of Export to create.

- `account_statement_ofx` - Export an Open Financial Exchange (OFX) file of
transactions and balances for a given time range and Account.
- `transaction_csv` - Export a CSV of all transactions for a given time range.
- `balance_csv` - Export a CSV of account balances for the dates in a given
range.

account_statement_ofx: Options for the created export. Required if `category` is equal to
`account_statement_ofx`.

balance_csv: Options for the created export. Required if `category` is equal to
`balance_csv`.

Expand All @@ -203,6 +216,7 @@ async def create(
body=maybe_transform(
{
"category": category,
"account_statement_ofx": account_statement_ofx,
"balance_csv": balance_csv,
"transaction_csv": transaction_csv,
},
Expand Down
4 changes: 3 additions & 1 deletion src/increase/types/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ class Export(BaseModel):
id: str
"""The Export identifier."""

category: Literal["transaction_csv", "balance_csv"]
category: Literal["account_statement_ofx", "transaction_csv", "balance_csv"]
"""The category of the Export.

We may add additional possible values for this enum over time; your application
should be able to handle that gracefully.

- `account_statement_ofx` - Export an Open Financial Exchange (OFX) file of
transactions and balances for a given time range and Account.
- `transaction_csv` - Export a CSV of all transactions for a given time range.
- `balance_csv` - Export a CSV of account balances for the dates in a given
range.
Expand Down
54 changes: 52 additions & 2 deletions src/increase/types/export_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,34 @@

from .._utils import PropertyInfo

__all__ = ["ExportCreateParams", "BalanceCsv", "BalanceCsvCreatedAt", "TransactionCsv", "TransactionCsvCreatedAt"]
__all__ = [
"ExportCreateParams",
"AccountStatementOfx",
"AccountStatementOfxCreatedAt",
"BalanceCsv",
"BalanceCsvCreatedAt",
"TransactionCsv",
"TransactionCsvCreatedAt",
]


class ExportCreateParams(TypedDict, total=False):
category: Required[Literal["transaction_csv", "balance_csv"]]
category: Required[Literal["account_statement_ofx", "transaction_csv", "balance_csv"]]
"""The type of Export to create.

- `account_statement_ofx` - Export an Open Financial Exchange (OFX) file of
transactions and balances for a given time range and Account.
- `transaction_csv` - Export a CSV of all transactions for a given time range.
- `balance_csv` - Export a CSV of account balances for the dates in a given
range.
"""

account_statement_ofx: AccountStatementOfx
"""Options for the created export.

Required if `category` is equal to `account_statement_ofx`.
"""

balance_csv: BalanceCsv
"""Options for the created export.

Expand All @@ -33,6 +49,40 @@ class ExportCreateParams(TypedDict, total=False):
"""


class AccountStatementOfxCreatedAt(TypedDict, total=False):
after: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]
"""
Return results after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)
timestamp.
"""

before: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]
"""
Return results before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)
timestamp.
"""

on_or_after: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]
"""
Return results on or after this
[ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp.
"""

on_or_before: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]
"""
Return results on or before this
[ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp.
"""


class AccountStatementOfx(TypedDict, total=False):
account_id: Required[str]
"""The Account to create a statement for."""

created_at: AccountStatementOfxCreatedAt
"""Filter results by time range on the `created_at` attribute."""


class BalanceCsvCreatedAt(TypedDict, total=False):
after: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]
"""
Expand Down
26 changes: 22 additions & 4 deletions tests/api_resources/test_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,23 @@ class TestExports:
@parametrize
def test_method_create(self, client: Increase) -> None:
export = client.exports.create(
category="transaction_csv",
category="account_statement_ofx",
)
assert_matches_type(Export, export, path=["response"])

@parametrize
def test_method_create_with_all_params(self, client: Increase) -> None:
export = client.exports.create(
category="transaction_csv",
category="account_statement_ofx",
account_statement_ofx={
"account_id": "string",
"created_at": {
"after": parse_datetime("2019-12-27T18:11:19.117Z"),
"before": parse_datetime("2019-12-27T18:11:19.117Z"),
"on_or_after": parse_datetime("2019-12-27T18:11:19.117Z"),
"on_or_before": parse_datetime("2019-12-27T18:11:19.117Z"),
},
},
balance_csv={
"account_id": "string",
"created_at": {
Expand Down Expand Up @@ -82,14 +91,23 @@ class TestAsyncExports:
@parametrize
async def test_method_create(self, client: AsyncIncrease) -> None:
export = await client.exports.create(
category="transaction_csv",
category="account_statement_ofx",
)
assert_matches_type(Export, export, path=["response"])

@parametrize
async def test_method_create_with_all_params(self, client: AsyncIncrease) -> None:
export = await client.exports.create(
category="transaction_csv",
category="account_statement_ofx",
account_statement_ofx={
"account_id": "string",
"created_at": {
"after": parse_datetime("2019-12-27T18:11:19.117Z"),
"before": parse_datetime("2019-12-27T18:11:19.117Z"),
"on_or_after": parse_datetime("2019-12-27T18:11:19.117Z"),
"on_or_before": parse_datetime("2019-12-27T18:11:19.117Z"),
},
},
balance_csv={
"account_id": "string",
"created_at": {
Expand Down