Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(types)!: improve auth rules types #671

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
from lithic.types import (
AccountFinancialAccountType,
Address,
AuthRule,
Carrier,
Currency,
Document,
InstanceFinancialAccountType,
ShippingAddress,
VelocityLimitParams,
VelocityLimitParamsPeriodWindow,
)
```

Expand Down Expand Up @@ -80,6 +77,12 @@ Types:

```python
from lithic.types.auth_rules import (
AuthRule,
AuthRuleCondition,
ConditionalAttribute,
ConditionalBlockParameters,
VelocityLimitParams,
VelocityLimitParamsPeriodWindow,
V2CreateResponse,
V2RetrieveResponse,
V2UpdateResponse,
Expand Down
3 changes: 0 additions & 3 deletions src/lithic/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@
from .shared import (
Address as Address,
Carrier as Carrier,
AuthRule as AuthRule,
Currency as Currency,
Document as Document,
ShippingAddress as ShippingAddress,
VelocityLimitParams as VelocityLimitParams,
AccountFinancialAccountType as AccountFinancialAccountType,
InstanceFinancialAccountType as InstanceFinancialAccountType,
VelocityLimitParamsPeriodWindow as VelocityLimitParamsPeriodWindow,
)
from .account import Account as Account
from .balance import Balance as Balance
Expand Down
8 changes: 8 additions & 0 deletions src/lithic/types/auth_rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,13 @@
from .v2_create_response import V2CreateResponse as V2CreateResponse
from .v2_report_response import V2ReportResponse as V2ReportResponse
from .v2_update_response import V2UpdateResponse as V2UpdateResponse
from .auth_rule_condition import AuthRuleCondition as AuthRuleCondition
from .v2_promote_response import V2PromoteResponse as V2PromoteResponse
from .v2_retrieve_response import V2RetrieveResponse as V2RetrieveResponse
from .conditional_attribute import ConditionalAttribute as ConditionalAttribute
from .velocity_limit_params import VelocityLimitParams as VelocityLimitParams
from .auth_rule_condition_param import AuthRuleConditionParam as AuthRuleConditionParam
from .velocity_limit_params_param import VelocityLimitParamsParam as VelocityLimitParamsParam
from .conditional_block_parameters import ConditionalBlockParameters as ConditionalBlockParameters
from .conditional_block_parameters_param import ConditionalBlockParametersParam as ConditionalBlockParametersParam
from .velocity_limit_params_period_window import VelocityLimitParamsPeriodWindow as VelocityLimitParamsPeriodWindow
57 changes: 57 additions & 0 deletions src/lithic/types/auth_rules/auth_rule_condition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import List, Union, Optional
from typing_extensions import Literal

from ..._models import BaseModel
from .conditional_attribute import ConditionalAttribute

__all__ = ["AuthRuleCondition"]


class AuthRuleCondition(BaseModel):
attribute: Optional[ConditionalAttribute] = None
"""The attribute to target.

The following attributes may be targeted:

- `MCC`: A four-digit number listed in ISO 18245. An MCC is used to classify a
business by the types of goods or services it provides.
- `COUNTRY`: Country of entity of card acceptor. Possible values are: (1) all
ISO 3166-1 alpha-3 country codes, (2) QZZ for Kosovo, and (3) ANT for
Netherlands Antilles.
- `CURRENCY`: 3-digit alphabetic ISO 4217 code for the merchant currency of the
transaction.
- `MERCHANT_ID`: Unique alphanumeric identifier for the payment card acceptor
(merchant).
- `DESCRIPTOR`: Short description of card acceptor.
- `LIABILITY_SHIFT`: Indicates whether chargeback liability shift to the issuer
applies to the transaction. Valid values are `NONE`, `3DS_AUTHENTICATED`, or
`TOKEN_AUTHENTICATED`.
- `PAN_ENTRY_MODE`: The method by which the cardholder's primary account number
(PAN) was entered. Valid values are `AUTO_ENTRY`, `BAR_CODE`, `CONTACTLESS`,
`ECOMMERCE`, `ERROR_KEYED`, `ERROR_MAGNETIC_STRIPE`, `ICC`, `KEY_ENTERED`,
`MAGNETIC_STRIPE`, `MANUAL`, `OCR`, `SECURE_CARDLESS`, `UNSPECIFIED`,
`UNKNOWN`, `CREDENTIAL_ON_FILE`, or `ECOMMERCE`.
- `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the acquirer
fee field in the settlement/cardholder billing currency. This is the amount
the issuer should authorize against unless the issuer is paying the acquirer
fee on behalf of the cardholder.
- `RISK_SCORE`: Network-provided score assessing risk level associated with a
given authorization. Scores are on a range of 0-999, with 0 representing the
lowest risk and 999 representing the highest risk. For Visa transactions,
where the raw score has a range of 0-99, Lithic will normalize the score by
multiplying the raw score by 10x.
- `CARD_TRANSACTION_COUNT_1H`: The number of transactions on the card in the
trailing hour up and until the authorization.
- `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the
trailing 24 hours up and until the authorization.
"""

operation: Optional[
Literal["IS_ONE_OF", "IS_NOT_ONE_OF", "MATCHES", "DOES_NOT_MATCH", "IS_GREATER_THAN", "IS_LESS_THAN"]
] = None
"""The operation to apply to the attribute"""

value: Union[str, int, List[str], None] = None
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""
56 changes: 56 additions & 0 deletions src/lithic/types/auth_rules/auth_rule_condition_param.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing import List, Union
from typing_extensions import Literal, TypedDict

from .conditional_attribute import ConditionalAttribute

__all__ = ["AuthRuleConditionParam"]


class AuthRuleConditionParam(TypedDict, total=False):
attribute: ConditionalAttribute
"""The attribute to target.

The following attributes may be targeted:

- `MCC`: A four-digit number listed in ISO 18245. An MCC is used to classify a
business by the types of goods or services it provides.
- `COUNTRY`: Country of entity of card acceptor. Possible values are: (1) all
ISO 3166-1 alpha-3 country codes, (2) QZZ for Kosovo, and (3) ANT for
Netherlands Antilles.
- `CURRENCY`: 3-digit alphabetic ISO 4217 code for the merchant currency of the
transaction.
- `MERCHANT_ID`: Unique alphanumeric identifier for the payment card acceptor
(merchant).
- `DESCRIPTOR`: Short description of card acceptor.
- `LIABILITY_SHIFT`: Indicates whether chargeback liability shift to the issuer
applies to the transaction. Valid values are `NONE`, `3DS_AUTHENTICATED`, or
`TOKEN_AUTHENTICATED`.
- `PAN_ENTRY_MODE`: The method by which the cardholder's primary account number
(PAN) was entered. Valid values are `AUTO_ENTRY`, `BAR_CODE`, `CONTACTLESS`,
`ECOMMERCE`, `ERROR_KEYED`, `ERROR_MAGNETIC_STRIPE`, `ICC`, `KEY_ENTERED`,
`MAGNETIC_STRIPE`, `MANUAL`, `OCR`, `SECURE_CARDLESS`, `UNSPECIFIED`,
`UNKNOWN`, `CREDENTIAL_ON_FILE`, or `ECOMMERCE`.
- `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the acquirer
fee field in the settlement/cardholder billing currency. This is the amount
the issuer should authorize against unless the issuer is paying the acquirer
fee on behalf of the cardholder.
- `RISK_SCORE`: Network-provided score assessing risk level associated with a
given authorization. Scores are on a range of 0-999, with 0 representing the
lowest risk and 999 representing the highest risk. For Visa transactions,
where the raw score has a range of 0-99, Lithic will normalize the score by
multiplying the raw score by 10x.
- `CARD_TRANSACTION_COUNT_1H`: The number of transactions on the card in the
trailing hour up and until the authorization.
- `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the
trailing 24 hours up and until the authorization.
"""

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, int, List[str]]
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""
19 changes: 19 additions & 0 deletions src/lithic/types/auth_rules/conditional_attribute.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing_extensions import Literal, TypeAlias

__all__ = ["ConditionalAttribute"]

ConditionalAttribute: TypeAlias = Literal[
"MCC",
"COUNTRY",
"CURRENCY",
"MERCHANT_ID",
"DESCRIPTOR",
"LIABILITY_SHIFT",
"PAN_ENTRY_MODE",
"TRANSACTION_AMOUNT",
"RISK_SCORE",
"CARD_TRANSACTION_COUNT_1H",
"CARD_TRANSACTION_COUNT_24H",
]
12 changes: 12 additions & 0 deletions src/lithic/types/auth_rules/conditional_block_parameters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import List

from ..._models import BaseModel
from .auth_rule_condition import AuthRuleCondition

__all__ = ["ConditionalBlockParameters"]


class ConditionalBlockParameters(BaseModel):
conditions: List[AuthRuleCondition]
14 changes: 14 additions & 0 deletions src/lithic/types/auth_rules/conditional_block_parameters_param.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing import Iterable
from typing_extensions import Required, TypedDict

from .auth_rule_condition_param import AuthRuleConditionParam

__all__ = ["ConditionalBlockParametersParam"]


class ConditionalBlockParametersParam(TypedDict, total=False):
conditions: Required[Iterable[AuthRuleConditionParam]]
152 changes: 5 additions & 147 deletions src/lithic/types/auth_rules/v2_apply_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,88 +4,12 @@
from typing_extensions import Literal, TypeAlias

from ..._models import BaseModel
from ..shared.velocity_limit_params import VelocityLimitParams

__all__ = [
"V2ApplyResponse",
"CurrentVersion",
"CurrentVersionParameters",
"CurrentVersionParametersConditionalBlockParameters",
"CurrentVersionParametersConditionalBlockParametersCondition",
"DraftVersion",
"DraftVersionParameters",
"DraftVersionParametersConditionalBlockParameters",
"DraftVersionParametersConditionalBlockParametersCondition",
]


class CurrentVersionParametersConditionalBlockParametersCondition(BaseModel):
attribute: Optional[
Literal[
"MCC",
"COUNTRY",
"CURRENCY",
"MERCHANT_ID",
"DESCRIPTOR",
"LIABILITY_SHIFT",
"PAN_ENTRY_MODE",
"TRANSACTION_AMOUNT",
"RISK_SCORE",
"CARD_TRANSACTION_COUNT_1H",
"CARD_TRANSACTION_COUNT_24H",
]
] = None
"""The attribute to target.

The following attributes may be targeted:

- `MCC`: A four-digit number listed in ISO 18245. An MCC is used to classify a
business by the types of goods or services it provides.
- `COUNTRY`: Country of entity of card acceptor. Possible values are: (1) all
ISO 3166-1 alpha-3 country codes, (2) QZZ for Kosovo, and (3) ANT for
Netherlands Antilles.
- `CURRENCY`: 3-digit alphabetic ISO 4217 code for the merchant currency of the
transaction.
- `MERCHANT_ID`: Unique alphanumeric identifier for the payment card acceptor
(merchant).
- `DESCRIPTOR`: Short description of card acceptor.
- `LIABILITY_SHIFT`: Indicates whether chargeback liability shift to the issuer
applies to the transaction. Valid values are `NONE`, `3DS_AUTHENTICATED`, or
`TOKEN_AUTHENTICATED`.
- `PAN_ENTRY_MODE`: The method by which the cardholder's primary account number
(PAN) was entered. Valid values are `AUTO_ENTRY`, `BAR_CODE`, `CONTACTLESS`,
`ECOMMERCE`, `ERROR_KEYED`, `ERROR_MAGNETIC_STRIPE`, `ICC`, `KEY_ENTERED`,
`MAGNETIC_STRIPE`, `MANUAL`, `OCR`, `SECURE_CARDLESS`, `UNSPECIFIED`,
`UNKNOWN`, `CREDENTIAL_ON_FILE`, or `ECOMMERCE`.
- `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the acquirer
fee field in the settlement/cardholder billing currency. This is the amount
the issuer should authorize against unless the issuer is paying the acquirer
fee on behalf of the cardholder.
- `RISK_SCORE`: Network-provided score assessing risk level associated with a
given authorization. Scores are on a range of 0-999, with 0 representing the
lowest risk and 999 representing the highest risk. For Visa transactions,
where the raw score has a range of 0-99, Lithic will normalize the score by
multiplying the raw score by 10x.
- `CARD_TRANSACTION_COUNT_1H`: The number of transactions on the card in the
trailing hour up and until the authorization.
- `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the
trailing 24 hours up and until the authorization.
"""

operation: Optional[
Literal["IS_ONE_OF", "IS_NOT_ONE_OF", "MATCHES", "DOES_NOT_MATCH", "IS_GREATER_THAN", "IS_LESS_THAN"]
] = None
"""The operation to apply to the attribute"""

value: Union[str, int, List[str], None] = None
"""A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`"""
from .velocity_limit_params import VelocityLimitParams
from .conditional_block_parameters import ConditionalBlockParameters

__all__ = ["V2ApplyResponse", "CurrentVersion", "CurrentVersionParameters", "DraftVersion", "DraftVersionParameters"]

class CurrentVersionParametersConditionalBlockParameters(BaseModel):
conditions: List[CurrentVersionParametersConditionalBlockParametersCondition]


CurrentVersionParameters: TypeAlias = Union[CurrentVersionParametersConditionalBlockParameters, VelocityLimitParams]
CurrentVersionParameters: TypeAlias = Union[ConditionalBlockParameters, VelocityLimitParams]


class CurrentVersion(BaseModel):
Expand All @@ -99,73 +23,7 @@ class CurrentVersion(BaseModel):
"""


class DraftVersionParametersConditionalBlockParametersCondition(BaseModel):
attribute: Optional[
Literal[
"MCC",
"COUNTRY",
"CURRENCY",
"MERCHANT_ID",
"DESCRIPTOR",
"LIABILITY_SHIFT",
"PAN_ENTRY_MODE",
"TRANSACTION_AMOUNT",
"RISK_SCORE",
"CARD_TRANSACTION_COUNT_1H",
"CARD_TRANSACTION_COUNT_24H",
]
] = None
"""The attribute to target.

The following attributes may be targeted:

- `MCC`: A four-digit number listed in ISO 18245. An MCC is used to classify a
business by the types of goods or services it provides.
- `COUNTRY`: Country of entity of card acceptor. Possible values are: (1) all
ISO 3166-1 alpha-3 country codes, (2) QZZ for Kosovo, and (3) ANT for
Netherlands Antilles.
- `CURRENCY`: 3-digit alphabetic ISO 4217 code for the merchant currency of the
transaction.
- `MERCHANT_ID`: Unique alphanumeric identifier for the payment card acceptor
(merchant).
- `DESCRIPTOR`: Short description of card acceptor.
- `LIABILITY_SHIFT`: Indicates whether chargeback liability shift to the issuer
applies to the transaction. Valid values are `NONE`, `3DS_AUTHENTICATED`, or
`TOKEN_AUTHENTICATED`.
- `PAN_ENTRY_MODE`: The method by which the cardholder's primary account number
(PAN) was entered. Valid values are `AUTO_ENTRY`, `BAR_CODE`, `CONTACTLESS`,
`ECOMMERCE`, `ERROR_KEYED`, `ERROR_MAGNETIC_STRIPE`, `ICC`, `KEY_ENTERED`,
`MAGNETIC_STRIPE`, `MANUAL`, `OCR`, `SECURE_CARDLESS`, `UNSPECIFIED`,
`UNKNOWN`, `CREDENTIAL_ON_FILE`, or `ECOMMERCE`.
- `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the acquirer
fee field in the settlement/cardholder billing currency. This is the amount
the issuer should authorize against unless the issuer is paying the acquirer
fee on behalf of the cardholder.
- `RISK_SCORE`: Network-provided score assessing risk level associated with a
given authorization. Scores are on a range of 0-999, with 0 representing the
lowest risk and 999 representing the highest risk. For Visa transactions,
where the raw score has a range of 0-99, Lithic will normalize the score by
multiplying the raw score by 10x.
- `CARD_TRANSACTION_COUNT_1H`: The number of transactions on the card in the
trailing hour up and until the authorization.
- `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the
trailing 24 hours up and until the authorization.
"""

operation: Optional[
Literal["IS_ONE_OF", "IS_NOT_ONE_OF", "MATCHES", "DOES_NOT_MATCH", "IS_GREATER_THAN", "IS_LESS_THAN"]
] = None
"""The operation to apply to the attribute"""

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


class DraftVersionParametersConditionalBlockParameters(BaseModel):
conditions: List[DraftVersionParametersConditionalBlockParametersCondition]


DraftVersionParameters: TypeAlias = Union[DraftVersionParametersConditionalBlockParameters, VelocityLimitParams]
DraftVersionParameters: TypeAlias = Union[ConditionalBlockParameters, VelocityLimitParams]


class DraftVersion(BaseModel):
Expand Down
Loading