| 1 | package HTTP::API::Core::Example::Stripe; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use HTTP::API::Core; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use HTTP::API::Core::Auth qw(bearer_auth); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use HTTP::API::Core::Form qw(form_urlencode); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=15.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 11 | 1 | my ($class, %args) = @_; | |||||||||||||||||||||||||||
| 12 | 1 | my $token = delete $args{token}; | |||||||||||||||||||||||||||
| 13 | 1 | ▶ | die "token is required\n" if !defined($token) || $token eq ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $token or $token eq ""
MC/DC0%0/2
not defined $token or $token eq ""
not defined $token
$token eq ""
Truth table33%1/3
not(A) or B
A= not defined $tokenB= $token eq ""
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | my $api = HTTP::API::Core->new( | ||||||||||||||||||||||||||||
| 16 | 1 | ▶ | base_url => delete($args{base_url}) || 'https://api.stripe.com/v1', | ||||||||||||||||||||||||||
|
Condition50%1/2
delete $args{'base_url'} || 'https://api.stripe.com/v1'
MC/DC0%0/1
delete $args{'base_url'} || 'https://api.stripe.com/v1'
delete $args{'base_url'}
Truth table50%1/2
A
A= delete $args{'base_url'}
| |||||||||||||||||||||||||||||
| 17 | hooks => { before_request => bearer_auth($token) }, | ||||||||||||||||||||||||||||
| 18 | %args, | ||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||
| 20 | 1 | return bless { api => $api }, $class; | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | sub customers_pager { | ||||||||||||||||||||||||||
|
Subroutine
customers_pager: called CC=1 SCAR=0.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 24 | 1 | my ($self, %query) = @_; | |||||||||||||||||||||||||||
| 25 | return $self->{api}->paginate( | ||||||||||||||||||||||||||||
| 26 | '/customers', | ||||||||||||||||||||||||||||
| 27 | mode => 'cursor', | ||||||||||||||||||||||||||||
| 28 | items => 'data', | ||||||||||||||||||||||||||||
| 29 | 2 | ▶ | next => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.5
| |||||||||||||||||||||||||||||
| 30 | 2 | my ($json) = @_; | |||||||||||||||||||||||||||
| 31 | 2 | ▶ | return undef if !$json->{has_more}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 1 | ▶ | return undef if ref($json->{data}) ne 'ARRAY' || !@{ $json->{data} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $json->{"data"} ne "ARRAY" or not @{$json->{"data"};}
MC/DC0%0/2
ref $json->{"data"} ne "ARRAY" or not @{$json->{"data"};}
ref $json->{"data"} ne "ARRAY"
not @{$json->{"data"};}
Truth table33%1/3
A or not(B)
A= ref $json->{"data"} ne "ARRAY"B= not @{$json->{"data"};}
| |||||||||||||||||||||||||||||
| 33 | 1 | return $json->{data}[-1]{id}; | |||||||||||||||||||||||||||
| 34 | }, | ||||||||||||||||||||||||||||
| 35 | 1 | cursor_param => 'starting_after', | |||||||||||||||||||||||||||
| 36 | query => \%query, | ||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 2 | ▶ | sub create_customer { | ||||||||||||||||||||||||||
|
Subroutine
create_customer: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 41 | 2 | my ($self, %args) = @_; | |||||||||||||||||||||||||||
| 42 | 2 | my $idempotency_key = delete $args{idempotency_key}; | |||||||||||||||||||||||||||
| 43 | 2 | my $content = form_urlencode(\%args); | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | return $self->{api}->post( | ||||||||||||||||||||||||||||
| 46 | 2 | ▶ | '/customers', | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | headers => { 'content-type' => 'application/x-www-form-urlencoded' }, | ||||||||||||||||||||||||||||
| 48 | content => $content, | ||||||||||||||||||||||||||||
| 49 | (defined($idempotency_key) ? ( | ||||||||||||||||||||||||||||
| 50 | idempotency => { | ||||||||||||||||||||||||||||
| 51 | key => $idempotency_key, | ||||||||||||||||||||||||||||
| 52 | header => 'Idempotency-Key', | ||||||||||||||||||||||||||||
| 53 | }, | ||||||||||||||||||||||||||||
| 54 | ) : ()), | ||||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 1 | 1; | |||||||||||||||||||||||||||