"""ows-product connector.""" from http import HTTPStatus from owsclient import OwsClient from src.exceptions import StereoProductNotFound class OwsProductConnector: def __init__(self, client: OwsClient): """Initialize ows-product connector.""" self.client = client def get_release_id_by_upc(self, upc: int) -> int: """Fetch the release_id for a given UPC. Args: upc (int): UPC of the release Returns: (int): release_id """ response = self.client.get("ows-product", path=f"/product/upc/{upc}") if response.status_code == HTTPStatus.NOT_FOUND: raise StereoProductNotFound(f"No release found for stereo UPC {upc}") response.raise_for_status() return int(response.json()["product_id"])