Mage_Directory_Model_Currency_Import_Webservicex Class Reference

Inheritance diagram for Mage_Directory_Model_Currency_Import_Webservicex:

Mage_Directory_Model_Currency_Import_Abstract

List of all members.

Public Member Functions

 __construct ()

Protected Member Functions

 _convert ($currencyFrom, $currencyTo, $retry=0)

Protected Attributes

 $_url = 'http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency={{CURRENCY_FROM}}&ToCurrency={{CURRENCY_TO}}'
 $_messages = array()
 $_httpClient


Detailed Description

Definition at line 34 of file Webservicex.php.


Constructor & Destructor Documentation

__construct (  ) 

Definition at line 46 of file Webservicex.php.

00047     {
00048         $this->_httpClient = new Varien_Http_Client();
00049     }


Member Function Documentation

_convert ( currencyFrom,
currencyTo,
retry = 0 
) [protected]

Definition at line 51 of file Webservicex.php.

00052     {
00053         $url = str_replace('{{CURRENCY_FROM}}', $currencyFrom, $this->_url);
00054         $url = str_replace('{{CURRENCY_TO}}', $currencyTo, $url);
00055 
00056         try {
00057             $response = $this->_httpClient
00058                 ->setUri($url)
00059                 ->setConfig(array('timeout' => Mage::getStoreConfig('currency/webservicex/timeout')))
00060                 ->request('GET')
00061                 ->getBody();
00062 
00063             $xml = simplexml_load_string($response, null, LIBXML_NOERROR);
00064             if( !$xml ) {
00065                 $this->_messages[] = Mage::helper('directory')->__('Cannot retrieve rate from %s', $url);
00066                 return null;
00067             }
00068             return (float) $xml;
00069         }
00070         catch (Exception $e) {
00071             if( $retry == 0 ) {
00072                 $this->_convert($currencyFrom, $currencyTo, 1);
00073             } else {
00074                 $this->_messages[] = Mage::helper('directory')->__('Cannot retrieve rate from %s', $url);
00075             }
00076         }
00077     }


Member Data Documentation

$_httpClient [protected]

Definition at line 44 of file Webservicex.php.

$_messages = array() [protected]

Definition at line 37 of file Webservicex.php.

$_url = 'http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency={{CURRENCY_FROM}}&ToCurrency={{CURRENCY_TO}}' [protected]

Definition at line 36 of file Webservicex.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:07 2009 for Magento by  doxygen 1.5.8