"""Interface to the ows-abacus_account microservice.""" from oto import response from owsrequest import request from collaborator.constants import error, header, service_name from collaborator.utils import owsrequest from collaborator.utils.typing import Account def get_abacus_account_metadata(account: Account) -> response.Response: """Get abacus account's metadata. Args: account (Account): The Account tuple Returns: oto.response.Response """ abacus_account_metadata_url = f"/account/{account.id}/account-payment-term" headers = { header.ORCHARD_PROFILE_TYPE: header.COLLABORATORS_PROFILE, header.ORCHARD_ROLES: header.ROYALTIES_ROLE, } res = request.get( service_name.OWS_ABACUS_ACCOUNT, abacus_account_metadata_url, headers=headers ) return owsrequest.unwrap_data_or_error(res, error.ERROR_CODE_OWS_ABACUS_ACCOUNT) def get_account_payee(account_id: int): """Get payee info for an account. Args: account_id (int): ID of the account. """ payee_account_dataloader_url = "/account-payee/dataloader/account" body = [account_id] res = request.post( service_name.OWS_ABACUS_ACCOUNT, payee_account_dataloader_url, headers=owsrequest.get_default_ows_headers(), json=body, ) return owsrequest.unwrap_data_or_error(res, error.ERROR_CODE_OWS_ABACUS_ACCOUNT)