| 1 | package WebService::Avalara::AvaTax::Role::Connection; | ||||||||||
| 2 | |||||||||||
| 3 | # ABSTRACT: Common attributes and methods for AvaTax | ||||||||||
| 4 | |||||||||||
| 5 | 9 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 9 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 9 | our $VERSION = '0.020'; # VERSION | |||||||||
| 9 | 9 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | #pod =head1 SYNOPSIS | ||||||||||
| 12 | #pod | ||||||||||
| 13 | #pod use Moo; | ||||||||||
| 14 | #pod with 'WebService::Avalara::AvaTax::Role::Connection'; | ||||||||||
| 15 | #pod | ||||||||||
| 16 | #pod =head1 DESCRIPTION | ||||||||||
| 17 | #pod | ||||||||||
| 18 | #pod This role factors out the common attributes and methods used by the | ||||||||||
| 19 | #pod Avalara AvaTax (C<http://developer.avalara.com/api-docs/soap>) | ||||||||||
| 20 | #pod web service interface. | ||||||||||
| 21 | #pod | ||||||||||
| 22 | #pod =cut | ||||||||||
| 23 | |||||||||||
| 24 | 9 | ▶ | use Log::Report; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | 9 | ▶ | use LWP::UserAgent; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 9 | ▶ | use LWPx::UserAgent::Cached; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 9 | ▶ | use Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 9 | ▶ | use Mozilla::CA; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | 9 | ▶ | use Types::Standard qw(Bool InstanceOf Str); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 30 | 9 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 31 | |||||||||||
| 32 | #pod =attr username | ||||||||||
| 33 | #pod | ||||||||||
| 34 | #pod The Avalara AvaTax Admin Console user name. Usually an email address. Required. | ||||||||||
| 35 | #pod | ||||||||||
| 36 | #pod =cut | ||||||||||
| 37 | |||||||||||
| 38 | 9 | has username => ( is => 'ro', isa => Str, required => 1 ); | |||||||||
| 39 | |||||||||||
| 40 | #pod =attr password | ||||||||||
| 41 | #pod | ||||||||||
| 42 | #pod The password used for Avalara authentication. Required. | ||||||||||
| 43 | #pod | ||||||||||
| 44 | #pod =cut | ||||||||||
| 45 | |||||||||||
| 46 | 9 | has password => ( is => 'ro', isa => Str, required => 1 ); | |||||||||
| 47 | |||||||||||
| 48 | #pod =attr use_wss | ||||||||||
| 49 | #pod | ||||||||||
| 50 | #pod A boolean value that indicates whether or not to use WSS security tokens in | ||||||||||
| 51 | #pod the SOAP header or to use those specified in Avalara's alternate security WSDL. | ||||||||||
| 52 | #pod Defaults to true. Normally you should leave this alone unless your application | ||||||||||
| 53 | #pod does not work correctly with WSS. | ||||||||||
| 54 | #pod | ||||||||||
| 55 | #pod =cut | ||||||||||
| 56 | |||||||||||
| 57 | 9 | has use_wss => ( is => 'rwp', isa => Bool, default => 1 ); | |||||||||
| 58 | |||||||||||
| 59 | #pod =attr is_production | ||||||||||
| 60 | #pod | ||||||||||
| 61 | #pod A boolean value that indicates whether to connect to the production AvaTax | ||||||||||
| 62 | #pod services (true) or development (false). Defaults to false. | ||||||||||
| 63 | #pod | ||||||||||
| 64 | #pod =cut | ||||||||||
| 65 | |||||||||||
| 66 | 9 | has is_production => ( is => 'ro', isa => Bool, default => 0 ); | |||||||||
| 67 | |||||||||||
| 68 | #pod =attr debug | ||||||||||
| 69 | #pod | ||||||||||
| 70 | #pod When set to true, the L<Log::Report|Log::Report> dispatcher used by | ||||||||||
| 71 | #pod L<XML::Compile|XML::Compile> and friends is set to I<DEBUG> mode. | ||||||||||
| 72 | #pod | ||||||||||
| 73 | #pod =cut | ||||||||||
| 74 | |||||||||||
| 75 | has debug => ( | ||||||||||
| 76 | is => 'ro', | ||||||||||
| 77 | isa => Bool, | ||||||||||
| 78 | default => 0, | ||||||||||
| 79 | trigger => | ||||||||||
| 80 | 0 | ▶ | sub { dispatcher( mode => ( $_[1] ? 'DEBUG' : 'NORMAL' ), 'ALL' ) }, | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||
| 81 | 9 | ); | |||||||||
| 82 | |||||||||||
| 83 | #pod =attr user_agent | ||||||||||
| 84 | #pod | ||||||||||
| 85 | #pod An instance of an L<LWP::UserAgent|LWP::UserAgent> (sub-)class. You can | ||||||||||
| 86 | #pod use your own subclass to add features such as caching or enhanced logging. | ||||||||||
| 87 | #pod | ||||||||||
| 88 | #pod If you do not specify a C<user_agent> then we default to an instance of | ||||||||||
| 89 | #pod L<LWPx::UserAgent::Cached|LWPx::UserAgent::Cached>. Note that we also set | ||||||||||
| 90 | #pod the C<HTTPS_CA_FILE> environment variable to the result from | ||||||||||
| 91 | #pod L<Mozilla::CA::SSL_ca_file|Mozilla::CA> in order to correctly | ||||||||||
| 92 | #pod resolve certificate names. | ||||||||||
| 93 | #pod | ||||||||||
| 94 | #pod =cut | ||||||||||
| 95 | |||||||||||
| 96 | 9 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 97 | ## no critic (Subroutines::ProhibitCallsToUnexportedSubs) | ||||||||||
| 98 | ## no critic (Variables::RequireLocalizedPunctuationVars) | ||||||||||
| 99 | 9 | $ENV{HTTPS_CA_FILE} = Mozilla::CA::SSL_ca_file(); | |||||||||
| 100 | } | ||||||||||
| 101 | has user_agent => ( | ||||||||||
| 102 | is => 'lazy', | ||||||||||
| 103 | isa => InstanceOf ['LWP::UserAgent'], | ||||||||||
| 104 | 1 | ▶ | default => sub { LWPx::UserAgent::Cached->new }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 105 | 9 | ); | |||||||||
| 106 | |||||||||||
| 107 | 9 | 1; | |||||||||
| 108 | |||||||||||
| 109 | __END__ | ||||||||||