<?php

abstract class Atmail_Voicemail_Providers_Abstract
{
	
	/*
		This virtual carrier is implimented as a DB so all commands are dorected at the DB
		Other provider implimentations are more likely to be by API, SOAP, SIP or XCAP interface
	*/
	private $_config;
	private $id = null;
	private $errorCodes = array();
	private $errorMessages = array();
	public $mimeType = 'audio/x-wav';
	    
	public function __construct( $configArray = array() ) 
	{
	
		if( count($configArray) > 0 )
			$this->_config = $configArray;
		if( isset($this->_config['id']) )
			$this->id = $this->_config['id'];
        $this->dbAdapter = Zend_Registry::get('dbAdapter');
		
    }
	/***
		Voicemail functions
	***/
	/* for purposes of proof of concept we need a 3rd party service we can query for voice mails. 
		Twilio is suitable, except that they dont house the VM info for us, they want to call a partner script to 
		log the messages (they only host the VM file) so we will need to impliment a mini provider server to 
		answer queries for current VM, get, delete etc. 

*/

	protected function validateId( Array $args = array() )
	{
		
		if( empty($args['id']) )
		{
			if( empty($this->id) )
			{
				$this->errorCodes[] = 1;
				$this->errorMessages[] = 'No Voicemail box id specified';
				return false;
			}
		}
		else
			$this->id = $args['id'];
		return true;
		
	}

	abstract public function list( Array $args );

	abstract public function getInfo( Array $args );
	
	public function getRecordingContents( Array $args ) { return false; }
	
	public function getRecordingUrl( Array $args ) { return false; }

	public function transcribe( Array $args ) { return false; }

	public function flagAsHeard( Array $args ) { return false; }
	
	public function flagAsUnheard( Array $args ) { return false; }
	
	abstract public function delete( Array $args );
}
