NAME

WebService::Avalara::AvaTax - Avalara SOAP interface as compiled Perl methods

VERSION

version 0.001

SYNOPSIS

use WebService::Avalara::AvaTax;
my $avatax = WebService::Avalara::AvaTax->new(
    username => 'avalara@example.com',
    password => 'sekrit',
);
my $answer_ref = $avatax->ping;

DESCRIPTION

This class provides a Perl method API for Avalara AvaTax web services. The first call to any AvaTax SOAP operation uses XML::Compile::WSDL11 to compile and execute against the specified Avalara AvaTax service; subsequent calls can vary the parameters but will use the same compiled code.

METHODS

Available method names are dynamically loaded from the AvaTax WSDL file's operations, and can be passed either a hash or reference to a hash with the necessary parameters. In scalar context they return a reference to a hash containing the results of the SOAP call; in list context they return the results hashref and an XML::Compile::SOAP::Trace object suitable for debugging and exception handling.

As of this writing the following operations are published in the Avalara AvaTax schema. Consult Avalara's Help Center for full documentation on input and output parameters for each operation.

If there is no result then an exception will be thrown.

get_tax

Example:

use DateTime;
use DateTime::Format::XSD;
my ( $result_ref, $trace ) = $avatax->get_tax(
    CustomerCode => 'ABC4335',
    DocDate      => DateTime::Format::XSD->format_datetime(
        DateTime->new( year => 2014, month => 1, day => 1 ) ),
    CompanyCode  => 'APITrialCompany',
    DocCode      => 'INV001',
    DetailLevel  =>  'Tax',
    Commit       => 0,
    DocType      => 'SalesInvoice',
);

post_tax

commit_tax

cancel_tax

adjust_tax

get_tax_history

is_authorized

ping

use List::Util 1.33 'any';
my ( $result_ref, $trace ) = $avatax->ping;
for my $code ( $result_ref->{parameters}{PingResult}{ResultCode} ) {
    if ( $code eq 'Success' ) { say $code; last }
    if ( $code eq 'Warning' ) {
        warn $result_ref->{parameters}{PingResult}{Messages};
        last;
    }
    if ( any {$code eq $_} qw(Error Exception) ) {
        die $result_ref->{parameters}{PingResult}{Messages};
    }
}

validate

OTHER METHODS AND ATTRIBUTES

Because this class consumes the WebService::Avalara::AvaTax::Role::Connection role, it also has that role's attributes and methods. Please consult that module for attributes important for establishing a connection such as username and password. You can also use other attributes, such as the user_agent attribute to access the LWP::UserAgent used to retrieve and call the AvaTax service, or the wsdl method to access the underlying XML::Compile::WSDL11 object.

SUPPORT

Perldoc

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

perldoc WebService::Avalara::AvaTax

Websites

The following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources.

Bugs / Feature Requests

Please report any bugs or feature requests through the web interface at https://github.com/mjgardner/WebService-Avalara-AvaTax/issues. You will be automatically notified of any progress on the request by the system.

Source Code

The code is open to the world, and available for you to hack on. Please feel free to browse it and play with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull from your repository :)

https://github.com/mjgardner/WebService-Avalara-AvaTax

git clone git://github.com/mjgardner/WebService-Avalara-AvaTax.git

AUTHOR

Mark Gardner <mjgardner@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by ZipRecruiter. No license is granted to other entities.