Skip to content

Commit

Permalink
Create ACHRelationship model
Browse files Browse the repository at this point in the history
  • Loading branch information
drew887 committed May 4, 2022
1 parent b443799 commit 24e6f24
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 1 deletion.
9 changes: 9 additions & 0 deletions alpaca/broker/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pydantic import parse_obj_as
from requests import HTTPError, Response

from .enums import ACHRelationshipStatus
from .constants import BROKER_DOCUMENT_UPLOAD_LIMIT
from .models import (
Account,
Expand All @@ -18,6 +19,7 @@
TradeAccount,
TradeDocument,
UploadDocumentRequest,
ACHRelationship,
)
from ..common import APIError
from ..common.constants import ACCOUNT_ACTIVITIES_DEFAULT_PAGE_SIZE
Expand Down Expand Up @@ -589,3 +591,10 @@ def download_trade_document_for_account_by_id(
f.write(chunk)

# ############################## FUNDING ################################# #

def get_ach_relationships_for_account(
self,
account_id: Union[UUID, str],
statuses: Optional[List[ACHRelationshipStatus]],
) -> List[ACHRelationship]:
pass
23 changes: 23 additions & 0 deletions alpaca/broker/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,26 @@ class UploadDocumentMimeType(str, Enum):
PNG = "image/png"
JPEG = "image/jpeg"
JSON = "application/json"


class ACHRelationshipStatus(str, Enum):
"""
Represents the state that an ACHRelationship is in.
Please see https://alpaca.markets/docs/api-references/broker-api/funding/ach/#attributes for more details
"""

QUEUED = "QUEUED"
APPROVED = "APPROVED"
PENDING = "PENDING"


class BankAccountType(str, Enum):
"""
Represents a kind of bank account.
Please see https://alpaca.markets/docs/api-references/broker-api/funding/ach/#attributes
"""

CHECKING = "CHECKING"
SAVINGS = "SAVINGS"
1 change: 1 addition & 0 deletions alpaca/broker/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
from .cip import *
from .requests import *
from .documents import *
from .funding import *
35 changes: 35 additions & 0 deletions alpaca/broker/models/funding.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from datetime import datetime
from typing import Optional
from uuid import UUID

from ..enums import ACHRelationshipStatus, BankAccountType
from alpaca.common.models import ValidateBaseModel as BaseModel


class ACHRelationship(BaseModel):
"""
Attributes:
id (UUID): ID of Relationship
account_id (UUID): ID of the Account this ACHRelationship is tied to
created_at (datetime): Date and time this relationship was created
updated_at (datetime): Date and time of when this relationship was last updated
status (ACHRelationshipStatus): Current status of the relationship
account_owner_name (str): Full name of the account owner
bank_account_type (BankAccountType): The kind of bank account this relationship points to
bank_account_number (str): The number of bank account that the relationship points to
bank_routing_number (str): Routing number for the bank account
nickname (str): User provided name for account
processor_token (Optional[str]): If you are using Plaid, then this is a Plaid processor token.
"""

id: UUID
account_id: UUID
created_at: datetime
updated_at: datetime
status: ACHRelationshipStatus
account_owner_name: str
bank_account_type: BankAccountType
bank_account_number: str
bank_routing_number: str
nickname: str
processor_token: Optional[str] = None
19 changes: 19 additions & 0 deletions docs/api_reference/broker/models/funding.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.. toctree::
:maxdepth: 2
:caption: Contents:

Models For Accessing and Controlling Funding of Accounts
========================================================

This page is for the models representing the information that various API requests require/can use.

This has been separated out into a different module internally (and here in the docs) for ease of development
but is still accessible from ``alpaca.broker.models`` directly.

For example:

>>> from alpaca.broker.models import ACHRelationship


.. automodule:: alpaca.broker.models.funding
:members:
2 changes: 1 addition & 1 deletion tools/scripts/generate-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ poetry run make clean

#run make html with a flag to make sphinx treat warnings as errors instead of generating incomplete docs
#we also run doctest to ensure any doctests are successful before generating html
poetry run make doctest html SPHINXOPTS="-W"
poetry run make html doctest SPHINXOPTS="-W"

0 comments on commit 24e6f24

Please sign in to comment.