<?php

class VframeApp_ModelApi extends Vframe_Model
{
  protected
    
$_oApi null,
    
$_oApiAuth null,
    
$_oApiPackages = array();
  
  protected function 
db($sPackage)
  {
    require_once 
Vframe::_('V_API');
    
    if(!
$this->_oApi)
    {
      
$aAuth = array
      (
        
'apiKey' => Vframe::_('V_API_KEY'),
      );
      
      
$this->_oApiAuth = new lastfmApiAuth('setsession'$aAuth);
      
$this->_oApi = new lastfmApi();
    }
    
    if(!isset(
$this->_oApiPackages[$sPackage]))
      if((
$oPackage $this->_oApi->getPackage($this->_oApiAuth$sPackage)))
        
$this->_oApiPackages[$sPackage] = $oPackage;
      else
        throw new 
Vframe_Exception('Uknown Last.fm "' $sPackage '" API package.');
    
    return 
$this->_oApiPackages[$sPackage];
  }
}

?>