from imobiliar.auth import ImobPost

class Imovel(ImobPost):
    def __init__(self, url:str, token:str):
        super().__init__(url)
        self.token = token
        
    def LOCACAO_IMOVEL_CONSULTAR(self, cod_imovel: int) -> tuple[bool, dict | str]:
        data = {
            'Header':{
                'SessionId':self.token,
                'Action':"LOCACAO_IMOVEL_CONSULTAR"
            },
            'Body':{
                'CodImovel': cod_imovel
            },
        }       
        error, response = self.post(data=data)
        
        if error:
            message = None
            try:
                message = response["Body"]["Erros"]
            except:
                message = response
            return error, message
        return False, response["Body"]["CodPessoaLocat"]