Exemplo n.º 1
0
    def _add(self, url, account_type, login, options=None):
        """
        Add a bank account user/login to Plaid and receive an access token
        unless a 2nd level of authentication is required, in which case
        an MFA (Multi Factor Authentication) question(s) is returned

        `url`           str     Plaid endpoint url
        `account_type`  str     The type of bank account you want to sign in
                                to, must be one of the keys in `ACCOUNT_TYPES`
        `login`         dict
            `username`        str     username for the bank account
            `password`        str     The password for the bank account
            `pin`             int     (optional) pin for the bank account

        `options`       dict
            `webhook`   str         URL to hit once the account's transactions
                                    have been processed
            `mfa_list`  boolean     List all available MFA (Multi Factor
                                    Authentication) options
        """

        return post_request(
            url,
            data={
                "client_id": self.client_id,
                "secret": self.secret,
                "type": account_type,
                "credentials": json.dumps(login),
                "options": json.dumps(dict({"list": True}, **(options if options is not None else {}))),
            },
            suppress_errors=self.suppress_http_errors,
        )
Exemplo n.º 2
0
    def _step(self, credentials, url, method, account_type, mfa, options=None):
        """
        Perform a MFA (Multi Factor Authentication) step with access_token.

        `method`        str     HTTP Method
        `url`           str     Plaid endpoint url

        `account_type`  str     The type of bank account you're performing MFA
                                on, must match what you used in the `connect`
                                call
        `mfa`           str     The MFA answer, e.g. an answer to q security
                                question or code sent to your phone, etc.
        `options`       dict
            `send_method`   dict    The send method your MFA answer is for,
                                    e.g. {'type': phone'}, should come from
                                    the list from the `mfa_list` option in
                                    the call
        """
        return http_request(
            url,
            method=method,
            data=dict(
                {"type": account_type, "mfa": mfa, "options": json.dumps(options if options is not None else {})},
                **credentials
            ),
            suppress_errors=self.suppress_http_errors,
        )
Exemplo n.º 3
0
    def _step(self, credentials, url, method, account_type, mfa, options=None):
        '''
        Perform a MFA (Multi Factor Authentication) step with access_token.

        `method`        str     HTTP Method
        `url`           str     Plaid endpoint url

        `account_type`  str     The type of bank account you're performing MFA
                                on, must match what you used in the `connect`
                                call
        `mfa`           str     The MFA answer, e.g. an answer to q security
                                question or code sent to your phone, etc.
        `options`       dict
            `send_method`   dict    The send method your MFA answer is for,
                                    e.g. {'type': phone'}, should come from
                                    the list from the `mfa_list` option in
                                    the call
        '''
        return http_request(
            url,
            method=method,
            data=dict(
                {
                    'type': account_type,
                    'mfa': mfa,
                    'options':
                    json.dumps(options if options is not None else {}),
                }, **credentials),
            suppress_errors=self.suppress_http_errors)
Exemplo n.º 4
0
def answer_selections(selections):
    # We have magically inferred the answers
    # so we respond immediately
    # In the real world, we would present the selection
    # questions and choices to our user and submit their responses
    # in a JSON-encoded array with answers provided
    # in the same order as the given questions
    answer = json.dumps(['Yes', 'No'])
    return client.connect_step(account_type, answer)
Exemplo n.º 5
0
    def get_advanced_friend_data(self, username):
        make_json = []
        for items in self.get_friends(username):
            names = items['user_name']
            make_json.append(self.build_json(names))
        #print make_json.replace("'","")

    # make_json=str(make_json).replace("'","")
    #print json.loads(make_json)
        make_json = {"get_advanced_friend_data": make_json}
        return json.dumps(make_json)
Exemplo n.º 6
0
    def _add(self, url, account_type, login, options=None):
        '''
        Add a bank account user/login to Plaid and receive an access token
        unless a 2nd level of authentication is required, in which case
        an MFA (Multi Factor Authentication) question(s) is returned

        `url`           str     Plaid endpoint url
        `account_type`  str     The type of bank account you want to sign in
                                to, must be one of the keys in `ACCOUNT_TYPES`
        `login`         dict
            `username`        str     username for the bank account
            `password`        str     The password for the bank account
            `pin`             int     (optional) pin for the bank account

        `options`       dict
            `webhook`   str         URL to hit once the account's transactions
                                    have been processed
            `mfa_list`  boolean     List all available MFA (Multi Factor
                                    Authentication) options
        '''

        return post_request(
            url,
            data={
                'client_id':
                self.client_id,
                'secret':
                self.secret,
                'type':
                account_type,
                'credentials':
                json.dumps(login),
                'options':
                json.dumps(
                    dict({'list': True},
                         **(options if options is not None else {}))),
            },
            suppress_errors=self.suppress_http_errors)
Exemplo n.º 7
0
    def connect_get(self, url, credentials, opts=None):
        """
        Fetch a list of transactions, requires `access_token`

        `options`   dict (optional)
            `pending`     bool      Fetch pending transactions (default false)
            `account`     str       Fetch transactions only from this account
            `gte`         date      Fetch transactions posted after this date
                                    (default 30 days ago)
            `lte`         date      Fetch transactions posted before this date
        """

        return post_request(
            url,
            data=dict(credentials, **{"options": json.dumps(opts if opts is not None else {})}),
            suppress_errors=self.suppress_http_errors,
        )
Exemplo n.º 8
0
    def connect_get(self, url, credentials, opts=None):
        '''
        Fetch a list of transactions, requires `access_token`

        `options`   dict (optional)
            `pending`     bool      Fetch pending transactions (default false)
            `account`     str       Fetch transactions only from this account
            `gte`         date      Fetch transactions posted after this date
                                    (default 30 days ago)
            `lte`         date      Fetch transactions posted before this date
        '''

        return post_request(
            url,
            data=dict(
                credentials,
                **{'options': json.dumps(opts if opts is not None else {})}),
            suppress_errors=self.suppress_http_errors)