def risk_get(self, url, credentials): ''' Fetches income for a user ''' return post_request(url, data=credentials, suppress_errors=self.suppress_http_errors)
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)
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)
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, )
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 )
def info_get(self, url, credentials): ''' Fetches info for a user ''' return post_request( url, data=credentials, suppress_errors=self.suppress_http_errors )
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)
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, )
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, )
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, )
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, )
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)
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 )
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, )
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, )
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)
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)
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 )
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)
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)
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)
def risk_get(self, url, credentials): """ Fetches income for a user """ return post_request(url, data=credentials, suppress_errors=self.suppress_http_errors)
def _post(self, path, data): return post_request(urljoin( 'https://' + self.environment + '.plaid.com', path), data=data, timeout=self.timeout)