def get_ynab_account_id_mapping(ynab_client, budget_id):
    """Build a mapping of YNAB account names to internal ids

    Args:
        ynab_client (ynab_client): YNAB configured client with the credentials
        budget_id (str): id of the budget to query

    Returns:
        dict: Dictionary with account names as keys and ids as values
    """
    response = ynab_client.AccountsApi().get_accounts(budget_id).data.accounts
    mapping = {account.name: account.id for account in response}
    return mapping