Skip to content

Commit 74346e6

Browse files
feat(api): add route method to transactions
1 parent 1071dc2 commit 74346e6

12 files changed

Lines changed: 178 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

lib/lithic.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@
479479
require_relative "lithic/models/transaction_monitoring/queue_update_params"
480480
require_relative "lithic/models/transaction_monitoring/resolution_outcome"
481481
require_relative "lithic/models/transaction_retrieve_params"
482+
require_relative "lithic/models/transaction_route_params"
482483
require_relative "lithic/models/transactions/enhanced_commercial_data_retrieve_params"
483484
require_relative "lithic/models/transactions/enhanced_commercial_data_retrieve_response"
484485
require_relative "lithic/models/transactions/events/enhanced_commercial_data_retrieve_params"

lib/lithic/models.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,8 @@ module Lithic
578578

579579
TransactionRetrieveParams = Lithic::Models::TransactionRetrieveParams
580580

581+
TransactionRouteParams = Lithic::Models::TransactionRouteParams
582+
581583
Transactions = Lithic::Models::Transactions
582584

583585
TransactionSimulateAuthorizationAdviceParams =
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# frozen_string_literal: true
2+
3+
module Lithic
4+
module Models
5+
# @see Lithic::Resources::Transactions#route
6+
class TransactionRouteParams < Lithic::Internal::Type::BaseModel
7+
extend Lithic::Internal::Type::RequestParameters::Converter
8+
include Lithic::Internal::Type::RequestParameters
9+
10+
# @!attribute transaction_token
11+
#
12+
# @return [String]
13+
required :transaction_token, String
14+
15+
# @!attribute financial_account_token
16+
# The token of the financial account to route the transaction to.
17+
#
18+
# @return [String]
19+
required :financial_account_token, String
20+
21+
# @!method initialize(transaction_token:, financial_account_token:, request_options: {})
22+
# @param transaction_token [String]
23+
#
24+
# @param financial_account_token [String] The token of the financial account to route the transaction to.
25+
#
26+
# @param request_options [Lithic::RequestOptions, Hash{Symbol=>Object}]
27+
end
28+
end
29+
end

lib/lithic/resources/transactions.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,31 @@ def expire_authorization(transaction_token, params = {})
9494
)
9595
end
9696

97+
# Route a card transaction to a financial account. Only available for select use
98+
# cases and programs.
99+
#
100+
# @overload route(transaction_token, financial_account_token:, request_options: {})
101+
#
102+
# @param transaction_token [String] The token of the transaction to route.
103+
#
104+
# @param financial_account_token [String] The token of the financial account to route the transaction to.
105+
#
106+
# @param request_options [Lithic::RequestOptions, Hash{Symbol=>Object}, nil]
107+
#
108+
# @return [nil]
109+
#
110+
# @see Lithic::Models::TransactionRouteParams
111+
def route(transaction_token, params)
112+
parsed, options = Lithic::TransactionRouteParams.dump_request(params)
113+
@client.request(
114+
method: :post,
115+
path: ["v1/transactions/%1$s/route", transaction_token],
116+
body: parsed,
117+
model: NilClass,
118+
options: options
119+
)
120+
end
121+
97122
# Some parameter documentations has been truncated, see
98123
# {Lithic::Models::TransactionSimulateAuthorizationParams} for more details.
99124
#

rbi/lithic/models.rbi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,8 @@ module Lithic
606606

607607
TransactionRetrieveParams = Lithic::Models::TransactionRetrieveParams
608608

609+
TransactionRouteParams = Lithic::Models::TransactionRouteParams
610+
609611
Transactions = Lithic::Models::Transactions
610612

611613
TransactionSimulateAuthorizationAdviceParams =
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# typed: strong
2+
3+
module Lithic
4+
module Models
5+
class TransactionRouteParams < Lithic::Internal::Type::BaseModel
6+
extend Lithic::Internal::Type::RequestParameters::Converter
7+
include Lithic::Internal::Type::RequestParameters
8+
9+
OrHash =
10+
T.type_alias do
11+
T.any(Lithic::TransactionRouteParams, Lithic::Internal::AnyHash)
12+
end
13+
14+
sig { returns(String) }
15+
attr_accessor :transaction_token
16+
17+
# The token of the financial account to route the transaction to.
18+
sig { returns(String) }
19+
attr_accessor :financial_account_token
20+
21+
sig do
22+
params(
23+
transaction_token: String,
24+
financial_account_token: String,
25+
request_options: Lithic::RequestOptions::OrHash
26+
).returns(T.attached_class)
27+
end
28+
def self.new(
29+
transaction_token:,
30+
# The token of the financial account to route the transaction to.
31+
financial_account_token:,
32+
request_options: {}
33+
)
34+
end
35+
36+
sig do
37+
override.returns(
38+
{
39+
transaction_token: String,
40+
financial_account_token: String,
41+
request_options: Lithic::RequestOptions
42+
}
43+
)
44+
end
45+
def to_hash
46+
end
47+
end
48+
end
49+
end

rbi/lithic/resources/transactions.rbi

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,24 @@ module Lithic
8282
)
8383
end
8484

85+
# Route a card transaction to a financial account. Only available for select use
86+
# cases and programs.
87+
sig do
88+
params(
89+
transaction_token: String,
90+
financial_account_token: String,
91+
request_options: Lithic::RequestOptions::OrHash
92+
).void
93+
end
94+
def route(
95+
# The token of the transaction to route.
96+
transaction_token,
97+
# The token of the financial account to route the transaction to.
98+
financial_account_token:,
99+
request_options: {}
100+
)
101+
end
102+
85103
# Simulates an authorization request from the card network as if it came from a
86104
# merchant acquirer. If you are configured for ASA, simulating authorizations
87105
# requires your ASA client to be set up properly, i.e. be able to respond to the

sig/lithic/models.rbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,8 @@ module Lithic
525525

526526
class TransactionRetrieveParams = Lithic::Models::TransactionRetrieveParams
527527

528+
class TransactionRouteParams = Lithic::Models::TransactionRouteParams
529+
528530
module Transactions = Lithic::Models::Transactions
529531

530532
class TransactionSimulateAuthorizationAdviceParams = Lithic::Models::TransactionSimulateAuthorizationAdviceParams
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module Lithic
2+
module Models
3+
type transaction_route_params =
4+
{ transaction_token: String, financial_account_token: String }
5+
& Lithic::Internal::Type::request_parameters
6+
7+
class TransactionRouteParams < Lithic::Internal::Type::BaseModel
8+
extend Lithic::Internal::Type::RequestParameters::Converter
9+
include Lithic::Internal::Type::RequestParameters
10+
11+
attr_accessor transaction_token: String
12+
13+
attr_accessor financial_account_token: String
14+
15+
def initialize: (
16+
transaction_token: String,
17+
financial_account_token: String,
18+
?request_options: Lithic::request_opts
19+
) -> void
20+
21+
def to_hash: -> {
22+
transaction_token: String,
23+
financial_account_token: String,
24+
request_options: Lithic::RequestOptions
25+
}
26+
end
27+
end
28+
end

0 commit comments

Comments
 (0)