"""Interface for the ows-royalties microservice.""" from oto import response from owsrequest import request as requests from ows_product_physical.constant import service_name from ows_product_physical.utils.response_handler_util import safe_decode_json def is_abacus_account_mech_admin(abacus_account_id): """Check if an Abacus account is a mech admin. Args: abacus_account_id (str): The Abacus account id (i.e. the vendor id). Returns: Response: Response containing the mech admin status for physical (`mechadmin_physical`) and digital (`mechadmin_digital`). """ mech_admin_response = requests.get( service_name.OWS_ROYALTIES, f'/contracts/mechanical-deductions/account/{abacus_account_id}/mechadmin') content = safe_decode_json(mech_admin_response, service_name.OWS_ROYALTIES) if mech_admin_response.status_code != 200: return response.create_error_response( status=mech_admin_response.status_code, code=content.get('code'), message=content.get('message')) return response.Response( status=mech_admin_response.status_code, message=content)