| 1 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | package Net::FreshBooks::API::Recurring::AutoBill; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 8 | $Net::FreshBooks::API::Recurring::AutoBill::VERSION = '0.24'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use Net::FreshBooks::API::Recurring::AutoBill::Card; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 8 | extends 'Net::FreshBooks::API::Base'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 8 | has 'gateway_name' => ( is => 'rw', ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | has 'card' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | isa => 'Net::FreshBooks::API::Recurring::AutoBill::Card', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | default => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | ▶ | sub { return Net::FreshBooks::API::Recurring::AutoBill::Card->new }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub node_name { return 'autobill' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
node_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # ensure only fully initialized objects make the cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # Due to the way this module works, when recurring items are updated, all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # mutable fields already in the object are passed back to FreshBooks. This | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # causes a problem with the following scenario: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # 1) A recurring item is fetched from FreshBooks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # 2) The card number field returned by FreshBooks will look something like **** **** **** 1111 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # 3) When an update request is sent to FreshBooks, the request will fail on an invalid number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # So, to protect the user from this condition, if a card number in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # recurring item contains a '*', the AutoBill fields won't be passed for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # updating. In most cases this is probably the behaviour which you want as it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # prevents you from having to set autobill to an empty string on the update of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # any recurring item. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # this method returns true if any one of the autobill params is non-empty, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # provided that the card number is not the one returned to us by FreshBooks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | ▶ | sub _validates { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validates: called CC=7 SCAR=20.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | ▶ | return 0 if $self->card->number && $self->card->number =~ m{\*}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->card->number and $self->card->number =~ /\*/
MC/DC0%0/2
$self->card->number and $self->card->number =~ /\*/
$self->card->number
$self->card->number =~ /\*/
Truth table66%2/3
A and B
A= $self->card->numberB= $self->card->number =~ /\*/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | ▶ | return 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$self->gateway_name or $self->card->name or $self->card->month or $self->card->year
$self->gateway_name or $self->card->name or $self->card->month
$self->gateway_name or $self->card->name
MC/DC25%1/4
$self->gateway_name or $self->card->name or $self->card->month or $self->card->year
$self->gateway_name
$self->card->name
$self->card->month
$self->card->year
Truth table40%2/5
A or B or C or D
A= $self->gateway_nameB= $self->card->nameC= $self->card->monthD= $self->card->year
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | if ( $self->gateway_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | || $self->card->name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | || $self->card->month | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | || $self->card->year ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub _fields { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fields: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | gateway_name => { is => 'rw' }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | card => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | made_of => 'Net::FreshBooks::API::Recurring::AutoBill::Card', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | presented_as => 'object', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 8 | __PACKAGE__->meta->make_immutable(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # ABSTRACT: Adds AutoBill support to FreshBooks Recurring Items | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||