| 1 | package Twilio::Version; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 18 | ▶ | use 5.016; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 18 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 18 | ▶ | use Twilio::Exceptions::RestException; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 18 | ▶ | use Twilio::Exceptions::TwilioServiceException; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 18 | ▶ | use Twilio::Stream; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 18 | our $VERSION = '2.001'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 18 | my $MAX_PAGE_SIZE = 1000; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 18 | my $FIRST_SUCCESS_STATUS = 200; | |||||||||||||||||||||||||||
| 15 | 18 | my $FIRST_ERROR_STATUS = 400; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1944 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 18 | 1944 | my ($class, $domain) = @_; | |||||||||||||||||||||||||||
| 19 | 1944 | return bless { domain => $domain, version => undef }, $class; | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 35 | ▶ | sub absolute_url { | ||||||||||||||||||||||||||
|
Subroutine
absolute_url: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | 35 | my ($self, $uri) = @_; | |||||||||||||||||||||||||||
| 24 | 35 | return $self->get_domain->absolute_url($self->relative_uri($uri)); | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 1905 | ▶ | sub relative_uri { | ||||||||||||||||||||||||||
|
Subroutine
relative_uri: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | 1905 | my ($self, $uri) = @_; | |||||||||||||||||||||||||||
| 29 | 1905 | ▶ | return join q{/}, map { s{\A/+|/+\z}{}gr } $self->{version} // q{}, $uri; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"version"} // ""
MC/DC100%1/1
$self->{"version"} // ""
$self->{"version"}
Truth table100%2/2
A
A= $self->{"version"}
| |||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 1836 | ▶ | sub request { | ||||||||||||||||||||||||||
|
Subroutine
request: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 33 | 1836 | my ($self, $method, $uri, $options) = @_; | |||||||||||||||||||||||||||
| 34 | 1836 | return $self->get_domain->request($method, $self->relative_uri($uri), $options); | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 43 | ▶ | sub exception { | ||||||||||||||||||||||||||
|
Subroutine
exception: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 43 | my ($self, $response, $header) = @_; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 43 | my $status = $response->get_status_code; | |||||||||||||||||||||||||||
| 41 | 43 | my $message = "[HTTP $status] $header"; | |||||||||||||||||||||||||||
| 42 | 43 | my $content = $response->get_content; | |||||||||||||||||||||||||||
| 43 | 43 | ▶ | if (ref $content ne 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 5 | return Twilio::Exceptions::RestException->new($message, $status, $status); | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | # As in twilio-python and twilio-node, the shape of the body decides, whatever the API. | ||||||||||||||||||||||||||||
| 48 | 38 | ▶ | if (Twilio::Exceptions::TwilioServiceException->is_problem($content)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 9 | return Twilio::Exceptions::TwilioServiceException->new($message, $content, $status); | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 29 | ▶ | $message .= ": $content->{message}" if defined $content->{message}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | return Twilio::Exceptions::RestException->new($message, $content->{code} // $status, | ||||||||||||||||||||||||||||
| 54 | 29 | ▶ | $status, $content->{more_info}, $content->{details}); | ||||||||||||||||||||||||||
|
Condition66%2/3
$content->{"code"} // $status
MC/DC0%0/2
$content->{"code"} // $status
$content->{"code"}
$status
Truth table66%2/3
A // B
A= $content->{"code"}B= $status
| |||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 46 | ▶ | sub read_limits { | ||||||||||||||||||||||||||
|
Subroutine
read_limits: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||
| 58 | 46 | my ($self, $limit, $page_size) = @_; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 46 | ▶ | $page_size //= $limit if $limit; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$page_size //= $limit
MC/DC0%0/2
$page_size //= $limit
$page_size
$limit
Truth table66%2/3
A //= B
A= $page_sizeB= $limit
| |||||||||||||||||||||||||||||
| 61 | 46 | ▶ | $page_size = $MAX_PAGE_SIZE if ($page_size // 0) > $MAX_PAGE_SIZE; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$page_size // 0
MC/DC100%1/1
$page_size // 0
$page_size
Truth table100%2/2
A
A= $page_size
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 46 | ▶ | return { limit => $limit || undef, page_size => $page_size || undef, page_limit => undef }; | ||||||||||||||||||||||||||
|
Condition100%4/4
$limit || undef
$page_size || undef
MC/DC100%1/1
$limit || undef
$limit
MC/DC100%1/1
$page_size || undef
$page_size
Truth table100%2/2
A
A= $limit
Truth table100%2/2
A
A= $page_size
| |||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 446 | ▶ | sub page { | ||||||||||||||||||||||||||
|
Subroutine
page: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 67 | 446 | my ($self, $method, $uri, $options) = @_; | |||||||||||||||||||||||||||
| 68 | 446 | return $self->request($method, $uri, $options); | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 54 | ▶ | sub stream { | ||||||||||||||||||||||||||
|
Subroutine
stream: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 54 | my ($self, $page, $limit, $page_limit) = @_; | |||||||||||||||||||||||||||
| 73 | 54 | return Twilio::Stream->new($page, $limit, $page_limit); | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 1388 | ▶ | sub handle_request { | ||||||||||||||||||||||||||
|
Subroutine
handle_request: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 77 | 1388 | my ($self, $method, $uri, $operation, $options) = @_; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 1388 | my $response = $self->request($method, $uri, $options); | |||||||||||||||||||||||||||
| 80 | 1387 | my $status = $response->get_status_code; | |||||||||||||||||||||||||||
| 81 | 1387 | ▶ | if ($status < $FIRST_SUCCESS_STATUS || $status >= $FIRST_ERROR_STATUS) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$status < $FIRST_SUCCESS_STATUS or $status >= $FIRST_ERROR_STATUS
MC/DC100%2/2
$status < $FIRST_SUCCESS_STATUS or $status >= $FIRST_ERROR_STATUS
$status < $FIRST_SUCCESS_STATUS
$status >= $FIRST_ERROR_STATUS
Truth table100%3/3
A or B
A= $status < $FIRST_SUCCESS_STATUSB= $status >= $FIRST_ERROR_STATUS
| |||||||||||||||||||||||||||||
| 82 | 16 | die $self->exception($response, "Unable to $operation record"); ## no critic (ErrorHandling::RequireCarping) | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 1371 | return $response; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 2140 | ▶ | sub get_domain { return $_[0]{domain} } | ||||||||||||||||||||||||||
|
Subroutine
get_domain: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 89 | 2 | ▶ | sub get_version { return $_[0]{version} } | ||||||||||||||||||||||||||
|
Subroutine
get_version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 18 | 1; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | __END__ | ||||||||||||||||||||||||||||