Skip to content

github4bhavin/Forex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

NAME

Forex - Historic Foreign Exchange Rates from Open Exchange Rates

VERSION

1.3

SYNOPSIS

use Forex;


my $forex = new Forex( 'APP_ID' => $app_id, 'BASE' => 'USD');


#__fetch and initialize daily rates from $from_date to $to_date in yyyy-mm-dd 
$forex->get_rates_from ( $from_date, $to_date );

#___ fetches rates for $date (yyyy-mm-dd)
$forex->get_rates( $date );
 

#___ fetches reates for today 
$forex->get_rates();


#___ gives AUD on 2012-09-01 in USD Base currency
$usd = $forex->get_rate_of ( 'AUD', '2012-09-01' );  


if ($Forex::LASTERROR )
   { print "\n Something went wrong" , $oxr->last_error_message(); }  

DESCRIPTION

METHODS

Constructors

new Forex()

returns new Forex object with defaults values for

get_rate_of( $currency, <$date> )

This method returns forex rate for $currency on $date in BASE currency, $date should be in yyyy-mm-dd format.

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

get_rates_from ( $from_date , $to_date )

downloads and fills CURRENCIES hash for $from_date to $to_date both dates should be in yyyy-mm-dd formate

get_rates ( <$day> )

downloads and fills in values for all currencies in the 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

COPYRIGHT AND LICENSE

This Software is free to use , licensed under:

The Artistic License 2.0 (GPL Compatible)

About

Foreign Exchange Rates from OpenExchangeRates.org

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages