Bhavin Patel > Forex-1.2 > Forex

Download:
Forex-1.2.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.2   Source   Latest Release: Forex-1.3

NAME ^

Forex - Historic Foreign Exchange Rates from Open Exchange Rates

VERSION ^

1.2

SYNOPSIS ^

 use Forex;
 
 my $oxr = new Forex( 'APP_ID' => $app_id, 'BASE' => 'USD');
 
 #__fetch and initialize daily rates from $from_date to $to_date in yyyy-mm-dd 
 $oxr->get_rates_from ( $from_date, $to_date );

 #___ fetches rates for $date (yyyy-mm-dd)
 $oxr->get_rates( $date );
         
 #___ fetches reates for today 
 $oxr->get_rates();
        
 #___ gives AUD on 2012-09-01 in USD Base currency
 $usd = $oxr->get_rate_of ( 'AUD', '2012-09-01' );  
 
 if ($Forex::OXR::LASTERROR )
    { print "\n Something went wrong" , $oxr->last_error_message(); }  

DESCRIPTION ^

METHODS ^

Constructors

new Forex()

returns new Forex object with defaults values for OXR_HOME = 'http://openexchangerates.org', API_HOOK = 'api', APP_ID = 'temp-e091fc14b3884a516d6cc2c299a', BASE = 'USD'

 my $oxe = new Forex::OXR( OXR_HOME => 'https://openexchangerates.org',
                                                                        API_HOOK => 'api',
                                                                        APP_ID   => 'temp-e091fc14b3884a516d6cc2c299a',
                                                                        BASE     => 'AUD');

get_rate_of( $currency, <$date> )

This method returns forex rate for $currency on $date in USD, $date should be in yyyy-mm-dd format. This method looks for currency rates in $obj->{ CURRENCIES } array.Which is filled by get_rates or get_rates_from() methods

my $AUD = $oxr->get_rate_of( 'AUD' , '2012-09-10' );

get_rates_from ( $from_date , $to_date )

downloads and fills in values for all currencies in the $obj->{CURRENCIES} hash for $from_date - $to_date both dates should be in yyyy-mm-dd formate

get_rates ( <$day> )

downloads and fills in values for all currencies in the $obj->{CURRENCIES} hash for given $day $day should be in yyyy-mm-dd formate if $day is skipped , it uses todays date,

get_currency_symbols()

this method downloads and initializes all currency symbols from openexchangerates site. this method should be run before either get_rates or get_rates_from

base_currency( <$BASE_CURRENCY> )

sets BASE currency so that succeeding request will request the rates with base currency as specified by $BASE_CURRENCY. if the parameter is omitted it return the current BASE_CURRENCY value;

Note: you will have to flush the $CURRENCIES hash if you change the BASE currency. with flush_values()

oxr_home ( <$OXR_HOME> )

sets OXR_HOME parameter to $OXR_HOME value , if the parameter is omitted it returns the current value of the OXR_HOME. OXR_HOME value should cuntaion "http://" .

Note: you could you it to change the default "http://" to "https://" if you have enterprise APP_ID

app_id ( <$APP_ID> )

sets app_id for all succeeding requests. return current app_id if the parameter is omitted.

get_currencies()

returns all the currencies in the currencies hash

last_error()

returns last error object as returned by Open Exchange Rates API

last_error_message ()

returns last error message

ERROR

on errors module sets $LASTERROR global variable which can be accessed by $Forex::LASTERROR. And error message can be accessed via last_error_message() or last_error()

KNOWN BUGS

SUPPORT

please submit known issues or bugs to mail4bhavin@yahoo.com

AUTHOR

Bhavin Patel <mail4bhavin@gmail.com

COPYRIGHT AND LICENSE

This Software is free to use , licensed under:

        The Artistic License 2.0 (GPL Compatible)
syntax highlighting: