<?php

interface TrackingInterface{
    public function getObjectTracking($object);
    public function autentication($data = array());
    public function getEvents($data = array());
}


abstract class Tracking implements TrackingInterface{

    protected $usuario       = null  ;
    protected $senha         = null  ;
    protected $error         = ''    ;
    protected $autentication = false ;
    protected $eventos       = false ;   
    private   $log                   ;

    public function autentication($data = array()){

        $param = array(
            'usuario' => $data['usuario'],
            'senha'   => $data['senha'],
        );

        if(count(array_filter($param))==2){
            $this->usuario = $data['usuario'] ;
            $this->senha   = $data['senha']   ;
            $this->autentication = true ;
            return true;
        }else{
            throw new Exception("Falha ao autenticar o módulo de rastreio");
        }

    }

    public function setErrorLog($arquivo, $tracking, $msg){    
        $error  = 'Tracking => '.$tracking.PHP_EOL;
        $error .= 'Error    => '.$msg.PHP_EOL;

        $this->log = new Log($arquivo);
        $this->log->write($error);
    }    
    
    public function setError($value){
        $this->error = $value;
    }

    public function getError(){
        return $this->error;
    }    

    public function getAutentication(){
        return $this->autentication ;
    }

}

?>