Object::eBay::Currency(3)

NAME
Object::eBay::Currency - Represents a currency used by eBay

SYNOPSIS
    # assuming that $item is an Object::eBay::Item object
    my $price = $item->selling_status->current_price;

    # supports string, numeric and boolean context
    print "Going for $price\n";          # "Going for USD12.99"
    print "Bargain!\n" if $price < 20;   # numeric context
    print "Has price\n" if $price;       # boolean context

    # accessor methods are also available
    my $currency_id = $price->currency_id; # just the currency ID
    my $value       = $price->value;       # same as numeric context
    my $string      = $price->as_string;   # same as string context

DESCRIPTION
Many of eBay's API calls return values which represent an amount of a particular currency. Item prices are a good example. An Object::eBay::Currency object represents a particular quantity of a particular currency. Methods throughout Object::eBay return Currency objects where appropriate.

As mentioned in the "SYNOPSIS" string, numeric and boolean context are supported. In numeric context, the object evaluates to the amount of currency represented. In string context, the object evaluates to a string which represents the currency and the quantity both (see "as_string" for details). Boolean context returns the same value as numeric context. This overloading of boolean context makes Object::eBay::Currency objects behave as expected in boolean context instead of returning true all the time.

METHODS

  as_bool
Returns a boolean representation of the currency amount. Namely, if the currency amount is 0, false is returned. Otherwise, true is returned. This method provides the implementation for boolean context.

  as_string
Returns a string representation of the currency amount. The string is produced by concatenating the currency ID with the quantity. For example 10 U.S. Dollars is represented as 'USD10.00' The value will always be rounded to two numbers after the decimal. The rounding algorithm is that used by "sprintf('%.2f')".

This method provides the value for string context.

  currency_id
Returns a string identifying the type of currency this object represents. The possible values are determined by eBay.

  value
Returns the quantity of currency represented by this object. It's generally a bad idea to use this method unless you already know the type of currency. For example, if the return value is '10', that could mean 10 U.S. Dollars or 10 Euros.

This method provides the value for numeric context.

DIAGNOSTICS

  Missing 'content' and/or 'currencyID'
This exception is thrown when trying to construct a Currency object from an invalid hashref. This indicates a problem (or change) with eBay's XML response.

CONFIGURATION AND ENVIRONMENT
Object::eBay::Currency requires no configuration files or environment variables.

DEPENDENCIES

•   Class::Std

INCOMPATIBILITIES
None known.

BUGS AND LIMITATIONS
Please report any bugs or feature requests to "bug-object-ebay at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Object-eBay>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT
You can find documentation for this module with the perldoc command.

    perldoc Object::eBay;

You can also look for information at:

•   AnnoCPAN: Annotated CPAN documentation

    <http://annocpan.org/dist/Object-eBay>

•   CPAN Ratings

    <http://cpanratings.perl.org/d/Object-eBay>

•   RT: CPAN's request tracker

    <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Object-eBay>

•   Search CPAN

    <http://search.cpan.org/dist/Object-eBay>

ACKNOWLEDGEMENTS

AUTHOR
Michael Hendricks <michael@ndrix.org>

LICENSE AND COPYRIGHT
Copyright (c) 2006 Michael Hendricks (<michael@ndrix.org>). All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.