Skip to content

Commit 8301127

Browse files
feat(api): add action_counts to rule performance reports and code to authorization actions
1 parent 2459d2e commit 8301127

15 files changed

Lines changed: 450 additions & 42 deletions

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 184
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-a45946df228eec554b3cd2491f658bd5a45cb91509da0a9f92d50468ea88072f.yml
3-
openapi_spec_hash: 24c7c13e1e7385cab5442ca66091ffc6
4-
config_hash: 50031f78031362c2e4900222b9ce7ada
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-b29a4bd5ca21348ef426162cbd1fa21070f695572626e4e6faabfa14af38f0b0.yml
3+
openapi_spec_hash: e7c285d6b7006d040ecb50a9d0d2fc17
4+
config_hash: fb5070d41fcabdedbc084b83964b592a

api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Types:
9696
from lithic.types.auth_rules import (
9797
AuthRule,
9898
AuthRuleCondition,
99+
BacktestStats,
99100
Conditional3DSActionParameters,
100101
ConditionalACHActionParameters,
101102
ConditionalAttribute,
@@ -106,7 +107,7 @@ from lithic.types.auth_rules import (
106107
ConditionalValue,
107108
EventStream,
108109
MerchantLockParameters,
109-
RuleStats,
110+
ReportStats,
110111
VelocityLimitParams,
111112
VelocityLimitPeriod,
112113
V2ListResultsResponse,

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

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

99
import httpx
@@ -634,6 +634,8 @@ def list_results(
634634
self,
635635
*,
636636
auth_rule_token: str | Omit = omit,
637+
begin: Union[str, datetime] | Omit = omit,
638+
end: Union[str, datetime] | Omit = omit,
637639
ending_before: str | Omit = omit,
638640
event_token: str | Omit = omit,
639641
has_actions: bool | Omit = omit,
@@ -658,6 +660,12 @@ def list_results(
658660
Args:
659661
auth_rule_token: Filter by Auth Rule token
660662
663+
begin: Date string in RFC 3339 format. Only events evaluated after the specified time
664+
will be included. UTC time zone.
665+
666+
end: Date string in RFC 3339 format. Only events evaluated before the specified time
667+
will be included. UTC time zone.
668+
661669
ending_before: A cursor representing an item's token before which a page of results should end.
662670
Used to retrieve the previous page of results before this item.
663671
@@ -690,6 +698,8 @@ def list_results(
690698
query=maybe_transform(
691699
{
692700
"auth_rule_token": auth_rule_token,
701+
"begin": begin,
702+
"end": end,
693703
"ending_before": ending_before,
694704
"event_token": event_token,
695705
"has_actions": has_actions,
@@ -1442,6 +1452,8 @@ def list_results(
14421452
self,
14431453
*,
14441454
auth_rule_token: str | Omit = omit,
1455+
begin: Union[str, datetime] | Omit = omit,
1456+
end: Union[str, datetime] | Omit = omit,
14451457
ending_before: str | Omit = omit,
14461458
event_token: str | Omit = omit,
14471459
has_actions: bool | Omit = omit,
@@ -1466,6 +1478,12 @@ def list_results(
14661478
Args:
14671479
auth_rule_token: Filter by Auth Rule token
14681480
1481+
begin: Date string in RFC 3339 format. Only events evaluated after the specified time
1482+
will be included. UTC time zone.
1483+
1484+
end: Date string in RFC 3339 format. Only events evaluated before the specified time
1485+
will be included. UTC time zone.
1486+
14691487
ending_before: A cursor representing an item's token before which a page of results should end.
14701488
Used to retrieve the previous page of results before this item.
14711489
@@ -1498,6 +1516,8 @@ def list_results(
14981516
query=maybe_transform(
14991517
{
15001518
"auth_rule_token": auth_rule_token,
1519+
"begin": begin,
1520+
"end": end,
15011521
"ending_before": ending_before,
15021522
"event_token": event_token,
15031523
"has_actions": has_actions,

src/lithic/types/auth_rules/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
from __future__ import annotations
44

55
from .auth_rule import AuthRule as AuthRule
6-
from .rule_stats import RuleStats as RuleStats
76
from .event_stream import EventStream as EventStream
7+
from .report_stats import ReportStats as ReportStats
8+
from .backtest_stats import BacktestStats as BacktestStats
89
from .v2_list_params import V2ListParams as V2ListParams
910
from .v2_draft_params import V2DraftParams as V2DraftParams
1011
from .v2_create_params import V2CreateParams as V2CreateParams

src/lithic/types/auth_rules/rule_stats.py renamed to src/lithic/types/auth_rules/backtest_stats.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66

77
from ..._models import BaseModel
88

9-
__all__ = ["RuleStats", "Example"]
9+
__all__ = ["BacktestStats", "Example"]
1010

1111

1212
class Example(BaseModel):
13-
approved: Optional[bool] = None
14-
"""Whether the rule would have approved the request."""
15-
1613
decision: Optional[Literal["APPROVED", "DECLINED", "CHALLENGED"]] = None
1714
"""The decision made by the rule for this event."""
1815

@@ -23,26 +20,26 @@ class Example(BaseModel):
2320
"""The timestamp of the event."""
2421

2522

26-
class RuleStats(BaseModel):
23+
class BacktestStats(BaseModel):
2724
approved: Optional[int] = None
2825
"""
2926
The total number of historical transactions approved by this rule during the
30-
relevant period, or the number of transactions that would have been approved if
27+
backtest period, or the number of transactions that would have been approved if
3128
the rule was evaluated in shadow mode.
3229
"""
3330

3431
challenged: Optional[int] = None
3532
"""
3633
The total number of historical transactions challenged by this rule during the
37-
relevant period, or the number of transactions that would have been challenged
34+
backtest period, or the number of transactions that would have been challenged
3835
if the rule was evaluated in shadow mode. Currently applicable only for 3DS Auth
3936
Rules.
4037
"""
4138

4239
declined: Optional[int] = None
4340
"""
4441
The total number of historical transactions declined by this rule during the
45-
relevant period, or the number of transactions that would have been declined if
42+
backtest period, or the number of transactions that would have been declined if
4643
the rule was evaluated in shadow mode.
4744
"""
4845

src/lithic/types/auth_rules/conditional_ach_action_parameters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
from .conditional_value import ConditionalValue
88
from .conditional_operation import ConditionalOperation
99

10-
__all__ = ["ConditionalACHActionParameters", "Action", "ActionApproveAction", "ActionReturnAction", "Condition"]
10+
__all__ = ["ConditionalACHActionParameters", "Action", "ActionApproveActionACH", "ActionReturnAction", "Condition"]
1111

1212

13-
class ActionApproveAction(BaseModel):
13+
class ActionApproveActionACH(BaseModel):
1414
type: Literal["APPROVE"]
1515
"""Approve the ACH transaction"""
1616

@@ -98,7 +98,7 @@ class ActionReturnAction(BaseModel):
9898
"""Return the ACH transaction"""
9999

100100

101-
Action: TypeAlias = Union[ActionApproveAction, ActionReturnAction]
101+
Action: TypeAlias = Union[ActionApproveActionACH, ActionReturnAction]
102102

103103

104104
class Condition(BaseModel):

src/lithic/types/auth_rules/conditional_ach_action_parameters_param.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
from .conditional_operation import ConditionalOperation
1010
from .conditional_value_param import ConditionalValueParam
1111

12-
__all__ = ["ConditionalACHActionParametersParam", "Action", "ActionApproveAction", "ActionReturnAction", "Condition"]
12+
__all__ = ["ConditionalACHActionParametersParam", "Action", "ActionApproveActionACH", "ActionReturnAction", "Condition"]
1313

1414

15-
class ActionApproveAction(TypedDict, total=False):
15+
class ActionApproveActionACH(TypedDict, total=False):
1616
type: Required[Literal["APPROVE"]]
1717
"""Approve the ACH transaction"""
1818

@@ -102,7 +102,7 @@ class ActionReturnAction(TypedDict, total=False):
102102
"""Return the ACH transaction"""
103103

104104

105-
Action: TypeAlias = Union[ActionApproveAction, ActionReturnAction]
105+
Action: TypeAlias = Union[ActionApproveActionACH, ActionReturnAction]
106106

107107

108108
class Condition(TypedDict, total=False):

src/lithic/types/auth_rules/conditional_tokenization_action_parameters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
__all__ = [
1111
"ConditionalTokenizationActionParameters",
1212
"Action",
13-
"ActionDeclineAction",
13+
"ActionDeclineActionTokenization",
1414
"ActionRequireTfaAction",
1515
"Condition",
1616
]
1717

1818

19-
class ActionDeclineAction(BaseModel):
19+
class ActionDeclineActionTokenization(BaseModel):
2020
type: Literal["DECLINE"]
2121
"""Decline the tokenization request"""
2222

@@ -66,7 +66,7 @@ class ActionRequireTfaAction(BaseModel):
6666
"""Reason code for requiring two-factor authentication"""
6767

6868

69-
Action: TypeAlias = Union[ActionDeclineAction, ActionRequireTfaAction]
69+
Action: TypeAlias = Union[ActionDeclineActionTokenization, ActionRequireTfaAction]
7070

7171

7272
class Condition(BaseModel):

src/lithic/types/auth_rules/conditional_tokenization_action_parameters_param.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
__all__ = [
1313
"ConditionalTokenizationActionParametersParam",
1414
"Action",
15-
"ActionDeclineAction",
15+
"ActionDeclineActionTokenization",
1616
"ActionRequireTfaAction",
1717
"Condition",
1818
]
1919

2020

21-
class ActionDeclineAction(TypedDict, total=False):
21+
class ActionDeclineActionTokenization(TypedDict, total=False):
2222
type: Required[Literal["DECLINE"]]
2323
"""Decline the tokenization request"""
2424

@@ -64,7 +64,7 @@ class ActionRequireTfaAction(TypedDict, total=False):
6464
"""Reason code for requiring two-factor authentication"""
6565

6666

67-
Action: TypeAlias = Union[ActionDeclineAction, ActionRequireTfaAction]
67+
Action: TypeAlias = Union[ActionDeclineActionTokenization, ActionRequireTfaAction]
6868

6969

7070
class Condition(TypedDict, total=False):

0 commit comments

Comments
 (0)