"""Client for making requests to OwsMoneyhub.""" from moneyhub.connectors.ows_service import OwsService class OwsMoneyhub(OwsService): """OwsMoneyhub client for fetching requests.""" _service = 'ows-moneyhub' @classmethod def backfill_vat_summary(cls, statement_period_id: int, filtered_data: list) -> list: """Create a POST request to backfill vat summary documents. Args: statement_period_id (int): the statement period id. filtered_data (list): a list of filtered data. Returns: list: list of created vat summary entries. """ path = f'/ledger-vat-summary/statement-period/{statement_period_id}/backfill' return cls.validate_response_type(cls.post(path, filtered_data), list) @classmethod def create_statement_attachments(cls, statement_period_id: int) -> list: """Create a POST request for statement attachments for a specified statement period. Args: statement_period_id (int): The id of statement period Returns: list: list of statement attachments """ path = f'/statement-attachment/statement-period/{statement_period_id}' return cls.validate_response_type(cls.post(path), list) @classmethod def regenerate_custom_reports(cls, statement_period_id) -> list: """Create a request regenerate custom reports. Args: statement_period_id (int): The id of statement period Returns: list: list of statement attachments """ path = f'/reports/custom/statement-period/{statement_period_id}/regenerate' return cls.validate_response_type(cls.post(path), list) @classmethod def regenerate_statement_attachments(cls, statement_period_id: int, body: dict) -> list: """Create a request to regenerate statement attachments for a statement period. Args: statement_period_id (int): The ID of statement period body (dict): Payload for filtering statement attachments Returns: list: list of statement attachments """ path = f'/statement-attachment/statement-period/{statement_period_id}/regenerate' return cls.validate_response_type(cls.post(path, body), list) @classmethod def sync_revenue_analysis(cls, body: dict) -> dict: """Create a request to Sync the data in the revenue analysis tables. Args: body (dict): JSON body payload Returns: dict: Mapping of revenue analysis table to query ID """ path = '/revenue-analysis/sync' return cls.validate_response_type(cls.post(path, body), dict) @classmethod def trigger_attachment_generation( cls, statement_period_id: int, account_id: int | None = None) -> dict: """Create a request to trigger attachments. Args: statement_period_id (int): The ID of statement period. account_id (int): the ID of an account. Returns: dict: response status ok """ params = {'account_id': account_id} if account_id else None path = f'/statement-attachment/statement-period/{statement_period_id}/generate' return cls.validate_response_type(cls.post(path, params=params), dict)