Skip to content

Commit b4aff37

Browse files
feat(api): Add card/account/business account signals endpoints and behavioral rule attributes
1 parent 15e0091 commit b4aff37

9 files changed

Lines changed: 770 additions & 16 deletions

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 191
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-28c9b43d3182bf0e1c9635f6100e4995a744724db1edd635cfd3fc7702ced68c.yml
3-
openapi_spec_hash: aba00a65f877c5095499d9d1a66b5e5f
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-d29b68bb85936070878d8badaa8a7c5991313285e70a990bc812c838eba85373.yml
3+
openapi_spec_hash: 54b44da68df22eb0ea99f2bc564667a2
44
config_hash: ac8326134e692f3f3bdec82396bbec80

lib/lithic/models/auth_rules/conditional_authorization_action_parameters.rb

Lines changed: 143 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,33 @@ class Condition < Lithic::Internal::Type::BaseModel
107107
# - `CARD_AGE`: The age of the card in seconds at the time of the authorization.
108108
# - `ACCOUNT_AGE`: The age of the account holder's account in seconds at the time
109109
# of the authorization.
110+
# - `AMOUNT_Z_SCORE`: The z-score of the transaction amount relative to the
111+
# entity's transaction history. Null if fewer than 30 approved transactions in
112+
# the specified window. Requires `parameters.scope` and `parameters.interval`.
113+
# - `AVG_TRANSACTION_AMOUNT`: The average approved transaction amount for the
114+
# entity over the specified window, in cents. Requires `parameters.scope` and
115+
# `parameters.interval`.
116+
# - `STDEV_TRANSACTION_AMOUNT`: The standard deviation of approved transaction
117+
# amounts for the entity over the specified window, in cents. Null if fewer than
118+
# 30 approved transactions in the specified window. Requires `parameters.scope`
119+
# and `parameters.interval`.
120+
# - `IS_NEW_COUNTRY`: Whether the transaction's merchant country has not been seen
121+
# in the entity's transaction history. Valid values are `TRUE`, `FALSE`.
122+
# Requires `parameters.scope`.
123+
# - `IS_NEW_MCC`: Whether the transaction's MCC has not been seen in the entity's
124+
# transaction history. Valid values are `TRUE`, `FALSE`. Requires
125+
# `parameters.scope`.
126+
# - `IS_FIRST_TRANSACTION`: Whether this is the first transaction for the entity.
127+
# Valid values are `TRUE`, `FALSE`. Requires `parameters.scope`.
128+
# - `CONSECUTIVE_DECLINES`: The number of consecutive declined transactions for
129+
# the entity over the last 30 days (rolling). Requires `parameters.scope`. Not
130+
# supported for `BUSINESS_ACCOUNT` scope.
131+
# - `TIME_SINCE_LAST_TRANSACTION`: The number of days since the last approved
132+
# transaction for the entity. Requires `parameters.scope`.
133+
# - `DISTINCT_COUNTRY_COUNT`: The number of distinct merchant countries seen in
134+
# the entity's transaction history. Requires `parameters.scope`.
135+
# - `THREE_DS_SUCCESS_RATE`: The 3DS authentication success rate for the card, as
136+
# a percentage from 0.0 to 100.0. Card-scoped only; no `parameters` required.
110137
#
111138
# @return [Symbol, Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Attribute]
112139
required :attribute,
@@ -124,7 +151,18 @@ class Condition < Lithic::Internal::Type::BaseModel
124151
# @return [String, Integer, Array<String>, Time]
125152
required :value, union: -> { Lithic::AuthRules::ConditionalValue }
126153

127-
# @!method initialize(attribute:, operation:, value:)
154+
# @!attribute parameters
155+
# Additional parameters required for transaction history signal attributes.
156+
# Required when `attribute` is one of `AMOUNT_Z_SCORE`, `AVG_TRANSACTION_AMOUNT`,
157+
# `STDEV_TRANSACTION_AMOUNT`, `IS_NEW_COUNTRY`, `IS_NEW_MCC`,
158+
# `IS_FIRST_TRANSACTION`, `CONSECUTIVE_DECLINES`, `TIME_SINCE_LAST_TRANSACTION`,
159+
# or `DISTINCT_COUNTRY_COUNT`. Not used for other attributes.
160+
#
161+
# @return [Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters, nil]
162+
optional :parameters,
163+
-> { Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters }
164+
165+
# @!method initialize(attribute:, operation:, value:, parameters: nil)
128166
# Some parameter documentations has been truncated, see
129167
# {Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition}
130168
# for more details.
@@ -134,6 +172,8 @@ class Condition < Lithic::Internal::Type::BaseModel
134172
# @param operation [Symbol, Lithic::Models::AuthRules::ConditionalOperation] The operation to apply to the attribute
135173
#
136174
# @param value [String, Integer, Array<String>, Time] A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`
175+
#
176+
# @param parameters [Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters] Additional parameters required for transaction history signal attributes. Requir
137177

138178
# The attribute to target.
139179
#
@@ -206,6 +246,33 @@ class Condition < Lithic::Internal::Type::BaseModel
206246
# - `CARD_AGE`: The age of the card in seconds at the time of the authorization.
207247
# - `ACCOUNT_AGE`: The age of the account holder's account in seconds at the time
208248
# of the authorization.
249+
# - `AMOUNT_Z_SCORE`: The z-score of the transaction amount relative to the
250+
# entity's transaction history. Null if fewer than 30 approved transactions in
251+
# the specified window. Requires `parameters.scope` and `parameters.interval`.
252+
# - `AVG_TRANSACTION_AMOUNT`: The average approved transaction amount for the
253+
# entity over the specified window, in cents. Requires `parameters.scope` and
254+
# `parameters.interval`.
255+
# - `STDEV_TRANSACTION_AMOUNT`: The standard deviation of approved transaction
256+
# amounts for the entity over the specified window, in cents. Null if fewer than
257+
# 30 approved transactions in the specified window. Requires `parameters.scope`
258+
# and `parameters.interval`.
259+
# - `IS_NEW_COUNTRY`: Whether the transaction's merchant country has not been seen
260+
# in the entity's transaction history. Valid values are `TRUE`, `FALSE`.
261+
# Requires `parameters.scope`.
262+
# - `IS_NEW_MCC`: Whether the transaction's MCC has not been seen in the entity's
263+
# transaction history. Valid values are `TRUE`, `FALSE`. Requires
264+
# `parameters.scope`.
265+
# - `IS_FIRST_TRANSACTION`: Whether this is the first transaction for the entity.
266+
# Valid values are `TRUE`, `FALSE`. Requires `parameters.scope`.
267+
# - `CONSECUTIVE_DECLINES`: The number of consecutive declined transactions for
268+
# the entity over the last 30 days (rolling). Requires `parameters.scope`. Not
269+
# supported for `BUSINESS_ACCOUNT` scope.
270+
# - `TIME_SINCE_LAST_TRANSACTION`: The number of days since the last approved
271+
# transaction for the entity. Requires `parameters.scope`.
272+
# - `DISTINCT_COUNTRY_COUNT`: The number of distinct merchant countries seen in
273+
# the entity's transaction history. Requires `parameters.scope`.
274+
# - `THREE_DS_SUCCESS_RATE`: The 3DS authentication success rate for the card, as
275+
# a percentage from 0.0 to 100.0. Card-scoped only; no `parameters` required.
209276
#
210277
# @see Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition#attribute
211278
module Attribute
@@ -237,10 +304,85 @@ module Attribute
237304
SERVICE_LOCATION_POSTAL_CODE = :SERVICE_LOCATION_POSTAL_CODE
238305
CARD_AGE = :CARD_AGE
239306
ACCOUNT_AGE = :ACCOUNT_AGE
307+
AMOUNT_Z_SCORE = :AMOUNT_Z_SCORE
308+
AVG_TRANSACTION_AMOUNT = :AVG_TRANSACTION_AMOUNT
309+
STDEV_TRANSACTION_AMOUNT = :STDEV_TRANSACTION_AMOUNT
310+
IS_NEW_COUNTRY = :IS_NEW_COUNTRY
311+
IS_NEW_MCC = :IS_NEW_MCC
312+
IS_FIRST_TRANSACTION = :IS_FIRST_TRANSACTION
313+
CONSECUTIVE_DECLINES = :CONSECUTIVE_DECLINES
314+
TIME_SINCE_LAST_TRANSACTION = :TIME_SINCE_LAST_TRANSACTION
315+
DISTINCT_COUNTRY_COUNT = :DISTINCT_COUNTRY_COUNT
316+
THREE_DS_SUCCESS_RATE = :THREE_DS_SUCCESS_RATE
240317

241318
# @!method self.values
242319
# @return [Array<Symbol>]
243320
end
321+
322+
# @see Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition#parameters
323+
class Parameters < Lithic::Internal::Type::BaseModel
324+
# @!attribute interval
325+
# The time window for statistical attributes (`AMOUNT_Z_SCORE`,
326+
# `AVG_TRANSACTION_AMOUNT`, `STDEV_TRANSACTION_AMOUNT`). Use `LIFETIME` for
327+
# all-time history or a specific window (`7D`, `30D`, `90D`).
328+
#
329+
# @return [Symbol, Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Interval, nil]
330+
optional :interval,
331+
enum: -> { Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Interval }
332+
333+
# @!attribute scope
334+
# The entity scope to evaluate the attribute against.
335+
#
336+
# @return [Symbol, Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Scope, nil]
337+
optional :scope,
338+
enum: -> { Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Scope }
339+
340+
# @!method initialize(interval: nil, scope: nil)
341+
# Some parameter documentations has been truncated, see
342+
# {Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters}
343+
# for more details.
344+
#
345+
# Additional parameters required for transaction history signal attributes.
346+
# Required when `attribute` is one of `AMOUNT_Z_SCORE`, `AVG_TRANSACTION_AMOUNT`,
347+
# `STDEV_TRANSACTION_AMOUNT`, `IS_NEW_COUNTRY`, `IS_NEW_MCC`,
348+
# `IS_FIRST_TRANSACTION`, `CONSECUTIVE_DECLINES`, `TIME_SINCE_LAST_TRANSACTION`,
349+
# or `DISTINCT_COUNTRY_COUNT`. Not used for other attributes.
350+
#
351+
# @param interval [Symbol, Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Interval] The time window for statistical attributes (`AMOUNT_Z_SCORE`, `AVG_TRANSACTION_A
352+
#
353+
# @param scope [Symbol, Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Scope] The entity scope to evaluate the attribute against.
354+
355+
# The time window for statistical attributes (`AMOUNT_Z_SCORE`,
356+
# `AVG_TRANSACTION_AMOUNT`, `STDEV_TRANSACTION_AMOUNT`). Use `LIFETIME` for
357+
# all-time history or a specific window (`7D`, `30D`, `90D`).
358+
#
359+
# @see Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters#interval
360+
module Interval
361+
extend Lithic::Internal::Type::Enum
362+
363+
LIFETIME = :LIFETIME
364+
INTERVAL_7_D = :"7D"
365+
INTERVAL_30_D = :"30D"
366+
INTERVAL_90_D = :"90D"
367+
368+
# @!method self.values
369+
# @return [Array<Symbol>]
370+
end
371+
372+
# The entity scope to evaluate the attribute against.
373+
#
374+
# @see Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters#scope
375+
module Scope
376+
extend Lithic::Internal::Type::Enum
377+
378+
CARD = :CARD
379+
ACCOUNT = :ACCOUNT
380+
BUSINESS_ACCOUNT = :BUSINESS_ACCOUNT
381+
382+
# @!method self.values
383+
# @return [Array<Symbol>]
384+
end
385+
end
244386
end
245387
end
246388
end

lib/lithic/models/auth_rules/rule_feature.rb

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ module AuthRules
2424
# - `SPEND_VELOCITY`: Spend velocity data for the card or account. Requires
2525
# `scope`, `period`, and optionally `filters` to configure the velocity
2626
# calculation. Available for AUTHORIZATION event stream rules.
27+
# - `TRANSACTION_HISTORY_SIGNALS`: Behavioral feature state derived from the
28+
# entity's transaction history. Requires `scope` to specify whether to load
29+
# card, account, or business account history. Available for AUTHORIZATION event
30+
# stream rules.
2731
module RuleFeature
2832
extend Lithic::Internal::Type::Union
2933

@@ -43,6 +47,8 @@ module RuleFeature
4347

4448
variant -> { Lithic::AuthRules::RuleFeature::SpendVelocityFeature }
4549

50+
variant -> { Lithic::AuthRules::RuleFeature::TransactionHistorySignalsFeature }
51+
4652
class AuthorizationFeature < Lithic::Internal::Type::BaseModel
4753
# @!attribute type
4854
#
@@ -223,8 +229,48 @@ module Scope
223229
end
224230
end
225231

232+
class TransactionHistorySignalsFeature < Lithic::Internal::Type::BaseModel
233+
# @!attribute scope
234+
# The entity scope to load transaction history signals for.
235+
#
236+
# @return [Symbol, Lithic::Models::AuthRules::RuleFeature::TransactionHistorySignalsFeature::Scope]
237+
required :scope, enum: -> { Lithic::AuthRules::RuleFeature::TransactionHistorySignalsFeature::Scope }
238+
239+
# @!attribute type
240+
#
241+
# @return [Symbol, :TRANSACTION_HISTORY_SIGNALS]
242+
required :type, const: :TRANSACTION_HISTORY_SIGNALS
243+
244+
# @!attribute name
245+
# The variable name for this feature in the rule function signature
246+
#
247+
# @return [String, nil]
248+
optional :name, String
249+
250+
# @!method initialize(scope:, name: nil, type: :TRANSACTION_HISTORY_SIGNALS)
251+
# @param scope [Symbol, Lithic::Models::AuthRules::RuleFeature::TransactionHistorySignalsFeature::Scope] The entity scope to load transaction history signals for.
252+
#
253+
# @param name [String] The variable name for this feature in the rule function signature
254+
#
255+
# @param type [Symbol, :TRANSACTION_HISTORY_SIGNALS]
256+
257+
# The entity scope to load transaction history signals for.
258+
#
259+
# @see Lithic::Models::AuthRules::RuleFeature::TransactionHistorySignalsFeature#scope
260+
module Scope
261+
extend Lithic::Internal::Type::Enum
262+
263+
CARD = :CARD
264+
ACCOUNT = :ACCOUNT
265+
BUSINESS_ACCOUNT = :BUSINESS_ACCOUNT
266+
267+
# @!method self.values
268+
# @return [Array<Symbol>]
269+
end
270+
end
271+
226272
# @!method self.variants
227-
# @return [Array(Lithic::Models::AuthRules::RuleFeature::AuthorizationFeature, Lithic::Models::AuthRules::RuleFeature::AuthenticationFeature, Lithic::Models::AuthRules::RuleFeature::TokenizationFeature, Lithic::Models::AuthRules::RuleFeature::ACHReceiptFeature, Lithic::Models::AuthRules::RuleFeature::CardFeature, Lithic::Models::AuthRules::RuleFeature::AccountHolderFeature, Lithic::Models::AuthRules::RuleFeature::IPMetadataFeature, Lithic::Models::AuthRules::RuleFeature::SpendVelocityFeature)]
273+
# @return [Array(Lithic::Models::AuthRules::RuleFeature::AuthorizationFeature, Lithic::Models::AuthRules::RuleFeature::AuthenticationFeature, Lithic::Models::AuthRules::RuleFeature::TokenizationFeature, Lithic::Models::AuthRules::RuleFeature::ACHReceiptFeature, Lithic::Models::AuthRules::RuleFeature::CardFeature, Lithic::Models::AuthRules::RuleFeature::AccountHolderFeature, Lithic::Models::AuthRules::RuleFeature::IPMetadataFeature, Lithic::Models::AuthRules::RuleFeature::SpendVelocityFeature, Lithic::Models::AuthRules::RuleFeature::TransactionHistorySignalsFeature)]
228274
end
229275
end
230276
end

lib/lithic/models/auth_rules/typescript_code_parameters.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class TypescriptCodeParameters < Lithic::Internal::Type::BaseModel
1515
# @!attribute features
1616
# Features available to the TypeScript code at evaluation time
1717
#
18-
# @return [Array<Lithic::Models::AuthRules::RuleFeature::AuthorizationFeature, Lithic::Models::AuthRules::RuleFeature::AuthenticationFeature, Lithic::Models::AuthRules::RuleFeature::TokenizationFeature, Lithic::Models::AuthRules::RuleFeature::ACHReceiptFeature, Lithic::Models::AuthRules::RuleFeature::CardFeature, Lithic::Models::AuthRules::RuleFeature::AccountHolderFeature, Lithic::Models::AuthRules::RuleFeature::IPMetadataFeature, Lithic::Models::AuthRules::RuleFeature::SpendVelocityFeature>]
18+
# @return [Array<Lithic::Models::AuthRules::RuleFeature::AuthorizationFeature, Lithic::Models::AuthRules::RuleFeature::AuthenticationFeature, Lithic::Models::AuthRules::RuleFeature::TokenizationFeature, Lithic::Models::AuthRules::RuleFeature::ACHReceiptFeature, Lithic::Models::AuthRules::RuleFeature::CardFeature, Lithic::Models::AuthRules::RuleFeature::AccountHolderFeature, Lithic::Models::AuthRules::RuleFeature::IPMetadataFeature, Lithic::Models::AuthRules::RuleFeature::SpendVelocityFeature, Lithic::Models::AuthRules::RuleFeature::TransactionHistorySignalsFeature>]
1919
required :features, -> { Lithic::Internal::Type::ArrayOf[union: Lithic::AuthRules::RuleFeature] }
2020

2121
# @!method initialize(code:, features:)
@@ -26,7 +26,7 @@ class TypescriptCodeParameters < Lithic::Internal::Type::BaseModel
2626
#
2727
# @param code [String] The TypeScript source code of the rule. Must define a `rule()` function that acc
2828
#
29-
# @param features [Array<Lithic::Models::AuthRules::RuleFeature::AuthorizationFeature, Lithic::Models::AuthRules::RuleFeature::AuthenticationFeature, Lithic::Models::AuthRules::RuleFeature::TokenizationFeature, Lithic::Models::AuthRules::RuleFeature::ACHReceiptFeature, Lithic::Models::AuthRules::RuleFeature::CardFeature, Lithic::Models::AuthRules::RuleFeature::AccountHolderFeature, Lithic::Models::AuthRules::RuleFeature::IPMetadataFeature, Lithic::Models::AuthRules::RuleFeature::SpendVelocityFeature>] Features available to the TypeScript code at evaluation time
29+
# @param features [Array<Lithic::Models::AuthRules::RuleFeature::AuthorizationFeature, Lithic::Models::AuthRules::RuleFeature::AuthenticationFeature, Lithic::Models::AuthRules::RuleFeature::TokenizationFeature, Lithic::Models::AuthRules::RuleFeature::ACHReceiptFeature, Lithic::Models::AuthRules::RuleFeature::CardFeature, Lithic::Models::AuthRules::RuleFeature::AccountHolderFeature, Lithic::Models::AuthRules::RuleFeature::IPMetadataFeature, Lithic::Models::AuthRules::RuleFeature::SpendVelocityFeature, Lithic::Models::AuthRules::RuleFeature::TransactionHistorySignalsFeature>] Features available to the TypeScript code at evaluation time
3030
end
3131
end
3232
end

0 commit comments

Comments
 (0)