Ejemplo n.º 1
0
 def risk_get(self, url, credentials):
     '''
     Fetches income for a user
     '''
     return post_request(url,
                         data=credentials,
                         suppress_errors=self.suppress_http_errors)
Ejemplo n.º 2
0
 def auth_get(self, url, credentials):
     '''
     Fetch accounts associated with the set access_token
     '''
     return post_request(url,
                         data=credentials,
                         suppress_errors=self.suppress_http_errors)
Ejemplo n.º 3
0
    def upgrade(self, url, credentials, product):
        """
        Upgrade account to another plaid type

        `product`     str    [auth | connect]
        """
        return post_request(url, data=dict(credentials, upgrade_to=product), suppress_errors=self.suppress_http_errors)
Ejemplo n.º 4
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,
        )
Ejemplo n.º 5
0
 def auth_get(self, url, credentials):
     '''
     Fetch accounts associated with the set access_token
     '''
     return post_request(
         url,
         data=credentials,
         suppress_errors=self.suppress_http_errors
     )
Ejemplo n.º 6
0
 def info_get(self, url, credentials):
     '''
     Fetches info for a user
     '''
     return post_request(
         url,
         data=credentials,
         suppress_errors=self.suppress_http_errors
     )
Ejemplo n.º 7
0
    def upgrade(self, url, credentials, product):
        '''
        Upgrade account to another plaid type

        `product`     str    [auth | connect]
        '''
        return post_request(url,
                            data=dict(credentials, upgrade_to=product),
                            suppress_errors=self.suppress_http_errors)
Ejemplo n.º 8
0
 def _post(self, path, data):
     headers = {}
     if self.api_version is not None:
         headers = {'Plaid-Version': self.api_version}
     return post_request(
         urljoin('https://' + self.environment + '.plaid.com', path),
         data=data,
         timeout=self.timeout,
         headers=headers,
     )
Ejemplo n.º 9
0
 def _post(self, path, data, is_json):
     headers = {}
     if self.api_version is not None:
         headers = {'Plaid-Version': self.api_version}
     return post_request(
         urljoin('https://' + self.environment + '.plaid.com', path),
         data=data,
         timeout=self.timeout,
         is_json=is_json,
         headers=headers,
     )
Ejemplo n.º 10
0
    def exchange_token(self, url, public_token):
        """
        Only applicable to apps using the Link front-end SDK
        Exchange a Link public_token for an API access_token

        `public_token`     str    public_token returned by Link client
        """
        return post_request(
            url,
            data={"client_id": self.client_id, "secret": self.secret, "public_token": public_token},
            suppress_errors=self.suppress_http_errors,
        )
Ejemplo n.º 11
0
 def _post(self, path, data, is_json):
     headers = {}
     if self.api_version is not None:
         headers['Plaid-Version'] = self.api_version
     if self.client_app is not None:
         headers['Plaid-Client-App'] = self.client_app
     return post_request(
         urljoin('https://' + self.environment + '.plaid.com', path),
         data=data,
         timeout=self.timeout,
         is_json=is_json,
         headers=headers,
     )
Ejemplo n.º 12
0
    def exchange_token(self, url, public_token):
        '''
        Only applicable to apps using the Link front-end SDK
        Exchange a Link public_token for an API access_token

        `public_token`     str    public_token returned by Link client
        '''
        return post_request(url,
                            data={
                                'client_id': self.client_id,
                                'secret': self.secret,
                                'public_token': public_token,
                            },
                            suppress_errors=self.suppress_http_errors)
Ejemplo n.º 13
0
    def exchange_token(self, url, public_token):
        '''
        Only applicable to apps using the Link front-end SDK
        Exchange a Link public_token for an API access_token

        `public_token`     str    public_token returned by Link client
        '''
        return post_request(
            url,
            data={
                'client_id': self.client_id,
                'secret': self.secret,
                'public_token': public_token,
            },
            suppress_errors=self.suppress_http_errors
        )
Ejemplo n.º 14
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,
        )
Ejemplo n.º 15
0
    def exchange_token(self, url, public_token, account_id=None):
        """
        Only applicable to apps using the Link front-end SDK
        Exchange a Link public_token for an API access_token

        `public_token`  str    public_token returned by Link client
        `account_id`    str    Plaid account ID
                               used to create a bank account token
        """
        return post_request(
            url,
            data=dict(
                {"client_id": self.client_id, "secret": self.secret, "public_token": public_token},
                **({} if account_id is None else {"account_id": account_id})
            ),
            suppress_errors=self.suppress_http_errors,
        )
Ejemplo n.º 16
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)
Ejemplo n.º 17
0
    def exchange_token(self, url, public_token, account_id=None):
        '''
        Only applicable to apps using the Link front-end SDK
        Exchange a Link public_token for an API access_token

        `public_token`  str    public_token returned by Link client
        `account_id`    str    Plaid account ID
                               used to create a bank account token
        '''
        return post_request(url,
                            data=dict(
                                {
                                    'client_id': self.client_id,
                                    'secret': self.secret,
                                    'public_token': public_token,
                                },
                                **({} if account_id is None else {
                                    'account_id': account_id
                                })),
                            suppress_errors=self.suppress_http_errors)
Ejemplo n.º 18
0
    def exchange_token(self, url, public_token, account_id=None):
        '''
        Only applicable to apps using the Link front-end SDK
        Exchange a Link public_token for an API access_token

        `public_token`  str    public_token returned by Link client
        `account_id`    str    Plaid account ID
                               used to create a bank account token
        '''
        return post_request(
            url,
            data=dict({
                'client_id': self.client_id,
                'secret': self.secret,
                'public_token': public_token,
            }, **(
                {} if account_id is None
                else {'account_id': account_id}
            )),
            suppress_errors=self.suppress_http_errors
        )
Ejemplo n.º 19
0
 def institutions_all(self, url, credentials, count=100, offset=0, products=None):
     """
     Fetch all Plaid institutions, using /institutions/all
     `count`               int   Number of Institutions to fetch. Optional.
     `offset`              int   Number of Institutions to skip. Optional.
     `products`            [str] Return only Institutions that support
                                 the specified product(s). Optional.
     """
     params = dict(
         [
             (key, value)
             for key, value in [
                 ("count", count),
                 ("offset", offset),
                 ("products", products),
                 ("client_id", credentials["client_id"]),
                 ("secret", credentials["secret"]),
             ]
             if value is not None
         ]
     )
     return post_request(url, data=params, suppress_errors=self.suppress_http_errors)
Ejemplo n.º 20
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)
Ejemplo n.º 21
0
 def institutions_all(self,
                      url,
                      credentials,
                      count=100,
                      offset=0,
                      products=None):
     '''
     Fetch all Plaid institutions, using /institutions/all
     `count`               int   Number of Institutions to fetch. Optional.
     `offset`              int   Number of Institutions to skip. Optional.
     `products`            [str] Return only Institutions that support
                                 the specified product(s). Optional.
     '''
     params = dict([
         (key, value) for key, value in [('count', count), (
             'offset',
             offset), ('products',
                       products), ('client_id', credentials['client_id']
                                   ), ('secret', credentials['secret'])]
         if value is not None
     ])
     return post_request(url,
                         data=params,
                         suppress_errors=self.suppress_http_errors)
Ejemplo n.º 22
0
 def risk_get(self, url, credentials):
     """
     Fetches income for a user
     """
     return post_request(url, data=credentials, suppress_errors=self.suppress_http_errors)
Ejemplo n.º 23
0
 def _post(self, path, data):
     return post_request(urljoin(
         'https://' + self.environment + '.plaid.com', path),
                         data=data,
                         timeout=self.timeout)