WebService-Avalara-AvaTax

 view release on metacpan or  search on metacpan

lib/WebService/Avalara/AvaTax/Service/Tax.pm  view on Meta::CPAN

use XML::Compile::SOAP12;
use XML::Compile::WSDL11;
use namespace::clean;
with qw(
    WebService::Avalara::AvaTax::Role::Connection
    WebService::Avalara::AvaTax::Role::Service
    WebService::Avalara::AvaTax::Role::Dumper
);

#pod =attr uri
#pod
#pod The L<URI|URI> of the WSDL file used to define the web service.
#pod Defaults to C</tax/taxsvc.wsdl>, with the URI base either
#pod C<https://avatax.avalara.net/> if
#pod L<is_production|WebService::Avalara::AvaTax::Role::Connection/is_production>
#pod returns true, or C<https://development.avalara.net/> if it returns false.
#pod
#pod Note that if
#pod L<use_wss|WebService::Avalara::AvaTax::Role::Connection/use_wss>
#pod is false, the alternate security WSDL file C</tax/taxsvcaltsec.wsdl>
#pod will be used instead.
#pod
#pod =cut

has '+uri' => (
    default => sub {
        my $self = shift;
        URI->new_abs( '/tax/taxsvc'
                . ( $self->use_wss ? q{} : 'altsec' )
                . '.wsdl' => 'https://'
                . ( $self->is_production ? 'avatax' : 'development' )
                . '.avalara.net/' );
    },
);

#pod =attr port
#pod
#pod The SOAP port identifier (not to be confused with the TCP/IP port) used in the
#pod WSDL file at L</uri>.
#pod Defaults to C<AddressSvcSoap>.
#pod
#pod =cut

has '+port' => ( default =>
        sub { 'TaxSvc' . ( $_[0]->use_wss ? q{} : 'AltSec' ) . 'Soap' }, );

#pod =attr service
#pod
#pod The SOAP service name used in the WSDL file at L</uri>.
#pod Defaults to C<AddressSvc>.
#pod
#pod =cut

has '+service' => ( default => 'TaxSvc' );

#pod =head1 WORKAROUNDS FOR INCORRECT AVALARA RESPONSES
#pod
#pod As of this writing the Avalara SOAP API returns responses that are
#pod inconsistent with the WSDL document provided. Specifically, the C<TaxIncluded>
#pod and C<GeocodeType> fields in the C<GetTaxResponse> are wrongly placed in their
#pod sequences of fields. This module adds an overlay to the Avalara tax service
#pod WSDL file that attempts to work around these problems so that the responses
#pod may be successfully parsed.
#pod
#pod =cut

has '+wsdl' => (
    default => sub {
        my $self = shift;
        my $wsdl = XML::Compile::WSDL11->new(
            $self->user_agent->get( $self->uri )->content );
        $wsdl->addWSDL( module_file( __PACKAGE__, 'taxsvc_patch.wsdl' ) );
        return $wsdl;
    },
);

#pod =for Pod::Coverage BUILDARGS
#pod
#pod =cut

1;

__END__

=pod

=for :stopwords Mark Gardner ZipRecruiter cpan testmatrix url annocpan anno bugtracker rt
cpants kwalitee diff irc mailto metadata placeholders metacpan

=head1 NAME

WebService::Avalara::AvaTax::Service::Tax - Avalara AvaTax tax engine service via SOAP

=head1 VERSION

version 0.020

=head1 SYNOPSIS

    use WebService::Avalara::AvaTax::Service::Tax;

    my $avatax = WebService::Avalara::AvaTax::Service::Tax->new(
        username => 'avalara@example.com',
        password => 'sekrit',
    );
    my ( $answer_ref, $trace ) = $avatax->call('Ping');

=head1 DESCRIPTION

This class implements basic support for the
Avalara AvaTax (C<http://developer.avalara.com/api-docs/soap>)
tax engine service using SOAP. Most of its mechanics are in
L<WebService::Avalara::AvaTax::Role::Connection|WebService::Avalara::AvaTax::Role::Connection>,
with defaults for certain attributes as listed below.

=head1 ATTRIBUTES

=head2 uri

The L<URI|URI> of the WSDL file used to define the web service.
Defaults to C</tax/taxsvc.wsdl>, with the URI base either
C<https://avatax.avalara.net/> if
L<is_production|WebService::Avalara::AvaTax::Role::Connection/is_production>
returns true, or C<https://development.avalara.net/> if it returns false.

Note that if
L<use_wss|WebService::Avalara::AvaTax::Role::Connection/use_wss>
is false, the alternate security WSDL file C</tax/taxsvcaltsec.wsdl>
will be used instead.

=head2 port

The SOAP port identifier (not to be confused with the TCP/IP port) used in the
WSDL file at L</uri>.
Defaults to C<AddressSvcSoap>.

=head2 service

The SOAP service name used in the WSDL file at L</uri>.
Defaults to C<AddressSvc>.

=head1 WORKAROUNDS FOR INCORRECT AVALARA RESPONSES

As of this writing the Avalara SOAP API returns responses that are
inconsistent with the WSDL document provided. Specifically, the C<TaxIncluded>
and C<GeocodeType> fields in the C<GetTaxResponse> are wrongly placed in their
sequences of fields. This module adds an overlay to the Avalara tax service
WSDL file that attempts to work around these problems so that the responses
may be successfully parsed.

=for Pod::Coverage BUILDARGS

=head1 SUPPORT

=head2 Perldoc

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

  perldoc WebService::Avalara::AvaTax

=head2 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.

=over 4

=item *

MetaCPAN

A modern, open-source CPAN search engine, useful to view POD in HTML format.

L<http://metacpan.org/release/WebService-Avalara-AvaTax>

=item *

Search CPAN

The default CPAN search engine, useful to view POD in HTML format.

L<http://search.cpan.org/dist/WebService-Avalara-AvaTax>

=item *

AnnoCPAN

The AnnoCPAN is a website that allows community annotations of Perl module documentation.

L<http://annocpan.org/dist/WebService-Avalara-AvaTax>

=item *

CPAN Ratings

The CPAN Ratings is a website that allows community ratings and reviews of Perl modules.

L<http://cpanratings.perl.org/d/WebService-Avalara-AvaTax>

=item *

CPAN Forum

The CPAN Forum is a web forum for discussing Perl modules.

L<http://cpanforum.com/dist/WebService-Avalara-AvaTax>



( run in 1.108 second using v1.01-cache-2.11-cpan-97f6503c9c8 )