def get_balance(): try: request = AccountsBalanceGetRequest(access_token=access_token) response = client.accounts_balance_get(request) pretty_print_response(response.to_dict()) return jsonify(response.to_dict()) except plaid.ApiException as e: error_response = format_error(e) return jsonify(error_response)
def read_records( self, sync_mode: SyncMode, cursor_field: List[str] = None, stream_slice: Mapping[str, Any] = None, stream_state: Mapping[str, Any] = None, ) -> Iterable[Mapping[str, Any]]: balance_response = self.client.accounts_balance_get(AccountsBalanceGetRequest(access_token=self.access_token)) for balance in balance_response["accounts"]: message_dict = balance["balances"].to_dict() message_dict["account_id"] = balance["account_id"] yield message_dict
def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> Tuple[bool, Optional[Any]]: try: plaid_config = plaid.Configuration( host=SPEC_ENV_TO_PLAID_ENV[config["plaid_env"]], api_key={"clientId": config["client_id"], "secret": config["api_key"]} ) api_client = plaid.ApiClient(plaid_config) client = plaid_api.PlaidApi(api_client) try: request = AccountsBalanceGetRequest(access_token=config["access_token"]) client.accounts_balance_get(request) return True, None except plaid.ApiException as e: response = json.loads(e.body) return False, response except Exception as error: return False, error