"""ows-moneyhub connector.""" from collaborator.api import ows_client from collaborator.constants import service_name def get_currencies_for_period_range(account_id, period_id_from, period_id_to): """Get currencies for a specific period range. Args: account_id (int): The account ID. period_id_from (int): The start period ID. period_id_to (int): The end period ID. """ url = f"/account/{account_id}/statement-periods" response = ows_client.get(service_name.OWS_MONEYHUB, url).raise_for_status() statement_periods_by_id = { statement_period["statement_period_id"]: statement_period for statement_period in response.json() } statement_period_ids = range(period_id_from, period_id_to + 1) statement_periods = [ statement_periods_by_id[statement_period_id] for statement_period_id in statement_period_ids if statement_period_id in statement_periods_by_id ] if len(statement_periods) != len(statement_period_ids): raise ValueError("Not all statement periods were found.") currencies = list( set(statement_period["currency_code"] for statement_period in statement_periods) ) return currencies