Skip to content

Commit ced5f0d

Browse files
feat(api): Add result schemas for Authorization and Authentication (3DS) actions
1 parent e50dd4d commit ced5f0d

3 files changed

Lines changed: 128 additions & 31 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: 176
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-fe39002b6b38eb33ba43532f28e317bdd4dbb5b0efd46fa098178cb6a544d585.yml
3-
openapi_spec_hash: 8ee7b837e77df089ca3359b5502c7525
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-a4803fcc96eac3196b6763e16264cc1b3292394102f3645a986a575c57d0a290.yml
3+
openapi_spec_hash: 8a62dfde46b1749196575f2879f54d77
44
config_hash: 693dddc4721eef512d75ab6c60897794

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Union, Optional
5+
from typing import Any, List, Union, Optional, cast
66
from datetime import date
77
from typing_extensions import Literal, overload
88

@@ -696,7 +696,7 @@ def list_results(
696696
v2_list_results_params.V2ListResultsParams,
697697
),
698698
),
699-
model=V2ListResultsResponse,
699+
model=cast(Any, V2ListResultsResponse), # Union types cannot be passed in as arguments in the type system
700700
)
701701

702702
def promote(
@@ -1501,7 +1501,7 @@ def list_results(
15011501
v2_list_results_params.V2ListResultsParams,
15021502
),
15031503
),
1504-
model=V2ListResultsResponse,
1504+
model=cast(Any, V2ListResultsResponse), # Union types cannot be passed in as arguments in the type system
15051505
)
15061506

15071507
async def promote(

src/lithic/types/auth_rules/v2_list_results_response.py

Lines changed: 123 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,97 @@
55
from typing_extensions import Literal, TypeAlias
66

77
from ..._models import BaseModel
8-
from .event_stream import EventStream
98

109
__all__ = [
1110
"V2ListResultsResponse",
12-
"Action",
13-
"ActionAuthorizationAction",
14-
"ActionAuthentication3DSAction",
15-
"ActionDeclineAction",
16-
"ActionRequireTfaAction",
17-
"ActionApproveAction",
18-
"ActionReturnAction",
11+
"AuthorizationResult",
12+
"AuthorizationResultAction",
13+
"Authentication3DSResult",
14+
"Authentication3DsResultAction",
15+
"TokenizationResult",
16+
"TokenizationResultAction",
17+
"TokenizationResultActionDeclineAction",
18+
"TokenizationResultActionRequireTfaAction",
19+
"ACHResult",
20+
"ACHResultAction",
21+
"ACHResultActionApproveAction",
22+
"ACHResultActionReturnAction",
1923
]
2024

2125

22-
class ActionAuthorizationAction(BaseModel):
26+
class AuthorizationResultAction(BaseModel):
27+
type: Literal["DECLINE", "CHALLENGE"]
28+
2329
explanation: Optional[str] = None
2430
"""Optional explanation for why this action was taken"""
2531

2632

27-
class ActionAuthentication3DSAction(BaseModel):
33+
class AuthorizationResult(BaseModel):
34+
token: str
35+
"""Globally unique identifier for the evaluation"""
36+
37+
actions: List[AuthorizationResultAction]
38+
"""Actions returned by the rule evaluation"""
39+
40+
auth_rule_token: str
41+
"""The Auth Rule token"""
42+
43+
evaluation_time: datetime
44+
"""Timestamp of the rule evaluation"""
45+
46+
event_stream: Literal["AUTHORIZATION"]
47+
"""The event stream during which the rule was evaluated"""
48+
49+
event_token: str
50+
"""Token of the event that triggered the evaluation"""
51+
52+
mode: Literal["ACTIVE", "INACTIVE"]
53+
"""The state of the Auth Rule"""
54+
55+
rule_version: int
56+
"""Version of the rule that was evaluated"""
57+
58+
59+
class Authentication3DsResultAction(BaseModel):
60+
type: Literal["DECLINE", "CHALLENGE"]
61+
2862
explanation: Optional[str] = None
2963
"""Optional explanation for why this action was taken"""
3064

3165

32-
class ActionDeclineAction(BaseModel):
66+
class Authentication3DSResult(BaseModel):
67+
token: str
68+
"""Globally unique identifier for the evaluation"""
69+
70+
actions: List[Authentication3DsResultAction]
71+
"""Actions returned by the rule evaluation"""
72+
73+
auth_rule_token: str
74+
"""The Auth Rule token"""
75+
76+
evaluation_time: datetime
77+
"""Timestamp of the rule evaluation"""
78+
79+
event_stream: Literal["THREE_DS_AUTHENTICATION"]
80+
"""The event stream during which the rule was evaluated"""
81+
82+
event_token: str
83+
"""Token of the event that triggered the evaluation"""
84+
85+
mode: Literal["ACTIVE", "INACTIVE"]
86+
"""The state of the Auth Rule"""
87+
88+
rule_version: int
89+
"""Version of the rule that was evaluated"""
90+
91+
92+
class TokenizationResultActionDeclineAction(BaseModel):
3393
type: Literal["DECLINE"]
3494
"""Decline the tokenization request"""
3595

96+
explanation: Optional[str] = None
97+
"""Optional explanation for why this action was taken"""
98+
3699
reason: Optional[
37100
Literal[
38101
"ACCOUNT_SCORE_1",
@@ -53,10 +116,13 @@ class ActionDeclineAction(BaseModel):
53116
"""Reason code for declining the tokenization request"""
54117

55118

56-
class ActionRequireTfaAction(BaseModel):
119+
class TokenizationResultActionRequireTfaAction(BaseModel):
57120
type: Literal["REQUIRE_TFA"]
58121
"""Require two-factor authentication for the tokenization request"""
59122

123+
explanation: Optional[str] = None
124+
"""Optional explanation for why this action was taken"""
125+
60126
reason: Optional[
61127
Literal[
62128
"WALLET_RECOMMENDED_TFA",
@@ -79,12 +145,46 @@ class ActionRequireTfaAction(BaseModel):
79145
"""Reason code for requiring two-factor authentication"""
80146

81147

82-
class ActionApproveAction(BaseModel):
148+
TokenizationResultAction: TypeAlias = Union[
149+
TokenizationResultActionDeclineAction, TokenizationResultActionRequireTfaAction
150+
]
151+
152+
153+
class TokenizationResult(BaseModel):
154+
token: str
155+
"""Globally unique identifier for the evaluation"""
156+
157+
actions: List[TokenizationResultAction]
158+
"""Actions returned by the rule evaluation"""
159+
160+
auth_rule_token: str
161+
"""The Auth Rule token"""
162+
163+
evaluation_time: datetime
164+
"""Timestamp of the rule evaluation"""
165+
166+
event_stream: Literal["TOKENIZATION"]
167+
"""The event stream during which the rule was evaluated"""
168+
169+
event_token: str
170+
"""Token of the event that triggered the evaluation"""
171+
172+
mode: Literal["ACTIVE", "INACTIVE"]
173+
"""The state of the Auth Rule"""
174+
175+
rule_version: int
176+
"""Version of the rule that was evaluated"""
177+
178+
179+
class ACHResultActionApproveAction(BaseModel):
83180
type: Literal["APPROVE"]
84181
"""Approve the ACH transaction"""
85182

183+
explanation: Optional[str] = None
184+
"""Optional explanation for why this action was taken"""
185+
86186

87-
class ActionReturnAction(BaseModel):
187+
class ACHResultActionReturnAction(BaseModel):
88188
code: Literal[
89189
"R01",
90190
"R02",
@@ -166,24 +266,18 @@ class ActionReturnAction(BaseModel):
166266
type: Literal["RETURN"]
167267
"""Return the ACH transaction"""
168268

269+
explanation: Optional[str] = None
270+
"""Optional explanation for why this action was taken"""
169271

170-
Action: TypeAlias = Union[
171-
ActionAuthorizationAction,
172-
ActionAuthentication3DSAction,
173-
ActionDeclineAction,
174-
ActionRequireTfaAction,
175-
ActionApproveAction,
176-
ActionReturnAction,
177-
]
178272

273+
ACHResultAction: TypeAlias = Union[ACHResultActionApproveAction, ACHResultActionReturnAction]
179274

180-
class V2ListResultsResponse(BaseModel):
181-
"""Result of an Auth Rule evaluation"""
182275

276+
class ACHResult(BaseModel):
183277
token: str
184278
"""Globally unique identifier for the evaluation"""
185279

186-
actions: List[Action]
280+
actions: List[ACHResultAction]
187281
"""Actions returned by the rule evaluation"""
188282

189283
auth_rule_token: str
@@ -192,7 +286,7 @@ class V2ListResultsResponse(BaseModel):
192286
evaluation_time: datetime
193287
"""Timestamp of the rule evaluation"""
194288

195-
event_stream: EventStream
289+
event_stream: Literal["ACH_CREDIT_RECEIPT", "ACH_DEBIT_RECEIPT"]
196290
"""The event stream during which the rule was evaluated"""
197291

198292
event_token: str
@@ -203,3 +297,6 @@ class V2ListResultsResponse(BaseModel):
203297

204298
rule_version: int
205299
"""Version of the rule that was evaluated"""
300+
301+
302+
V2ListResultsResponse: TypeAlias = Union[AuthorizationResult, Authentication3DSResult, TokenizationResult, ACHResult]

0 commit comments

Comments
 (0)