| 1 | package Twilio::CredentialProvider::ClientCredentialProvider; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 3 | ▶ | use 5.016; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 3 | ▶ | use parent 'Twilio::CredentialProvider::CredentialProvider'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 3 | ▶ | use Twilio::AuthStrategy::TokenAuthStrategy; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 3 | ▶ | use Twilio::Exceptions::ConfigurationException; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 3 | ▶ | use Twilio::Http::BearerToken::ApiTokenManager; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 3 | our $VERSION = '2.001'; | |||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 30 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 15 | 30 | my ($class, $options) = @_; | |||||||||||||||||||
| 16 | 30 | ▶ | $options //= {}; | ||||||||||||||||||
|
Condition100%2/2
$options //= {}
MC/DC100%1/1
$options //= {}
$options
Truth table100%2/2
A
A= $options
| |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 30 | for my $name (qw(client_id client_secret)) { | |||||||||||||||||||
| 19 | 57 | ▶ | next if length($options->{$name} // q{}); | ||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$options->{$name} // ""
MC/DC100%1/1
$options->{$name} // ""
$options->{$name}
Truth table100%2/2
A
A= $options->{$name}
| |||||||||||||||||||||
| 20 | 4 | Twilio::Exceptions::ConfigurationException->throw("$name is required"); | |||||||||||||||||||
| 21 | } | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 26 | my $self = $class->SUPER::new('client-credentials'); | |||||||||||||||||||
| 24 | 26 | $self->{grant_type} = 'client_credentials'; | |||||||||||||||||||
| 25 | 26 | $self->{client_id} = $options->{client_id}; | |||||||||||||||||||
| 26 | 26 | $self->{client_secret} = $options->{client_secret}; | |||||||||||||||||||
| 27 | $self->{token_manager} = $options->{token_manager} // $class->token_manager_class->new( | ||||||||||||||||||||
| 28 | { | ||||||||||||||||||||
| 29 | grant_type => $self->{grant_type}, | ||||||||||||||||||||
| 30 | client_id => $self->{client_id}, | ||||||||||||||||||||
| 31 | client_secret => $self->{client_secret}, | ||||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | 26 | ▶ | ); | ||||||||||||||||||
|
Condition66%2/3
$options->{"token_manager"} // $class->token_manager_class->new({"grant_type", $self->{"grant_type"}, "client_id", $self->{"client_id"}, "client_secret", $self->{"client_secret"}})
MC/DC0%0/2
$options->{"token_manager"} // $class->token_manager_class->new({"grant_type", $self->{"grant_type"}, "client_id", $self->{"client_id"}, "client_secret", $self->{"client_secret"}})
$options->{"token_manager"}
$class->token_manager_class->new({"grant_type", $self->{"grant_type"}, "client_id", $self->{"client_id"}, "client_secret", $self->{"client_secret"}})
Truth table66%2/3
A // B
A= $options->{"token_manager"}B= $class->token_manager_class->new({"grant_type", $self->{"grant_type"}, "client_id", $self->{"client_id"}, "client_secret", $self->{"client_secret"}})
| |||||||||||||||||||||
| 34 | 26 | return $self; | |||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 22 | ▶ | sub token_manager_class { return 'Twilio::Http::BearerToken::ApiTokenManager' } | ||||||||||||||||||
|
Subroutine
token_manager_class: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | # twilio-php returns a new strategy each time, and so asks for a token on every request. One | ||||||||||||||||||||
| 40 | # strategy per provider keeps the token until it is about to expire, as twilio-python does, and | ||||||||||||||||||||
| 41 | # clients that share the provider share the token. | ||||||||||||||||||||
| 42 | 26 | ▶ | sub to_auth_strategy { | ||||||||||||||||||
|
Subroutine
to_auth_strategy: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||
| 43 | 26 | my ($self) = @_; | |||||||||||||||||||
| 44 | 26 | ▶ | $self->{auth_strategy} //= Twilio::AuthStrategy::TokenAuthStrategy->new($self->{token_manager}); | ||||||||||||||||||
|
Condition66%2/3
$self->{"auth_strategy"} //= "Twilio::AuthStrategy::TokenAuthStrategy"->new($self->{"token_manager"})
MC/DC0%0/2
$self->{"auth_strategy"} //= "Twilio::AuthStrategy::TokenAuthStrategy"->new($self->{"token_manager"})
$self->{"auth_strategy"}
"Twilio::AuthStrategy::TokenAuthStrategy"->new($self->{"token_manager"})
Truth table66%2/3
A //= B
A= $self->{"auth_strategy"}B= "Twilio::AuthStrategy::TokenAuthStrategy"->new($self->{"token_manager"})
| |||||||||||||||||||||
| 45 | 26 | return $self->{auth_strategy}; | |||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 1 | ▶ | sub get_client_id { return $_[0]{client_id} } | ||||||||||||||||||
|
Subroutine
get_client_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 49 | 3 | ▶ | sub get_token_manager { return $_[0]{token_manager} } | ||||||||||||||||||
|
Subroutine
get_token_manager: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 3 | 1; | |||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | __END__ | ||||||||||||||||||||