Skip to content
8 changes: 7 additions & 1 deletion method/method.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from method.resources.HealthCheck import PingResponse, HealthCheckResource
from method.resources.Simulate import SimulateResource
from method.resources.Events import EventResource
from method.resources.CardProduct import CardProductResource
from method.resources.Opal import OpalResource

class Method:
accounts: AccountResource
Expand All @@ -22,6 +24,8 @@ class Method:
webhooks: WebhookResource
healthcheck: HealthCheckResource
simulate: SimulateResource
card_products: CardProductResource
opal: OpalResource

def __init__(self, opts: ConfigurationOpts = None, **kwargs: ConfigurationOpts):
_opts: ConfigurationOpts = {**(opts or {}), **kwargs} # type: ignore
Expand All @@ -37,6 +41,8 @@ def __init__(self, opts: ConfigurationOpts = None, **kwargs: ConfigurationOpts):
self.webhooks = WebhookResource(config)
self.healthcheck = HealthCheckResource(config)
self.simulate = SimulateResource(config)

self.card_products = CardProductResource(config)
self.opal = OpalResource(config)

def ping(self) -> MethodResponse[PingResponse]:
return self.healthcheck.retrieve()
5 changes: 4 additions & 1 deletion method/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def finalize_response(self, request_start_time: Optional[int] = None, request_en

class RequestOpts(TypedDict):
idempotency_key: Optional[str]
prefer: Optional[str]


class ResourceListOpts(TypedDict):
Expand All @@ -146,7 +147,7 @@ def __init__(self, config: Configuration):
'Authorization': 'Bearer {token}'.format(token=config.api_key),
'Content-Type': 'application/json',
'User-Agent': 'Method-Python/v{version}'.format(version=version('method-python')),
'method-version': '2024-04-04'
'method-version': '2025-07-04'
})

def _make_request(self, method: str, path: Optional[str] = None, data: Optional[Dict] = None, params: Optional[Dict] = None, headers: Optional[Dict] = None, raw: bool = False, download: bool = False) -> Union[MethodResponse[T], str]:
Expand Down Expand Up @@ -224,6 +225,8 @@ def _create(self, data: Dict, params: Optional[Dict] = None, request_opts: Optio
headers = {}
if request_opts and request_opts.get('idempotency_key'):
headers['Idempotency-Key'] = request_opts.get('idempotency_key')
if request_opts and request_opts.get('prefer'):
headers['Prefer'] = request_opts.get('prefer')
return self._make_request('POST', data=data, headers=headers, params=params)

@MethodError.catch
Expand Down
16 changes: 9 additions & 7 deletions method/resources/Accounts/CardBrands.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@


class AccountCardBrandInfo(TypedDict):
art_id: str
url: str
name: str
id: str
card_product_id: str
description: str
name: str
issuer: str
network: str
type: Literal['specific', 'generic', 'in_review']
url: str


class AccountCardBrand(TypedDict):
id: str
account_id: str
network: str
issuer: str
last4: str
brands: List[AccountCardBrandInfo]
status: Literal['completed', 'failed']
status: Literal['completed', 'in_progress', 'failed']
shared: bool
source: Optional[Literal['method', 'network']]
error: Optional[ResourceError]
Expand Down
5 changes: 1 addition & 4 deletions method/resources/Accounts/Products.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AccountProduct(TypedDict):
status: AccountProductTypeStatusLiterals
status_error: Optional[ResourceError]
latest_request_id: str
latest_successful_request_id: str
latest_successful_request_id: Optional[str]
is_subscribable: bool
created_at: str
updated_at: str
Expand All @@ -38,8 +38,5 @@ class AccountProductResource(Resource):
def __init__(self, config: Configuration):
super(AccountProductResource, self).__init__(config.add_path('products'))

def retrieve(self, prd_id: str) -> MethodResponse[AccountProduct]:
return super(AccountProductResource, self)._get_with_id(prd_id)

def list(self) -> MethodResponse[AccountProductListResponse]:
return super(AccountProductResource, self)._list()
16 changes: 16 additions & 0 deletions method/resources/Accounts/Types.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,29 @@ class AccountLiabilityStudentLoans(AccountLiabilityBase):
original_loan_amount: Optional[int]
term_length: Optional[int]

AccountLiabilitySubTypesLiterals = Literal[
'business',
'unsecured',
'lease',
'loan',
'heloc',
'charge',
'flexible_spending',
'secured',
'purchase',
'note',
'private',
'federal',
'rent'
]

class AccountLiability(TypedDict):
mch_id: str
mask: Optional[str]
ownership: Optional[AccountOwnershipLiterals]
fingerprint: Optional[str]
type: Optional[AccountLiabilityTypesLiterals]
sub_type: Optional[AccountLiabilitySubTypesLiterals]
name: Optional[str]


Expand Down
39 changes: 39 additions & 0 deletions method/resources/CardProduct.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from typing import TypedDict, Optional, List, Literal

from method.resource import MethodResponse, Resource
from method.configuration import Configuration
from method.errors import ResourceError


CardProductTypeLiterals = Literal[
'specific',
'generic',
'in_review',
]

class CardProductBrand(TypedDict):
id: str
description: str
network: str
default_image: str


class CardProduct(TypedDict):
id: str
name: str
issuer: str
type: CardProductTypeLiterals
brands: List[CardProductBrand]
error: Optional[ResourceError]
created_at: str
updated_at: str


class CardProductResource(Resource):
def __init__(self, config: Configuration):
super(CardProductResource, self).__init__(config.add_path('card_product'))


def retrieve(self, prt_id: str) -> MethodResponse[CardProduct]:
return super(CardProductResource, self)._get_with_id(prt_id)

11 changes: 6 additions & 5 deletions method/resources/Entities/Connect.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import TypedDict, Optional, Literal, List

from method.resource import MethodResponse, Resource, ResourceListOpts
from method.resource import MethodResponse, RequestOpts, Resource, ResourceListOpts
from method.configuration import Configuration
from method.errors import ResourceError

Expand Down Expand Up @@ -40,8 +40,8 @@ class EntityConnect(TypedDict):
id: str
status: EntityConnectResponseStatusLiterals
accounts: Optional[List[str]]
requested_products: Optional[List[str]]
requested_subscriptions: Optional[List[str]]
requested_products: List[AccountProductsEligibleForAutomaticExecutionLiteral]
requested_subscriptions: List[AccountSubscriptionsEligibleForAutomaticExecutionLiteral]
error: Optional[ResourceError]
created_at: str
updated_at: str
Expand Down Expand Up @@ -76,7 +76,8 @@ def list(
def create(
self,
opts: ConnectCreateOpts = {},
params: Optional[ConnectExpandOpts] = None
params: Optional[ConnectExpandOpts] = None,
request_opts: Optional[RequestOpts] = None
) -> MethodResponse[EntityConnect]:
return super(EntityConnectResource, self)._create(data=opts, params=params)
return super(EntityConnectResource, self)._create(data=opts, params=params, request_opts=request_opts)

5 changes: 1 addition & 4 deletions method/resources/Entities/Products.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class EntityProduct(TypedDict):
status: EntityProductTypeStatusLiterals
status_error: Optional[ResourceError]
latest_request_id: str
latest_successful_request_id: str
latest_successful_request_id: Optional[str]
is_subscribable: bool
created_at: str
updated_at: str
Expand All @@ -35,8 +35,5 @@ class EntityProductResource(Resource):
def __init__(self, config: Configuration):
super(EntityProductResource, self).__init__(config.add_path('products'))

def retrieve(self, prd_id: str) -> MethodResponse[EntityProduct]:
return super(EntityProductResource, self)._get_with_id(prd_id)

def list(self) -> MethodResponse[EntityProductListResponse]:
return super(EntityProductResource, self)._list()
12 changes: 12 additions & 0 deletions method/resources/Opal/Opal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from method.resource import Resource
from method.configuration import Configuration
from method.resources.Opal.Token import OpalTokenResource


class OpalResource(Resource):
token: OpalTokenResource

def __init__(self, config: Configuration):
_config = config.add_path('opal')
super(OpalResource, self).__init__(_config)
self.token = OpalTokenResource(_config)
104 changes: 104 additions & 0 deletions method/resources/Opal/Token.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
from typing import TypedDict, Optional, Literal, List, Dict

from method.resource import MethodResponse, Resource
from method.configuration import Configuration

OpalModesLiterals = Literal[
'identity_verification',
'connect',
'card_connect',
'account_verification',
'transactions'
]


SkipPIILiterals = Literal[
'name',
'dob',
'address',
'ssn_4'
]


AccountFiltersAccountTypesLiterals = Literal[
'credit_card',
'auto_loan',
'mortgage',
'personal_loan',
'student_loan'
]


SelectionTypeLiterals = Literal['single', 'multiple', 'all']


class OpalAccountFiltersInclude(TypedDict):
account_types: List[AccountFiltersAccountTypesLiterals]


class OpalAccountFiltersExclude(TypedDict):
account_types: List[AccountFiltersAccountTypesLiterals]
mch_ids: List[str]
unverified_account_numbers: bool


class ConnectAccountFilters(TypedDict):
include: OpalAccountFiltersInclude
exclude: OpalAccountFiltersExclude


class CardConnectAccountFiltersExclude(TypedDict):
mch_ids: List[str]
unverified_account_numbers: bool


class CardConnectAccountFilters(TypedDict):
exclude: CardConnectAccountFiltersExclude


class OpalIdentityVerificationCreateOpts(TypedDict):
skip_pii: List[SkipPIILiterals]


class OpalConnectCreateOpts(TypedDict):
skip_pii: List[SkipPIILiterals]
selection_type: SelectionTypeLiterals
account_filters: ConnectAccountFilters


class OpalCardConnectCreateOpts(TypedDict):
skip_pii: List[SkipPIILiterals]
selection_type: SelectionTypeLiterals
account_filters: CardConnectAccountFilters


class OpalAccountVerificationCreateOpts(TypedDict):
account_id: str


class OpalTransactionsCreateOpts(TypedDict):
transactions: Dict[str, any]


class OpalTokenCreateOpts(TypedDict):
mode: OpalModesLiterals
entity_id: str
identity_verification: Optional[OpalIdentityVerificationCreateOpts]
connect: Optional[OpalConnectCreateOpts]
card_connect: Optional[OpalCardConnectCreateOpts]
account_verification: Optional[OpalAccountVerificationCreateOpts]
transactions: Optional[OpalTransactionsCreateOpts]


class OpalToken(TypedDict):
token: str
valid_until: str
session_id: str


class OpalTokenResource(Resource):
def __init__(self, config: Configuration):
super(OpalTokenResource, self).__init__(config.add_path('token'))

def create(self, opts: OpalTokenCreateOpts) -> MethodResponse[OpalToken]:
return super(OpalTokenResource, self)._create(opts)
2 changes: 2 additions & 0 deletions method/resources/Opal/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from method.resources.Opal.Opal import OpalResource
from method.resources.Opal.Token import OpalTokenResource, OpalToken
28 changes: 28 additions & 0 deletions method/resources/Simulate/Attributes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from method.resource import MethodResponse, Resource
from method.configuration import Configuration
from typing import Optional, Literal, List, TypedDict


AttributesBehaviorsLiterals = Literal[
'new_soft_inquiry'
]


class SimulateEntityAttributesOpts(TypedDict):
behaviors: List[AttributesBehaviorsLiterals]


class SimulateAttributesInstance(Resource):
def __init__(self, entity_id: str, config: Configuration):
super(SimulateAttributesInstance, self).__init__(config.add_path(entity_id))

def create(self, opts: SimulateEntityAttributesOpts) -> MethodResponse[Optional[None]]:
return super(SimulateAttributesInstance, self)._create(opts)


class SimulateAttributesResource(Resource):
def __init__(self, config: Configuration):
super(SimulateAttributesResource, self).__init__(config.add_path('attributes'))

def __call__(self, entity_id: str) -> SimulateAttributesInstance:
return SimulateAttributesInstance(entity_id, self.config)
Loading