import requests


def update_account_balance(TOKEN, BUDGET_ID, ACCOUNT_ID, AMOUNT, DATE):
    """
    Makes a POST request to the YNAB API 

    Args:
        BASE_URL [str]: The base URL for the YNAB API.
        TOKEN [str]: YNAB token used for API authentication.
        BUDGET_ID [str]: ID for the YNAB Budget containing the Account you want the budget for.
        ACCOUNT_ID [str]: ID for the specific YNAB Account you need the balance for.
        AMOUNT [float]: The amount for the transactions as an interger. 
        DATE [str]: Transaction date in the following format: 'Year-Month-Day' ie 2021-10-03

    Returns:
        [dir]: YNAB API response data from the POST request
    """    
    amount_interger = int(AMOUNT) * 1000
    transactionData = { 
        'transaction': {
        'account_id': ACCOUNT_ID,
        'date': DATE,
        'amount': amount_interger,
        'payee_name': 'Coinbase',
        'cleared': 'cleared',
        'approved': True
        }
    }
    
    headers = {'Authorization': 'Bearer ' + TOKEN}
    response = requests.post(f'http://api.youneedabudget.com/v1/budgets/{BUDGET_ID}/transactions', json=transactionData, headers=headers)
    data = response.json()
    return data