Skip to content
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
43 changes: 15 additions & 28 deletions method/resources/Account.py → method/resources/Account/Account.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from method.configuration import Configuration
from method.errors import ResourceError
from method.resources.Verification import VerificationResource
from method.resources.AccountSync import AccountSyncResource, AccountSync
from method.resources.Account import AccountSyncResource, AccountSync, \
AccountVerificationSessionResource, AccountPayoffsResource, AccountBalancesResource


# Literals, keep ordered alphabetically
Expand Down Expand Up @@ -127,12 +128,6 @@
'over_120'
]

AccountPayoffStatusesLiterals = Literal[
'completed',
'in_progress',
'pending',
'failed'
]

class AccountACH(TypedDict):
routing: int
Expand Down Expand Up @@ -479,24 +474,21 @@ class AccountPaymentHistory(TypedDict):
payment_history: List[CreditReportTradelinePaymentHistoryItem]


class AccountPayoff(TypedDict):
id: str
status: AccountPayoffStatusesLiterals
amount: Optional[int]
term: Optional[int]
per_diem_amount: Optional[int]
error: Optional[ResourceError]
created_at: str
updated_at: str


class AccountSubResources:
verification: VerificationResource
sync: AccountSyncResource
syncs: AccountSyncResource
payoffs: AccountPayoffsResource
verification_sessions: AccountVerificationSessionResource
balances: AccountBalancesResource


def __init__(self, _id: str, config: Configuration):
self.verification = VerificationResource(config.add_path(_id))
self.syncs = AccountSyncResource(config.add_path(_id))
self.payoffs = AccountPayoffsResource(config.add_path(_id))
self.verification_sessions = AccountVerificationSessionResource(config.add_path(_id))
self.balances = AccountBalancesResource(config.add_path(_id))


class AccountResource(Resource):
def __init__(self, config: Configuration):
Expand All @@ -505,7 +497,7 @@ def __init__(self, config: Configuration):
def __call__(self, _id: str) -> AccountSubResources:
return AccountSubResources(_id, self.config)

def get(self, _id: str) -> Account:
def retrieve(self, _id: str) -> Account:
return super(AccountResource, self)._get_with_id(_id)

def update(self, _id: str, opts: LiabilityUpdateOpts) -> Account:
Expand All @@ -517,10 +509,10 @@ def list(self, params: Optional[AccountListOpts] = None) -> List[Account]:
def create(self, opts: Union[AccountACHCreateOpts, AccountLiabilityCreateOpts, AccountClearingCreateOpts], request_opts: Optional[RequestOpts] = None) -> Account:
return super(AccountResource, self)._create(opts, request_opts)

def get_payment_history(self, _id: str) -> AccountPaymentHistory:
def retrieve_payment_history(self, _id: str) -> AccountPaymentHistory:
return super(AccountResource, self)._get_with_sub_path('{_id}/payment_history'.format(_id=_id))

def get_details(self, _id: str) -> AccountDetail:
def retrieve_details(self, _id: str) -> AccountDetail:
return super(AccountResource, self)._get_with_sub_path('{_id}/details'.format(_id=_id))

def bulk_sync(self, acc_ids: AccountCreateBulkSyncOpts) -> AccountCreateBulkSyncResponse:
Expand All @@ -543,9 +535,4 @@ def unenroll_auto_syncs(self, _id: str) -> Account:

def withdraw_consent(self, _id: str, data: AccountWithdrawConsentOpts = { 'type': 'withdraw', 'reason': 'holder_withdrew_consent' }) -> Account:
return super(AccountResource, self)._create_with_sub_path('{_id}/consent'.format(_id=_id), data)

def get_payoff(self, _id: str, pyf_id: str) -> AccountPayoff:
return super(AccountResource, self)._get_with_sub_path('{_id}/payoffs/{pyf_id}'.format(_id=_id, pyf_id=pyf_id))

def create_payoff(self, _id: str) -> AccountPayoff:
return super(AccountResource, self)._create_with_sub_path('{_id}/payoffs'.format(_id=_id), {})

30 changes: 30 additions & 0 deletions method/resources/Account/Balances.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from typing import TypedDict, Optional, Literal

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

AccountBalanceStatusLiterals = Literal[
'completed',
'in_progress',
'pending',
'failed'
]

class AccountBalances(TypedDict):
id: str
status: AccountBalanceStatusLiterals
balance: Optional[int]
error: Optional[ResourceError]
created_at: str
updated_at: str

class AccountBalancesResource(Resource):
def __init__(self, config: Configuration):
super(AccountBalancesResource, self).__init__(config.add_path('balances'))

def retrieve(self, bal_id: str) -> AccountBalances:
return super(AccountBalancesResource, self)._get_with_id(bal_id)

def create(self) -> AccountBalances:
return super(AccountBalancesResource, self)._create({})
262 changes: 262 additions & 0 deletions method/resources/Account/ExternalTypes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
from typing import TypedDict, Optional, List, Literal


PlaidTransactionTypesLiterals = Literal[
'digital',
'place',
'special',
'unresolved'
]


PlaidTransactionPaymentChannelTypesLiterals = Literal[
'online',
'in_store',
'other'
]


PlaidTransactionCodeLiterals = Literal[
'adjustment',
'atm',
'bank charge',
'bill payment',
'cash',
'cashback',
'cheque',
'direct debit',
'interest',
'purchase',
'standing order',
'transfer',
'null'
]


PlaidCounterpartyTypeLiterals = Literal[
'merchant',
'financial_institution',
'payment_app',
'marketplace',
'payment_terminal',
'income_source'
]


class PlaidBalance(TypedDict):
available: Optional[int]
current: Optional[int]
iso_currency_code: Optional[str]
limit: Optional[int]
unofficial_currency_code: Optional[str]


class PlaidLocation(TypedDict):
address: Optional[str]
city: Optional[str]
region: Optional[str]
postal_code: Optional[str]
country: Optional[str]
lat: Optional[int]
lon: Optional[int]
store_number: Optional[str]


class PlaidPaymentMeta(TypedDict):
reference_number: Optional[str]
ppd_id: Optional[str]
payee: Optional[str]
by_order_of: Optional[str]
payer: Optional[str]
payment_method: Optional[str]
payment_processor: Optional[str]
reason: Optional[str]


class PlaidPersonalFinanceCategory(TypedDict):
primary: str
detailed: str
confidence_level: Optional[str]


class PlaidTransactionCounterparty(TypedDict):
name: str
entity_id: Optional[str]
type: PlaidCounterpartyTypeLiterals;
website: Optional[str]
logo_url: Optional[str]
confidence_level: Optional[str]


class PlaidTransaction(TypedDict):
account_id: str
amount: int
iso_currency_code: Optional[str]
unofficial_currency_code: Optional[str]
category: Optional[List[str]]
category_id: Optional[str]
check_number: Optional[str]
date: str
location: PlaidLocation;
name: str
merchant_name: Optional[str]
original_description: Optional[str]
payment_meta: PlaidPaymentMeta;
pending: bool
pending_transaction_id: Optional[str]
account_owner: Optional[str]
transaction_id: str
transaction_type: Optional[PlaidTransactionTypesLiterals];
logo_url: Optional[str]
website: Optional[str]
authorized_date: Optional[str]
authorized_datetime: Optional[str]
datetime: Optional[str]
payment_channel: PlaidTransactionPaymentChannelTypesLiterals
personal_finance_category: Optional[PlaidPersonalFinanceCategory]
transaction_code: Optional[PlaidTransactionCodeLiterals]
personal_finance_category_icon_url: str
counterparties: List[PlaidTransactionCounterparty]
merchant_entity_id: Optional[str]


class MXAccount(TypedDict):
account_number: str
account_ownership: str
annuity_policy_to_date: str
annuity_provider: str
annuity_term_year: int
apr: int
apy: int
available_balance: int
available_credit: int
balance: int
cash_balance: int
cash_surrender_value: int
created_at: str
credit_limit: int
currency_code: str
day_payment_is_due: int
death_benefit: int
guid: str
holdings_value: int
id: str
imported_at: str
interest_rate: int
institution_code: str
insured_name: str
is_closed: bool
is_hidden: bool
is_manual: bool
last_payment: int
last_payment_at: str
loan_amount: int
margin_balance: int
matures_on: str
member_guid: str
member_id: str
member_is_managed_by_user: bool
metadata: str
minimum_balance: int
minimum_payment: int
name: str
nickname: str
original_balance: int
pay_out_amount: int
payment_due_at: str
payoff_balance: int
premium_amount: int
property_type: str
routing_number: str
skip_webhook: bool
started_on: str
subtype: str
today_ugl_amount: int
today_ugl_percentage: int
total_account_value: int
type: str
updated_at: str
user_guid: str
user_id: str


class MXTransaction(TypedDict):
account_guid: str
account_id: str
amount: int
category: str
category_guid: str
check_number_string: str
created_at: str
currency_code: str
date: str
description: str
extended_transaction_type: str
guid: str
id: str
is_bill_pay: bool
is_direct_deposit: bool
is_expense: bool
is_fee: bool
is_income: bool
is_international: bool
is_overdraft_fee: bool
is_payroll_advance: bool
is_recurring: bool
is_subscription: bool
latitude: int
localized_description: str
localized_memo: str
longitude: int
member_guid: str
member_is_managed_by_user: bool
memo: str
merchant_category_code: int
merchant_guid: str
merchant_location_guid: str
metadata: str
original_description: str
posted_at: str
status: str
top_level_category: str
transacted_at: str
type: str
updated_at: str
user_guid: str
user_id: str


class TellerLinks(TypedDict):
account: str
self: str


class TellerBalance(TypedDict):
ledger: int
links: TellerLinks
account_id: str
available: int


class TellerTransactionCounterparty(TypedDict):
type: str
name: str


class TellerTransactionDetails(TypedDict):
category: str
counterparty: TellerTransactionCounterparty
processing_status: str


class TellerTransaction(TypedDict):
running_balance: Optional[int]
details: TellerTransactionDetails
description: str
account_id: str
date: str
id: str
links: TellerLinks
amount: int
type: str
status: str
Loading