def import_into_database(self, user, sub_account, access_token): # data = PlaidData.getData('wells', "joefarned3", "angela0816", '*****@*****.**') client = Client(client_id=self.client_id, secret=self.secret) client.set_access_token(access_token) connect = client.transactions() data = json.loads(connect.content) c = MongoClient() db = c['pava'] accounts = db['accounts'] transactions = db['transactions'] for account in data['accounts']: account['_user_id'] = user.id account['_user_account'] = sub_account.id if not accounts.find({'_id': account['_id']}).count(): print accounts.insert(account) else: accounts.update({'_id': account['_id']}, account) for transaction in data['transactions']: transaction['_user_id'] = user.id if not transactions.find({'_id': transaction['_id']}).count(): print transactions.insert(transaction) return data
def login_step(self, access_token, answer, account_type): client = Client(client_id=self.client_id, secret=self.secret) client.set_access_token(access_token) step = client.step(account_type=account_type, mfa=answer) return json.loads(step.content)