Skip to content

Commit 0d84634

Browse files
fix(types): convert CaseTransaction to union with Card/Payment variants
1 parent 1385cde commit 0d84634

9 files changed

Lines changed: 380 additions & 156 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 214
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic/lithic-d83e3ddb148bc0c81ff97bd31b82027d5b37efc110f5981103e7b9a2ae281c86.yml
3-
openapi_spec_hash: f607b0571c4ed82a93a3df7bc9e9351b
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic/lithic-9e397c65ffb81e2928b8ecf979769a79131ae6058b6fb373a5e930dc8a168732.yml
3+
openapi_spec_hash: 93aea3855d2d1c390107d223762aa818
44
config_hash: 5bb913c05ebeb301ec925b16e75bb251

lib/lithic/internal/type/union.rb

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,14 @@ module Type
66
# @api private
77
#
88
# @example
9-
# # `account_activity_list_response` is a `Lithic::Models::AccountActivityListResponse`
10-
# case account_activity_list_response
11-
# when Lithic::Models::AccountActivityListResponse::Internal
12-
# puts(account_activity_list_response.token)
13-
# when Lithic::BookTransferResponse
14-
# puts(account_activity_list_response.category)
15-
# when Lithic::Models::AccountActivityListResponse::Card
16-
# # ...
9+
# # `case_transaction` is a `Lithic::TransactionMonitoring::CaseTransaction`
10+
# case case_transaction
11+
# when Lithic::TransactionMonitoring::CaseTransaction::CardCaseTransaction
12+
# puts(case_transaction.token)
13+
# when Lithic::TransactionMonitoring::CaseTransaction::PaymentCaseTransaction
14+
# puts(case_transaction.added_at)
1715
# else
18-
# puts(account_activity_list_response)
19-
# end
20-
#
21-
# @example
22-
# case account_activity_list_response
23-
# in {family: :INTERNAL, token: token, category: category, created: created}
24-
# puts(token)
25-
# in {family: :TRANSFER, token: token, category: category, created: created}
26-
# puts(category)
27-
# in {family: :PAYMENT, token: token, category: category, created: created}
28-
# puts(created)
29-
# else
30-
# puts(account_activity_list_response)
16+
# puts(case_transaction)
3117
# end
3218
module Union
3319
include Lithic::Internal::Type::Converter

lib/lithic/models/transaction_monitoring/case_transaction.rb

Lines changed: 120 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,127 @@
33
module Lithic
44
module Models
55
module TransactionMonitoring
6+
# A single transaction associated with a case. The `category` field identifies
7+
# whether this is a card transaction or a payment transaction.
8+
#
69
# @see Lithic::Resources::TransactionMonitoring::Cases#list_transactions
7-
class CaseTransaction < Lithic::Internal::Type::BaseModel
8-
# @!attribute token
9-
# Globally unique identifier for the transaction
10-
#
11-
# @return [String]
12-
required :token, String
13-
14-
# @!attribute account_token
15-
# Token of the account the transaction belongs to
16-
#
17-
# @return [String]
18-
required :account_token, String
19-
20-
# @!attribute added_at
21-
# Date and time at which the transaction was added to the case
22-
#
23-
# @return [Time]
24-
required :added_at, Time
25-
26-
# @!attribute card_token
27-
# Token of the card the transaction was made on
28-
#
29-
# @return [String]
30-
required :card_token, String
31-
32-
# @!attribute transaction_created_at
33-
# Date and time at which the transaction was created
34-
#
35-
# @return [Time]
36-
required :transaction_created_at, Time
37-
38-
# @!method initialize(token:, account_token:, added_at:, card_token:, transaction_created_at:)
39-
# A single transaction associated with a case
40-
#
41-
# @param token [String] Globally unique identifier for the transaction
42-
#
43-
# @param account_token [String] Token of the account the transaction belongs to
44-
#
45-
# @param added_at [Time] Date and time at which the transaction was added to the case
46-
#
47-
# @param card_token [String] Token of the card the transaction was made on
48-
#
49-
# @param transaction_created_at [Time] Date and time at which the transaction was created
10+
module CaseTransaction
11+
extend Lithic::Internal::Type::Union
12+
13+
discriminator :category
14+
15+
# A card transaction associated with a case
16+
variant -> { Lithic::TransactionMonitoring::CaseTransaction::CardCaseTransaction }
17+
18+
# A payment (ACH) transaction associated with a case
19+
variant -> { Lithic::TransactionMonitoring::CaseTransaction::PaymentCaseTransaction }
20+
21+
class CardCaseTransaction < Lithic::Internal::Type::BaseModel
22+
# @!attribute token
23+
# Globally unique identifier for the card transaction
24+
#
25+
# @return [String]
26+
required :token, String
27+
28+
# @!attribute account_token
29+
# Token of the account the transaction belongs to
30+
#
31+
# @return [String]
32+
required :account_token, String
33+
34+
# @!attribute added_at
35+
# Date and time at which the transaction was added to the case
36+
#
37+
# @return [Time]
38+
required :added_at, Time
39+
40+
# @!attribute card_token
41+
# Token of the card the transaction was made on
42+
#
43+
# @return [String]
44+
required :card_token, String
45+
46+
# @!attribute category
47+
#
48+
# @return [Symbol, :CARD]
49+
required :category, const: :CARD
50+
51+
# @!attribute transaction_created_at
52+
# Date and time at which the transaction was created
53+
#
54+
# @return [Time]
55+
required :transaction_created_at, Time
56+
57+
# @!method initialize(token:, account_token:, added_at:, card_token:, transaction_created_at:, category: :CARD)
58+
# A card transaction associated with a case
59+
#
60+
# @param token [String] Globally unique identifier for the card transaction
61+
#
62+
# @param account_token [String] Token of the account the transaction belongs to
63+
#
64+
# @param added_at [Time] Date and time at which the transaction was added to the case
65+
#
66+
# @param card_token [String] Token of the card the transaction was made on
67+
#
68+
# @param transaction_created_at [Time] Date and time at which the transaction was created
69+
#
70+
# @param category [Symbol, :CARD]
71+
end
72+
73+
class PaymentCaseTransaction < Lithic::Internal::Type::BaseModel
74+
# @!attribute token
75+
# Globally unique identifier for the payment transaction
76+
#
77+
# @return [String]
78+
required :token, String
79+
80+
# @!attribute added_at
81+
# Date and time at which the transaction was added to the case
82+
#
83+
# @return [Time]
84+
required :added_at, Time
85+
86+
# @!attribute category
87+
#
88+
# @return [Symbol, :PAYMENT]
89+
required :category, const: :PAYMENT
90+
91+
# @!attribute financial_account_token
92+
# Token of the financial account the payment belongs to
93+
#
94+
# @return [String]
95+
required :financial_account_token, String
96+
97+
# @!attribute transaction_created_at
98+
# Date and time at which the transaction was created
99+
#
100+
# @return [Time]
101+
required :transaction_created_at, Time
102+
103+
# @!attribute account_token
104+
# Token of the account the payment belongs to, if applicable
105+
#
106+
# @return [String, nil]
107+
optional :account_token, String
108+
109+
# @!method initialize(token:, added_at:, financial_account_token:, transaction_created_at:, account_token: nil, category: :PAYMENT)
110+
# A payment (ACH) transaction associated with a case
111+
#
112+
# @param token [String] Globally unique identifier for the payment transaction
113+
#
114+
# @param added_at [Time] Date and time at which the transaction was added to the case
115+
#
116+
# @param financial_account_token [String] Token of the financial account the payment belongs to
117+
#
118+
# @param transaction_created_at [Time] Date and time at which the transaction was created
119+
#
120+
# @param account_token [String] Token of the account the payment belongs to, if applicable
121+
#
122+
# @param category [Symbol, :PAYMENT]
123+
end
124+
125+
# @!method self.variants
126+
# @return [Array(Lithic::Models::TransactionMonitoring::CaseTransaction::CardCaseTransaction, Lithic::Models::TransactionMonitoring::CaseTransaction::PaymentCaseTransaction)]
50127
end
51128
end
52129
end

lib/lithic/resources/transaction_monitoring/cases.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def list_activity(case_token, params = {})
178178
#
179179
# @param request_options [Lithic::RequestOptions, Hash{Symbol=>Object}, nil]
180180
#
181-
# @return [Lithic::Internal::CursorPage<Lithic::Models::TransactionMonitoring::CaseTransaction>]
181+
# @return [Lithic::Internal::CursorPage<Lithic::Models::TransactionMonitoring::CaseTransaction::CardCaseTransaction, Lithic::Models::TransactionMonitoring::CaseTransaction::PaymentCaseTransaction>]
182182
#
183183
# @see Lithic::Models::TransactionMonitoring::CaseListTransactionsParams
184184
def list_transactions(case_token, params = {})

0 commit comments

Comments
 (0)