import requests
from bs4 import BeautifulSoup


def get_holdings(base_url, mms_id, api_key):
    """
    Get the holdings id(s) for the bib record via the Alma API.
    """
    holdings_list = []
    query = 'bibs/{}/holdings?apikey={}'
    r = requests.get(''.join([base_url, query.format(mms_id, api_key)]))
    soup = BeautifulSoup(r.text, 'xml')
    holdings = soup.find_all('holding_id')
    for id in holdings:
        holdings_list.append(id.text)

    return holdings_list