Skip to content

Commit d11a496

Browse files
feat(api): add route method to transactions
1 parent 133cace commit d11a496

10 files changed

Lines changed: 111 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: 213
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: 214
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
@@ -537,6 +537,7 @@ Methods:
537537
- <code title="get /v1/transactions/{transaction_token}">client.transactions.<a href="./src/resources/transactions/transactions.ts">retrieve</a>(transactionToken) -> Transaction</code>
538538
- <code title="get /v1/transactions">client.transactions.<a href="./src/resources/transactions/transactions.ts">list</a>({ ...params }) -> TransactionsCursorPage</code>
539539
- <code title="post /v1/transactions/{transaction_token}/expire_authorization">client.transactions.<a href="./src/resources/transactions/transactions.ts">expireAuthorization</a>(transactionToken) -> void</code>
540+
- <code title="post /v1/transactions/{transaction_token}/route">client.transactions.<a href="./src/resources/transactions/transactions.ts">route</a>(transactionToken, { ...params }) -> void</code>
540541
- <code title="post /v1/simulate/authorize">client.transactions.<a href="./src/resources/transactions/transactions.ts">simulateAuthorization</a>({ ...params }) -> TransactionSimulateAuthorizationResponse</code>
541542
- <code title="post /v1/simulate/authorization_advice">client.transactions.<a href="./src/resources/transactions/transactions.ts">simulateAuthorizationAdvice</a>({ ...params }) -> TransactionSimulateAuthorizationAdviceResponse</code>
542543
- <code title="post /v1/simulate/clearing">client.transactions.<a href="./src/resources/transactions/transactions.ts">simulateClearing</a>({ ...params }) -> TransactionSimulateClearingResponse</code>

packages/mcp-server/src/code-tool-worker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ const fuse = new Fuse(
243243
'client.transactions.expireAuthorization',
244244
'client.transactions.list',
245245
'client.transactions.retrieve',
246+
'client.transactions.route',
246247
'client.transactions.simulateAuthorization',
247248
'client.transactions.simulateAuthorizationAdvice',
248249
'client.transactions.simulateClearing',

packages/mcp-server/src/local-docs-search.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7593,6 +7593,55 @@ const EMBEDDED_METHODS: MethodEntry[] = [
75937593
},
75947594
},
75957595
},
7596+
{
7597+
name: 'route',
7598+
endpoint: '/v1/transactions/{transaction_token}/route',
7599+
httpMethod: 'post',
7600+
summary: 'Route a transaction',
7601+
description:
7602+
'Route a card transaction to a financial account. Only available for select use cases and programs.',
7603+
stainlessPath: '(resource) transactions > (method) route',
7604+
qualified: 'client.transactions.route',
7605+
params: ['transaction_token: string;', 'financial_account_token: string;'],
7606+
markdown:
7607+
"## route\n\n`client.transactions.route(transaction_token: string, financial_account_token: string): void`\n\n**post** `/v1/transactions/{transaction_token}/route`\n\nRoute a card transaction to a financial account. Only available for select use cases and programs.\n\n### Parameters\n\n- `transaction_token: string`\n\n- `financial_account_token: string`\n The token of the financial account to route the transaction to.\n\n### Example\n\n```typescript\nimport Lithic from 'lithic';\n\nconst client = new Lithic();\n\nawait client.transactions.route('00000000-0000-0000-0000-000000000000', { financial_account_token: '00000000-0000-0000-0000-000000000000' })\n```",
7608+
perLanguage: {
7609+
typescript: {
7610+
method: 'client.transactions.route',
7611+
example:
7612+
"import Lithic from 'lithic';\n\nconst client = new Lithic({\n apiKey: process.env['LITHIC_API_KEY'], // This is the default and can be omitted\n});\n\nawait client.transactions.route('00000000-0000-0000-0000-000000000000', {\n financial_account_token: '00000000-0000-0000-0000-000000000000',\n});",
7613+
},
7614+
python: {
7615+
method: 'transactions.route',
7616+
example:
7617+
'import os\nfrom lithic import Lithic\n\nclient = Lithic(\n api_key=os.environ.get("LITHIC_API_KEY"), # This is the default and can be omitted\n)\nclient.transactions.route(\n transaction_token="00000000-0000-0000-0000-000000000000",\n financial_account_token="00000000-0000-0000-0000-000000000000",\n)',
7618+
},
7619+
java: {
7620+
method: 'transactions().route',
7621+
example:
7622+
'package com.lithic.api.example;\n\nimport com.lithic.api.client.LithicClient;\nimport com.lithic.api.client.okhttp.LithicOkHttpClient;\nimport com.lithic.api.models.TransactionRouteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n LithicClient client = LithicOkHttpClient.fromEnv();\n\n TransactionRouteParams params = TransactionRouteParams.builder()\n .transactionToken("00000000-0000-0000-0000-000000000000")\n .financialAccountToken("00000000-0000-0000-0000-000000000000")\n .build();\n client.transactions().route(params);\n }\n}',
7623+
},
7624+
kotlin: {
7625+
method: 'transactions().route',
7626+
example:
7627+
'package com.lithic.api.example\n\nimport com.lithic.api.client.LithicClient\nimport com.lithic.api.client.okhttp.LithicOkHttpClient\nimport com.lithic.api.models.TransactionRouteParams\n\nfun main() {\n val client: LithicClient = LithicOkHttpClient.fromEnv()\n\n val params: TransactionRouteParams = TransactionRouteParams.builder()\n .transactionToken("00000000-0000-0000-0000-000000000000")\n .financialAccountToken("00000000-0000-0000-0000-000000000000")\n .build()\n client.transactions().route(params)\n}',
7628+
},
7629+
go: {
7630+
method: 'client.Transactions.Route',
7631+
example:
7632+
'package main\n\nimport (\n\t"context"\n\n\t"github.com/lithic-com/lithic-go"\n\t"github.com/lithic-com/lithic-go/option"\n)\n\nfunc main() {\n\tclient := lithic.NewClient(\n\t\toption.WithAPIKey("My Lithic API Key"),\n\t)\n\terr := client.Transactions.Route(\n\t\tcontext.TODO(),\n\t\t"00000000-0000-0000-0000-000000000000",\n\t\tlithic.TransactionRouteParams{\n\t\t\tFinancialAccountToken: lithic.F("00000000-0000-0000-0000-000000000000"),\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n',
7633+
},
7634+
ruby: {
7635+
method: 'transactions.route',
7636+
example:
7637+
'require "lithic"\n\nlithic = Lithic::Client.new(\n api_key: "My Lithic API Key",\n environment: "sandbox" # defaults to "production"\n)\n\nresult = lithic.transactions.route(\n "00000000-0000-0000-0000-000000000000",\n financial_account_token: "00000000-0000-0000-0000-000000000000"\n)\n\nputs(result)',
7638+
},
7639+
http: {
7640+
example:
7641+
'curl https://api.lithic.com/v1/transactions/$TRANSACTION_TOKEN/route \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: $LITHIC_API_KEY" \\\n -d \'{\n "financial_account_token": "00000000-0000-0000-0000-000000000000"\n }\'',
7642+
},
7643+
},
7644+
},
75967645
{
75977646
name: 'retrieve',
75987647
endpoint: '/v1/transactions/{transaction_token}/enhanced_commercial_data',

packages/mcp-server/src/methods.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,12 @@ export const sdkMethods: SdkMethod[] = [
821821
httpMethod: 'post',
822822
httpPath: '/v1/transactions/{transaction_token}/expire_authorization',
823823
},
824+
{
825+
clientCallName: 'client.transactions.route',
826+
fullyQualifiedName: 'transactions.route',
827+
httpMethod: 'post',
828+
httpPath: '/v1/transactions/{transaction_token}/route',
829+
},
824830
{
825831
clientCallName: 'client.transactions.simulateAuthorization',
826832
fullyQualifiedName: 'transactions.simulateAuthorization',

src/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ import {
355355
TokenInfo,
356356
Transaction,
357357
TransactionListParams,
358+
TransactionRouteParams,
358359
TransactionSimulateAuthorizationAdviceParams,
359360
TransactionSimulateAuthorizationAdviceResponse,
360361
TransactionSimulateAuthorizationParams,
@@ -1409,6 +1410,7 @@ export declare namespace Lithic {
14091410
type TransactionSimulateVoidResponse as TransactionSimulateVoidResponse,
14101411
type TransactionsCursorPage as TransactionsCursorPage,
14111412
type TransactionListParams as TransactionListParams,
1413+
type TransactionRouteParams as TransactionRouteParams,
14121414
type TransactionSimulateAuthorizationParams as TransactionSimulateAuthorizationParams,
14131415
type TransactionSimulateAuthorizationAdviceParams as TransactionSimulateAuthorizationAdviceParams,
14141416
type TransactionSimulateClearingParams as TransactionSimulateClearingParams,

src/resources/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ export {
281281
type TransactionSimulateReturnReversalResponse,
282282
type TransactionSimulateVoidResponse,
283283
type TransactionListParams,
284+
type TransactionRouteParams,
284285
type TransactionSimulateAuthorizationParams,
285286
type TransactionSimulateAuthorizationAdviceParams,
286287
type TransactionSimulateClearingParams,

src/resources/transactions/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export {
1919
type TransactionSimulateReturnReversalResponse,
2020
type TransactionSimulateVoidResponse,
2121
type TransactionListParams,
22+
type TransactionRouteParams,
2223
type TransactionSimulateAuthorizationParams,
2324
type TransactionSimulateAuthorizationAdviceParams,
2425
type TransactionSimulateClearingParams,

src/resources/transactions/transactions.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,25 @@ export class Transactions extends APIResource {
6464
return this._client.post(path`/v1/transactions/${transactionToken}/expire_authorization`, options);
6565
}
6666

67+
/**
68+
* Route a card transaction to a financial account. Only available for select use
69+
* cases and programs.
70+
*
71+
* @example
72+
* ```ts
73+
* await client.transactions.route(
74+
* '00000000-0000-0000-0000-000000000000',
75+
* {
76+
* financial_account_token:
77+
* '00000000-0000-0000-0000-000000000000',
78+
* },
79+
* );
80+
* ```
81+
*/
82+
route(transactionToken: string, body: TransactionRouteParams, options?: RequestOptions): APIPromise<void> {
83+
return this._client.post(path`/v1/transactions/${transactionToken}/route`, { body, ...options });
84+
}
85+
6786
/**
6887
* Simulates an authorization request from the card network as if it came from a
6988
* merchant acquirer. If you are configured for ASA, simulating authorizations
@@ -1291,6 +1310,13 @@ export interface TransactionListParams extends CursorPageParams {
12911310
status?: 'PENDING' | 'VOIDED' | 'SETTLED' | 'DECLINED' | 'EXPIRED';
12921311
}
12931312

1313+
export interface TransactionRouteParams {
1314+
/**
1315+
* The token of the financial account to route the transaction to.
1316+
*/
1317+
financial_account_token: string;
1318+
}
1319+
12941320
export interface TransactionSimulateAuthorizationParams {
12951321
/**
12961322
* Amount (in cents) to authorize. For credit authorizations and financial credit
@@ -1578,6 +1604,7 @@ export declare namespace Transactions {
15781604
type TransactionSimulateVoidResponse as TransactionSimulateVoidResponse,
15791605
type TransactionsCursorPage as TransactionsCursorPage,
15801606
type TransactionListParams as TransactionListParams,
1607+
type TransactionRouteParams as TransactionRouteParams,
15811608
type TransactionSimulateAuthorizationParams as TransactionSimulateAuthorizationParams,
15821609
type TransactionSimulateAuthorizationAdviceParams as TransactionSimulateAuthorizationAdviceParams,
15831610
type TransactionSimulateClearingParams as TransactionSimulateClearingParams,

tests/api-resources/transactions/transactions.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,25 @@ describe('resource transactions', () => {
6161
expect(dataAndResponse.response).toBe(rawResponse);
6262
});
6363

64+
test('route: only required params', async () => {
65+
const responsePromise = client.transactions.route('00000000-0000-0000-0000-000000000000', {
66+
financial_account_token: '00000000-0000-0000-0000-000000000000',
67+
});
68+
const rawResponse = await responsePromise.asResponse();
69+
expect(rawResponse).toBeInstanceOf(Response);
70+
const response = await responsePromise;
71+
expect(response).not.toBeInstanceOf(Response);
72+
const dataAndResponse = await responsePromise.withResponse();
73+
expect(dataAndResponse.data).toBe(response);
74+
expect(dataAndResponse.response).toBe(rawResponse);
75+
});
76+
77+
test('route: required and optional params', async () => {
78+
const response = await client.transactions.route('00000000-0000-0000-0000-000000000000', {
79+
financial_account_token: '00000000-0000-0000-0000-000000000000',
80+
});
81+
});
82+
6483
test('simulateAuthorization: only required params', async () => {
6584
const responsePromise = client.transactions.simulateAuthorization({
6685
amount: 3831,

0 commit comments

Comments
 (0)