From 846d5d99cea53078bbda45f2a4b845bc4f7f33d2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 7 May 2026 18:12:25 +0000 Subject: [PATCH 1/3] feat(api): add travel speed/distance attributes and unit parameter to auth_rules --- .stats.yml | 4 +- ...itional_authorization_action_parameters.rb | 81 +++++++-- ...tional_authorization_action_parameters.rbi | 160 ++++++++++++++++-- ...tional_authorization_action_parameters.rbs | 32 +++- 4 files changed, 242 insertions(+), 35 deletions(-) diff --git a/.stats.yml b/.stats.yml index 883f26c0..11ef5a19 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 191 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic/lithic-0f374e78a0212145a2f55a55dfc39a612de19094d5152ae26b1bc74b01b9e343.yml -openapi_spec_hash: ec888cdaebea979a2cd6231ca04c346c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic/lithic-af9701d01abffc53ba2bf56c06415d893460e6b420f122e602cf4afe67bbf57b.yml +openapi_spec_hash: 963688b09480159a06865075c94a2577 config_hash: 01dfc901bb6d54b0f582155d779bcbe0 diff --git a/lib/lithic/models/auth_rules/conditional_authorization_action_parameters.rb b/lib/lithic/models/auth_rules/conditional_authorization_action_parameters.rb index d850048d..4bd6b39c 100644 --- a/lib/lithic/models/auth_rules/conditional_authorization_action_parameters.rb +++ b/lib/lithic/models/auth_rules/conditional_authorization_action_parameters.rb @@ -138,6 +138,15 @@ class Condition < Lithic::Internal::Type::BaseModel # `parameters` required. # - `THREE_DS_SUCCESS_RATE`: The 3DS authentication success rate for the card, as # a percentage from 0.0 to 100.0. Card-scoped only; no `parameters` required. + # - `TRAVEL_SPEED`: The estimated speed of travel derived from the distance + # between the postal code centers of the last card-present transaction and the + # current transaction, divided by the elapsed time. Null if there is no prior + # card-present transaction, if either postal code cannot be geocoded, or if + # elapsed time is zero. Requires `parameters.unit` set to `MPH` or `KPH`. + # - `DISTANCE_FROM_LAST_TRANSACTION`: The estimated distance between the postal + # code centers of the last card-present transaction and the current transaction. + # Null if there is no prior card-present transaction or if either postal code + # cannot be geocoded. Requires `parameters.unit` set to `MILES` or `KILOMETERS`. # # @return [Symbol, Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Attribute] required :attribute, @@ -156,11 +165,12 @@ class Condition < Lithic::Internal::Type::BaseModel required :value, union: -> { Lithic::AuthRules::ConditionalValue } # @!attribute parameters - # Additional parameters required for transaction history signal attributes. - # Required when `attribute` is one of `AMOUNT_Z_SCORE`, `AVG_TRANSACTION_AMOUNT`, - # `STDEV_TRANSACTION_AMOUNT`, `IS_NEW_COUNTRY`, `IS_NEW_MCC`, - # `IS_FIRST_TRANSACTION`, `CONSECUTIVE_DECLINES`, `TIME_SINCE_LAST_TRANSACTION`, - # or `DISTINCT_COUNTRY_COUNT`. Not used for other attributes. + # Additional parameters for certain attributes. Required when `attribute` is one + # of `AMOUNT_Z_SCORE`, `AVG_TRANSACTION_AMOUNT`, `STDEV_TRANSACTION_AMOUNT`, + # `IS_NEW_COUNTRY`, `IS_NEW_MCC`, `IS_FIRST_TRANSACTION`, `CONSECUTIVE_DECLINES`, + # `TIME_SINCE_LAST_TRANSACTION`, or `DISTINCT_COUNTRY_COUNT` (require `scope`); or + # `TRAVEL_SPEED` or `DISTANCE_FROM_LAST_TRANSACTION` (require `unit`). Not used + # for other attributes. # # @return [Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters, nil] optional :parameters, @@ -177,7 +187,7 @@ class Condition < Lithic::Internal::Type::BaseModel # # @param value [String, Integer, Array, Time] A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` # - # @param parameters [Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters] Additional parameters required for transaction history signal attributes. Requir + # @param parameters [Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters] Additional parameters for certain attributes. Required when `attribute` is one o # The attribute to target. # @@ -281,6 +291,15 @@ class Condition < Lithic::Internal::Type::BaseModel # `parameters` required. # - `THREE_DS_SUCCESS_RATE`: The 3DS authentication success rate for the card, as # a percentage from 0.0 to 100.0. Card-scoped only; no `parameters` required. + # - `TRAVEL_SPEED`: The estimated speed of travel derived from the distance + # between the postal code centers of the last card-present transaction and the + # current transaction, divided by the elapsed time. Null if there is no prior + # card-present transaction, if either postal code cannot be geocoded, or if + # elapsed time is zero. Requires `parameters.unit` set to `MPH` or `KPH`. + # - `DISTANCE_FROM_LAST_TRANSACTION`: The estimated distance between the postal + # code centers of the last card-present transaction and the current transaction. + # Null if there is no prior card-present transaction or if either postal code + # cannot be geocoded. Requires `parameters.unit` set to `MILES` or `KILOMETERS`. # # @see Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition#attribute module Attribute @@ -323,6 +342,8 @@ module Attribute DISTINCT_COUNTRY_COUNT = :DISTINCT_COUNTRY_COUNT IS_NEW_MERCHANT = :IS_NEW_MERCHANT THREE_DS_SUCCESS_RATE = :THREE_DS_SUCCESS_RATE + TRAVEL_SPEED = :TRAVEL_SPEED + DISTANCE_FROM_LAST_TRANSACTION = :DISTANCE_FROM_LAST_TRANSACTION # @!method self.values # @return [Array] @@ -346,20 +367,36 @@ class Parameters < Lithic::Internal::Type::BaseModel optional :scope, enum: -> { Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Scope } - # @!method initialize(interval: nil, scope: nil) + # @!attribute unit + # The unit for impossible travel attributes. Required when `attribute` is + # `TRAVEL_SPEED` or `DISTANCE_FROM_LAST_TRANSACTION`. + # + # For `TRAVEL_SPEED`: `MPH` (miles per hour) or `KPH` (kilometers per hour). + # + # For `DISTANCE_FROM_LAST_TRANSACTION`: `MILES` or `KILOMETERS`. + # + # @return [Symbol, Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Unit, nil] + optional :unit, + enum: -> { Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Unit } + + # @!method initialize(interval: nil, scope: nil, unit: nil) # Some parameter documentations has been truncated, see # {Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters} # for more details. # - # Additional parameters required for transaction history signal attributes. - # Required when `attribute` is one of `AMOUNT_Z_SCORE`, `AVG_TRANSACTION_AMOUNT`, - # `STDEV_TRANSACTION_AMOUNT`, `IS_NEW_COUNTRY`, `IS_NEW_MCC`, - # `IS_FIRST_TRANSACTION`, `CONSECUTIVE_DECLINES`, `TIME_SINCE_LAST_TRANSACTION`, - # or `DISTINCT_COUNTRY_COUNT`. Not used for other attributes. + # Additional parameters for certain attributes. Required when `attribute` is one + # of `AMOUNT_Z_SCORE`, `AVG_TRANSACTION_AMOUNT`, `STDEV_TRANSACTION_AMOUNT`, + # `IS_NEW_COUNTRY`, `IS_NEW_MCC`, `IS_FIRST_TRANSACTION`, `CONSECUTIVE_DECLINES`, + # `TIME_SINCE_LAST_TRANSACTION`, or `DISTINCT_COUNTRY_COUNT` (require `scope`); or + # `TRAVEL_SPEED` or `DISTANCE_FROM_LAST_TRANSACTION` (require `unit`). Not used + # for other attributes. # # @param interval [Symbol, Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Interval] The time window for statistical attributes (`AMOUNT_Z_SCORE`, `AVG_TRANSACTION_A # # @param scope [Symbol, Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Scope] The entity scope to evaluate the attribute against. + # + # @param unit [Symbol, Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Unit] The unit for impossible travel attributes. Required when `attribute` is + # `TRAVEL\_ # The time window for statistical attributes (`AMOUNT_Z_SCORE`, # `AVG_TRANSACTION_AMOUNT`, `STDEV_TRANSACTION_AMOUNT`). Use `LIFETIME` for @@ -391,6 +428,26 @@ module Scope # @!method self.values # @return [Array] end + + # The unit for impossible travel attributes. Required when `attribute` is + # `TRAVEL_SPEED` or `DISTANCE_FROM_LAST_TRANSACTION`. + # + # For `TRAVEL_SPEED`: `MPH` (miles per hour) or `KPH` (kilometers per hour). + # + # For `DISTANCE_FROM_LAST_TRANSACTION`: `MILES` or `KILOMETERS`. + # + # @see Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters#unit + module Unit + extend Lithic::Internal::Type::Enum + + MPH = :MPH + KPH = :KPH + MILES = :MILES + KILOMETERS = :KILOMETERS + + # @!method self.values + # @return [Array] + end end end end diff --git a/rbi/lithic/models/auth_rules/conditional_authorization_action_parameters.rbi b/rbi/lithic/models/auth_rules/conditional_authorization_action_parameters.rbi index b1469dc9..9475b196 100644 --- a/rbi/lithic/models/auth_rules/conditional_authorization_action_parameters.rbi +++ b/rbi/lithic/models/auth_rules/conditional_authorization_action_parameters.rbi @@ -207,6 +207,15 @@ module Lithic # `parameters` required. # - `THREE_DS_SUCCESS_RATE`: The 3DS authentication success rate for the card, as # a percentage from 0.0 to 100.0. Card-scoped only; no `parameters` required. + # - `TRAVEL_SPEED`: The estimated speed of travel derived from the distance + # between the postal code centers of the last card-present transaction and the + # current transaction, divided by the elapsed time. Null if there is no prior + # card-present transaction, if either postal code cannot be geocoded, or if + # elapsed time is zero. Requires `parameters.unit` set to `MPH` or `KPH`. + # - `DISTANCE_FROM_LAST_TRANSACTION`: The estimated distance between the postal + # code centers of the last card-present transaction and the current transaction. + # Null if there is no prior card-present transaction or if either postal code + # cannot be geocoded. Requires `parameters.unit` set to `MILES` or `KILOMETERS`. sig do returns( Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Attribute::OrSymbol @@ -222,11 +231,12 @@ module Lithic sig { returns(Lithic::AuthRules::ConditionalValue::Variants) } attr_accessor :value - # Additional parameters required for transaction history signal attributes. - # Required when `attribute` is one of `AMOUNT_Z_SCORE`, `AVG_TRANSACTION_AMOUNT`, - # `STDEV_TRANSACTION_AMOUNT`, `IS_NEW_COUNTRY`, `IS_NEW_MCC`, - # `IS_FIRST_TRANSACTION`, `CONSECUTIVE_DECLINES`, `TIME_SINCE_LAST_TRANSACTION`, - # or `DISTINCT_COUNTRY_COUNT`. Not used for other attributes. + # Additional parameters for certain attributes. Required when `attribute` is one + # of `AMOUNT_Z_SCORE`, `AVG_TRANSACTION_AMOUNT`, `STDEV_TRANSACTION_AMOUNT`, + # `IS_NEW_COUNTRY`, `IS_NEW_MCC`, `IS_FIRST_TRANSACTION`, `CONSECUTIVE_DECLINES`, + # `TIME_SINCE_LAST_TRANSACTION`, or `DISTINCT_COUNTRY_COUNT` (require `scope`); or + # `TRAVEL_SPEED` or `DISTANCE_FROM_LAST_TRANSACTION` (require `unit`). Not used + # for other attributes. sig do returns( T.nilable( @@ -357,16 +367,26 @@ module Lithic # `parameters` required. # - `THREE_DS_SUCCESS_RATE`: The 3DS authentication success rate for the card, as # a percentage from 0.0 to 100.0. Card-scoped only; no `parameters` required. + # - `TRAVEL_SPEED`: The estimated speed of travel derived from the distance + # between the postal code centers of the last card-present transaction and the + # current transaction, divided by the elapsed time. Null if there is no prior + # card-present transaction, if either postal code cannot be geocoded, or if + # elapsed time is zero. Requires `parameters.unit` set to `MPH` or `KPH`. + # - `DISTANCE_FROM_LAST_TRANSACTION`: The estimated distance between the postal + # code centers of the last card-present transaction and the current transaction. + # Null if there is no prior card-present transaction or if either postal code + # cannot be geocoded. Requires `parameters.unit` set to `MILES` or `KILOMETERS`. attribute:, # The operation to apply to the attribute operation:, # A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` value:, - # Additional parameters required for transaction history signal attributes. - # Required when `attribute` is one of `AMOUNT_Z_SCORE`, `AVG_TRANSACTION_AMOUNT`, - # `STDEV_TRANSACTION_AMOUNT`, `IS_NEW_COUNTRY`, `IS_NEW_MCC`, - # `IS_FIRST_TRANSACTION`, `CONSECUTIVE_DECLINES`, `TIME_SINCE_LAST_TRANSACTION`, - # or `DISTINCT_COUNTRY_COUNT`. Not used for other attributes. + # Additional parameters for certain attributes. Required when `attribute` is one + # of `AMOUNT_Z_SCORE`, `AVG_TRANSACTION_AMOUNT`, `STDEV_TRANSACTION_AMOUNT`, + # `IS_NEW_COUNTRY`, `IS_NEW_MCC`, `IS_FIRST_TRANSACTION`, `CONSECUTIVE_DECLINES`, + # `TIME_SINCE_LAST_TRANSACTION`, or `DISTINCT_COUNTRY_COUNT` (require `scope`); or + # `TRAVEL_SPEED` or `DISTANCE_FROM_LAST_TRANSACTION` (require `unit`). Not used + # for other attributes. parameters: nil ) end @@ -488,6 +508,15 @@ module Lithic # `parameters` required. # - `THREE_DS_SUCCESS_RATE`: The 3DS authentication success rate for the card, as # a percentage from 0.0 to 100.0. Card-scoped only; no `parameters` required. + # - `TRAVEL_SPEED`: The estimated speed of travel derived from the distance + # between the postal code centers of the last card-present transaction and the + # current transaction, divided by the elapsed time. Null if there is no prior + # card-present transaction, if either postal code cannot be geocoded, or if + # elapsed time is zero. Requires `parameters.unit` set to `MPH` or `KPH`. + # - `DISTANCE_FROM_LAST_TRANSACTION`: The estimated distance between the postal + # code centers of the last card-present transaction and the current transaction. + # Null if there is no prior card-present transaction or if either postal code + # cannot be geocoded. Requires `parameters.unit` set to `MILES` or `KILOMETERS`. module Attribute extend Lithic::Internal::Type::Enum @@ -685,6 +714,16 @@ module Lithic :THREE_DS_SUCCESS_RATE, Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Attribute::TaggedSymbol ) + TRAVEL_SPEED = + T.let( + :TRAVEL_SPEED, + Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Attribute::TaggedSymbol + ) + DISTANCE_FROM_LAST_TRANSACTION = + T.let( + :DISTANCE_FROM_LAST_TRANSACTION, + Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Attribute::TaggedSymbol + ) sig do override.returns( @@ -744,17 +783,43 @@ module Lithic end attr_writer :scope - # Additional parameters required for transaction history signal attributes. - # Required when `attribute` is one of `AMOUNT_Z_SCORE`, `AVG_TRANSACTION_AMOUNT`, - # `STDEV_TRANSACTION_AMOUNT`, `IS_NEW_COUNTRY`, `IS_NEW_MCC`, - # `IS_FIRST_TRANSACTION`, `CONSECUTIVE_DECLINES`, `TIME_SINCE_LAST_TRANSACTION`, - # or `DISTINCT_COUNTRY_COUNT`. Not used for other attributes. + # The unit for impossible travel attributes. Required when `attribute` is + # `TRAVEL_SPEED` or `DISTANCE_FROM_LAST_TRANSACTION`. + # + # For `TRAVEL_SPEED`: `MPH` (miles per hour) or `KPH` (kilometers per hour). + # + # For `DISTANCE_FROM_LAST_TRANSACTION`: `MILES` or `KILOMETERS`. + sig do + returns( + T.nilable( + Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Unit::OrSymbol + ) + ) + end + attr_reader :unit + + sig do + params( + unit: + Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Unit::OrSymbol + ).void + end + attr_writer :unit + + # Additional parameters for certain attributes. Required when `attribute` is one + # of `AMOUNT_Z_SCORE`, `AVG_TRANSACTION_AMOUNT`, `STDEV_TRANSACTION_AMOUNT`, + # `IS_NEW_COUNTRY`, `IS_NEW_MCC`, `IS_FIRST_TRANSACTION`, `CONSECUTIVE_DECLINES`, + # `TIME_SINCE_LAST_TRANSACTION`, or `DISTINCT_COUNTRY_COUNT` (require `scope`); or + # `TRAVEL_SPEED` or `DISTANCE_FROM_LAST_TRANSACTION` (require `unit`). Not used + # for other attributes. sig do params( interval: Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Interval::OrSymbol, scope: - Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Scope::OrSymbol + Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Scope::OrSymbol, + unit: + Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Unit::OrSymbol ).returns(T.attached_class) end def self.new( @@ -763,7 +828,14 @@ module Lithic # all-time history or a specific window (`7D`, `30D`, `90D`). interval: nil, # The entity scope to evaluate the attribute against. - scope: nil + scope: nil, + # The unit for impossible travel attributes. Required when `attribute` is + # `TRAVEL_SPEED` or `DISTANCE_FROM_LAST_TRANSACTION`. + # + # For `TRAVEL_SPEED`: `MPH` (miles per hour) or `KPH` (kilometers per hour). + # + # For `DISTANCE_FROM_LAST_TRANSACTION`: `MILES` or `KILOMETERS`. + unit: nil ) end @@ -773,7 +845,9 @@ module Lithic interval: Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Interval::OrSymbol, scope: - Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Scope::OrSymbol + Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Scope::OrSymbol, + unit: + Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Unit::OrSymbol } ) end @@ -866,6 +940,56 @@ module Lithic def self.values end end + + # The unit for impossible travel attributes. Required when `attribute` is + # `TRAVEL_SPEED` or `DISTANCE_FROM_LAST_TRANSACTION`. + # + # For `TRAVEL_SPEED`: `MPH` (miles per hour) or `KPH` (kilometers per hour). + # + # For `DISTANCE_FROM_LAST_TRANSACTION`: `MILES` or `KILOMETERS`. + module Unit + extend Lithic::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all( + Symbol, + Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Unit + ) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + MPH = + T.let( + :MPH, + Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Unit::TaggedSymbol + ) + KPH = + T.let( + :KPH, + Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Unit::TaggedSymbol + ) + MILES = + T.let( + :MILES, + Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Unit::TaggedSymbol + ) + KILOMETERS = + T.let( + :KILOMETERS, + Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Unit::TaggedSymbol + ) + + sig do + override.returns( + T::Array[ + Lithic::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::Unit::TaggedSymbol + ] + ) + end + def self.values + end + end end end end diff --git a/sig/lithic/models/auth_rules/conditional_authorization_action_parameters.rbs b/sig/lithic/models/auth_rules/conditional_authorization_action_parameters.rbs index ab0b560f..c19412e0 100644 --- a/sig/lithic/models/auth_rules/conditional_authorization_action_parameters.rbs +++ b/sig/lithic/models/auth_rules/conditional_authorization_action_parameters.rbs @@ -106,6 +106,8 @@ module Lithic | :DISTINCT_COUNTRY_COUNT | :IS_NEW_MERCHANT | :THREE_DS_SUCCESS_RATE + | :TRAVEL_SPEED + | :DISTANCE_FROM_LAST_TRANSACTION module Attribute extend Lithic::Internal::Type::Enum @@ -147,6 +149,8 @@ module Lithic DISTINCT_COUNTRY_COUNT: :DISTINCT_COUNTRY_COUNT IS_NEW_MERCHANT: :IS_NEW_MERCHANT THREE_DS_SUCCESS_RATE: :THREE_DS_SUCCESS_RATE + TRAVEL_SPEED: :TRAVEL_SPEED + DISTANCE_FROM_LAST_TRANSACTION: :DISTANCE_FROM_LAST_TRANSACTION def self?.values: -> ::Array[Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::attribute] end @@ -154,7 +158,8 @@ module Lithic type parameters = { interval: Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::interval, - scope: Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::scope + scope: Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::scope, + unit: Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::unit } class Parameters < Lithic::Internal::Type::BaseModel @@ -170,14 +175,22 @@ module Lithic Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::scope ) -> Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::scope + attr_reader unit: Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::unit? + + def unit=: ( + Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::unit + ) -> Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::unit + def initialize: ( ?interval: Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::interval, - ?scope: Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::scope + ?scope: Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::scope, + ?unit: Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::unit ) -> void def to_hash: -> { interval: Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::interval, - scope: Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::scope + scope: Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::scope, + unit: Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::unit } type interval = :LIFETIME | :"7D" | :"30D" | :"90D" @@ -204,6 +217,19 @@ module Lithic def self?.values: -> ::Array[Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::scope] end + + type unit = :MPH | :KPH | :MILES | :KILOMETERS + + module Unit + extend Lithic::Internal::Type::Enum + + MPH: :MPH + KPH: :KPH + MILES: :MILES + KILOMETERS: :KILOMETERS + + def self?.values: -> ::Array[Lithic::Models::AuthRules::ConditionalAuthorizationActionParameters::Condition::Parameters::unit] + end end end end From c6446ffce562ebe1d451d86a56372e3bf91004e9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 8 May 2026 17:08:30 +0000 Subject: [PATCH 2/3] feat(api): add retrieve_signals method to accounts and cards --- .stats.yml | 6 +- lib/lithic.rb | 3 + lib/lithic/models.rb | 6 + .../models/account_retrieve_signals_params.rb | 20 + .../models/card_retrieve_signals_params.rb | 20 + lib/lithic/models/signals_response.rb | 306 +++++++++++++++ lib/lithic/resources/accounts.rb | 27 ++ lib/lithic/resources/cards.rb | 25 ++ rbi/lithic/models.rbi | 6 + .../account_retrieve_signals_params.rbi | 35 ++ .../models/card_retrieve_signals_params.rbi | 35 ++ rbi/lithic/models/signals_response.rbi | 352 ++++++++++++++++++ rbi/lithic/resources/accounts.rbi | 21 ++ rbi/lithic/resources/cards.rbi | 19 + sig/lithic/models.rbs | 6 + .../account_retrieve_signals_params.rbs | 23 ++ .../models/card_retrieve_signals_params.rbs | 23 ++ sig/lithic/models/signals_response.rbs | 170 +++++++++ sig/lithic/resources/accounts.rbs | 5 + sig/lithic/resources/cards.rbs | 5 + test/lithic/resources/accounts_test.rb | 44 +++ test/lithic/resources/cards_test.rb | 44 +++ 22 files changed, 1198 insertions(+), 3 deletions(-) create mode 100644 lib/lithic/models/account_retrieve_signals_params.rb create mode 100644 lib/lithic/models/card_retrieve_signals_params.rb create mode 100644 lib/lithic/models/signals_response.rb create mode 100644 rbi/lithic/models/account_retrieve_signals_params.rbi create mode 100644 rbi/lithic/models/card_retrieve_signals_params.rbi create mode 100644 rbi/lithic/models/signals_response.rbi create mode 100644 sig/lithic/models/account_retrieve_signals_params.rbs create mode 100644 sig/lithic/models/card_retrieve_signals_params.rbs create mode 100644 sig/lithic/models/signals_response.rbs diff --git a/.stats.yml b/.stats.yml index 11ef5a19..9a940850 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 191 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic/lithic-af9701d01abffc53ba2bf56c06415d893460e6b420f122e602cf4afe67bbf57b.yml +configured_endpoints: 193 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic/lithic-00f07b0edcc0c3c5ef79920ced7f58dac2434df5e4c27ff6041783e8228315f9.yml openapi_spec_hash: 963688b09480159a06865075c94a2577 -config_hash: 01dfc901bb6d54b0f582155d779bcbe0 +config_hash: 265a2b679964f4ad5706de101ad2a942 diff --git a/lib/lithic.rb b/lib/lithic.rb index 28dde370..1137bedd 100644 --- a/lib/lithic.rb +++ b/lib/lithic.rb @@ -109,6 +109,7 @@ require_relative "lithic/models/account_holder_verification_webhook_event" require_relative "lithic/models/account_list_params" require_relative "lithic/models/account_retrieve_params" +require_relative "lithic/models/account_retrieve_signals_params" require_relative "lithic/models/account_retrieve_spend_limits_params" require_relative "lithic/models/account_spend_limits" require_relative "lithic/models/account_update_params" @@ -195,6 +196,7 @@ require_relative "lithic/models/card_renewed_webhook_event" require_relative "lithic/models/card_renew_params" require_relative "lithic/models/card_retrieve_params" +require_relative "lithic/models/card_retrieve_signals_params" require_relative "lithic/models/card_retrieve_spend_limits_params" require_relative "lithic/models/cards/balance_list_params" require_relative "lithic/models/cards/financial_transaction_list_params" @@ -394,6 +396,7 @@ require_relative "lithic/models/settlement_report_updated_webhook_event" require_relative "lithic/models/settlement_summary_details" require_relative "lithic/models/shipping_address" +require_relative "lithic/models/signals_response" require_relative "lithic/models/spend_limit_duration" require_relative "lithic/models/statements_created_webhook_event" require_relative "lithic/models/statement_totals" diff --git a/lib/lithic/models.rb b/lib/lithic/models.rb index baf6f347..40841577 100644 --- a/lib/lithic/models.rb +++ b/lib/lithic/models.rb @@ -82,6 +82,8 @@ module Lithic AccountRetrieveParams = Lithic::Models::AccountRetrieveParams + AccountRetrieveSignalsParams = Lithic::Models::AccountRetrieveSignalsParams + AccountRetrieveSpendLimitsParams = Lithic::Models::AccountRetrieveSpendLimitsParams AccountSpendLimits = Lithic::Models::AccountSpendLimits @@ -176,6 +178,8 @@ module Lithic CardRetrieveParams = Lithic::Models::CardRetrieveParams + CardRetrieveSignalsParams = Lithic::Models::CardRetrieveSignalsParams + CardRetrieveSpendLimitsParams = Lithic::Models::CardRetrieveSpendLimitsParams Cards = Lithic::Models::Cards @@ -487,6 +491,8 @@ module Lithic ShippingAddress = Lithic::Models::ShippingAddress + SignalsResponse = Lithic::Models::SignalsResponse + SpendLimitDuration = Lithic::Models::SpendLimitDuration StatementsCreatedWebhookEvent = Lithic::Models::StatementsCreatedWebhookEvent diff --git a/lib/lithic/models/account_retrieve_signals_params.rb b/lib/lithic/models/account_retrieve_signals_params.rb new file mode 100644 index 00000000..27465948 --- /dev/null +++ b/lib/lithic/models/account_retrieve_signals_params.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Lithic + module Models + # @see Lithic::Resources::Accounts#retrieve_signals + class AccountRetrieveSignalsParams < Lithic::Internal::Type::BaseModel + extend Lithic::Internal::Type::RequestParameters::Converter + include Lithic::Internal::Type::RequestParameters + + # @!attribute account_token + # + # @return [String] + required :account_token, String + + # @!method initialize(account_token:, request_options: {}) + # @param account_token [String] + # @param request_options [Lithic::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/lithic/models/card_retrieve_signals_params.rb b/lib/lithic/models/card_retrieve_signals_params.rb new file mode 100644 index 00000000..dfed450c --- /dev/null +++ b/lib/lithic/models/card_retrieve_signals_params.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Lithic + module Models + # @see Lithic::Resources::Cards#retrieve_signals + class CardRetrieveSignalsParams < Lithic::Internal::Type::BaseModel + extend Lithic::Internal::Type::RequestParameters::Converter + include Lithic::Internal::Type::RequestParameters + + # @!attribute card_token + # + # @return [String] + required :card_token, String + + # @!method initialize(card_token:, request_options: {}) + # @param card_token [String] + # @param request_options [Lithic::RequestOptions, Hash{Symbol=>Object}] + end + end +end diff --git a/lib/lithic/models/signals_response.rb b/lib/lithic/models/signals_response.rb new file mode 100644 index 00000000..ec0f0a18 --- /dev/null +++ b/lib/lithic/models/signals_response.rb @@ -0,0 +1,306 @@ +# frozen_string_literal: true + +module Lithic + module Models + class SignalsResponse < Lithic::Internal::Type::BaseModel + # @!attribute approved_txn_amount_m2 + # The Welford M2 accumulator for lifetime approved transaction amounts. Used + # together with `avg_transaction_amount` and `approved_txn_count` to compute the + # z-score of a new transaction amount (variance = M2 / (count - 1)). + # + # @return [Float, nil] + required :approved_txn_amount_m2, Float, nil?: true + + # @!attribute approved_txn_amount_m2_30d + # The Welford M2 accumulator for approved transaction amounts over the last 30 + # days. + # + # @return [Float, nil] + required :approved_txn_amount_m2_30d, Float, nil?: true + + # @!attribute approved_txn_amount_m2_7d + # The Welford M2 accumulator for approved transaction amounts over the last 7 + # days. + # + # @return [Float, nil] + required :approved_txn_amount_m2_7d, Float, nil?: true + + # @!attribute approved_txn_amount_m2_90d + # The Welford M2 accumulator for approved transaction amounts over the last 90 + # days. + # + # @return [Float, nil] + required :approved_txn_amount_m2_90d, Float, nil?: true + + # @!attribute approved_txn_count + # The total number of approved transactions over the entity's lifetime. + # + # @return [Integer, nil] + required :approved_txn_count, Integer, nil?: true + + # @!attribute approved_txn_count_30d + # The number of approved transactions in the last 30 days. + # + # @return [Integer, nil] + required :approved_txn_count_30d, Integer, nil?: true + + # @!attribute approved_txn_count_7d + # The number of approved transactions in the last 7 days. + # + # @return [Integer, nil] + required :approved_txn_count_7d, Integer, nil?: true + + # @!attribute approved_txn_count_90d + # The number of approved transactions in the last 90 days. + # + # @return [Integer, nil] + required :approved_txn_count_90d, Integer, nil?: true + + # @!attribute avg_transaction_amount + # The average approved transaction amount over the entity's lifetime, in cents. + # Null if fewer than 5 approved transactions have been recorded. + # + # @return [Float, nil] + required :avg_transaction_amount, Float, nil?: true + + # @!attribute avg_transaction_amount_30d + # The average approved transaction amount over the last 30 days, in cents. Null if + # fewer than 5 approved transactions in window. + # + # @return [Float, nil] + required :avg_transaction_amount_30d, Float, nil?: true + + # @!attribute avg_transaction_amount_7d + # The average approved transaction amount over the last 7 days, in cents. Null if + # fewer than 5 approved transactions in window. + # + # @return [Float, nil] + required :avg_transaction_amount_7d, Float, nil?: true + + # @!attribute avg_transaction_amount_90d + # The average approved transaction amount over the last 90 days, in cents. Null if + # fewer than 5 approved transactions in window. + # + # @return [Float, nil] + required :avg_transaction_amount_90d, Float, nil?: true + + # @!attribute distinct_country_count + # The number of distinct merchant countries seen in the entity's transaction + # history. + # + # @return [Integer, nil] + required :distinct_country_count, Integer, nil?: true + + # @!attribute distinct_mcc_count + # The number of distinct MCCs seen in the entity's transaction history. + # + # @return [Integer, nil] + required :distinct_mcc_count, Integer, nil?: true + + # @!attribute first_txn_at + # The timestamp of the first approved transaction for the entity, in ISO 8601 + # format. + # + # @return [Time, nil] + required :first_txn_at, Time, nil?: true + + # @!attribute is_first_transaction + # Whether the entity has no prior transaction history. Returns true if no history + # is found. Null if transaction history exists but a first transaction timestamp + # is unavailable. + # + # @return [Boolean, nil] + required :is_first_transaction, Lithic::Internal::Type::Boolean, nil?: true + + # @!attribute last_cp_country + # The merchant country of the last card-present transaction. + # + # @return [String, nil] + required :last_cp_country, String, nil?: true + + # @!attribute last_cp_postal_code + # The merchant postal code of the last card-present transaction. + # + # @return [String, nil] + required :last_cp_postal_code, String, nil?: true + + # @!attribute last_cp_timestamp + # The timestamp of the last card-present transaction, in ISO 8601 format. + # + # @return [Time, nil] + required :last_cp_timestamp, Time, nil?: true + + # @!attribute last_txn_approved_at + # The timestamp of the most recent approved transaction for the entity, in ISO + # 8601 format. + # + # @return [Time, nil] + required :last_txn_approved_at, Time, nil?: true + + # @!attribute seen_countries + # The set of merchant countries seen in the entity's transaction history. Clients + # can use this to determine whether a new transaction's country is novel (i.e. + # compute `is_new_country`). + # + # @return [Array, nil] + required :seen_countries, Lithic::Internal::Type::ArrayOf[String], nil?: true + + # @!attribute seen_mccs + # The set of MCCs seen in the entity's transaction history. Clients can use this + # to determine whether a new transaction's MCC is novel (i.e. compute + # `is_new_mcc`). + # + # @return [Array, nil] + required :seen_mccs, Lithic::Internal::Type::ArrayOf[String], nil?: true + + # @!attribute seen_merchants + # The set of card acceptor IDs seen in the card's approved transaction history, + # capped at the 1000 most recently seen. Null for account responses. Clients can + # use this to determine whether a new transaction's merchant is novel (i.e. + # compute `is_new_merchant`). + # + # @return [Array, nil] + required :seen_merchants, Lithic::Internal::Type::ArrayOf[String], nil?: true + + # @!attribute stdev_transaction_amount + # The standard deviation of approved transaction amounts over the entity's + # lifetime, in cents. Null if fewer than 30 approved transactions have been + # recorded. + # + # @return [Float, nil] + required :stdev_transaction_amount, Float, nil?: true + + # @!attribute stdev_transaction_amount_30d + # The standard deviation of approved transaction amounts over the last 30 days, in + # cents. Null if fewer than 30 approved transactions in window. + # + # @return [Float, nil] + required :stdev_transaction_amount_30d, Float, nil?: true + + # @!attribute stdev_transaction_amount_7d + # The standard deviation of approved transaction amounts over the last 7 days, in + # cents. Null if fewer than 30 approved transactions in window. + # + # @return [Float, nil] + required :stdev_transaction_amount_7d, Float, nil?: true + + # @!attribute stdev_transaction_amount_90d + # The standard deviation of approved transaction amounts over the last 90 days, in + # cents. Null if fewer than 30 approved transactions in window. + # + # @return [Float, nil] + required :stdev_transaction_amount_90d, Float, nil?: true + + # @!attribute three_ds_success_count + # The number of successful 3DS authentications for the card. Null for account + # responses. + # + # @return [Integer, nil] + required :three_ds_success_count, Integer, nil?: true + + # @!attribute three_ds_success_rate + # The 3DS authentication success rate for the card, as a percentage from 0.0 to + # 100.0. Null for account responses. + # + # @return [Float, nil] + required :three_ds_success_rate, Float, nil?: true + + # @!attribute three_ds_total_count + # The total number of 3DS authentication attempts for the card. Null for account + # responses. + # + # @return [Integer, nil] + required :three_ds_total_count, Integer, nil?: true + + # @!attribute time_since_last_transaction_days + # The number of days since the last approved transaction on the entity. + # + # @return [Float, nil] + required :time_since_last_transaction_days, Float, nil?: true + + # @!method initialize(approved_txn_amount_m2:, approved_txn_amount_m2_30d:, approved_txn_amount_m2_7d:, approved_txn_amount_m2_90d:, approved_txn_count:, approved_txn_count_30d:, approved_txn_count_7d:, approved_txn_count_90d:, avg_transaction_amount:, avg_transaction_amount_30d:, avg_transaction_amount_7d:, avg_transaction_amount_90d:, distinct_country_count:, distinct_mcc_count:, first_txn_at:, is_first_transaction:, last_cp_country:, last_cp_postal_code:, last_cp_timestamp:, last_txn_approved_at:, seen_countries:, seen_mccs:, seen_merchants:, stdev_transaction_amount:, stdev_transaction_amount_30d:, stdev_transaction_amount_7d:, stdev_transaction_amount_90d:, three_ds_success_count:, three_ds_success_rate:, three_ds_total_count:, time_since_last_transaction_days:) + # Some parameter documentations has been truncated, see + # {Lithic::Models::SignalsResponse} for more details. + # + # Behavioral feature state for a card or account derived from its transaction + # history. + # + # Derived statistical features (averages, standard deviations, z-scores) are + # computed using Welford's online algorithm over approved transactions. Average + # fields are null when fewer than 5 approved transactions have been recorded. + # Standard deviation fields are null when fewer than 30 approved transactions have + # been recorded. + # + # 3DS fields (`three_ds_success_rate`, `three_ds_success_count`, + # `three_ds_total_count`) are card-scoped and will be null for account responses. + # + # Raw fields (`seen_countries`, `seen_mccs`, `approved_txn_amount_m2`, etc.) are + # included so clients can compute their own transaction-specific derivations, such + # as checking whether a new transaction's country is in `seen_countries` to + # determine `is_new_country`, or computing a z-score using the raw mean and M2 + # values. + # + # @param approved_txn_amount_m2 [Float, nil] The Welford M2 accumulator for lifetime approved transaction amounts. Used toget + # + # @param approved_txn_amount_m2_30d [Float, nil] The Welford M2 accumulator for approved transaction amounts over the last 30 day + # + # @param approved_txn_amount_m2_7d [Float, nil] The Welford M2 accumulator for approved transaction amounts over the last 7 days + # + # @param approved_txn_amount_m2_90d [Float, nil] The Welford M2 accumulator for approved transaction amounts over the last 90 day + # + # @param approved_txn_count [Integer, nil] The total number of approved transactions over the entity's lifetime. + # + # @param approved_txn_count_30d [Integer, nil] The number of approved transactions in the last 30 days. + # + # @param approved_txn_count_7d [Integer, nil] The number of approved transactions in the last 7 days. + # + # @param approved_txn_count_90d [Integer, nil] The number of approved transactions in the last 90 days. + # + # @param avg_transaction_amount [Float, nil] The average approved transaction amount over the entity's lifetime, in cents. Nu + # + # @param avg_transaction_amount_30d [Float, nil] The average approved transaction amount over the last 30 days, in cents. Null if + # + # @param avg_transaction_amount_7d [Float, nil] The average approved transaction amount over the last 7 days, in cents. Null if + # + # @param avg_transaction_amount_90d [Float, nil] The average approved transaction amount over the last 90 days, in cents. Null if + # + # @param distinct_country_count [Integer, nil] The number of distinct merchant countries seen in the entity's transaction histo + # + # @param distinct_mcc_count [Integer, nil] The number of distinct MCCs seen in the entity's transaction history. + # + # @param first_txn_at [Time, nil] The timestamp of the first approved transaction for the entity, in ISO 8601 form + # + # @param is_first_transaction [Boolean, nil] Whether the entity has no prior transaction history. Returns true if no history + # + # @param last_cp_country [String, nil] The merchant country of the last card-present transaction. + # + # @param last_cp_postal_code [String, nil] The merchant postal code of the last card-present transaction. + # + # @param last_cp_timestamp [Time, nil] The timestamp of the last card-present transaction, in ISO 8601 format. + # + # @param last_txn_approved_at [Time, nil] The timestamp of the most recent approved transaction for the entity, in ISO 860 + # + # @param seen_countries [Array, nil] The set of merchant countries seen in the entity's transaction history. Clients + # + # @param seen_mccs [Array, nil] The set of MCCs seen in the entity's transaction history. Clients can use this t + # + # @param seen_merchants [Array, nil] The set of card acceptor IDs seen in the card's approved transaction history, ca + # + # @param stdev_transaction_amount [Float, nil] The standard deviation of approved transaction amounts over the entity's lifetim + # + # @param stdev_transaction_amount_30d [Float, nil] The standard deviation of approved transaction amounts over the last 30 days, in + # + # @param stdev_transaction_amount_7d [Float, nil] The standard deviation of approved transaction amounts over the last 7 days, in + # + # @param stdev_transaction_amount_90d [Float, nil] The standard deviation of approved transaction amounts over the last 90 days, in + # + # @param three_ds_success_count [Integer, nil] The number of successful 3DS authentications for the card. Null for account resp + # + # @param three_ds_success_rate [Float, nil] The 3DS authentication success rate for the card, as a percentage from 0.0 to 10 + # + # @param three_ds_total_count [Integer, nil] The total number of 3DS authentication attempts for the card. Null for account r + # + # @param time_since_last_transaction_days [Float, nil] The number of days since the last approved transaction on the entity. + end + end +end diff --git a/lib/lithic/resources/accounts.rb b/lib/lithic/resources/accounts.rb index 421ac64e..018a3f11 100644 --- a/lib/lithic/resources/accounts.rb +++ b/lib/lithic/resources/accounts.rb @@ -99,6 +99,33 @@ def list(params = {}) ) end + # Returns behavioral feature state derived from an account's transaction history. + # + # These signals expose the same data used by behavioral rule attributes (e.g. + # `AMOUNT_Z_SCORE` with `scope: ACCOUNT`, `IS_NEW_COUNTRY` with `scope: ACCOUNT`) + # and custom code `TRANSACTION_HISTORY_SIGNALS` features, allowing clients to + # inspect feature values before writing rules and debug rule behavior. + # + # Note: 3DS fields are not available at the account scope and will be null. + # + # @overload retrieve_signals(account_token, request_options: {}) + # + # @param account_token [String] The token of the account to fetch signals for. + # + # @param request_options [Lithic::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Lithic::Models::SignalsResponse] + # + # @see Lithic::Models::AccountRetrieveSignalsParams + def retrieve_signals(account_token, params = {}) + @client.request( + method: :get, + path: ["v1/accounts/%1$s/signals", account_token], + model: Lithic::SignalsResponse, + options: params[:request_options] + ) + end + # Get an Account's available spend limits, which is based on the spend limit # configured on the Account and the amount already spent over the spend limit's # duration. For example, if the Account has a daily spend limit of $1000 diff --git a/lib/lithic/resources/cards.rb b/lib/lithic/resources/cards.rb index 37e40cb1..029ef58d 100644 --- a/lib/lithic/resources/cards.rb +++ b/lib/lithic/resources/cards.rb @@ -404,6 +404,31 @@ def renew(card_token, params) ) end + # Returns behavioral feature state derived from a card's transaction history. + # + # These signals expose the same data used by behavioral rule attributes (e.g. + # `AMOUNT_Z_SCORE` with `scope: CARD`, `IS_NEW_COUNTRY` with `scope: CARD`) and + # custom code `TRANSACTION_HISTORY_SIGNALS` features, allowing clients to inspect + # feature values before writing rules and debug rule behavior. + # + # @overload retrieve_signals(card_token, request_options: {}) + # + # @param card_token [String] The token of the card to fetch signals for. + # + # @param request_options [Lithic::RequestOptions, Hash{Symbol=>Object}, nil] + # + # @return [Lithic::Models::SignalsResponse] + # + # @see Lithic::Models::CardRetrieveSignalsParams + def retrieve_signals(card_token, params = {}) + @client.request( + method: :get, + path: ["v1/cards/%1$s/signals", card_token], + model: Lithic::SignalsResponse, + options: params[:request_options] + ) + end + # Get a Card's available spend limit, which is based on the spend limit configured # on the Card and the amount already spent over the spend limit's duration. For # example, if the Card has a monthly spend limit of $1000 configured, and has diff --git a/rbi/lithic/models.rbi b/rbi/lithic/models.rbi index b5750b72..9a7bcb63 100644 --- a/rbi/lithic/models.rbi +++ b/rbi/lithic/models.rbi @@ -53,6 +53,8 @@ module Lithic AccountRetrieveParams = Lithic::Models::AccountRetrieveParams + AccountRetrieveSignalsParams = Lithic::Models::AccountRetrieveSignalsParams + AccountRetrieveSpendLimitsParams = Lithic::Models::AccountRetrieveSpendLimitsParams @@ -153,6 +155,8 @@ module Lithic CardRetrieveParams = Lithic::Models::CardRetrieveParams + CardRetrieveSignalsParams = Lithic::Models::CardRetrieveSignalsParams + CardRetrieveSpendLimitsParams = Lithic::Models::CardRetrieveSpendLimitsParams Cards = Lithic::Models::Cards @@ -501,6 +505,8 @@ module Lithic ShippingAddress = Lithic::Models::ShippingAddress + SignalsResponse = Lithic::Models::SignalsResponse + SpendLimitDuration = Lithic::Models::SpendLimitDuration StatementsCreatedWebhookEvent = Lithic::Models::StatementsCreatedWebhookEvent diff --git a/rbi/lithic/models/account_retrieve_signals_params.rbi b/rbi/lithic/models/account_retrieve_signals_params.rbi new file mode 100644 index 00000000..c5b15ace --- /dev/null +++ b/rbi/lithic/models/account_retrieve_signals_params.rbi @@ -0,0 +1,35 @@ +# typed: strong + +module Lithic + module Models + class AccountRetrieveSignalsParams < Lithic::Internal::Type::BaseModel + extend Lithic::Internal::Type::RequestParameters::Converter + include Lithic::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Lithic::AccountRetrieveSignalsParams, Lithic::Internal::AnyHash) + end + + sig { returns(String) } + attr_accessor :account_token + + sig do + params( + account_token: String, + request_options: Lithic::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(account_token:, request_options: {}) + end + + sig do + override.returns( + { account_token: String, request_options: Lithic::RequestOptions } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/lithic/models/card_retrieve_signals_params.rbi b/rbi/lithic/models/card_retrieve_signals_params.rbi new file mode 100644 index 00000000..223da171 --- /dev/null +++ b/rbi/lithic/models/card_retrieve_signals_params.rbi @@ -0,0 +1,35 @@ +# typed: strong + +module Lithic + module Models + class CardRetrieveSignalsParams < Lithic::Internal::Type::BaseModel + extend Lithic::Internal::Type::RequestParameters::Converter + include Lithic::Internal::Type::RequestParameters + + OrHash = + T.type_alias do + T.any(Lithic::CardRetrieveSignalsParams, Lithic::Internal::AnyHash) + end + + sig { returns(String) } + attr_accessor :card_token + + sig do + params( + card_token: String, + request_options: Lithic::RequestOptions::OrHash + ).returns(T.attached_class) + end + def self.new(card_token:, request_options: {}) + end + + sig do + override.returns( + { card_token: String, request_options: Lithic::RequestOptions } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/lithic/models/signals_response.rbi b/rbi/lithic/models/signals_response.rbi new file mode 100644 index 00000000..9c2caae6 --- /dev/null +++ b/rbi/lithic/models/signals_response.rbi @@ -0,0 +1,352 @@ +# typed: strong + +module Lithic + module Models + class SignalsResponse < Lithic::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Lithic::SignalsResponse, Lithic::Internal::AnyHash) + end + + # The Welford M2 accumulator for lifetime approved transaction amounts. Used + # together with `avg_transaction_amount` and `approved_txn_count` to compute the + # z-score of a new transaction amount (variance = M2 / (count - 1)). + sig { returns(T.nilable(Float)) } + attr_accessor :approved_txn_amount_m2 + + # The Welford M2 accumulator for approved transaction amounts over the last 30 + # days. + sig { returns(T.nilable(Float)) } + attr_accessor :approved_txn_amount_m2_30d + + # The Welford M2 accumulator for approved transaction amounts over the last 7 + # days. + sig { returns(T.nilable(Float)) } + attr_accessor :approved_txn_amount_m2_7d + + # The Welford M2 accumulator for approved transaction amounts over the last 90 + # days. + sig { returns(T.nilable(Float)) } + attr_accessor :approved_txn_amount_m2_90d + + # The total number of approved transactions over the entity's lifetime. + sig { returns(T.nilable(Integer)) } + attr_accessor :approved_txn_count + + # The number of approved transactions in the last 30 days. + sig { returns(T.nilable(Integer)) } + attr_accessor :approved_txn_count_30d + + # The number of approved transactions in the last 7 days. + sig { returns(T.nilable(Integer)) } + attr_accessor :approved_txn_count_7d + + # The number of approved transactions in the last 90 days. + sig { returns(T.nilable(Integer)) } + attr_accessor :approved_txn_count_90d + + # The average approved transaction amount over the entity's lifetime, in cents. + # Null if fewer than 5 approved transactions have been recorded. + sig { returns(T.nilable(Float)) } + attr_accessor :avg_transaction_amount + + # The average approved transaction amount over the last 30 days, in cents. Null if + # fewer than 5 approved transactions in window. + sig { returns(T.nilable(Float)) } + attr_accessor :avg_transaction_amount_30d + + # The average approved transaction amount over the last 7 days, in cents. Null if + # fewer than 5 approved transactions in window. + sig { returns(T.nilable(Float)) } + attr_accessor :avg_transaction_amount_7d + + # The average approved transaction amount over the last 90 days, in cents. Null if + # fewer than 5 approved transactions in window. + sig { returns(T.nilable(Float)) } + attr_accessor :avg_transaction_amount_90d + + # The number of distinct merchant countries seen in the entity's transaction + # history. + sig { returns(T.nilable(Integer)) } + attr_accessor :distinct_country_count + + # The number of distinct MCCs seen in the entity's transaction history. + sig { returns(T.nilable(Integer)) } + attr_accessor :distinct_mcc_count + + # The timestamp of the first approved transaction for the entity, in ISO 8601 + # format. + sig { returns(T.nilable(Time)) } + attr_accessor :first_txn_at + + # Whether the entity has no prior transaction history. Returns true if no history + # is found. Null if transaction history exists but a first transaction timestamp + # is unavailable. + sig { returns(T.nilable(T::Boolean)) } + attr_accessor :is_first_transaction + + # The merchant country of the last card-present transaction. + sig { returns(T.nilable(String)) } + attr_accessor :last_cp_country + + # The merchant postal code of the last card-present transaction. + sig { returns(T.nilable(String)) } + attr_accessor :last_cp_postal_code + + # The timestamp of the last card-present transaction, in ISO 8601 format. + sig { returns(T.nilable(Time)) } + attr_accessor :last_cp_timestamp + + # The timestamp of the most recent approved transaction for the entity, in ISO + # 8601 format. + sig { returns(T.nilable(Time)) } + attr_accessor :last_txn_approved_at + + # The set of merchant countries seen in the entity's transaction history. Clients + # can use this to determine whether a new transaction's country is novel (i.e. + # compute `is_new_country`). + sig { returns(T.nilable(T::Array[String])) } + attr_accessor :seen_countries + + # The set of MCCs seen in the entity's transaction history. Clients can use this + # to determine whether a new transaction's MCC is novel (i.e. compute + # `is_new_mcc`). + sig { returns(T.nilable(T::Array[String])) } + attr_accessor :seen_mccs + + # The set of card acceptor IDs seen in the card's approved transaction history, + # capped at the 1000 most recently seen. Null for account responses. Clients can + # use this to determine whether a new transaction's merchant is novel (i.e. + # compute `is_new_merchant`). + sig { returns(T.nilable(T::Array[String])) } + attr_accessor :seen_merchants + + # The standard deviation of approved transaction amounts over the entity's + # lifetime, in cents. Null if fewer than 30 approved transactions have been + # recorded. + sig { returns(T.nilable(Float)) } + attr_accessor :stdev_transaction_amount + + # The standard deviation of approved transaction amounts over the last 30 days, in + # cents. Null if fewer than 30 approved transactions in window. + sig { returns(T.nilable(Float)) } + attr_accessor :stdev_transaction_amount_30d + + # The standard deviation of approved transaction amounts over the last 7 days, in + # cents. Null if fewer than 30 approved transactions in window. + sig { returns(T.nilable(Float)) } + attr_accessor :stdev_transaction_amount_7d + + # The standard deviation of approved transaction amounts over the last 90 days, in + # cents. Null if fewer than 30 approved transactions in window. + sig { returns(T.nilable(Float)) } + attr_accessor :stdev_transaction_amount_90d + + # The number of successful 3DS authentications for the card. Null for account + # responses. + sig { returns(T.nilable(Integer)) } + attr_accessor :three_ds_success_count + + # The 3DS authentication success rate for the card, as a percentage from 0.0 to + # 100.0. Null for account responses. + sig { returns(T.nilable(Float)) } + attr_accessor :three_ds_success_rate + + # The total number of 3DS authentication attempts for the card. Null for account + # responses. + sig { returns(T.nilable(Integer)) } + attr_accessor :three_ds_total_count + + # The number of days since the last approved transaction on the entity. + sig { returns(T.nilable(Float)) } + attr_accessor :time_since_last_transaction_days + + # Behavioral feature state for a card or account derived from its transaction + # history. + # + # Derived statistical features (averages, standard deviations, z-scores) are + # computed using Welford's online algorithm over approved transactions. Average + # fields are null when fewer than 5 approved transactions have been recorded. + # Standard deviation fields are null when fewer than 30 approved transactions have + # been recorded. + # + # 3DS fields (`three_ds_success_rate`, `three_ds_success_count`, + # `three_ds_total_count`) are card-scoped and will be null for account responses. + # + # Raw fields (`seen_countries`, `seen_mccs`, `approved_txn_amount_m2`, etc.) are + # included so clients can compute their own transaction-specific derivations, such + # as checking whether a new transaction's country is in `seen_countries` to + # determine `is_new_country`, or computing a z-score using the raw mean and M2 + # values. + sig do + params( + approved_txn_amount_m2: T.nilable(Float), + approved_txn_amount_m2_30d: T.nilable(Float), + approved_txn_amount_m2_7d: T.nilable(Float), + approved_txn_amount_m2_90d: T.nilable(Float), + approved_txn_count: T.nilable(Integer), + approved_txn_count_30d: T.nilable(Integer), + approved_txn_count_7d: T.nilable(Integer), + approved_txn_count_90d: T.nilable(Integer), + avg_transaction_amount: T.nilable(Float), + avg_transaction_amount_30d: T.nilable(Float), + avg_transaction_amount_7d: T.nilable(Float), + avg_transaction_amount_90d: T.nilable(Float), + distinct_country_count: T.nilable(Integer), + distinct_mcc_count: T.nilable(Integer), + first_txn_at: T.nilable(Time), + is_first_transaction: T.nilable(T::Boolean), + last_cp_country: T.nilable(String), + last_cp_postal_code: T.nilable(String), + last_cp_timestamp: T.nilable(Time), + last_txn_approved_at: T.nilable(Time), + seen_countries: T.nilable(T::Array[String]), + seen_mccs: T.nilable(T::Array[String]), + seen_merchants: T.nilable(T::Array[String]), + stdev_transaction_amount: T.nilable(Float), + stdev_transaction_amount_30d: T.nilable(Float), + stdev_transaction_amount_7d: T.nilable(Float), + stdev_transaction_amount_90d: T.nilable(Float), + three_ds_success_count: T.nilable(Integer), + three_ds_success_rate: T.nilable(Float), + three_ds_total_count: T.nilable(Integer), + time_since_last_transaction_days: T.nilable(Float) + ).returns(T.attached_class) + end + def self.new( + # The Welford M2 accumulator for lifetime approved transaction amounts. Used + # together with `avg_transaction_amount` and `approved_txn_count` to compute the + # z-score of a new transaction amount (variance = M2 / (count - 1)). + approved_txn_amount_m2:, + # The Welford M2 accumulator for approved transaction amounts over the last 30 + # days. + approved_txn_amount_m2_30d:, + # The Welford M2 accumulator for approved transaction amounts over the last 7 + # days. + approved_txn_amount_m2_7d:, + # The Welford M2 accumulator for approved transaction amounts over the last 90 + # days. + approved_txn_amount_m2_90d:, + # The total number of approved transactions over the entity's lifetime. + approved_txn_count:, + # The number of approved transactions in the last 30 days. + approved_txn_count_30d:, + # The number of approved transactions in the last 7 days. + approved_txn_count_7d:, + # The number of approved transactions in the last 90 days. + approved_txn_count_90d:, + # The average approved transaction amount over the entity's lifetime, in cents. + # Null if fewer than 5 approved transactions have been recorded. + avg_transaction_amount:, + # The average approved transaction amount over the last 30 days, in cents. Null if + # fewer than 5 approved transactions in window. + avg_transaction_amount_30d:, + # The average approved transaction amount over the last 7 days, in cents. Null if + # fewer than 5 approved transactions in window. + avg_transaction_amount_7d:, + # The average approved transaction amount over the last 90 days, in cents. Null if + # fewer than 5 approved transactions in window. + avg_transaction_amount_90d:, + # The number of distinct merchant countries seen in the entity's transaction + # history. + distinct_country_count:, + # The number of distinct MCCs seen in the entity's transaction history. + distinct_mcc_count:, + # The timestamp of the first approved transaction for the entity, in ISO 8601 + # format. + first_txn_at:, + # Whether the entity has no prior transaction history. Returns true if no history + # is found. Null if transaction history exists but a first transaction timestamp + # is unavailable. + is_first_transaction:, + # The merchant country of the last card-present transaction. + last_cp_country:, + # The merchant postal code of the last card-present transaction. + last_cp_postal_code:, + # The timestamp of the last card-present transaction, in ISO 8601 format. + last_cp_timestamp:, + # The timestamp of the most recent approved transaction for the entity, in ISO + # 8601 format. + last_txn_approved_at:, + # The set of merchant countries seen in the entity's transaction history. Clients + # can use this to determine whether a new transaction's country is novel (i.e. + # compute `is_new_country`). + seen_countries:, + # The set of MCCs seen in the entity's transaction history. Clients can use this + # to determine whether a new transaction's MCC is novel (i.e. compute + # `is_new_mcc`). + seen_mccs:, + # The set of card acceptor IDs seen in the card's approved transaction history, + # capped at the 1000 most recently seen. Null for account responses. Clients can + # use this to determine whether a new transaction's merchant is novel (i.e. + # compute `is_new_merchant`). + seen_merchants:, + # The standard deviation of approved transaction amounts over the entity's + # lifetime, in cents. Null if fewer than 30 approved transactions have been + # recorded. + stdev_transaction_amount:, + # The standard deviation of approved transaction amounts over the last 30 days, in + # cents. Null if fewer than 30 approved transactions in window. + stdev_transaction_amount_30d:, + # The standard deviation of approved transaction amounts over the last 7 days, in + # cents. Null if fewer than 30 approved transactions in window. + stdev_transaction_amount_7d:, + # The standard deviation of approved transaction amounts over the last 90 days, in + # cents. Null if fewer than 30 approved transactions in window. + stdev_transaction_amount_90d:, + # The number of successful 3DS authentications for the card. Null for account + # responses. + three_ds_success_count:, + # The 3DS authentication success rate for the card, as a percentage from 0.0 to + # 100.0. Null for account responses. + three_ds_success_rate:, + # The total number of 3DS authentication attempts for the card. Null for account + # responses. + three_ds_total_count:, + # The number of days since the last approved transaction on the entity. + time_since_last_transaction_days: + ) + end + + sig do + override.returns( + { + approved_txn_amount_m2: T.nilable(Float), + approved_txn_amount_m2_30d: T.nilable(Float), + approved_txn_amount_m2_7d: T.nilable(Float), + approved_txn_amount_m2_90d: T.nilable(Float), + approved_txn_count: T.nilable(Integer), + approved_txn_count_30d: T.nilable(Integer), + approved_txn_count_7d: T.nilable(Integer), + approved_txn_count_90d: T.nilable(Integer), + avg_transaction_amount: T.nilable(Float), + avg_transaction_amount_30d: T.nilable(Float), + avg_transaction_amount_7d: T.nilable(Float), + avg_transaction_amount_90d: T.nilable(Float), + distinct_country_count: T.nilable(Integer), + distinct_mcc_count: T.nilable(Integer), + first_txn_at: T.nilable(Time), + is_first_transaction: T.nilable(T::Boolean), + last_cp_country: T.nilable(String), + last_cp_postal_code: T.nilable(String), + last_cp_timestamp: T.nilable(Time), + last_txn_approved_at: T.nilable(Time), + seen_countries: T.nilable(T::Array[String]), + seen_mccs: T.nilable(T::Array[String]), + seen_merchants: T.nilable(T::Array[String]), + stdev_transaction_amount: T.nilable(Float), + stdev_transaction_amount_30d: T.nilable(Float), + stdev_transaction_amount_7d: T.nilable(Float), + stdev_transaction_amount_90d: T.nilable(Float), + three_ds_success_count: T.nilable(Integer), + three_ds_success_rate: T.nilable(Float), + three_ds_total_count: T.nilable(Integer), + time_since_last_transaction_days: T.nilable(Float) + } + ) + end + def to_hash + end + end + end +end diff --git a/rbi/lithic/resources/accounts.rbi b/rbi/lithic/resources/accounts.rbi index 23d3a1d6..223b6eb0 100644 --- a/rbi/lithic/resources/accounts.rbi +++ b/rbi/lithic/resources/accounts.rbi @@ -123,6 +123,27 @@ module Lithic ) end + # Returns behavioral feature state derived from an account's transaction history. + # + # These signals expose the same data used by behavioral rule attributes (e.g. + # `AMOUNT_Z_SCORE` with `scope: ACCOUNT`, `IS_NEW_COUNTRY` with `scope: ACCOUNT`) + # and custom code `TRANSACTION_HISTORY_SIGNALS` features, allowing clients to + # inspect feature values before writing rules and debug rule behavior. + # + # Note: 3DS fields are not available at the account scope and will be null. + sig do + params( + account_token: String, + request_options: Lithic::RequestOptions::OrHash + ).returns(Lithic::SignalsResponse) + end + def retrieve_signals( + # The token of the account to fetch signals for. + account_token, + request_options: {} + ) + end + # Get an Account's available spend limits, which is based on the spend limit # configured on the Account and the amount already spent over the spend limit's # duration. For example, if the Account has a daily spend limit of $1000 diff --git a/rbi/lithic/resources/cards.rbi b/rbi/lithic/resources/cards.rbi index 057c572b..73ea5372 100644 --- a/rbi/lithic/resources/cards.rbi +++ b/rbi/lithic/resources/cards.rbi @@ -590,6 +590,25 @@ module Lithic ) end + # Returns behavioral feature state derived from a card's transaction history. + # + # These signals expose the same data used by behavioral rule attributes (e.g. + # `AMOUNT_Z_SCORE` with `scope: CARD`, `IS_NEW_COUNTRY` with `scope: CARD`) and + # custom code `TRANSACTION_HISTORY_SIGNALS` features, allowing clients to inspect + # feature values before writing rules and debug rule behavior. + sig do + params( + card_token: String, + request_options: Lithic::RequestOptions::OrHash + ).returns(Lithic::SignalsResponse) + end + def retrieve_signals( + # The token of the card to fetch signals for. + card_token, + request_options: {} + ) + end + # Get a Card's available spend limit, which is based on the spend limit configured # on the Card and the amount already spent over the spend limit's duration. For # example, if the Card has a monthly spend limit of $1000 configured, and has diff --git a/sig/lithic/models.rbs b/sig/lithic/models.rbs index a0c41968..7965717f 100644 --- a/sig/lithic/models.rbs +++ b/sig/lithic/models.rbs @@ -41,6 +41,8 @@ module Lithic class AccountRetrieveParams = Lithic::Models::AccountRetrieveParams + class AccountRetrieveSignalsParams = Lithic::Models::AccountRetrieveSignalsParams + class AccountRetrieveSpendLimitsParams = Lithic::Models::AccountRetrieveSpendLimitsParams class AccountSpendLimits = Lithic::Models::AccountSpendLimits @@ -133,6 +135,8 @@ module Lithic class CardRetrieveParams = Lithic::Models::CardRetrieveParams + class CardRetrieveSignalsParams = Lithic::Models::CardRetrieveSignalsParams + class CardRetrieveSpendLimitsParams = Lithic::Models::CardRetrieveSpendLimitsParams module Cards = Lithic::Models::Cards @@ -437,6 +441,8 @@ module Lithic class ShippingAddress = Lithic::Models::ShippingAddress + class SignalsResponse = Lithic::Models::SignalsResponse + module SpendLimitDuration = Lithic::Models::SpendLimitDuration class StatementsCreatedWebhookEvent = Lithic::Models::StatementsCreatedWebhookEvent diff --git a/sig/lithic/models/account_retrieve_signals_params.rbs b/sig/lithic/models/account_retrieve_signals_params.rbs new file mode 100644 index 00000000..8fae3d84 --- /dev/null +++ b/sig/lithic/models/account_retrieve_signals_params.rbs @@ -0,0 +1,23 @@ +module Lithic + module Models + type account_retrieve_signals_params = + { account_token: String } & Lithic::Internal::Type::request_parameters + + class AccountRetrieveSignalsParams < Lithic::Internal::Type::BaseModel + extend Lithic::Internal::Type::RequestParameters::Converter + include Lithic::Internal::Type::RequestParameters + + attr_accessor account_token: String + + def initialize: ( + account_token: String, + ?request_options: Lithic::request_opts + ) -> void + + def to_hash: -> { + account_token: String, + request_options: Lithic::RequestOptions + } + end + end +end diff --git a/sig/lithic/models/card_retrieve_signals_params.rbs b/sig/lithic/models/card_retrieve_signals_params.rbs new file mode 100644 index 00000000..d801feaf --- /dev/null +++ b/sig/lithic/models/card_retrieve_signals_params.rbs @@ -0,0 +1,23 @@ +module Lithic + module Models + type card_retrieve_signals_params = + { card_token: String } & Lithic::Internal::Type::request_parameters + + class CardRetrieveSignalsParams < Lithic::Internal::Type::BaseModel + extend Lithic::Internal::Type::RequestParameters::Converter + include Lithic::Internal::Type::RequestParameters + + attr_accessor card_token: String + + def initialize: ( + card_token: String, + ?request_options: Lithic::request_opts + ) -> void + + def to_hash: -> { + card_token: String, + request_options: Lithic::RequestOptions + } + end + end +end diff --git a/sig/lithic/models/signals_response.rbs b/sig/lithic/models/signals_response.rbs new file mode 100644 index 00000000..a8afd35c --- /dev/null +++ b/sig/lithic/models/signals_response.rbs @@ -0,0 +1,170 @@ +module Lithic + module Models + type signals_response = + { + :approved_txn_amount_m2 => Float?, + :approved_txn_amount_m2_30d => Float?, + :approved_txn_amount_m2_7d => Float?, + :approved_txn_amount_m2_90d => Float?, + approved_txn_count: Integer?, + :approved_txn_count_30d => Integer?, + :approved_txn_count_7d => Integer?, + :approved_txn_count_90d => Integer?, + avg_transaction_amount: Float?, + :avg_transaction_amount_30d => Float?, + :avg_transaction_amount_7d => Float?, + :avg_transaction_amount_90d => Float?, + distinct_country_count: Integer?, + distinct_mcc_count: Integer?, + first_txn_at: Time?, + is_first_transaction: bool?, + last_cp_country: String?, + last_cp_postal_code: String?, + last_cp_timestamp: Time?, + last_txn_approved_at: Time?, + seen_countries: ::Array[String]?, + seen_mccs: ::Array[String]?, + seen_merchants: ::Array[String]?, + stdev_transaction_amount: Float?, + :stdev_transaction_amount_30d => Float?, + :stdev_transaction_amount_7d => Float?, + :stdev_transaction_amount_90d => Float?, + three_ds_success_count: Integer?, + three_ds_success_rate: Float?, + three_ds_total_count: Integer?, + time_since_last_transaction_days: Float? + } + + class SignalsResponse < Lithic::Internal::Type::BaseModel + attr_accessor approved_txn_amount_m2: Float? + + attr_accessor approved_txn_amount_m2_30d: Float? + + attr_accessor approved_txn_amount_m2_7d: Float? + + attr_accessor approved_txn_amount_m2_90d: Float? + + attr_accessor approved_txn_count: Integer? + + attr_accessor approved_txn_count_30d: Integer? + + attr_accessor approved_txn_count_7d: Integer? + + attr_accessor approved_txn_count_90d: Integer? + + attr_accessor avg_transaction_amount: Float? + + attr_accessor avg_transaction_amount_30d: Float? + + attr_accessor avg_transaction_amount_7d: Float? + + attr_accessor avg_transaction_amount_90d: Float? + + attr_accessor distinct_country_count: Integer? + + attr_accessor distinct_mcc_count: Integer? + + attr_accessor first_txn_at: Time? + + attr_accessor is_first_transaction: bool? + + attr_accessor last_cp_country: String? + + attr_accessor last_cp_postal_code: String? + + attr_accessor last_cp_timestamp: Time? + + attr_accessor last_txn_approved_at: Time? + + attr_accessor seen_countries: ::Array[String]? + + attr_accessor seen_mccs: ::Array[String]? + + attr_accessor seen_merchants: ::Array[String]? + + attr_accessor stdev_transaction_amount: Float? + + attr_accessor stdev_transaction_amount_30d: Float? + + attr_accessor stdev_transaction_amount_7d: Float? + + attr_accessor stdev_transaction_amount_90d: Float? + + attr_accessor three_ds_success_count: Integer? + + attr_accessor three_ds_success_rate: Float? + + attr_accessor three_ds_total_count: Integer? + + attr_accessor time_since_last_transaction_days: Float? + + def initialize: ( + approved_txn_amount_m2: Float?, + approved_txn_amount_m2_30d: Float?, + approved_txn_amount_m2_7d: Float?, + approved_txn_amount_m2_90d: Float?, + approved_txn_count: Integer?, + approved_txn_count_30d: Integer?, + approved_txn_count_7d: Integer?, + approved_txn_count_90d: Integer?, + avg_transaction_amount: Float?, + avg_transaction_amount_30d: Float?, + avg_transaction_amount_7d: Float?, + avg_transaction_amount_90d: Float?, + distinct_country_count: Integer?, + distinct_mcc_count: Integer?, + first_txn_at: Time?, + is_first_transaction: bool?, + last_cp_country: String?, + last_cp_postal_code: String?, + last_cp_timestamp: Time?, + last_txn_approved_at: Time?, + seen_countries: ::Array[String]?, + seen_mccs: ::Array[String]?, + seen_merchants: ::Array[String]?, + stdev_transaction_amount: Float?, + stdev_transaction_amount_30d: Float?, + stdev_transaction_amount_7d: Float?, + stdev_transaction_amount_90d: Float?, + three_ds_success_count: Integer?, + three_ds_success_rate: Float?, + three_ds_total_count: Integer?, + time_since_last_transaction_days: Float? + ) -> void + + def to_hash: -> { + :approved_txn_amount_m2 => Float?, + :approved_txn_amount_m2_30d => Float?, + :approved_txn_amount_m2_7d => Float?, + :approved_txn_amount_m2_90d => Float?, + approved_txn_count: Integer?, + :approved_txn_count_30d => Integer?, + :approved_txn_count_7d => Integer?, + :approved_txn_count_90d => Integer?, + avg_transaction_amount: Float?, + :avg_transaction_amount_30d => Float?, + :avg_transaction_amount_7d => Float?, + :avg_transaction_amount_90d => Float?, + distinct_country_count: Integer?, + distinct_mcc_count: Integer?, + first_txn_at: Time?, + is_first_transaction: bool?, + last_cp_country: String?, + last_cp_postal_code: String?, + last_cp_timestamp: Time?, + last_txn_approved_at: Time?, + seen_countries: ::Array[String]?, + seen_mccs: ::Array[String]?, + seen_merchants: ::Array[String]?, + stdev_transaction_amount: Float?, + :stdev_transaction_amount_30d => Float?, + :stdev_transaction_amount_7d => Float?, + :stdev_transaction_amount_90d => Float?, + three_ds_success_count: Integer?, + three_ds_success_rate: Float?, + three_ds_total_count: Integer?, + time_since_last_transaction_days: Float? + } + end + end +end diff --git a/sig/lithic/resources/accounts.rbs b/sig/lithic/resources/accounts.rbs index 56aebf0d..fced6c59 100644 --- a/sig/lithic/resources/accounts.rbs +++ b/sig/lithic/resources/accounts.rbs @@ -27,6 +27,11 @@ module Lithic ?request_options: Lithic::request_opts ) -> Lithic::Internal::CursorPage[Lithic::Account] + def retrieve_signals: ( + String account_token, + ?request_options: Lithic::request_opts + ) -> Lithic::SignalsResponse + def retrieve_spend_limits: ( String account_token, ?request_options: Lithic::request_opts diff --git a/sig/lithic/resources/cards.rbs b/sig/lithic/resources/cards.rbs index b8288b8f..71d04318 100644 --- a/sig/lithic/resources/cards.rbs +++ b/sig/lithic/resources/cards.rbs @@ -108,6 +108,11 @@ module Lithic ?request_options: Lithic::request_opts ) -> Lithic::Card + def retrieve_signals: ( + String card_token, + ?request_options: Lithic::request_opts + ) -> Lithic::SignalsResponse + def retrieve_spend_limits: ( String card_token, ?request_options: Lithic::request_opts diff --git a/test/lithic/resources/accounts_test.rb b/test/lithic/resources/accounts_test.rb index 0becca4d..887da7c8 100644 --- a/test/lithic/resources/accounts_test.rb +++ b/test/lithic/resources/accounts_test.rb @@ -81,6 +81,50 @@ def test_list end end + def test_retrieve_signals + response = @lithic.accounts.retrieve_signals("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + assert_pattern do + response => Lithic::SignalsResponse + end + + assert_pattern do + response => { + approved_txn_amount_m2: Float | nil, + approved_txn_amount_m2_30d: Float | nil, + approved_txn_amount_m2_7d: Float | nil, + approved_txn_amount_m2_90d: Float | nil, + approved_txn_count: Integer | nil, + approved_txn_count_30d: Integer | nil, + approved_txn_count_7d: Integer | nil, + approved_txn_count_90d: Integer | nil, + avg_transaction_amount: Float | nil, + avg_transaction_amount_30d: Float | nil, + avg_transaction_amount_7d: Float | nil, + avg_transaction_amount_90d: Float | nil, + distinct_country_count: Integer | nil, + distinct_mcc_count: Integer | nil, + first_txn_at: Time | nil, + is_first_transaction: Lithic::Internal::Type::Boolean | nil, + last_cp_country: String | nil, + last_cp_postal_code: String | nil, + last_cp_timestamp: Time | nil, + last_txn_approved_at: Time | nil, + seen_countries: ^(Lithic::Internal::Type::ArrayOf[String]) | nil, + seen_mccs: ^(Lithic::Internal::Type::ArrayOf[String]) | nil, + seen_merchants: ^(Lithic::Internal::Type::ArrayOf[String]) | nil, + stdev_transaction_amount: Float | nil, + stdev_transaction_amount_30d: Float | nil, + stdev_transaction_amount_7d: Float | nil, + stdev_transaction_amount_90d: Float | nil, + three_ds_success_count: Integer | nil, + three_ds_success_rate: Float | nil, + three_ds_total_count: Integer | nil, + time_since_last_transaction_days: Float | nil + } + end + end + def test_retrieve_spend_limits response = @lithic.accounts.retrieve_spend_limits("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/test/lithic/resources/cards_test.rb b/test/lithic/resources/cards_test.rb index fb20bcb0..ef519052 100644 --- a/test/lithic/resources/cards_test.rb +++ b/test/lithic/resources/cards_test.rb @@ -142,6 +142,50 @@ def test_renew_required_params end end + def test_retrieve_signals + response = @lithic.cards.retrieve_signals("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + assert_pattern do + response => Lithic::SignalsResponse + end + + assert_pattern do + response => { + approved_txn_amount_m2: Float | nil, + approved_txn_amount_m2_30d: Float | nil, + approved_txn_amount_m2_7d: Float | nil, + approved_txn_amount_m2_90d: Float | nil, + approved_txn_count: Integer | nil, + approved_txn_count_30d: Integer | nil, + approved_txn_count_7d: Integer | nil, + approved_txn_count_90d: Integer | nil, + avg_transaction_amount: Float | nil, + avg_transaction_amount_30d: Float | nil, + avg_transaction_amount_7d: Float | nil, + avg_transaction_amount_90d: Float | nil, + distinct_country_count: Integer | nil, + distinct_mcc_count: Integer | nil, + first_txn_at: Time | nil, + is_first_transaction: Lithic::Internal::Type::Boolean | nil, + last_cp_country: String | nil, + last_cp_postal_code: String | nil, + last_cp_timestamp: Time | nil, + last_txn_approved_at: Time | nil, + seen_countries: ^(Lithic::Internal::Type::ArrayOf[String]) | nil, + seen_mccs: ^(Lithic::Internal::Type::ArrayOf[String]) | nil, + seen_merchants: ^(Lithic::Internal::Type::ArrayOf[String]) | nil, + stdev_transaction_amount: Float | nil, + stdev_transaction_amount_30d: Float | nil, + stdev_transaction_amount_7d: Float | nil, + stdev_transaction_amount_90d: Float | nil, + three_ds_success_count: Integer | nil, + three_ds_success_rate: Float | nil, + three_ds_total_count: Integer | nil, + time_since_last_transaction_days: Float | nil + } + end + end + def test_retrieve_spend_limits response = @lithic.cards.retrieve_spend_limits("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") From 22f03c653112d656d288a51cc7d103ed628a11ca Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 8 May 2026 17:09:04 +0000 Subject: [PATCH 3/3] release: 0.14.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 9 +++++++++ Gemfile.lock | 2 +- README.md | 2 +- lib/lithic/version.rb | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index d52d2b97..a26ebfc1 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.13.0" + ".": "0.14.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d93c054..817f72a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 0.14.0 (2026-05-08) + +Full Changelog: [v0.13.0...v0.14.0](https://github.com/lithic-com/lithic-ruby/compare/v0.13.0...v0.14.0) + +### Features + +* **api:** add retrieve_signals method to accounts and cards ([c6446ff](https://github.com/lithic-com/lithic-ruby/commit/c6446ffce562ebe1d451d86a56372e3bf91004e9)) +* **api:** add travel speed/distance attributes and unit parameter to auth_rules ([846d5d9](https://github.com/lithic-com/lithic-ruby/commit/846d5d99cea53078bbda45f2a4b845bc4f7f33d2)) + ## 0.13.0 (2026-05-06) Full Changelog: [v0.12.0...v0.13.0](https://github.com/lithic-com/lithic-ruby/compare/v0.12.0...v0.13.0) diff --git a/Gemfile.lock b/Gemfile.lock index 1c6d5542..eb19ce5f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: . specs: - lithic (0.13.0) + lithic (0.14.0) cgi connection_pool diff --git a/README.md b/README.md index 057c6c36..e73f009a 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ To use this gem, install via Bundler by adding the following to your application ```ruby -gem "lithic", "~> 0.13.0" +gem "lithic", "~> 0.14.0" ``` diff --git a/lib/lithic/version.rb b/lib/lithic/version.rb index 6760a97d..0d63350b 100644 --- a/lib/lithic/version.rb +++ b/lib/lithic/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Lithic - VERSION = "0.13.0" + VERSION = "0.14.0" end