View Source

<ac:macro ac:name="info"><ac:parameter ac:name="title">New Proposal Template</ac:parameter><ac:rich-text-body>
<p>This page has been created from a template that uses &quot;zones.&quot; To proceed:</p>

<ol>
<li>Edit the page</li>
<li>Replace sample content within each zone-data tag</li>
<li>Remove this notice</li>
<li>Save the page</li>
<li>When you are ready for review, remove the <ac:emoticon ac:name="warning" /> Under Construction notice</li>
</ol>
</ac:rich-text-body></ac:macro>

<ac:macro ac:name="note"><ac:parameter ac:name="title">Under Construction</ac:parameter><ac:rich-text-body>
<p>This proposal is under construction and is not ready for review.</p></ac:rich-text-body></ac:macro>

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template}

{zone-data:component-name}
Zend_Service_Currency
{zone-data}

{zone-data:proposer-list}
[André Hoffmann|mailto:antiHERO2006@gmail.com]
[Pádraic Brady|mailto:padraic.brady@yahoo.com]
[Darby Felton|mailto:darby@zend.com], Zend liaison
{zone-data}

{zone-data:revision}
1.0 - not yet: created proposal
{zone-data}

{zone-data:overview}
The purpose of this class is to utilise one or more FX rate sources to perform FX translations or return spot FX rates between any two currencies. Currencies will be denoted with Country Codes compliant with ISO 4217.
{zone-data}

{zone-data:references}
* [XMethods WSDL|http://www.soapclient.com/soapclient?fn=soapform&template=/clientform.html&soaptemplate=/soapresult.html&soapwsdl=http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl]
* [Pear::Service_ExchangeRates|Pear_Service_ExchangeRates]
{zone-data}

{zone-data:requirements}
* This component will fetch spot FX rates from a selection of possible services incl. at a minumum ECB (European Central Bank) and FRB (US Federal Reserve) published rates.
* This component will validate Country Currency codes correctly against a) Zend_Currency or b) the UNECE published list.
* This component will perform FX translations between any two currencies.
* This component will return correct rate for translation between any two currencies.
* This component will correctly handle locale issues such as comma/period differences from en_UK or en_US and mainland Europe.
* This component may save data for a specified time using Zend_Cache.
* This component may include a factory method.
* This component will allow subclassing for alternative rate sources from country specific institutions.
{zone-data}

{zone-data:dependencies}
* Zend_Service_Exception
* Zend_Service_Rest
* Zend_Locale
* Zend_Currency
* Zend_Cache
{zone-data}

{zone-data:operation}
Based on any two compliant ISO 4217 Country Currency codes, Zend_Service_Currency would fetch the relevant exchange rate from a selected source, or range of sources, and either:

a) perform a currency translation and return the result; or
b) return the relevant exchange rate
{zone-data}

{zone-data:milestones}
* Milestone 1: Publish relevant design notes and background on design decisions
* Milestone 2: Write Unit Tests for Use Case #1 and check implementing code into Incubator
* Milestone 3: Write Unit Tests/Code for remaining Use Cases and check implementing code into Incubator
* Milestone 4: Write documentation sufficient for core Use Cases
* Milestone 5: Perform review and additional refactoring. Assess additional Use Cases (if any).
{zone-data}

{zone-data:class-list}
* Zend_Service_ExchangeRates_Interface
* Zend_Service_ExchangeRates
* Zend_Service_ExchangeRates_ECB
* Zend_Service_ExchangeRates_FRB
* Zend_Service_ExchangeRates_XMethods
* Zend_Service_ExchangeRates_CountryCodes_Interface
* Zend_Service_ExchangeRates_CountryCodes_UNECE
{zone-data}

{zone-data:use-cases}
||UC-01||
{code}

/* en_UK query (no Zend_Currency use)
*
* Simple use case fetching the FX rate for translating between two currencies.
*/

// Fetch instance based on source (European Central Bank) from static
// Factory method
$fx = Zend_Service_ExchangeRates::factory('ECB');

// set To and From currencies (ISO 4217 Currency Codes)
$fx->setFromCurrency('EUR');
$fx->setToCurrency('USD');

// return the rate...
echo $fx->getFXRate();

{code}
{zone-data}

{zone-data:skeletons}
{code}
class Zend_Service_ExchangeRates {

protected $source = '';

protected $toCode = '';

protected $fromCode = '';

protected $options = array();

protected $sourceURL = '';

protected $fxRate = 1;

private function __construct();

public static function factory($source, $options);

public function setFromCurrency($fromCode);

public function setToCurrency($toCode);

public function translate($amount);

public function getFormula();

private function isValidCurrency();

private function format();

public abstract function getFXRate();

public abstract function getAllRates();

}
{code}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>