Skip to content

Commit 067a5b0

Browse files
feat(api): adds support for Auth Rule features
1 parent 8c818a5 commit 067a5b0

18 files changed

+500
-11
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 168
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-fbbce0ea11d3e86e532f705804f3d79e8eecfb8a7796e3a6ad3c50cccee14bb1.yml
3-
openapi_spec_hash: 3f44b97866ca74effe5e70fc9c64effb
4-
config_hash: 768e8f0faa1a21e26b07e6cdc395cebf
1+
configured_endpoints: 169
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-1a0e3a42c88b88140af0f9ad05ab0026fc87f0a500d6879c86b93dfa7f923810.yml
3+
openapi_spec_hash: 2b4db6185c6e4ab3626461a448c97d4b
4+
config_hash: 7a6a0c0bab3306093c6c171cd7407a45

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ from lithic.types.auth_rules import (
9696
V2DraftResponse,
9797
V2PromoteResponse,
9898
V2ReportResponse,
99+
V2RetrieveFeaturesResponse,
99100
V2RetrieveReportResponse,
100101
)
101102
```
@@ -111,6 +112,7 @@ Methods:
111112
- <code title="post /v2/auth_rules/{auth_rule_token}/draft">client.auth_rules.v2.<a href="./src/lithic/resources/auth_rules/v2/v2.py">draft</a>(auth_rule_token, \*\*<a href="src/lithic/types/auth_rules/v2_draft_params.py">params</a>) -> <a href="./src/lithic/types/auth_rules/v2_draft_response.py">V2DraftResponse</a></code>
112113
- <code title="post /v2/auth_rules/{auth_rule_token}/promote">client.auth_rules.v2.<a href="./src/lithic/resources/auth_rules/v2/v2.py">promote</a>(auth_rule_token) -> <a href="./src/lithic/types/auth_rules/v2_promote_response.py">V2PromoteResponse</a></code>
113114
- <code title="post /v2/auth_rules/{auth_rule_token}/report">client.auth_rules.v2.<a href="./src/lithic/resources/auth_rules/v2/v2.py">report</a>(auth_rule_token) -> <a href="./src/lithic/types/auth_rules/v2_report_response.py">V2ReportResponse</a></code>
115+
- <code title="get /v2/auth_rules/{auth_rule_token}/features">client.auth_rules.v2.<a href="./src/lithic/resources/auth_rules/v2/v2.py">retrieve_features</a>(auth_rule_token, \*\*<a href="src/lithic/types/auth_rules/v2_retrieve_features_params.py">params</a>) -> <a href="./src/lithic/types/auth_rules/v2_retrieve_features_response.py">V2RetrieveFeaturesResponse</a></code>
114116
- <code title="get /v2/auth_rules/{auth_rule_token}/report">client.auth_rules.v2.<a href="./src/lithic/resources/auth_rules/v2/v2.py">retrieve_report</a>(auth_rule_token, \*\*<a href="src/lithic/types/auth_rules/v2_retrieve_report_params.py">params</a>) -> <a href="./src/lithic/types/auth_rules/v2_retrieve_report_response.py">V2RetrieveReportResponse</a></code>
115117

116118
### Backtests

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

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
v2_create_params,
3333
v2_update_params,
3434
v2_retrieve_report_params,
35+
v2_retrieve_features_params,
3536
)
3637
from ....types.auth_rules.v2_list_response import V2ListResponse
3738
from ....types.auth_rules.v2_apply_response import V2ApplyResponse
@@ -42,6 +43,7 @@
4243
from ....types.auth_rules.v2_promote_response import V2PromoteResponse
4344
from ....types.auth_rules.v2_retrieve_response import V2RetrieveResponse
4445
from ....types.auth_rules.v2_retrieve_report_response import V2RetrieveReportResponse
46+
from ....types.auth_rules.v2_retrieve_features_response import V2RetrieveFeaturesResponse
4547

4648
__all__ = ["V2", "AsyncV2"]
4749

@@ -909,6 +911,59 @@ def report(
909911
cast_to=V2ReportResponse,
910912
)
911913

914+
def retrieve_features(
915+
self,
916+
auth_rule_token: str,
917+
*,
918+
account_token: str | Omit = omit,
919+
card_token: str | Omit = omit,
920+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
921+
# The extra values given here take precedence over values defined on the client or passed to this method.
922+
extra_headers: Headers | None = None,
923+
extra_query: Query | None = None,
924+
extra_body: Body | None = None,
925+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
926+
) -> V2RetrieveFeaturesResponse:
927+
"""
928+
Fetches the current calculated Feature values for the given Auth Rule
929+
930+
This only calculates the features for the active version.
931+
932+
- VelocityLimit Rules calculates the current Velocity Feature data. This
933+
requires a `card_token` or `account_token` matching what the rule is Scoped
934+
to.
935+
- ConditionalBlock Rules calculates the CARD*TRANSACTION_COUNT*\\** attributes on
936+
the rule. This requires a `card_token`
937+
938+
Args:
939+
extra_headers: Send extra headers
940+
941+
extra_query: Add additional query parameters to the request
942+
943+
extra_body: Add additional JSON properties to the request
944+
945+
timeout: Override the client-level default timeout for this request, in seconds
946+
"""
947+
if not auth_rule_token:
948+
raise ValueError(f"Expected a non-empty value for `auth_rule_token` but received {auth_rule_token!r}")
949+
return self._get(
950+
f"/v2/auth_rules/{auth_rule_token}/features",
951+
options=make_request_options(
952+
extra_headers=extra_headers,
953+
extra_query=extra_query,
954+
extra_body=extra_body,
955+
timeout=timeout,
956+
query=maybe_transform(
957+
{
958+
"account_token": account_token,
959+
"card_token": card_token,
960+
},
961+
v2_retrieve_features_params.V2RetrieveFeaturesParams,
962+
),
963+
),
964+
cast_to=V2RetrieveFeaturesResponse,
965+
)
966+
912967
def retrieve_report(
913968
self,
914969
auth_rule_token: str,
@@ -1834,6 +1889,59 @@ async def report(
18341889
cast_to=V2ReportResponse,
18351890
)
18361891

1892+
async def retrieve_features(
1893+
self,
1894+
auth_rule_token: str,
1895+
*,
1896+
account_token: str | Omit = omit,
1897+
card_token: str | Omit = omit,
1898+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1899+
# The extra values given here take precedence over values defined on the client or passed to this method.
1900+
extra_headers: Headers | None = None,
1901+
extra_query: Query | None = None,
1902+
extra_body: Body | None = None,
1903+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
1904+
) -> V2RetrieveFeaturesResponse:
1905+
"""
1906+
Fetches the current calculated Feature values for the given Auth Rule
1907+
1908+
This only calculates the features for the active version.
1909+
1910+
- VelocityLimit Rules calculates the current Velocity Feature data. This
1911+
requires a `card_token` or `account_token` matching what the rule is Scoped
1912+
to.
1913+
- ConditionalBlock Rules calculates the CARD*TRANSACTION_COUNT*\\** attributes on
1914+
the rule. This requires a `card_token`
1915+
1916+
Args:
1917+
extra_headers: Send extra headers
1918+
1919+
extra_query: Add additional query parameters to the request
1920+
1921+
extra_body: Add additional JSON properties to the request
1922+
1923+
timeout: Override the client-level default timeout for this request, in seconds
1924+
"""
1925+
if not auth_rule_token:
1926+
raise ValueError(f"Expected a non-empty value for `auth_rule_token` but received {auth_rule_token!r}")
1927+
return await self._get(
1928+
f"/v2/auth_rules/{auth_rule_token}/features",
1929+
options=make_request_options(
1930+
extra_headers=extra_headers,
1931+
extra_query=extra_query,
1932+
extra_body=extra_body,
1933+
timeout=timeout,
1934+
query=await async_maybe_transform(
1935+
{
1936+
"account_token": account_token,
1937+
"card_token": card_token,
1938+
},
1939+
v2_retrieve_features_params.V2RetrieveFeaturesParams,
1940+
),
1941+
),
1942+
cast_to=V2RetrieveFeaturesResponse,
1943+
)
1944+
18371945
async def retrieve_report(
18381946
self,
18391947
auth_rule_token: str,
@@ -1931,6 +2039,9 @@ def __init__(self, v2: V2) -> None:
19312039
v2.report, # pyright: ignore[reportDeprecated],
19322040
)
19332041
)
2042+
self.retrieve_features = _legacy_response.to_raw_response_wrapper(
2043+
v2.retrieve_features,
2044+
)
19342045
self.retrieve_report = _legacy_response.to_raw_response_wrapper(
19352046
v2.retrieve_report,
19362047
)
@@ -1975,6 +2086,9 @@ def __init__(self, v2: AsyncV2) -> None:
19752086
v2.report, # pyright: ignore[reportDeprecated],
19762087
)
19772088
)
2089+
self.retrieve_features = _legacy_response.async_to_raw_response_wrapper(
2090+
v2.retrieve_features,
2091+
)
19782092
self.retrieve_report = _legacy_response.async_to_raw_response_wrapper(
19792093
v2.retrieve_report,
19802094
)
@@ -2019,6 +2133,9 @@ def __init__(self, v2: V2) -> None:
20192133
v2.report, # pyright: ignore[reportDeprecated],
20202134
)
20212135
)
2136+
self.retrieve_features = to_streamed_response_wrapper(
2137+
v2.retrieve_features,
2138+
)
20222139
self.retrieve_report = to_streamed_response_wrapper(
20232140
v2.retrieve_report,
20242141
)
@@ -2063,6 +2180,9 @@ def __init__(self, v2: AsyncV2) -> None:
20632180
v2.report, # pyright: ignore[reportDeprecated],
20642181
)
20652182
)
2183+
self.retrieve_features = async_to_streamed_response_wrapper(
2184+
v2.retrieve_features,
2185+
)
20662186
self.retrieve_report = async_to_streamed_response_wrapper(
20672187
v2.retrieve_report,
20682188
)

src/lithic/types/auth_rules/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
from .merchant_lock_parameters import MerchantLockParameters as MerchantLockParameters
2323
from .auth_rule_condition_param import AuthRuleConditionParam as AuthRuleConditionParam
2424
from .v2_retrieve_report_params import V2RetrieveReportParams as V2RetrieveReportParams
25+
from .v2_retrieve_features_params import V2RetrieveFeaturesParams as V2RetrieveFeaturesParams
2526
from .v2_retrieve_report_response import V2RetrieveReportResponse as V2RetrieveReportResponse
2627
from .velocity_limit_params_param import VelocityLimitParamsParam as VelocityLimitParamsParam
2728
from .conditional_block_parameters import ConditionalBlockParameters as ConditionalBlockParameters
29+
from .v2_retrieve_features_response import V2RetrieveFeaturesResponse as V2RetrieveFeaturesResponse
2830
from .merchant_lock_parameters_param import MerchantLockParametersParam as MerchantLockParametersParam
2931
from .conditional_3ds_action_parameters import Conditional3DSActionParameters as Conditional3DSActionParameters
3032
from .conditional_block_parameters_param import ConditionalBlockParametersParam as ConditionalBlockParametersParam

src/lithic/types/auth_rules/v2_apply_response.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class CurrentVersionParametersConditionalAuthorizationActionParametersCondition(
3333
"LIABILITY_SHIFT",
3434
"PAN_ENTRY_MODE",
3535
"TRANSACTION_AMOUNT",
36+
"CASH_AMOUNT",
3637
"RISK_SCORE",
3738
"CARD_TRANSACTION_COUNT_15M",
3839
"CARD_TRANSACTION_COUNT_1H",
@@ -70,6 +71,8 @@ class CurrentVersionParametersConditionalAuthorizationActionParametersCondition(
7071
fee field in the settlement/cardholder billing currency. This is the amount
7172
the issuer should authorize against unless the issuer is paying the acquirer
7273
fee on behalf of the cardholder.
74+
- `CASH_AMOUNT`: The cash amount of the transaction in minor units (cents). This
75+
represents the amount of cash being withdrawn or advanced.
7376
- `RISK_SCORE`: Network-provided score assessing risk level associated with a
7477
given authorization. Scores are on a range of 0-999, with 0 representing the
7578
lowest risk and 999 representing the highest risk. For Visa transactions,
@@ -153,6 +156,7 @@ class DraftVersionParametersConditionalAuthorizationActionParametersCondition(Ba
153156
"LIABILITY_SHIFT",
154157
"PAN_ENTRY_MODE",
155158
"TRANSACTION_AMOUNT",
159+
"CASH_AMOUNT",
156160
"RISK_SCORE",
157161
"CARD_TRANSACTION_COUNT_15M",
158162
"CARD_TRANSACTION_COUNT_1H",
@@ -190,6 +194,8 @@ class DraftVersionParametersConditionalAuthorizationActionParametersCondition(Ba
190194
fee field in the settlement/cardholder billing currency. This is the amount
191195
the issuer should authorize against unless the issuer is paying the acquirer
192196
fee on behalf of the cardholder.
197+
- `CASH_AMOUNT`: The cash amount of the transaction in minor units (cents). This
198+
represents the amount of cash being withdrawn or advanced.
193199
- `RISK_SCORE`: Network-provided score assessing risk level associated with a
194200
given authorization. Scores are on a range of 0-999, with 0 representing the
195201
lowest risk and 999 representing the highest risk. For Visa transactions,
@@ -282,6 +288,12 @@ class V2ApplyResponse(BaseModel):
282288
event_stream: Literal["AUTHORIZATION", "THREE_DS_AUTHENTICATION"]
283289
"""The event stream during which the rule will be evaluated."""
284290

291+
lithic_managed: bool
292+
"""Indicates whether this auth rule is managed by Lithic.
293+
294+
If true, the rule cannot be modified or deleted by the user
295+
"""
296+
285297
name: Optional[str] = None
286298
"""Auth Rule Name"""
287299

src/lithic/types/auth_rules/v2_create_params.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class CreateAuthRuleRequestAccountTokensParametersConditionalAuthorizationAction
7070
"LIABILITY_SHIFT",
7171
"PAN_ENTRY_MODE",
7272
"TRANSACTION_AMOUNT",
73+
"CASH_AMOUNT",
7374
"RISK_SCORE",
7475
"CARD_TRANSACTION_COUNT_15M",
7576
"CARD_TRANSACTION_COUNT_1H",
@@ -106,6 +107,8 @@ class CreateAuthRuleRequestAccountTokensParametersConditionalAuthorizationAction
106107
fee field in the settlement/cardholder billing currency. This is the amount
107108
the issuer should authorize against unless the issuer is paying the acquirer
108109
fee on behalf of the cardholder.
110+
- `CASH_AMOUNT`: The cash amount of the transaction in minor units (cents). This
111+
represents the amount of cash being withdrawn or advanced.
109112
- `RISK_SCORE`: Network-provided score assessing risk level associated with a
110113
given authorization. Scores are on a range of 0-999, with 0 representing the
111114
lowest risk and 999 representing the highest risk. For Visa transactions,
@@ -206,6 +209,7 @@ class CreateAuthRuleRequestCardTokensParametersConditionalAuthorizationActionPar
206209
"LIABILITY_SHIFT",
207210
"PAN_ENTRY_MODE",
208211
"TRANSACTION_AMOUNT",
212+
"CASH_AMOUNT",
209213
"RISK_SCORE",
210214
"CARD_TRANSACTION_COUNT_15M",
211215
"CARD_TRANSACTION_COUNT_1H",
@@ -242,6 +246,8 @@ class CreateAuthRuleRequestCardTokensParametersConditionalAuthorizationActionPar
242246
fee field in the settlement/cardholder billing currency. This is the amount
243247
the issuer should authorize against unless the issuer is paying the acquirer
244248
fee on behalf of the cardholder.
249+
- `CASH_AMOUNT`: The cash amount of the transaction in minor units (cents). This
250+
represents the amount of cash being withdrawn or advanced.
245251
- `RISK_SCORE`: Network-provided score assessing risk level associated with a
246252
given authorization. Scores are on a range of 0-999, with 0 representing the
247253
lowest risk and 999 representing the highest risk. For Visa transactions,
@@ -345,6 +351,7 @@ class CreateAuthRuleRequestProgramLevelParametersConditionalAuthorizationActionP
345351
"LIABILITY_SHIFT",
346352
"PAN_ENTRY_MODE",
347353
"TRANSACTION_AMOUNT",
354+
"CASH_AMOUNT",
348355
"RISK_SCORE",
349356
"CARD_TRANSACTION_COUNT_15M",
350357
"CARD_TRANSACTION_COUNT_1H",
@@ -381,6 +388,8 @@ class CreateAuthRuleRequestProgramLevelParametersConditionalAuthorizationActionP
381388
fee field in the settlement/cardholder billing currency. This is the amount
382389
the issuer should authorize against unless the issuer is paying the acquirer
383390
fee on behalf of the cardholder.
391+
- `CASH_AMOUNT`: The cash amount of the transaction in minor units (cents). This
392+
represents the amount of cash being withdrawn or advanced.
384393
- `RISK_SCORE`: Network-provided score assessing risk level associated with a
385394
given authorization. Scores are on a range of 0-999, with 0 representing the
386395
lowest risk and 999 representing the highest risk. For Visa transactions,

src/lithic/types/auth_rules/v2_create_response.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class CurrentVersionParametersConditionalAuthorizationActionParametersCondition(
3333
"LIABILITY_SHIFT",
3434
"PAN_ENTRY_MODE",
3535
"TRANSACTION_AMOUNT",
36+
"CASH_AMOUNT",
3637
"RISK_SCORE",
3738
"CARD_TRANSACTION_COUNT_15M",
3839
"CARD_TRANSACTION_COUNT_1H",
@@ -70,6 +71,8 @@ class CurrentVersionParametersConditionalAuthorizationActionParametersCondition(
7071
fee field in the settlement/cardholder billing currency. This is the amount
7172
the issuer should authorize against unless the issuer is paying the acquirer
7273
fee on behalf of the cardholder.
74+
- `CASH_AMOUNT`: The cash amount of the transaction in minor units (cents). This
75+
represents the amount of cash being withdrawn or advanced.
7376
- `RISK_SCORE`: Network-provided score assessing risk level associated with a
7477
given authorization. Scores are on a range of 0-999, with 0 representing the
7578
lowest risk and 999 representing the highest risk. For Visa transactions,
@@ -153,6 +156,7 @@ class DraftVersionParametersConditionalAuthorizationActionParametersCondition(Ba
153156
"LIABILITY_SHIFT",
154157
"PAN_ENTRY_MODE",
155158
"TRANSACTION_AMOUNT",
159+
"CASH_AMOUNT",
156160
"RISK_SCORE",
157161
"CARD_TRANSACTION_COUNT_15M",
158162
"CARD_TRANSACTION_COUNT_1H",
@@ -190,6 +194,8 @@ class DraftVersionParametersConditionalAuthorizationActionParametersCondition(Ba
190194
fee field in the settlement/cardholder billing currency. This is the amount
191195
the issuer should authorize against unless the issuer is paying the acquirer
192196
fee on behalf of the cardholder.
197+
- `CASH_AMOUNT`: The cash amount of the transaction in minor units (cents). This
198+
represents the amount of cash being withdrawn or advanced.
193199
- `RISK_SCORE`: Network-provided score assessing risk level associated with a
194200
given authorization. Scores are on a range of 0-999, with 0 representing the
195201
lowest risk and 999 representing the highest risk. For Visa transactions,
@@ -282,6 +288,12 @@ class V2CreateResponse(BaseModel):
282288
event_stream: Literal["AUTHORIZATION", "THREE_DS_AUTHENTICATION"]
283289
"""The event stream during which the rule will be evaluated."""
284290

291+
lithic_managed: bool
292+
"""Indicates whether this auth rule is managed by Lithic.
293+
294+
If true, the rule cannot be modified or deleted by the user
295+
"""
296+
285297
name: Optional[str] = None
286298
"""Auth Rule Name"""
287299

src/lithic/types/auth_rules/v2_draft_params.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class ParametersConditionalAuthorizationActionParametersCondition(TypedDict, tot
3434
"LIABILITY_SHIFT",
3535
"PAN_ENTRY_MODE",
3636
"TRANSACTION_AMOUNT",
37+
"CASH_AMOUNT",
3738
"RISK_SCORE",
3839
"CARD_TRANSACTION_COUNT_15M",
3940
"CARD_TRANSACTION_COUNT_1H",
@@ -70,6 +71,8 @@ class ParametersConditionalAuthorizationActionParametersCondition(TypedDict, tot
7071
fee field in the settlement/cardholder billing currency. This is the amount
7172
the issuer should authorize against unless the issuer is paying the acquirer
7273
fee on behalf of the cardholder.
74+
- `CASH_AMOUNT`: The cash amount of the transaction in minor units (cents). This
75+
represents the amount of cash being withdrawn or advanced.
7376
- `RISK_SCORE`: Network-provided score assessing risk level associated with a
7477
given authorization. Scores are on a range of 0-999, with 0 representing the
7578
lowest risk and 999 representing the highest risk. For Visa transactions,

0 commit comments

Comments
 (0)