Skip to content

Commit b57ee38

Browse files
feat(api): add route method to transactions
1 parent 10673c1 commit b57ee38

6 files changed

Lines changed: 197 additions & 4 deletions

File tree

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 212
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic/lithic-6200f208b7ffdb9b4c7dd8468dbfe69f0078f8b8b0fd171ba2edc1c2a641f185.yml
3-
openapi_spec_hash: 2c396033aca49407378b3982e46d19e6
4-
config_hash: 126e04f676f61e5871a82889336dbf9d
1+
configured_endpoints: 213
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic/lithic-a4afc884f86f30a87445552888031ac1ca18aed0476d7120da555bf457627e65.yml
3+
openapi_spec_hash: ce8d0830986c702f0c7a693b1c3cc5a2
4+
config_hash: 4b618a1df59e555cebe6aa13e8c0218f

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ Methods:
588588
- <code title="get /v1/transactions/{transaction_token}">client.transactions.<a href="./src/lithic/resources/transactions/transactions.py">retrieve</a>(transaction_token) -> <a href="./src/lithic/types/transaction.py">Transaction</a></code>
589589
- <code title="get /v1/transactions">client.transactions.<a href="./src/lithic/resources/transactions/transactions.py">list</a>(\*\*<a href="src/lithic/types/transaction_list_params.py">params</a>) -> <a href="./src/lithic/types/transaction.py">SyncCursorPage[Transaction]</a></code>
590590
- <code title="post /v1/transactions/{transaction_token}/expire_authorization">client.transactions.<a href="./src/lithic/resources/transactions/transactions.py">expire_authorization</a>(transaction_token) -> None</code>
591+
- <code title="post /v1/transactions/{transaction_token}/route">client.transactions.<a href="./src/lithic/resources/transactions/transactions.py">route</a>(transaction_token, \*\*<a href="src/lithic/types/transaction_route_params.py">params</a>) -> None</code>
591592
- <code title="post /v1/simulate/authorize">client.transactions.<a href="./src/lithic/resources/transactions/transactions.py">simulate_authorization</a>(\*\*<a href="src/lithic/types/transaction_simulate_authorization_params.py">params</a>) -> <a href="./src/lithic/types/transaction_simulate_authorization_response.py">TransactionSimulateAuthorizationResponse</a></code>
592593
- <code title="post /v1/simulate/authorization_advice">client.transactions.<a href="./src/lithic/resources/transactions/transactions.py">simulate_authorization_advice</a>(\*\*<a href="src/lithic/types/transaction_simulate_authorization_advice_params.py">params</a>) -> <a href="./src/lithic/types/transaction_simulate_authorization_advice_response.py">TransactionSimulateAuthorizationAdviceResponse</a></code>
593594
- <code title="post /v1/simulate/clearing">client.transactions.<a href="./src/lithic/resources/transactions/transactions.py">simulate_clearing</a>(\*\*<a href="src/lithic/types/transaction_simulate_clearing_params.py">params</a>) -> <a href="./src/lithic/types/transaction_simulate_clearing_response.py">TransactionSimulateClearingResponse</a></code>

src/lithic/resources/transactions/transactions.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from ... import _legacy_response
1313
from ...types import (
1414
transaction_list_params,
15+
transaction_route_params,
1516
transaction_simulate_void_params,
1617
transaction_simulate_return_params,
1718
transaction_simulate_clearing_params,
@@ -239,6 +240,47 @@ def expire_authorization(
239240
cast_to=NoneType,
240241
)
241242

243+
def route(
244+
self,
245+
transaction_token: str,
246+
*,
247+
financial_account_token: str,
248+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
249+
# The extra values given here take precedence over values defined on the client or passed to this method.
250+
extra_headers: Headers | None = None,
251+
extra_query: Query | None = None,
252+
extra_body: Body | None = None,
253+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
254+
) -> None:
255+
"""Route a card transaction to a financial account.
256+
257+
Only available for select use
258+
cases and programs.
259+
260+
Args:
261+
financial_account_token: The token of the financial account to route the transaction to.
262+
263+
extra_headers: Send extra headers
264+
265+
extra_query: Add additional query parameters to the request
266+
267+
extra_body: Add additional JSON properties to the request
268+
269+
timeout: Override the client-level default timeout for this request, in seconds
270+
"""
271+
if not transaction_token:
272+
raise ValueError(f"Expected a non-empty value for `transaction_token` but received {transaction_token!r}")
273+
return self._post(
274+
path_template("/v1/transactions/{transaction_token}/route", transaction_token=transaction_token),
275+
body=maybe_transform(
276+
{"financial_account_token": financial_account_token}, transaction_route_params.TransactionRouteParams
277+
),
278+
options=make_request_options(
279+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
280+
),
281+
cast_to=NoneType,
282+
)
283+
242284
def simulate_authorization(
243285
self,
244286
*,
@@ -942,6 +984,47 @@ async def expire_authorization(
942984
cast_to=NoneType,
943985
)
944986

987+
async def route(
988+
self,
989+
transaction_token: str,
990+
*,
991+
financial_account_token: str,
992+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
993+
# The extra values given here take precedence over values defined on the client or passed to this method.
994+
extra_headers: Headers | None = None,
995+
extra_query: Query | None = None,
996+
extra_body: Body | None = None,
997+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
998+
) -> None:
999+
"""Route a card transaction to a financial account.
1000+
1001+
Only available for select use
1002+
cases and programs.
1003+
1004+
Args:
1005+
financial_account_token: The token of the financial account to route the transaction to.
1006+
1007+
extra_headers: Send extra headers
1008+
1009+
extra_query: Add additional query parameters to the request
1010+
1011+
extra_body: Add additional JSON properties to the request
1012+
1013+
timeout: Override the client-level default timeout for this request, in seconds
1014+
"""
1015+
if not transaction_token:
1016+
raise ValueError(f"Expected a non-empty value for `transaction_token` but received {transaction_token!r}")
1017+
return await self._post(
1018+
path_template("/v1/transactions/{transaction_token}/route", transaction_token=transaction_token),
1019+
body=await async_maybe_transform(
1020+
{"financial_account_token": financial_account_token}, transaction_route_params.TransactionRouteParams
1021+
),
1022+
options=make_request_options(
1023+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1024+
),
1025+
cast_to=NoneType,
1026+
)
1027+
9451028
async def simulate_authorization(
9461029
self,
9471030
*,
@@ -1478,6 +1561,9 @@ def __init__(self, transactions: Transactions) -> None:
14781561
self.expire_authorization = _legacy_response.to_raw_response_wrapper(
14791562
transactions.expire_authorization,
14801563
)
1564+
self.route = _legacy_response.to_raw_response_wrapper(
1565+
transactions.route,
1566+
)
14811567
self.simulate_authorization = _legacy_response.to_raw_response_wrapper(
14821568
transactions.simulate_authorization,
14831569
)
@@ -1527,6 +1613,9 @@ def __init__(self, transactions: AsyncTransactions) -> None:
15271613
self.expire_authorization = _legacy_response.async_to_raw_response_wrapper(
15281614
transactions.expire_authorization,
15291615
)
1616+
self.route = _legacy_response.async_to_raw_response_wrapper(
1617+
transactions.route,
1618+
)
15301619
self.simulate_authorization = _legacy_response.async_to_raw_response_wrapper(
15311620
transactions.simulate_authorization,
15321621
)
@@ -1576,6 +1665,9 @@ def __init__(self, transactions: Transactions) -> None:
15761665
self.expire_authorization = to_streamed_response_wrapper(
15771666
transactions.expire_authorization,
15781667
)
1668+
self.route = to_streamed_response_wrapper(
1669+
transactions.route,
1670+
)
15791671
self.simulate_authorization = to_streamed_response_wrapper(
15801672
transactions.simulate_authorization,
15811673
)
@@ -1625,6 +1717,9 @@ def __init__(self, transactions: AsyncTransactions) -> None:
16251717
self.expire_authorization = async_to_streamed_response_wrapper(
16261718
transactions.expire_authorization,
16271719
)
1720+
self.route = async_to_streamed_response_wrapper(
1721+
transactions.route,
1722+
)
16281723
self.simulate_authorization = async_to_streamed_response_wrapper(
16291724
transactions.simulate_authorization,
16301725
)

src/lithic/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
from .card_program_list_params import CardProgramListParams as CardProgramListParams
103103
from .tokenization_list_params import TokenizationListParams as TokenizationListParams
104104
from .tokenization_rule_result import TokenizationRuleResult as TokenizationRuleResult
105+
from .transaction_route_params import TransactionRouteParams as TransactionRouteParams
105106
from .transfer_limits_response import TransferLimitsResponse as TransferLimitsResponse
106107
from .book_transfer_list_params import BookTransferListParams as BookTransferListParams
107108
from .card_get_embed_url_params import CardGetEmbedURLParams as CardGetEmbedURLParams
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing_extensions import Required, TypedDict
6+
7+
__all__ = ["TransactionRouteParams"]
8+
9+
10+
class TransactionRouteParams(TypedDict, total=False):
11+
financial_account_token: Required[str]
12+
"""The token of the financial account to route the transaction to."""

tests/api_resources/test_transactions.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,48 @@ def test_path_params_expire_authorization(self, client: Lithic) -> None:
147147
"",
148148
)
149149

150+
@parametrize
151+
def test_method_route(self, client: Lithic) -> None:
152+
transaction = client.transactions.route(
153+
transaction_token="00000000-0000-0000-0000-000000000000",
154+
financial_account_token="00000000-0000-0000-0000-000000000000",
155+
)
156+
assert transaction is None
157+
158+
@parametrize
159+
def test_raw_response_route(self, client: Lithic) -> None:
160+
response = client.transactions.with_raw_response.route(
161+
transaction_token="00000000-0000-0000-0000-000000000000",
162+
financial_account_token="00000000-0000-0000-0000-000000000000",
163+
)
164+
165+
assert response.is_closed is True
166+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
167+
transaction = response.parse()
168+
assert transaction is None
169+
170+
@parametrize
171+
def test_streaming_response_route(self, client: Lithic) -> None:
172+
with client.transactions.with_streaming_response.route(
173+
transaction_token="00000000-0000-0000-0000-000000000000",
174+
financial_account_token="00000000-0000-0000-0000-000000000000",
175+
) as response:
176+
assert not response.is_closed
177+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
178+
179+
transaction = response.parse()
180+
assert transaction is None
181+
182+
assert cast(Any, response.is_closed) is True
183+
184+
@parametrize
185+
def test_path_params_route(self, client: Lithic) -> None:
186+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `transaction_token` but received ''"):
187+
client.transactions.with_raw_response.route(
188+
transaction_token="",
189+
financial_account_token="00000000-0000-0000-0000-000000000000",
190+
)
191+
150192
@parametrize
151193
def test_method_simulate_authorization(self, client: Lithic) -> None:
152194
transaction = client.transactions.simulate_authorization(
@@ -614,6 +656,48 @@ async def test_path_params_expire_authorization(self, async_client: AsyncLithic)
614656
"",
615657
)
616658

659+
@parametrize
660+
async def test_method_route(self, async_client: AsyncLithic) -> None:
661+
transaction = await async_client.transactions.route(
662+
transaction_token="00000000-0000-0000-0000-000000000000",
663+
financial_account_token="00000000-0000-0000-0000-000000000000",
664+
)
665+
assert transaction is None
666+
667+
@parametrize
668+
async def test_raw_response_route(self, async_client: AsyncLithic) -> None:
669+
response = await async_client.transactions.with_raw_response.route(
670+
transaction_token="00000000-0000-0000-0000-000000000000",
671+
financial_account_token="00000000-0000-0000-0000-000000000000",
672+
)
673+
674+
assert response.is_closed is True
675+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
676+
transaction = response.parse()
677+
assert transaction is None
678+
679+
@parametrize
680+
async def test_streaming_response_route(self, async_client: AsyncLithic) -> None:
681+
async with async_client.transactions.with_streaming_response.route(
682+
transaction_token="00000000-0000-0000-0000-000000000000",
683+
financial_account_token="00000000-0000-0000-0000-000000000000",
684+
) as response:
685+
assert not response.is_closed
686+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
687+
688+
transaction = await response.parse()
689+
assert transaction is None
690+
691+
assert cast(Any, response.is_closed) is True
692+
693+
@parametrize
694+
async def test_path_params_route(self, async_client: AsyncLithic) -> None:
695+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `transaction_token` but received ''"):
696+
await async_client.transactions.with_raw_response.route(
697+
transaction_token="",
698+
financial_account_token="00000000-0000-0000-0000-000000000000",
699+
)
700+
617701
@parametrize
618702
async def test_method_simulate_authorization(self, async_client: AsyncLithic) -> None:
619703
transaction = await async_client.transactions.simulate_authorization(

0 commit comments

Comments
 (0)