Skip to content

Commit f6dc800

Browse files
feat(api): add typescript_code rule type, state/error fields to auth_rules
1 parent 845458d commit f6dc800

16 files changed

Lines changed: 462 additions & 193 deletions

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 188
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-ee2b9f00d3a9e0000e25abc0774615d6ad3300ce17b2f094e71b0229a907760f.yml
3-
openapi_spec_hash: 01d2cbf4ac692dba2f3831462db929e4
4-
config_hash: a45e6da4e7b46db4ff6819d1dba5d815
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-1e902917b2eae41d549957e790eb6b137969e451efe673815647deba330fe05a.yml
3+
openapi_spec_hash: 82cab06ce65462e60316939db630460a
4+
config_hash: 00b60697e692f86b5be297d939962921

api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ from lithic.types.auth_rules import (
108108
EventStream,
109109
MerchantLockParameters,
110110
ReportStats,
111+
RuleFeature,
112+
TypescriptCodeParameters,
113+
VelocityLimitFilters,
111114
VelocityLimitParams,
112115
VelocityLimitPeriod,
113116
V2ListResultsResponse,

src/lithic/resources/auth_rules/v2/v2.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def create(
7272
self,
7373
*,
7474
parameters: v2_create_params.AccountLevelRuleParameters,
75-
type: Literal["CONDITIONAL_BLOCK", "VELOCITY_LIMIT", "MERCHANT_LOCK", "CONDITIONAL_ACTION"],
75+
type: Literal["CONDITIONAL_BLOCK", "VELOCITY_LIMIT", "MERCHANT_LOCK", "CONDITIONAL_ACTION", "TYPESCRIPT_CODE"],
7676
account_tokens: SequenceNotStr[str] | Omit = omit,
7777
business_account_tokens: SequenceNotStr[str] | Omit = omit,
7878
event_stream: EventStream | Omit = omit,
@@ -101,6 +101,8 @@ def create(
101101
- `MERCHANT_LOCK`: AUTHORIZATION event stream.
102102
- `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION,
103103
ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream.
104+
- `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION,
105+
ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream.
104106
105107
account_tokens: Account tokens to which the Auth Rule applies.
106108
@@ -126,7 +128,7 @@ def create(
126128
*,
127129
card_tokens: SequenceNotStr[str],
128130
parameters: v2_create_params.CardLevelRuleParameters,
129-
type: Literal["CONDITIONAL_BLOCK", "VELOCITY_LIMIT", "MERCHANT_LOCK", "CONDITIONAL_ACTION"],
131+
type: Literal["CONDITIONAL_BLOCK", "VELOCITY_LIMIT", "MERCHANT_LOCK", "CONDITIONAL_ACTION", "TYPESCRIPT_CODE"],
130132
event_stream: EventStream | Omit = omit,
131133
name: Optional[str] | Omit = omit,
132134
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -155,6 +157,8 @@ def create(
155157
- `MERCHANT_LOCK`: AUTHORIZATION event stream.
156158
- `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION,
157159
ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream.
160+
- `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION,
161+
ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream.
158162
159163
event_stream: The event stream during which the rule will be evaluated.
160164
@@ -176,7 +180,7 @@ def create(
176180
*,
177181
parameters: v2_create_params.ProgramLevelRuleParameters,
178182
program_level: bool,
179-
type: Literal["CONDITIONAL_BLOCK", "VELOCITY_LIMIT", "MERCHANT_LOCK", "CONDITIONAL_ACTION"],
183+
type: Literal["CONDITIONAL_BLOCK", "VELOCITY_LIMIT", "MERCHANT_LOCK", "CONDITIONAL_ACTION", "TYPESCRIPT_CODE"],
180184
event_stream: EventStream | Omit = omit,
181185
excluded_card_tokens: SequenceNotStr[str] | Omit = omit,
182186
name: Optional[str] | Omit = omit,
@@ -206,6 +210,8 @@ def create(
206210
- `MERCHANT_LOCK`: AUTHORIZATION event stream.
207211
- `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION,
208212
ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream.
213+
- `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION,
214+
ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream.
209215
210216
event_stream: The event stream during which the rule will be evaluated.
211217
@@ -232,7 +238,7 @@ def create(
232238
parameters: v2_create_params.AccountLevelRuleParameters
233239
| v2_create_params.CardLevelRuleParameters
234240
| v2_create_params.ProgramLevelRuleParameters,
235-
type: Literal["CONDITIONAL_BLOCK", "VELOCITY_LIMIT", "MERCHANT_LOCK", "CONDITIONAL_ACTION"],
241+
type: Literal["CONDITIONAL_BLOCK", "VELOCITY_LIMIT", "MERCHANT_LOCK", "CONDITIONAL_ACTION", "TYPESCRIPT_CODE"],
236242
account_tokens: SequenceNotStr[str] | Omit = omit,
237243
business_account_tokens: SequenceNotStr[str] | Omit = omit,
238244
event_stream: EventStream | Omit = omit,
@@ -890,7 +896,7 @@ async def create(
890896
self,
891897
*,
892898
parameters: v2_create_params.AccountLevelRuleParameters,
893-
type: Literal["CONDITIONAL_BLOCK", "VELOCITY_LIMIT", "MERCHANT_LOCK", "CONDITIONAL_ACTION"],
899+
type: Literal["CONDITIONAL_BLOCK", "VELOCITY_LIMIT", "MERCHANT_LOCK", "CONDITIONAL_ACTION", "TYPESCRIPT_CODE"],
894900
account_tokens: SequenceNotStr[str] | Omit = omit,
895901
business_account_tokens: SequenceNotStr[str] | Omit = omit,
896902
event_stream: EventStream | Omit = omit,
@@ -919,6 +925,8 @@ async def create(
919925
- `MERCHANT_LOCK`: AUTHORIZATION event stream.
920926
- `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION,
921927
ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream.
928+
- `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION,
929+
ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream.
922930
923931
account_tokens: Account tokens to which the Auth Rule applies.
924932
@@ -944,7 +952,7 @@ async def create(
944952
*,
945953
card_tokens: SequenceNotStr[str],
946954
parameters: v2_create_params.CardLevelRuleParameters,
947-
type: Literal["CONDITIONAL_BLOCK", "VELOCITY_LIMIT", "MERCHANT_LOCK", "CONDITIONAL_ACTION"],
955+
type: Literal["CONDITIONAL_BLOCK", "VELOCITY_LIMIT", "MERCHANT_LOCK", "CONDITIONAL_ACTION", "TYPESCRIPT_CODE"],
948956
event_stream: EventStream | Omit = omit,
949957
name: Optional[str] | Omit = omit,
950958
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -973,6 +981,8 @@ async def create(
973981
- `MERCHANT_LOCK`: AUTHORIZATION event stream.
974982
- `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION,
975983
ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream.
984+
- `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION,
985+
ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream.
976986
977987
event_stream: The event stream during which the rule will be evaluated.
978988
@@ -994,7 +1004,7 @@ async def create(
9941004
*,
9951005
parameters: v2_create_params.ProgramLevelRuleParameters,
9961006
program_level: bool,
997-
type: Literal["CONDITIONAL_BLOCK", "VELOCITY_LIMIT", "MERCHANT_LOCK", "CONDITIONAL_ACTION"],
1007+
type: Literal["CONDITIONAL_BLOCK", "VELOCITY_LIMIT", "MERCHANT_LOCK", "CONDITIONAL_ACTION", "TYPESCRIPT_CODE"],
9981008
event_stream: EventStream | Omit = omit,
9991009
excluded_card_tokens: SequenceNotStr[str] | Omit = omit,
10001010
name: Optional[str] | Omit = omit,
@@ -1024,6 +1034,8 @@ async def create(
10241034
- `MERCHANT_LOCK`: AUTHORIZATION event stream.
10251035
- `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION,
10261036
ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream.
1037+
- `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION,
1038+
ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream.
10271039
10281040
event_stream: The event stream during which the rule will be evaluated.
10291041
@@ -1050,7 +1062,7 @@ async def create(
10501062
parameters: v2_create_params.AccountLevelRuleParameters
10511063
| v2_create_params.CardLevelRuleParameters
10521064
| v2_create_params.ProgramLevelRuleParameters,
1053-
type: Literal["CONDITIONAL_BLOCK", "VELOCITY_LIMIT", "MERCHANT_LOCK", "CONDITIONAL_ACTION"],
1065+
type: Literal["CONDITIONAL_BLOCK", "VELOCITY_LIMIT", "MERCHANT_LOCK", "CONDITIONAL_ACTION", "TYPESCRIPT_CODE"],
10541066
account_tokens: SequenceNotStr[str] | Omit = omit,
10551067
business_account_tokens: SequenceNotStr[str] | Omit = omit,
10561068
event_stream: EventStream | Omit = omit,

src/lithic/types/auth_rules/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,36 @@
55
from .auth_rule import AuthRule as AuthRule
66
from .event_stream import EventStream as EventStream
77
from .report_stats import ReportStats as ReportStats
8+
from .rule_feature import RuleFeature as RuleFeature
89
from .backtest_stats import BacktestStats as BacktestStats
910
from .v2_list_params import V2ListParams as V2ListParams
1011
from .v2_draft_params import V2DraftParams as V2DraftParams
1112
from .v2_create_params import V2CreateParams as V2CreateParams
1213
from .v2_update_params import V2UpdateParams as V2UpdateParams
1314
from .conditional_value import ConditionalValue as ConditionalValue
15+
from .rule_feature_param import RuleFeatureParam as RuleFeatureParam
1416
from .auth_rule_condition import AuthRuleCondition as AuthRuleCondition
1517
from .conditional_attribute import ConditionalAttribute as ConditionalAttribute
1618
from .conditional_operation import ConditionalOperation as ConditionalOperation
1719
from .velocity_limit_params import VelocityLimitParams as VelocityLimitParams
1820
from .velocity_limit_period import VelocityLimitPeriod as VelocityLimitPeriod
1921
from .v2_list_results_params import V2ListResultsParams as V2ListResultsParams
22+
from .velocity_limit_filters import VelocityLimitFilters as VelocityLimitFilters
2023
from .conditional_value_param import ConditionalValueParam as ConditionalValueParam
2124
from .merchant_lock_parameters import MerchantLockParameters as MerchantLockParameters
2225
from .v2_list_results_response import V2ListResultsResponse as V2ListResultsResponse
2326
from .auth_rule_condition_param import AuthRuleConditionParam as AuthRuleConditionParam
2427
from .v2_retrieve_report_params import V2RetrieveReportParams as V2RetrieveReportParams
28+
from .typescript_code_parameters import TypescriptCodeParameters as TypescriptCodeParameters
2529
from .v2_retrieve_features_params import V2RetrieveFeaturesParams as V2RetrieveFeaturesParams
2630
from .v2_retrieve_report_response import V2RetrieveReportResponse as V2RetrieveReportResponse
2731
from .velocity_limit_params_param import VelocityLimitParamsParam as VelocityLimitParamsParam
2832
from .velocity_limit_period_param import VelocityLimitPeriodParam as VelocityLimitPeriodParam
2933
from .conditional_block_parameters import ConditionalBlockParameters as ConditionalBlockParameters
34+
from .velocity_limit_filters_param import VelocityLimitFiltersParam as VelocityLimitFiltersParam
3035
from .v2_retrieve_features_response import V2RetrieveFeaturesResponse as V2RetrieveFeaturesResponse
3136
from .merchant_lock_parameters_param import MerchantLockParametersParam as MerchantLockParametersParam
37+
from .typescript_code_parameters_param import TypescriptCodeParametersParam as TypescriptCodeParametersParam
3238
from .conditional_3ds_action_parameters import Conditional3DSActionParameters as Conditional3DSActionParameters
3339
from .conditional_ach_action_parameters import ConditionalACHActionParameters as ConditionalACHActionParameters
3440
from .conditional_block_parameters_param import ConditionalBlockParametersParam as ConditionalBlockParametersParam

src/lithic/types/auth_rules/auth_rule.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from .event_stream import EventStream
88
from .velocity_limit_params import VelocityLimitParams
99
from .merchant_lock_parameters import MerchantLockParameters
10+
from .typescript_code_parameters import TypescriptCodeParameters
1011
from .conditional_block_parameters import ConditionalBlockParameters
1112
from .conditional_3ds_action_parameters import Conditional3DSActionParameters
1213
from .conditional_ach_action_parameters import ConditionalACHActionParameters
@@ -23,6 +24,7 @@
2324
ConditionalAuthorizationActionParameters,
2425
ConditionalACHActionParameters,
2526
ConditionalTokenizationActionParameters,
27+
TypescriptCodeParameters,
2628
]
2729

2830

@@ -45,13 +47,34 @@ class CurrentVersion(BaseModel):
4547
ConditionalAuthorizationActionParameters,
4648
ConditionalACHActionParameters,
4749
ConditionalTokenizationActionParameters,
50+
TypescriptCodeParameters,
4851
]
4952

5053

5154
class DraftVersion(BaseModel):
55+
error: Optional[str] = None
56+
"""An error message if the draft version failed compilation.
57+
58+
Populated when `state` is `ERROR`, `null` otherwise.
59+
"""
60+
5261
parameters: DraftVersionParameters
5362
"""Parameters for the Auth Rule"""
5463

64+
state: Literal["PENDING", "SHADOWING", "ERROR"]
65+
"""The state of the draft version.
66+
67+
Most rules are created synchronously and the state is immediately `SHADOWING`.
68+
Rules backed by TypeScript code are compiled asynchronously — the state starts
69+
as `PENDING` and transitions to `SHADOWING` on success or `ERROR` on failure.
70+
71+
- `PENDING`: Compilation of the rule is in progress (TypeScript rules only).
72+
- `SHADOWING`: The draft version is ready and evaluating in shadow mode
73+
alongside the current active version. It can be promoted to the active
74+
version.
75+
- `ERROR`: Compilation of the rule failed. Check the `error` field for details.
76+
"""
77+
5578
version: int
5679
"""
5780
The version of the rule, this is incremented whenever the rule's parameters
@@ -94,7 +117,7 @@ class AuthRule(BaseModel):
94117
state: Literal["ACTIVE", "INACTIVE"]
95118
"""The state of the Auth Rule"""
96119

97-
type: Literal["CONDITIONAL_BLOCK", "VELOCITY_LIMIT", "MERCHANT_LOCK", "CONDITIONAL_ACTION"]
120+
type: Literal["CONDITIONAL_BLOCK", "VELOCITY_LIMIT", "MERCHANT_LOCK", "CONDITIONAL_ACTION", "TYPESCRIPT_CODE"]
98121
"""The type of Auth Rule.
99122
100123
For certain rule types, this determines the event stream during which it will be
@@ -107,6 +130,8 @@ class AuthRule(BaseModel):
107130
- `MERCHANT_LOCK`: AUTHORIZATION event stream.
108131
- `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION,
109132
ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream.
133+
- `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION,
134+
ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream.
110135
"""
111136

112137
excluded_card_tokens: Optional[List[str]] = None
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import Union, Optional
4+
from typing_extensions import Literal, TypeAlias
5+
6+
from ..._models import BaseModel
7+
from .velocity_limit_period import VelocityLimitPeriod
8+
from .velocity_limit_filters import VelocityLimitFilters
9+
10+
__all__ = [
11+
"RuleFeature",
12+
"AuthorizationFeature",
13+
"AuthenticationFeature",
14+
"TokenizationFeature",
15+
"ACHReceiptFeature",
16+
"CardFeature",
17+
"AccountHolderFeature",
18+
"IPMetadataFeature",
19+
"SpendVelocityFeature",
20+
]
21+
22+
23+
class AuthorizationFeature(BaseModel):
24+
type: Literal["AUTHORIZATION"]
25+
26+
name: Optional[str] = None
27+
"""The variable name for this feature in the rule function signature"""
28+
29+
30+
class AuthenticationFeature(BaseModel):
31+
type: Literal["AUTHENTICATION"]
32+
33+
name: Optional[str] = None
34+
"""The variable name for this feature in the rule function signature"""
35+
36+
37+
class TokenizationFeature(BaseModel):
38+
type: Literal["TOKENIZATION"]
39+
40+
name: Optional[str] = None
41+
"""The variable name for this feature in the rule function signature"""
42+
43+
44+
class ACHReceiptFeature(BaseModel):
45+
type: Literal["ACH_RECEIPT"]
46+
47+
name: Optional[str] = None
48+
"""The variable name for this feature in the rule function signature"""
49+
50+
51+
class CardFeature(BaseModel):
52+
type: Literal["CARD"]
53+
54+
name: Optional[str] = None
55+
"""The variable name for this feature in the rule function signature"""
56+
57+
58+
class AccountHolderFeature(BaseModel):
59+
type: Literal["ACCOUNT_HOLDER"]
60+
61+
name: Optional[str] = None
62+
"""The variable name for this feature in the rule function signature"""
63+
64+
65+
class IPMetadataFeature(BaseModel):
66+
type: Literal["IP_METADATA"]
67+
68+
name: Optional[str] = None
69+
"""The variable name for this feature in the rule function signature"""
70+
71+
72+
class SpendVelocityFeature(BaseModel):
73+
period: VelocityLimitPeriod
74+
"""Velocity over the current day since 00:00 / 12 AM in Eastern Time"""
75+
76+
scope: Literal["CARD", "ACCOUNT"]
77+
"""The scope the velocity is calculated for"""
78+
79+
type: Literal["SPEND_VELOCITY"]
80+
81+
filters: Optional[VelocityLimitFilters] = None
82+
83+
name: Optional[str] = None
84+
"""The variable name for this feature in the rule function signature"""
85+
86+
87+
RuleFeature: TypeAlias = Union[
88+
AuthorizationFeature,
89+
AuthenticationFeature,
90+
TokenizationFeature,
91+
ACHReceiptFeature,
92+
CardFeature,
93+
AccountHolderFeature,
94+
IPMetadataFeature,
95+
SpendVelocityFeature,
96+
]

0 commit comments

Comments
 (0)