Skip to content
Closed
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
23 changes: 16 additions & 7 deletions unit/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,31 @@ class DepositAccountDTO(object):
def __init__(self, id: str, created_at: datetime, name: str, deposit_product: str, routing_number: str,
account_number: str, currency: str, balance: int, hold: int, available: int, status: AccountStatus,
tags: Optional[Dict[str, str]], close_reason: Optional[CloseReason],
relationships: Optional[Dict[str, Relationship]]):
relationships: Optional[Dict[str, Relationship]], updated_at: Optional[datetime] = None,
freeze_reason: Optional[str] = None, fraud_reason: Optional[FraudReason] = None,
daca_status: Optional[str] = None, interest_terms: Optional[Dict] = None):
self.id = id
self.type = "depositAccount"
self.attributes = {"name": name, "createdAt": created_at, "depositProduct": deposit_product,
self.attributes = {"name": name, "createdAt": created_at, "updatedAt": updated_at,
"depositProduct": deposit_product,
"routingNumber": routing_number, "accountNumber": account_number, "currency": currency,
"balance": balance, "hold": hold, "available": available, "status": status,
"closeReason": close_reason, "tags": tags}
"freezeReason": freeze_reason, "closeReason": close_reason, "fraudReason": fraud_reason,
"dacaStatus": daca_status, "interestTerms": interest_terms, "tags": tags}
self.relationships = relationships

@staticmethod
def from_json_api(_id, _type, attributes, relationships):
return DepositAccountDTO(
_id, date_utils.to_datetime(attributes["createdAt"]), attributes["name"], attributes["depositProduct"],
attributes["routingNumber"], attributes["accountNumber"], attributes["currency"], attributes["balance"],
attributes["hold"], attributes["available"], attributes["status"], attributes.get("tags"),
attributes.get("closeReason"), relationships
id=_id, created_at=date_utils.to_datetime(attributes["createdAt"]), name=attributes["name"],
deposit_product=attributes["depositProduct"], routing_number=attributes["routingNumber"],
account_number=attributes["accountNumber"], currency=attributes["currency"],
balance=attributes["balance"], hold=attributes["hold"], available=attributes["available"],
status=attributes["status"], tags=attributes.get("tags"),
close_reason=attributes.get("closeReason"), relationships=relationships,
updated_at=date_utils.to_datetime(attributes.get("updatedAt")) if attributes.get("updatedAt") else None,
freeze_reason=attributes.get("freezeReason"), fraud_reason=attributes.get("fraudReason"),
daca_status=attributes.get("dacaStatus"), interest_terms=attributes.get("interestTerms"),
)


Expand Down
12 changes: 8 additions & 4 deletions unit/models/account_end_of_day.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@

class AccountEndOfDayDTO(object):
def __init__(self, id: str, date: str, balance: int, hold: int, available: int,
relationships: Optional[Dict[str, Relationship]]):
relationships: Optional[Dict[str, Relationship]], overdraft_limit: Optional[int] = None):
self.id = id
self.type = "accountEndOfDay"
self.attributes = {"date": date, "balance": balance, "hold": hold, "available": available}
self.attributes = {"date": date, "balance": balance, "hold": hold, "available": available,
"overdraftLimit": overdraft_limit}
self.relationships = relationships

@staticmethod
def from_json_api(_id, _type, attributes, relationships):
return AccountEndOfDayDTO(_id, attributes["date"], attributes["balance"], attributes["hold"],
attributes["available"], relationships)
return AccountEndOfDayDTO(
id=_id, date=attributes["date"], balance=attributes["balance"], hold=attributes["hold"],
available=attributes["available"], relationships=relationships,
overdraft_limit=attributes.get("overdraftLimit"),
)


class ListAccountEndOfDayParams(UnitParams):
Expand Down
14 changes: 9 additions & 5 deletions unit/models/counterparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,23 @@
class CounterpartyDTO(object):
def __init__(self, id: str, created_at: datetime, name: str, routing_number: str, bank: Optional[str],
account_number: str, account_type: str, type: str, permissions: str,
relationships: [Dict[str, Relationship]]):
relationships: [Dict[str, Relationship]], tags: Optional[Dict[str, str]] = None):
self.id = id
self.type = "achCounterparty"
self.attributes = {"createdAt": created_at, "name": name, "routingNumber": routing_number, "bank": bank,
"accountNumber": account_number, "accountType": account_type, "type": type,
"permissions": permissions}
"permissions": permissions, "tags": tags}
self.relationships = relationships

@staticmethod
def from_json_api(_id, _type, attributes, relationships):
return CounterpartyDTO(_id, date_utils.to_datetime(attributes["createdAt"]), attributes["name"],
attributes["routingNumber"], attributes.get("bank"), attributes["accountNumber"],
attributes["accountType"], attributes["type"], attributes["permissions"], relationships)
return CounterpartyDTO(
id=_id, created_at=date_utils.to_datetime(attributes["createdAt"]), name=attributes["name"],
routing_number=attributes["routingNumber"], bank=attributes.get("bank"),
account_number=attributes["accountNumber"], account_type=attributes["accountType"],
type=attributes["type"], permissions=attributes["permissions"], relationships=relationships,
tags=attributes.get("tags"),
)


class CreateCounterpartyRequest(UnitRequest):
Expand Down
46 changes: 29 additions & 17 deletions unit/models/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,31 @@ def __init__(self, id: str, created_at: datetime, full_name: FullName, date_of_b
phone: Phone, email: str, ssn: Optional[str], passport: Optional[str], nationality: Optional[str],
authorized_users: [AuthorizedUser], tags: Optional[Dict[str, str]],
relationships: Optional[Dict[str, Relationship]], status: CustomerStatus,
archive_reason: Optional[ArchiveReason]):
archive_reason: Optional[ArchiveReason], eligible_products: Optional[List[str]] = None,
ein: Optional[str] = None):
self.id = id
self.type = 'individualCustomer'
self.attributes = {"createdAt": created_at, "fullName": full_name, "dateOfBirth": date_of_birth,
"address": address, "phone": phone, "email": email, "ssn": ssn, "passport": passport,
"nationality": nationality, "authorizedUsers": authorized_users, "tags": tags,
"nationality": nationality, "ein": ein, "authorizedUsers": authorized_users,
"eligibleProducts": eligible_products, "tags": tags,
"status": status, "archiveReason": archive_reason}
self.relationships = relationships

@staticmethod
def from_json_api(_id, _type, attributes, relationships):
return IndividualCustomerDTO(
_id, date_utils.to_datetime(attributes["createdAt"]),
FullName.from_json_api(attributes["fullName"]), date_utils.to_date(attributes["dateOfBirth"]),
Address.from_json_api(attributes["address"]), Phone.from_json_api(attributes["phone"]),
attributes["email"], attributes.get("ssn"), attributes.get("passport"), attributes.get("nationality"),
AuthorizedUser.from_json_api(attributes["authorizedUsers"]), attributes.get("tags"), relationships,
attributes.get("status"), attributes.get("archiveReason")
id=_id, created_at=date_utils.to_datetime(attributes["createdAt"]),
full_name=FullName.from_json_api(attributes["fullName"]),
date_of_birth=date_utils.to_date(attributes["dateOfBirth"]),
address=Address.from_json_api(attributes["address"]),
phone=Phone.from_json_api(attributes["phone"]),
email=attributes["email"], ssn=attributes.get("ssn"), passport=attributes.get("passport"),
nationality=attributes.get("nationality"),
authorized_users=AuthorizedUser.from_json_api(attributes["authorizedUsers"]),
tags=attributes.get("tags"), relationships=relationships, status=attributes.get("status"),
archive_reason=attributes.get("archiveReason"),
eligible_products=attributes.get("eligibleProducts"), ein=attributes.get("ein"),
)


Expand All @@ -37,25 +44,30 @@ def __init__(self, id: str, created_at: datetime, name: str, address: Address, p
state_of_incorporation: str, ein: str, entity_type: EntityType, contact: BusinessContact,
authorized_users: [AuthorizedUser], dba: Optional[str], tags: Optional[Dict[str, str]],
relationships: Optional[Dict[str, Relationship]], status: CustomerStatus,
archive_reason: Optional[ArchiveReason]):
archive_reason: Optional[ArchiveReason], eligible_products: Optional[List[str]] = None):
self.id = id
self.type = 'businessCustomer'
self.attributes = {"createdAt": created_at, "name": name, "address": address, "phone": phone,
"stateOfIncorporation": state_of_incorporation, "ein": ein, "entityType": entity_type,
"contact": contact, "authorizedUsers": authorized_users, "dba": dba, "tags": tags,
"contact": contact, "authorizedUsers": authorized_users, "dba": dba,
"eligibleProducts": eligible_products, "tags": tags,
"status": status, "archiveReason": archive_reason}
self.relationships = relationships

@staticmethod
def from_json_api(_id, _type, attributes, relationships):
return BusinessCustomerDTO(
_id, date_utils.to_datetime(attributes["createdAt"]), attributes["name"],
Address.from_json_api(attributes["address"]), Phone.from_json_api(attributes["phone"]),
attributes["stateOfIncorporation"], attributes["ein"], attributes["entityType"],
BusinessContact.from_json_api(attributes["contact"]),
AuthorizedUser.from_json_api(attributes["authorizedUsers"]),
attributes.get("dba"), attributes.get("tags"), relationships, attributes.get("status"),
attributes.get("archiveReason"))
id=_id, created_at=date_utils.to_datetime(attributes["createdAt"]), name=attributes["name"],
address=Address.from_json_api(attributes["address"]),
phone=Phone.from_json_api(attributes["phone"]),
state_of_incorporation=attributes["stateOfIncorporation"], ein=attributes["ein"],
entity_type=attributes["entityType"],
contact=BusinessContact.from_json_api(attributes["contact"]),
authorized_users=AuthorizedUser.from_json_api(attributes["authorizedUsers"]),
dba=attributes.get("dba"), tags=attributes.get("tags"), relationships=relationships,
status=attributes.get("status"), archive_reason=attributes.get("archiveReason"),
eligible_products=attributes.get("eligibleProducts"),
)

CustomerDTO = Union[IndividualCustomerDTO, BusinessCustomerDTO]

Expand Down
25 changes: 14 additions & 11 deletions unit/models/dispute.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ def __init__(
status_history: List[Dict[str, str]],
status: DisputeStatus,
description: str,
dispute_type: str,
dispute_type: Optional[str],
created_at: datetime,
amount: int,
decision_reason: Optional[str],
relationships: Optional[Dict[str, Relationship]],
updated_at: Optional[datetime] = None,
):
self.id = id
self.type = "dispute"
self.attributes = {
"createdAt": created_at,
"updatedAt": updated_at,
"source": source,
"statusHistory": status_history,
"status": status,
Expand All @@ -41,14 +43,15 @@ def __init__(
@staticmethod
def from_json_api(_id, _type, attributes, relationships):
return DisputeDTO(
_id,
date_utils.to_datetime(attributes["createdAt"]),
attributes["source"],
attributes["statusHistory"],
attributes["status"],
attributes["description"],
attributes["disputeType"],
attributes["amount"],
attributes.get("decisionReason"),
relationships,
id=_id,
source=attributes["source"],
status_history=attributes["statusHistory"],
status=attributes["status"],
description=attributes["description"],
dispute_type=attributes.get("disputeType"),
created_at=date_utils.to_datetime(attributes["createdAt"]),
amount=attributes["amount"],
decision_reason=attributes.get("decisionReason"),
relationships=relationships,
updated_at=date_utils.to_datetime(attributes.get("updatedAt")) if attributes.get("updatedAt") else None,
)
Loading
Loading