def __init__(
        self,
        client_id,
        secret,
        public_key,
        environment,
        request_session,
        suppress_warnings=False,
        timeout=DEFAULT_TIMEOUT,
        api_version=None,
        client_app=None,
    ):
        '''
        Initialize a client with credentials.

        :param  str     client_id:          Your Plaid client ID
        :arg    str     secret:             Your Plaid secret
        :arg    str     public_key:         Your Plaid public key
        :arg    str     environment:        One of ``sandbox``,
                                            ``development``, or ``production``.
        :arg    bool    suppress_warnings:  Suppress Plaid warnings.
        :arg    int     timeout:            Timeout for API requests.
        :arg    str     api_version:        API version to use for requests
        :arg    str     client_app:         Internal header to include
                                            in requests
        :arg            request_session:    aiohttp ClientSession for http request
        '''
        self.client_id = client_id
        self.secret = secret
        self.public_key = public_key
        self.environment = environment
        self.suppress_warnings = suppress_warnings
        self.timeout = timeout
        self.api_version = api_version
        self.client_app = client_app
        self.request_session = request_session

        if self.environment == 'development' and not self.suppress_warnings:
            warnings.warn('''
                Development is not intended for production usage.
                Swap out url for https://production.plaid.com
                via Client.config before switching to production
            ''')

        # Mirror the HTTP API hierarchy
        self.Accounts = Accounts(self)
        self.AssetReport = AssetReport(self)
        self.Auth = Auth(self)
        self.Categories = Categories(self)
        self.CreditDetails = CreditDetails(self)
        self.Holdings = Holdings(self)
        self.Identity = Identity(self)
        self.Income = Income(self)
        self.Institutions = Institutions(self)
        self.InvestmentTransactions = InvestmentTransactions(self)
        self.Item = Item(self)
        self.Liabilities = Liabilities(self)
        self.Processor = Processor(self)
        self.Sandbox = Sandbox(self)
        self.Transactions = Transactions(self)
Exemplo n.º 2
0
    def __init__(self,
                 client_id,
                 secret,
                 public_key,
                 environment,
                 suppress_warnings=False,
                 timeout=DEFAULT_TIMEOUT):
        '''
        Initialize a client with credentials.

        :param  str     client_id:          Your Plaid client ID
        :arg    str     secret:             Your Plaid secret
        :arg    str     public_key:         Your Plaid public key
        :arg    str     environment:        One of ``sandbox``,
                                            ``development``, or ``production``.
        :arg    bool    suppress_warnings:  Suppress Plaid warnings.
        :arg    int     timeout:            Timeout for API requests.

        '''
        self.client_id = client_id
        self.secret = secret
        self.public_key = public_key
        self.environment = environment
        self.suppress_warnings = suppress_warnings
        self.timeout = timeout

        if self.environment == 'development' and not self.suppress_warnings:
            warnings.warn('''
                Development is not intended for production usage.
                Swap out url for https://production.plaid.com
                via Client.config before switching to production
            ''')

        # Mirror the HTTP API hierarchy
        self.Accounts = Accounts(self)
        self.Auth = Auth(self)
        self.Categories = Categories(self)
        self.CreditDetails = CreditDetails(self)
        self.Identity = Identity(self)
        self.Income = Income(self)
        self.Institutions = Institutions(self)
        self.Item = Item(self)
        self.Processor = Processor(self)
        self.Sandbox = Sandbox(self)
        self.Transactions = Transactions(self)
Exemplo n.º 3
0
def delete_plaid_account():
    """Delete user's linked plaid account from db"""
    account_id = request.form['accountId']
    # get account
    account = classes.Accounts.query.get(account_id)
    # get transactions associated with account
    transactions = classes.Transaction.query.\
        filter_by(account_id=account.id)

    accounts_with_plaid_id = classes.Accounts.query.\
        filter_by(plaid_id=account.plaid_id)\
        .count()
    # if only account associated with plaid id delete plaid id
    if accounts_with_plaid_id == 1:
        plaid_item = classes.PlaidItems.query.get(account.plaid_id)
        Item(client).remove(plaid_item.access_token)
        db.session.delete(plaid_item)

    for transaction in transactions:
        db.session.delete(transaction)
    db.session.delete(account)
    db.session.commit()

    return redirect(url_for('dashboard'))