Skip to content

Commit ffb07d5

Browse files
feat(api): add 13 attributes, interval/unit params to auth rules conditional actions
1 parent ace484d commit ffb07d5

3 files changed

Lines changed: 198 additions & 16 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 212
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic/lithic-65a6644277529a38afcac424d99d87cbfa4d8294423ad618dbbd875634ec1d3c.yml
3-
openapi_spec_hash: 6f3c1bb6a70830afb8af1dacd6352a97
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic/lithic-42c58dcdae350a8544a75a19ad38aaeb70f3ed98dc642b4a7b47a4b92d8c9c91.yml
3+
openapi_spec_hash: c26c7c8fab1f49977c23bb698ec64e28
44
config_hash: 126e04f676f61e5871a82889336dbf9d

src/lithic/types/auth_rules/conditional_card_transaction_update_action_parameters.py

Lines changed: 98 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,45 @@
1414

1515

1616
class ConditionParameters(BaseModel):
17-
"""Additional parameters for spend velocity attributes.
17+
"""Additional parameters for certain attributes.
1818
1919
Required when `attribute` is
20-
`SPEND_VELOCITY_COUNT` or `SPEND_VELOCITY_AMOUNT`. Not used for other attributes.
20+
`SPEND_VELOCITY_COUNT` or `SPEND_VELOCITY_AMOUNT` (require `scope`, `period`, and
21+
optional `filters`); `AMOUNT_Z_SCORE`, `AVG_TRANSACTION_AMOUNT`,
22+
`STDEV_TRANSACTION_AMOUNT`, `IS_NEW_COUNTRY`, `IS_NEW_MCC`, `IS_FIRST_TRANSACTION`,
23+
`CONSECUTIVE_DECLINES`, `TIME_SINCE_LAST_TRANSACTION`, or `DISTINCT_COUNTRY_COUNT`
24+
(require `scope`, and additionally `interval` for the statistical attributes); or
25+
`TRAVEL_SPEED` or `DISTANCE_FROM_LAST_TRANSACTION` (require `unit`). Not used for
26+
other attributes.
2127
"""
2228

2329
filters: Optional[SpendVelocityFilters] = None
2430

31+
interval: Optional[Literal["LIFETIME", "7D", "30D", "90D"]] = None
32+
"""
33+
The time window for statistical attributes (`AMOUNT_Z_SCORE`,
34+
`AVG_TRANSACTION_AMOUNT`, `STDEV_TRANSACTION_AMOUNT`). Use `LIFETIME` for
35+
all-time history or a specific window (`7D`, `30D`, `90D`).
36+
"""
37+
2538
period: Optional[VelocityLimitPeriod] = None
2639
"""The time period over which to calculate the spend velocity."""
2740

2841
scope: Optional[Literal["CARD", "ACCOUNT", "GLOBAL"]] = None
29-
"""The entity scope to evaluate the attribute against."""
42+
"""The entity scope to evaluate the attribute against.
43+
44+
`GLOBAL` is only valid for spend velocity attributes.
45+
"""
46+
47+
unit: Optional[Literal["MPH", "KPH", "MILES", "KILOMETERS"]] = None
48+
"""The unit for impossible travel attributes.
49+
50+
Required when `attribute` is `TRAVEL_SPEED` or `DISTANCE_FROM_LAST_TRANSACTION`.
51+
52+
For `TRAVEL_SPEED`: `MPH` (miles per hour) or `KPH` (kilometers per hour).
53+
54+
For `DISTANCE_FROM_LAST_TRANSACTION`: `MILES` or `KILOMETERS`.
55+
"""
3056

3157

3258
class Condition(BaseModel):
@@ -47,6 +73,19 @@ class Condition(BaseModel):
4773
"ACCOUNT_AGE",
4874
"SPEND_VELOCITY_COUNT",
4975
"SPEND_VELOCITY_AMOUNT",
76+
"AMOUNT_Z_SCORE",
77+
"AVG_TRANSACTION_AMOUNT",
78+
"STDEV_TRANSACTION_AMOUNT",
79+
"IS_NEW_COUNTRY",
80+
"IS_NEW_MCC",
81+
"IS_FIRST_TRANSACTION",
82+
"CONSECUTIVE_DECLINES",
83+
"TIME_SINCE_LAST_TRANSACTION",
84+
"DISTINCT_COUNTRY_COUNT",
85+
"IS_NEW_MERCHANT",
86+
"THREE_DS_SUCCESS_RATE",
87+
"TRAVEL_SPEED",
88+
"DISTANCE_FROM_LAST_TRANSACTION",
5089
]
5190
"""The attribute to target.
5291
@@ -102,6 +141,52 @@ class Condition(BaseModel):
102141
- `SPEND_VELOCITY_AMOUNT`: The total spend amount (in cents) of transactions
103142
matching the specified filters within the given period. Requires `parameters`
104143
with `scope`, `period`, and optional `filters`. Use an integer value.
144+
- `AMOUNT_Z_SCORE`: The z-score of the transaction amount relative to the
145+
entity's transaction history. Null if fewer than 30 approved transactions in
146+
the specified window. Requires `parameters.scope` and `parameters.interval`.
147+
Use a decimal value.
148+
- `AVG_TRANSACTION_AMOUNT`: The average approved transaction amount for the
149+
entity over the specified window, in cents. Requires `parameters.scope` and
150+
`parameters.interval`. Use a decimal value.
151+
- `STDEV_TRANSACTION_AMOUNT`: The standard deviation of approved transaction
152+
amounts for the entity over the specified window, in cents. Null if fewer than
153+
30 approved transactions in the specified window. Requires `parameters.scope`
154+
and `parameters.interval`. Use a decimal value.
155+
- `IS_NEW_COUNTRY`: Whether the transaction's merchant country has not been seen
156+
in the entity's transaction history. Valid values are `TRUE`, `FALSE`.
157+
Requires `parameters.scope`.
158+
- `IS_NEW_MCC`: Whether the transaction's MCC has not been seen in the entity's
159+
transaction history. Valid values are `TRUE`, `FALSE`. Requires
160+
`parameters.scope`.
161+
- `IS_FIRST_TRANSACTION`: Whether this is the first transaction for the entity.
162+
Valid values are `TRUE`, `FALSE`. Requires `parameters.scope`.
163+
- `CONSECUTIVE_DECLINES`: The number of consecutive declined transactions for
164+
the entity over the last 30 days (rolling). Requires `parameters.scope`. Use
165+
an integer value.
166+
- `TIME_SINCE_LAST_TRANSACTION`: The number of days since the last approved
167+
transaction for the entity, rounded to the nearest whole day. Requires
168+
`parameters.scope`. Use an integer value.
169+
- `DISTINCT_COUNTRY_COUNT`: The number of distinct merchant countries seen in
170+
the entity's transaction history. Requires `parameters.scope`. Use an integer
171+
value.
172+
- `IS_NEW_MERCHANT`: Whether the card acceptor ID has not been seen in the
173+
card's approved transaction history (capped at the 1000 most recently seen
174+
merchants). Valid values are `TRUE`, `FALSE`. Card-scoped only; no
175+
`parameters` required.
176+
- `THREE_DS_SUCCESS_RATE`: The 3DS authentication success rate for the card, as
177+
a percentage from 0.0 to 100.0. Card-scoped only; no `parameters` required.
178+
Use a decimal value.
179+
- `TRAVEL_SPEED`: The estimated speed of travel derived from the distance
180+
between the postal code centers of the last card-present transaction and the
181+
current transaction, divided by the elapsed time. Null if there is no prior
182+
card-present transaction, if either postal code cannot be geocoded, or if
183+
elapsed time is zero. Requires `parameters.unit` set to `MPH` or `KPH`. Use a
184+
decimal value.
185+
- `DISTANCE_FROM_LAST_TRANSACTION`: The estimated distance between the postal
186+
code centers of the last card-present transaction and the current transaction.
187+
Null if there is no prior card-present transaction or if either postal code
188+
cannot be geocoded. Requires `parameters.unit` set to `MILES` or `KILOMETERS`.
189+
Use a decimal value.
105190
"""
106191

107192
operation: ConditionalOperation
@@ -111,10 +196,16 @@ class Condition(BaseModel):
111196
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""
112197

113198
parameters: Optional[ConditionParameters] = None
114-
"""Additional parameters for spend velocity attributes.
115-
116-
Required when `attribute` is `SPEND_VELOCITY_COUNT` or `SPEND_VELOCITY_AMOUNT`.
117-
Not used for other attributes.
199+
"""Additional parameters for certain attributes.
200+
201+
Required when `attribute` is `SPEND_VELOCITY_COUNT` or `SPEND_VELOCITY_AMOUNT`
202+
(require `scope`, `period`, and optional `filters`); `AMOUNT_Z_SCORE`,
203+
`AVG_TRANSACTION_AMOUNT`, `STDEV_TRANSACTION_AMOUNT`, `IS_NEW_COUNTRY`,
204+
`IS_NEW_MCC`, `IS_FIRST_TRANSACTION`, `CONSECUTIVE_DECLINES`,
205+
`TIME_SINCE_LAST_TRANSACTION`, or `DISTINCT_COUNTRY_COUNT` (require `scope`, and
206+
additionally `interval` for the statistical attributes); or `TRAVEL_SPEED` or
207+
`DISTANCE_FROM_LAST_TRANSACTION` (require `unit`). Not used for other
208+
attributes.
118209
"""
119210

120211

src/lithic/types/auth_rules/conditional_card_transaction_update_action_parameters_param.py

Lines changed: 98 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,45 @@
1616

1717

1818
class ConditionParameters(TypedDict, total=False):
19-
"""Additional parameters for spend velocity attributes.
19+
"""Additional parameters for certain attributes.
2020
2121
Required when `attribute` is
22-
`SPEND_VELOCITY_COUNT` or `SPEND_VELOCITY_AMOUNT`. Not used for other attributes.
22+
`SPEND_VELOCITY_COUNT` or `SPEND_VELOCITY_AMOUNT` (require `scope`, `period`, and
23+
optional `filters`); `AMOUNT_Z_SCORE`, `AVG_TRANSACTION_AMOUNT`,
24+
`STDEV_TRANSACTION_AMOUNT`, `IS_NEW_COUNTRY`, `IS_NEW_MCC`, `IS_FIRST_TRANSACTION`,
25+
`CONSECUTIVE_DECLINES`, `TIME_SINCE_LAST_TRANSACTION`, or `DISTINCT_COUNTRY_COUNT`
26+
(require `scope`, and additionally `interval` for the statistical attributes); or
27+
`TRAVEL_SPEED` or `DISTANCE_FROM_LAST_TRANSACTION` (require `unit`). Not used for
28+
other attributes.
2329
"""
2430

2531
filters: SpendVelocityFiltersParam
2632

33+
interval: Literal["LIFETIME", "7D", "30D", "90D"]
34+
"""
35+
The time window for statistical attributes (`AMOUNT_Z_SCORE`,
36+
`AVG_TRANSACTION_AMOUNT`, `STDEV_TRANSACTION_AMOUNT`). Use `LIFETIME` for
37+
all-time history or a specific window (`7D`, `30D`, `90D`).
38+
"""
39+
2740
period: VelocityLimitPeriodParam
2841
"""The time period over which to calculate the spend velocity."""
2942

3043
scope: Literal["CARD", "ACCOUNT", "GLOBAL"]
31-
"""The entity scope to evaluate the attribute against."""
44+
"""The entity scope to evaluate the attribute against.
45+
46+
`GLOBAL` is only valid for spend velocity attributes.
47+
"""
48+
49+
unit: Literal["MPH", "KPH", "MILES", "KILOMETERS"]
50+
"""The unit for impossible travel attributes.
51+
52+
Required when `attribute` is `TRAVEL_SPEED` or `DISTANCE_FROM_LAST_TRANSACTION`.
53+
54+
For `TRAVEL_SPEED`: `MPH` (miles per hour) or `KPH` (kilometers per hour).
55+
56+
For `DISTANCE_FROM_LAST_TRANSACTION`: `MILES` or `KILOMETERS`.
57+
"""
3258

3359

3460
class Condition(TypedDict, total=False):
@@ -50,6 +76,19 @@ class Condition(TypedDict, total=False):
5076
"ACCOUNT_AGE",
5177
"SPEND_VELOCITY_COUNT",
5278
"SPEND_VELOCITY_AMOUNT",
79+
"AMOUNT_Z_SCORE",
80+
"AVG_TRANSACTION_AMOUNT",
81+
"STDEV_TRANSACTION_AMOUNT",
82+
"IS_NEW_COUNTRY",
83+
"IS_NEW_MCC",
84+
"IS_FIRST_TRANSACTION",
85+
"CONSECUTIVE_DECLINES",
86+
"TIME_SINCE_LAST_TRANSACTION",
87+
"DISTINCT_COUNTRY_COUNT",
88+
"IS_NEW_MERCHANT",
89+
"THREE_DS_SUCCESS_RATE",
90+
"TRAVEL_SPEED",
91+
"DISTANCE_FROM_LAST_TRANSACTION",
5392
]
5493
]
5594
"""The attribute to target.
@@ -106,6 +145,52 @@ class Condition(TypedDict, total=False):
106145
- `SPEND_VELOCITY_AMOUNT`: The total spend amount (in cents) of transactions
107146
matching the specified filters within the given period. Requires `parameters`
108147
with `scope`, `period`, and optional `filters`. Use an integer value.
148+
- `AMOUNT_Z_SCORE`: The z-score of the transaction amount relative to the
149+
entity's transaction history. Null if fewer than 30 approved transactions in
150+
the specified window. Requires `parameters.scope` and `parameters.interval`.
151+
Use a decimal value.
152+
- `AVG_TRANSACTION_AMOUNT`: The average approved transaction amount for the
153+
entity over the specified window, in cents. Requires `parameters.scope` and
154+
`parameters.interval`. Use a decimal value.
155+
- `STDEV_TRANSACTION_AMOUNT`: The standard deviation of approved transaction
156+
amounts for the entity over the specified window, in cents. Null if fewer than
157+
30 approved transactions in the specified window. Requires `parameters.scope`
158+
and `parameters.interval`. Use a decimal value.
159+
- `IS_NEW_COUNTRY`: Whether the transaction's merchant country has not been seen
160+
in the entity's transaction history. Valid values are `TRUE`, `FALSE`.
161+
Requires `parameters.scope`.
162+
- `IS_NEW_MCC`: Whether the transaction's MCC has not been seen in the entity's
163+
transaction history. Valid values are `TRUE`, `FALSE`. Requires
164+
`parameters.scope`.
165+
- `IS_FIRST_TRANSACTION`: Whether this is the first transaction for the entity.
166+
Valid values are `TRUE`, `FALSE`. Requires `parameters.scope`.
167+
- `CONSECUTIVE_DECLINES`: The number of consecutive declined transactions for
168+
the entity over the last 30 days (rolling). Requires `parameters.scope`. Use
169+
an integer value.
170+
- `TIME_SINCE_LAST_TRANSACTION`: The number of days since the last approved
171+
transaction for the entity, rounded to the nearest whole day. Requires
172+
`parameters.scope`. Use an integer value.
173+
- `DISTINCT_COUNTRY_COUNT`: The number of distinct merchant countries seen in
174+
the entity's transaction history. Requires `parameters.scope`. Use an integer
175+
value.
176+
- `IS_NEW_MERCHANT`: Whether the card acceptor ID has not been seen in the
177+
card's approved transaction history (capped at the 1000 most recently seen
178+
merchants). Valid values are `TRUE`, `FALSE`. Card-scoped only; no
179+
`parameters` required.
180+
- `THREE_DS_SUCCESS_RATE`: The 3DS authentication success rate for the card, as
181+
a percentage from 0.0 to 100.0. Card-scoped only; no `parameters` required.
182+
Use a decimal value.
183+
- `TRAVEL_SPEED`: The estimated speed of travel derived from the distance
184+
between the postal code centers of the last card-present transaction and the
185+
current transaction, divided by the elapsed time. Null if there is no prior
186+
card-present transaction, if either postal code cannot be geocoded, or if
187+
elapsed time is zero. Requires `parameters.unit` set to `MPH` or `KPH`. Use a
188+
decimal value.
189+
- `DISTANCE_FROM_LAST_TRANSACTION`: The estimated distance between the postal
190+
code centers of the last card-present transaction and the current transaction.
191+
Null if there is no prior card-present transaction or if either postal code
192+
cannot be geocoded. Requires `parameters.unit` set to `MILES` or `KILOMETERS`.
193+
Use a decimal value.
109194
"""
110195

111196
operation: Required[ConditionalOperation]
@@ -115,10 +200,16 @@ class Condition(TypedDict, total=False):
115200
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""
116201

117202
parameters: ConditionParameters
118-
"""Additional parameters for spend velocity attributes.
119-
120-
Required when `attribute` is `SPEND_VELOCITY_COUNT` or `SPEND_VELOCITY_AMOUNT`.
121-
Not used for other attributes.
203+
"""Additional parameters for certain attributes.
204+
205+
Required when `attribute` is `SPEND_VELOCITY_COUNT` or `SPEND_VELOCITY_AMOUNT`
206+
(require `scope`, `period`, and optional `filters`); `AMOUNT_Z_SCORE`,
207+
`AVG_TRANSACTION_AMOUNT`, `STDEV_TRANSACTION_AMOUNT`, `IS_NEW_COUNTRY`,
208+
`IS_NEW_MCC`, `IS_FIRST_TRANSACTION`, `CONSECUTIVE_DECLINES`,
209+
`TIME_SINCE_LAST_TRANSACTION`, or `DISTINCT_COUNTRY_COUNT` (require `scope`, and
210+
additionally `interval` for the statistical attributes); or `TRAVEL_SPEED` or
211+
`DISTANCE_FROM_LAST_TRANSACTION` (require `unit`). Not used for other
212+
attributes.
122213
"""
123214

124215

0 commit comments

Comments
 (0)