Skip to content

Commit

Permalink
feat(api): updates to Auth Rules numeric types, new Card Types and Au…
Browse files Browse the repository at this point in the history
…thorization Rule Backtests (#637)

- Specifies numeric types on Auth Rules to be integers
- adds `replacement_for` field to Card create requests
- improvements to documentation
- adds Authorization Rules Backtests
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Nov 25, 2024
1 parent 78321ef commit 6436634
Show file tree
Hide file tree
Showing 21 changed files with 196 additions and 151 deletions.
12 changes: 10 additions & 2 deletions src/lithic/resources/cards/cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def with_streaming_response(self) -> CardsWithStreamingResponse:
def create(
self,
*,
type: Literal["MERCHANT_LOCKED", "PHYSICAL", "SINGLE_USE", "VIRTUAL"],
type: Literal["MERCHANT_LOCKED", "PHYSICAL", "SINGLE_USE", "VIRTUAL", "UNLOCKED", "DIGITAL_WALLET"],
account_token: str | NotGiven = NOT_GIVEN,
card_program_token: str | NotGiven = NOT_GIVEN,
carrier: Carrier | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -157,6 +157,10 @@ def create(
- `SINGLE_USE` - Card is closed upon first successful authorization.
- `MERCHANT_LOCKED` - _[Deprecated]_ Card is locked to the first merchant that
successfully authorizes the card.
- `UNLOCKED` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please use
VIRTUAL instead.
- `DIGITAL_WALLET` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please
use VIRTUAL instead.
account_token: Globally unique identifier for the account that the card will be associated
with. Required for programs enrolling users using the
Expand Down Expand Up @@ -1006,7 +1010,7 @@ def with_streaming_response(self) -> AsyncCardsWithStreamingResponse:
async def create(
self,
*,
type: Literal["MERCHANT_LOCKED", "PHYSICAL", "SINGLE_USE", "VIRTUAL"],
type: Literal["MERCHANT_LOCKED", "PHYSICAL", "SINGLE_USE", "VIRTUAL", "UNLOCKED", "DIGITAL_WALLET"],
account_token: str | NotGiven = NOT_GIVEN,
card_program_token: str | NotGiven = NOT_GIVEN,
carrier: Carrier | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -1050,6 +1054,10 @@ async def create(
- `SINGLE_USE` - Card is closed upon first successful authorization.
- `MERCHANT_LOCKED` - _[Deprecated]_ Card is locked to the first merchant that
successfully authorizes the card.
- `UNLOCKED` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please use
VIRTUAL instead.
- `DIGITAL_WALLET` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please
use VIRTUAL instead.
account_token: Globally unique identifier for the account that the card will be associated
with. Required for programs enrolling users using the
Expand Down
192 changes: 100 additions & 92 deletions src/lithic/resources/transactions/transactions.py

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/lithic/types/auth_rules/v2_apply_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class CurrentVersionParametersConditionalBlockParametersCondition(BaseModel):
] = None
"""The operation to apply to the attribute"""

value: Union[str, float, List[str], None] = None
value: Union[str, int, List[str], None] = None
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""


Expand Down Expand Up @@ -145,7 +145,7 @@ class DraftVersionParametersConditionalBlockParametersCondition(BaseModel):
] = None
"""The operation to apply to the attribute"""

value: Union[str, float, List[str], None] = None
value: Union[str, int, List[str], None] = None
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""


Expand All @@ -169,6 +169,7 @@ class DraftVersion(BaseModel):

class V2ApplyResponse(BaseModel):
token: str
"""Auth Rule Token"""

account_tokens: List[str]
"""Account tokens to which the Auth Rule applies."""
Expand Down
6 changes: 3 additions & 3 deletions src/lithic/types/auth_rules/v2_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class CreateAuthRuleRequestAccountTokensParametersConditionalBlockParametersCond
operation: Literal["IS_ONE_OF", "IS_NOT_ONE_OF", "MATCHES", "DOES_NOT_MATCH", "IS_GREATER_THAN", "IS_LESS_THAN"]
"""The operation to apply to the attribute"""

value: Union[str, float, List[str]]
value: Union[str, int, List[str]]
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""


Expand Down Expand Up @@ -155,7 +155,7 @@ class CreateAuthRuleRequestCardTokensParametersConditionalBlockParametersConditi
operation: Literal["IS_ONE_OF", "IS_NOT_ONE_OF", "MATCHES", "DOES_NOT_MATCH", "IS_GREATER_THAN", "IS_LESS_THAN"]
"""The operation to apply to the attribute"""

value: Union[str, float, List[str]]
value: Union[str, int, List[str]]
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""


Expand Down Expand Up @@ -227,7 +227,7 @@ class CreateAuthRuleRequestProgramLevelParametersConditionalBlockParametersCondi
operation: Literal["IS_ONE_OF", "IS_NOT_ONE_OF", "MATCHES", "DOES_NOT_MATCH", "IS_GREATER_THAN", "IS_LESS_THAN"]
"""The operation to apply to the attribute"""

value: Union[str, float, List[str]]
value: Union[str, int, List[str]]
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""


Expand Down
5 changes: 3 additions & 2 deletions src/lithic/types/auth_rules/v2_create_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class CurrentVersionParametersConditionalBlockParametersCondition(BaseModel):
] = None
"""The operation to apply to the attribute"""

value: Union[str, float, List[str], None] = None
value: Union[str, int, List[str], None] = None
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""


Expand Down Expand Up @@ -145,7 +145,7 @@ class DraftVersionParametersConditionalBlockParametersCondition(BaseModel):
] = None
"""The operation to apply to the attribute"""

value: Union[str, float, List[str], None] = None
value: Union[str, int, List[str], None] = None
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""


Expand All @@ -169,6 +169,7 @@ class DraftVersion(BaseModel):

class V2CreateResponse(BaseModel):
token: str
"""Auth Rule Token"""

account_tokens: List[str]
"""Account tokens to which the Auth Rule applies."""
Expand Down
2 changes: 1 addition & 1 deletion src/lithic/types/auth_rules/v2_draft_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class ParametersConditionalBlockParametersCondition(TypedDict, total=False):
operation: Literal["IS_ONE_OF", "IS_NOT_ONE_OF", "MATCHES", "DOES_NOT_MATCH", "IS_GREATER_THAN", "IS_LESS_THAN"]
"""The operation to apply to the attribute"""

value: Union[str, float, List[str]]
value: Union[str, int, List[str]]
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""


Expand Down
5 changes: 3 additions & 2 deletions src/lithic/types/auth_rules/v2_draft_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class CurrentVersionParametersConditionalBlockParametersCondition(BaseModel):
] = None
"""The operation to apply to the attribute"""

value: Union[str, float, List[str], None] = None
value: Union[str, int, List[str], None] = None
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""


Expand Down Expand Up @@ -145,7 +145,7 @@ class DraftVersionParametersConditionalBlockParametersCondition(BaseModel):
] = None
"""The operation to apply to the attribute"""

value: Union[str, float, List[str], None] = None
value: Union[str, int, List[str], None] = None
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""


Expand All @@ -169,6 +169,7 @@ class DraftVersion(BaseModel):

class V2DraftResponse(BaseModel):
token: str
"""Auth Rule Token"""

account_tokens: List[str]
"""Account tokens to which the Auth Rule applies."""
Expand Down
5 changes: 3 additions & 2 deletions src/lithic/types/auth_rules/v2_list_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class CurrentVersionParametersConditionalBlockParametersCondition(BaseModel):
] = None
"""The operation to apply to the attribute"""

value: Union[str, float, List[str], None] = None
value: Union[str, int, List[str], None] = None
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""


Expand Down Expand Up @@ -145,7 +145,7 @@ class DraftVersionParametersConditionalBlockParametersCondition(BaseModel):
] = None
"""The operation to apply to the attribute"""

value: Union[str, float, List[str], None] = None
value: Union[str, int, List[str], None] = None
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""


Expand All @@ -169,6 +169,7 @@ class DraftVersion(BaseModel):

class V2ListResponse(BaseModel):
token: str
"""Auth Rule Token"""

account_tokens: List[str]
"""Account tokens to which the Auth Rule applies."""
Expand Down
5 changes: 3 additions & 2 deletions src/lithic/types/auth_rules/v2_promote_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class CurrentVersionParametersConditionalBlockParametersCondition(BaseModel):
] = None
"""The operation to apply to the attribute"""

value: Union[str, float, List[str], None] = None
value: Union[str, int, List[str], None] = None
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""


Expand Down Expand Up @@ -145,7 +145,7 @@ class DraftVersionParametersConditionalBlockParametersCondition(BaseModel):
] = None
"""The operation to apply to the attribute"""

value: Union[str, float, List[str], None] = None
value: Union[str, int, List[str], None] = None
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""


Expand All @@ -169,6 +169,7 @@ class DraftVersion(BaseModel):

class V2PromoteResponse(BaseModel):
token: str
"""Auth Rule Token"""

account_tokens: List[str]
"""Account tokens to which the Auth Rule applies."""
Expand Down
5 changes: 3 additions & 2 deletions src/lithic/types/auth_rules/v2_retrieve_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class CurrentVersionParametersConditionalBlockParametersCondition(BaseModel):
] = None
"""The operation to apply to the attribute"""

value: Union[str, float, List[str], None] = None
value: Union[str, int, List[str], None] = None
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""


Expand Down Expand Up @@ -145,7 +145,7 @@ class DraftVersionParametersConditionalBlockParametersCondition(BaseModel):
] = None
"""The operation to apply to the attribute"""

value: Union[str, float, List[str], None] = None
value: Union[str, int, List[str], None] = None
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""


Expand All @@ -169,6 +169,7 @@ class DraftVersion(BaseModel):

class V2RetrieveResponse(BaseModel):
token: str
"""Auth Rule Token"""

account_tokens: List[str]
"""Account tokens to which the Auth Rule applies."""
Expand Down
5 changes: 3 additions & 2 deletions src/lithic/types/auth_rules/v2_update_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class CurrentVersionParametersConditionalBlockParametersCondition(BaseModel):
] = None
"""The operation to apply to the attribute"""

value: Union[str, float, List[str], None] = None
value: Union[str, int, List[str], None] = None
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""


Expand Down Expand Up @@ -145,7 +145,7 @@ class DraftVersionParametersConditionalBlockParametersCondition(BaseModel):
] = None
"""The operation to apply to the attribute"""

value: Union[str, float, List[str], None] = None
value: Union[str, int, List[str], None] = None
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""


Expand All @@ -169,6 +169,7 @@ class DraftVersion(BaseModel):

class V2UpdateResponse(BaseModel):
token: str
"""Auth Rule Token"""

account_tokens: List[str]
"""Account tokens to which the Auth Rule applies."""
Expand Down
12 changes: 11 additions & 1 deletion src/lithic/types/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Card(BaseModel):
manufactured.
"""

type: Literal["MERCHANT_LOCKED", "PHYSICAL", "SINGLE_USE", "VIRTUAL"]
type: Literal["MERCHANT_LOCKED", "PHYSICAL", "SINGLE_USE", "VIRTUAL", "UNLOCKED", "DIGITAL_WALLET"]
"""Card types:
- `VIRTUAL` - Card will authorize at any merchant and can be added to a digital
Expand All @@ -134,6 +134,10 @@ class Card(BaseModel):
- `SINGLE_USE` - Card is closed upon first successful authorization.
- `MERCHANT_LOCKED` - _[Deprecated]_ Card is locked to the first merchant that
successfully authorizes the card.
- `UNLOCKED` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please use
VIRTUAL instead.
- `DIGITAL_WALLET` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please
use VIRTUAL instead.
"""

auth_rule_tokens: Optional[List[str]] = None
Expand Down Expand Up @@ -191,3 +195,9 @@ class Card(BaseModel):
This must be configured with Lithic before use. Specifies the configuration
(i.e., physical card art) that the card should be manufactured with.
"""

replacement_for: Optional[str] = None
"""
If the card is a replacement for another card, the globally unique identifier
for the card that was replaced.
"""
6 changes: 5 additions & 1 deletion src/lithic/types/card_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


class CardCreateParams(TypedDict, total=False):
type: Required[Literal["MERCHANT_LOCKED", "PHYSICAL", "SINGLE_USE", "VIRTUAL"]]
type: Required[Literal["MERCHANT_LOCKED", "PHYSICAL", "SINGLE_USE", "VIRTUAL", "UNLOCKED", "DIGITAL_WALLET"]]
"""Card types:
- `VIRTUAL` - Card will authorize at any merchant and can be added to a digital
Expand All @@ -25,6 +25,10 @@ class CardCreateParams(TypedDict, total=False):
- `SINGLE_USE` - Card is closed upon first successful authorization.
- `MERCHANT_LOCKED` - _[Deprecated]_ Card is locked to the first merchant that
successfully authorizes the card.
- `UNLOCKED` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please use
VIRTUAL instead.
- `DIGITAL_WALLET` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please
use VIRTUAL instead.
"""

account_token: str
Expand Down
6 changes: 3 additions & 3 deletions src/lithic/types/shared/velocity_limit_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ class Filters(BaseModel):
class VelocityLimitParams(BaseModel):
filters: Filters

period: Union[float, VelocityLimitParamsPeriodWindow]
period: Union[int, VelocityLimitParamsPeriodWindow]
"""The size of the trailing window to calculate Spend Velocity over in seconds.
The minimum value is 10 seconds, and the maximum value is 2678400 seconds.
"""

scope: Literal["CARD", "ACCOUNT"]

limit_amount: Optional[float] = None
limit_amount: Optional[int] = None
"""
The maximum amount of spend velocity allowed in the period in minor units (the
smallest unit of a currency, e.g. cents for USD). Transactions exceeding this
limit will be declined.
"""

limit_count: Optional[float] = None
limit_count: Optional[int] = None
"""
The number of spend velocity impacting transactions may not exceed this limit in
the period. Transactions exceeding this limit will be declined. A spend velocity
Expand Down
6 changes: 3 additions & 3 deletions src/lithic/types/shared_params/velocity_limit_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ class Filters(TypedDict, total=False):
class VelocityLimitParams(TypedDict, total=False):
filters: Required[Filters]

period: Required[Union[float, VelocityLimitParamsPeriodWindow]]
period: Required[Union[int, VelocityLimitParamsPeriodWindow]]
"""The size of the trailing window to calculate Spend Velocity over in seconds.
The minimum value is 10 seconds, and the maximum value is 2678400 seconds.
"""

scope: Required[Literal["CARD", "ACCOUNT"]]

limit_amount: Optional[float]
limit_amount: Optional[int]
"""
The maximum amount of spend velocity allowed in the period in minor units (the
smallest unit of a currency, e.g. cents for USD). Transactions exceeding this
limit will be declined.
"""

limit_count: Optional[float]
limit_count: Optional[int]
"""
The number of spend velocity impacting transactions may not exceed this limit in
the period. Transactions exceeding this limit will be declined. A spend velocity
Expand Down
6 changes: 3 additions & 3 deletions src/lithic/types/three_ds/authentication_retrieve_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ class MerchantRiskIndicator(BaseModel):
Maps to EMV 3DS field deliveryTimeframe.
"""

gift_card_amount: Optional[float] = None
gift_card_amount: Optional[int] = None
"""
In prepaid or gift card purchase transactions, purchase amount total in major
units (e.g., a purchase of USD $205.10 would be 205). Maps to EMV 3DS field
giftCardAmount.
"""

gift_card_count: Optional[float] = None
gift_card_count: Optional[int] = None
"""
In prepaid or gift card purchase transactions, count of individual prepaid or
gift cards/codes purchased. Maps to EMV 3DS field giftCardCount.
Expand Down Expand Up @@ -218,7 +218,7 @@ class AdditionalData(BaseModel):
authentication request to be low risk or not.
"""

network_risk_score: Optional[float] = None
network_risk_score: Optional[int] = None
"""
Mastercard only: Assessment by the network of the authentication risk level,
with a higher value indicating a higher amount of risk.
Expand Down
Loading

0 comments on commit 6436634

Please sign in to comment.