"""Model for ows-product.""" import logging import requests import config import const def get_account_document(account_id, account_type): """Get information about account from ows-account. Args: account_id (int): vendor / subaccount id. account_type (string): vendor / subaccount. Returns: dict: information about account. """ result = {} if not account_id: return result path = const.OWS_VENDOR_DOCUMENT_ENDPOINT.format(account_id) if account_type == 'subaccount': path = const.OWS_SUBACCOUNT_DOCUMENT_ENDPOINT.format(account_id) url = const.SERVICE_URL.format( environment=config.ENVIRONMENT, service_name=const.OWS_ACCOUNT_SERVICE_NAME, path=path) response = requests.get(url) if response.status_code not in (200, 404): logging.exception( const.OWS_ACCOUNT_ERROR.format(account_type)) raise Exception(const.OWS_ACCOUNT_ERROR.format(account_type)) if response.status_code == 200: result = response.json() return result