"""Interface for the ows-product-configuration microservice.""" from oto import response from owsrequest import request as requests import sentry_sdk from ows_product_physical.constant import error from ows_product_physical.constant import service_name def get_distribution_format_by_id(distribution_format_id): """Fetch data of distribution format by distribution format id. Args: distribution_format_id (int): Unique id of the distribution_format record to fetch. Returns: Response: A response object of distribution format. """ try: distribution_format_response = requests.get( service_name.OWS_PRODUCT_CONFIGURATION, '/distribution-format/{}'.format(distribution_format_id)) except Exception as exception: sentry_sdk.capture_exception(exception) return response.create_error_response( code=error.INTERNAL_ERROR, message='error fetching record', status=500 ) return response.Response( status=distribution_format_response.status_code, message=distribution_format_response.json() ) def get_supply_chain_defaults(): """Fetch data of supply chain defaults. Returns: Response: A response object of defaults with supply chain associated with it. """ try: supply_chain_defaults_response = requests.get( service_name.OWS_PRODUCT_CONFIGURATION, '/supply-chains/defaults') except Exception as exception: sentry_sdk.capture_exception(exception) return response.create_error_response( code=error.INTERNAL_ERROR, message='error fetching record', status=500 ) return response.Response( status=supply_chain_defaults_response.status_code, message=supply_chain_defaults_response.json() )