| 1 | package WebService::Avalara::AvaTax::Service::Tax; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | # ABSTRACT: Avalara AvaTax tax engine service via SOAP | ||||||||||||||
| 4 | |||||||||||||||
| 5 | 7 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 7 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | 7 | our $VERSION = '0.020'; # VERSION | |||||||||||||
| 9 | 7 | ▶ | use utf8; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | |||||||||||||||
| 11 | #pod =head1 SYNOPSIS | ||||||||||||||
| 12 | #pod | ||||||||||||||
| 13 | #pod use WebService::Avalara::AvaTax::Service::Tax; | ||||||||||||||
| 14 | #pod | ||||||||||||||
| 15 | #pod my $avatax = WebService::Avalara::AvaTax::Service::Tax->new( | ||||||||||||||
| 16 | #pod username => 'avalara@example.com', | ||||||||||||||
| 17 | #pod password => 'sekrit', | ||||||||||||||
| 18 | #pod ); | ||||||||||||||
| 19 | #pod my ( $answer_ref, $trace ) = $avatax->call('Ping'); | ||||||||||||||
| 20 | #pod | ||||||||||||||
| 21 | #pod =head1 DESCRIPTION | ||||||||||||||
| 22 | #pod | ||||||||||||||
| 23 | #pod This class implements basic support for the | ||||||||||||||
| 24 | #pod Avalara AvaTax (C<http://developer.avalara.com/api-docs/soap>) | ||||||||||||||
| 25 | #pod tax engine service using SOAP. Most of its mechanics are in | ||||||||||||||
| 26 | #pod L<WebService::Avalara::AvaTax::Role::Connection|WebService::Avalara::AvaTax::Role::Connection>, | ||||||||||||||
| 27 | #pod with defaults for certain attributes as listed below. | ||||||||||||||
| 28 | #pod | ||||||||||||||
| 29 | #pod =cut | ||||||||||||||
| 30 | |||||||||||||||
| 31 | 7 | ▶ | use File::ShareDir 1.00 'module_file'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 32 | 7 | ▶ | use Moo; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 33 | 7 | ▶ | use URI; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 34 | 7 | ▶ | use XML::Compile::SOAP11; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 35 | 7 | ▶ | use XML::Compile::SOAP12; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 36 | 7 | ▶ | use XML::Compile::WSDL11; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 37 | 7 | ▶ | use namespace::clean; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 38 | 7 | with qw( | |||||||||||||
| 39 | WebService::Avalara::AvaTax::Role::Connection | ||||||||||||||
| 40 | WebService::Avalara::AvaTax::Role::Service | ||||||||||||||
| 41 | WebService::Avalara::AvaTax::Role::Dumper | ||||||||||||||
| 42 | ); | ||||||||||||||
| 43 | |||||||||||||||
| 44 | #pod =attr uri | ||||||||||||||
| 45 | #pod | ||||||||||||||
| 46 | #pod The L<URI|URI> of the WSDL file used to define the web service. | ||||||||||||||
| 47 | #pod Defaults to C</tax/taxsvc.wsdl>, with the URI base either | ||||||||||||||
| 48 | #pod C<https://avatax.avalara.net/> if | ||||||||||||||
| 49 | #pod L<is_production|WebService::Avalara::AvaTax::Role::Connection/is_production> | ||||||||||||||
| 50 | #pod returns true, or C<https://development.avalara.net/> if it returns false. | ||||||||||||||
| 51 | #pod | ||||||||||||||
| 52 | #pod Note that if | ||||||||||||||
| 53 | #pod L<use_wss|WebService::Avalara::AvaTax::Role::Connection/use_wss> | ||||||||||||||
| 54 | #pod is false, the alternate security WSDL file C</tax/taxsvcaltsec.wsdl> | ||||||||||||||
| 55 | #pod will be used instead. | ||||||||||||||
| 56 | #pod | ||||||||||||||
| 57 | #pod =cut | ||||||||||||||
| 58 | |||||||||||||||
| 59 | has '+uri' => ( | ||||||||||||||
| 60 | 1 | ▶ | default => sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.0
| |||||||||||||||
| 61 | 1 | my $self = shift; | |||||||||||||
| 62 | 1 | ▶ | URI->new_abs( '/tax/taxsvc' | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 63 | . ( $self->use_wss ? q{} : 'altsec' ) | ||||||||||||||
| 64 | . '.wsdl' => 'https://' | ||||||||||||||
| 65 | . ( $self->is_production ? 'avatax' : 'development' ) | ||||||||||||||
| 66 | . '.avalara.net/' ); | ||||||||||||||
| 67 | }, | ||||||||||||||
| 68 | 7 | ); | |||||||||||||
| 69 | |||||||||||||||
| 70 | #pod =attr port | ||||||||||||||
| 71 | #pod | ||||||||||||||
| 72 | #pod The SOAP port identifier (not to be confused with the TCP/IP port) used in the | ||||||||||||||
| 73 | #pod WSDL file at L</uri>. | ||||||||||||||
| 74 | #pod Defaults to C<AddressSvcSoap>. | ||||||||||||||
| 75 | #pod | ||||||||||||||
| 76 | #pod =cut | ||||||||||||||
| 77 | |||||||||||||||
| 78 | has '+port' => ( default => | ||||||||||||||
| 79 | 0 | ▶ | sub { 'TaxSvc' . ( $_[0]->use_wss ? q{} : 'AltSec' ) . 'Soap' }, ); | ||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=13.0
Branch: 1 branch
| |||||||||||||||
| 80 | |||||||||||||||
| 81 | #pod =attr service | ||||||||||||||
| 82 | #pod | ||||||||||||||
| 83 | #pod The SOAP service name used in the WSDL file at L</uri>. | ||||||||||||||
| 84 | #pod Defaults to C<AddressSvc>. | ||||||||||||||
| 85 | #pod | ||||||||||||||
| 86 | #pod =cut | ||||||||||||||
| 87 | |||||||||||||||
| 88 | 7 | has '+service' => ( default => 'TaxSvc' ); | |||||||||||||
| 89 | |||||||||||||||
| 90 | #pod =head1 WORKAROUNDS FOR INCORRECT AVALARA RESPONSES | ||||||||||||||
| 91 | #pod | ||||||||||||||
| 92 | #pod As of this writing the Avalara SOAP API returns responses that are | ||||||||||||||
| 93 | #pod inconsistent with the WSDL document provided. Specifically, the C<TaxIncluded> | ||||||||||||||
| 94 | #pod and C<GeocodeType> fields in the C<GetTaxResponse> are wrongly placed in their | ||||||||||||||
| 95 | #pod sequences of fields. This module adds an overlay to the Avalara tax service | ||||||||||||||
| 96 | #pod WSDL file that attempts to work around these problems so that the responses | ||||||||||||||
| 97 | #pod may be successfully parsed. | ||||||||||||||
| 98 | #pod | ||||||||||||||
| 99 | #pod =cut | ||||||||||||||
| 100 | |||||||||||||||
| 101 | has '+wsdl' => ( | ||||||||||||||
| 102 | 1 | ▶ | default => sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 103 | 1 | my $self = shift; | |||||||||||||
| 104 | 1 | my $wsdl = XML::Compile::WSDL11->new( | |||||||||||||
| 105 | $self->user_agent->get( $self->uri )->content ); | ||||||||||||||
| 106 | 1 | $wsdl->addWSDL( module_file( __PACKAGE__, 'taxsvc_patch.wsdl' ) ); | |||||||||||||
| 107 | 1 | return $wsdl; | |||||||||||||
| 108 | }, | ||||||||||||||
| 109 | 7 | ); | |||||||||||||
| 110 | |||||||||||||||
| 111 | #pod =for Pod::Coverage BUILDARGS | ||||||||||||||
| 112 | #pod | ||||||||||||||
| 113 | #pod =cut | ||||||||||||||
| 114 | |||||||||||||||
| 115 | 7 | 1; | |||||||||||||
| 116 | |||||||||||||||
| 117 | __END__ | ||||||||||||||