PaymentsAdvanced/Response/FromHTTP.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 2 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 1 totaltotal 94.3% 50 / 53 CC 3 SCAR 4.1
CC
3
Cov
98%
BUILD
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« PaymentsAdvanced/Mocker/SilentPOST.pm ↑ Summary PaymentsAdvanced/Mocker.pm »
1 package WebService::PayPal::PaymentsAdvanced::Response::FromHTTP;
2  
3 7 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 7 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 7 our $VERSION = '0.000028';
8  
9 7 ▶use MooX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 7 ▶use Types::Standard qw( HashRef InstanceOf );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 7 ▶use Types::URI qw( Uri );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 7 ▶use URI ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 7 ▶use URI::QueryParam;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 7 ▶use WebService::PayPal::PaymentsAdvanced::Error::HTTP ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 # Don't use HasParams role as we want to build params rather than require them.
17  
18 7 has params => (
19 is => 'lazy',
20 isa => HashRef,
21 init_arg => undef,
22 );
23  
24 7 has _http_response => (
25 is => 'ro',
26 isa => InstanceOf ['HTTP::Response'],
27 init_arg => 'http_response',
28 required => 1,
29 handles => { _code => 'code', _content => 'content', },
30 );
31  
32 7 has _request_uri => (
33 init_arg => 'request_uri',
34 is => 'ro',
35 isa => Uri,
36 coerce => 1,
37 required => 1,
38 );
39  
40 19 ▶sub BUILD {
Subroutine BUILD: called CC=3 SCAR=11.0
Pod undocumented
41 19 my $self = shift;
42 return
43 19 ▶ if $self->_http_response->is_success
Branch: 1 branch
BranchTrueFalseTotal
if $self->_http_response->is_success and not $self->_http_response->header("X-Died") 15 4 19
Condition66%2/3
$self->_http_response->is_success and not $self->_http_response->header("X-Died")
!ll&&!rl&&r
4015
MC/DC50%1/2
$self->_http_response->is_success and not $self->_http_response->header("X-Died")
$self->_http_response->is_success not $self->_http_response->header("X-Died")
Truth table66%2/3
A and not(B)
A= $self->_http_response->is_successB= not $self->_http_response->header("X-Died")
ABresult
0X0
100
111
44 && !$self->_http_response->header('X-Died');
45  
46 4 WebService::PayPal::PaymentsAdvanced::Error::HTTP
47 ->throw_from_http_response(
48 http_response => $self->_http_response,
49 request_uri => $self->_request_uri,
50 );
51 }
52  
53 14 ▶sub _build_params {
Subroutine _build_params: called CC=1 SCAR=0.0
54 14 my $self = shift;
55 14 my $results = URI->new( '?' . $self->_content );
56 14 return $results->query_form_hash;
57 }
58  
59 7 1;
60  
61 =pod
62  
63 =encoding UTF-8
64  
65 =head1 NAME
66  
67 WebService::PayPal::PaymentsAdvanced::Response::FromHTTP - Response object for WebService::PayPal::PaymentsAdvanced instantiated from HTTP::Response object
68  
69 =head1 VERSION
70  
71 version 0.000028
72  
73 =head1 DESCRIPTION
74  
75 This module provides an interface for extracting returned params from an
76 L<HTTP::Response> object. You won't need to this module directly if you are
77 using L<PayPal::PaymentsAdvanced/create_secure_token>.
78  
79 Throws a L<WebService::PayPal::PaymentsAdvanced::Error::HTTP> exception if the
80 HTTP request was not successful.
81  
82 =head1 OBJECT INSTANTIATION
83  
84 The following parameters can be supplied to C<new()> when creating a new object.
85  
86 =head2 Required Parameters
87  
88 =head3 http_response
89  
90 An L<HTTP::Response> object.
91  
92 =head2 Methods
93  
94 =head3 params
95  
96 Returns a C<HashRef> of parameters which have been extracted from the
97 L<HTTP::Response> object.
98  
99 =head1 SUPPORT
100  
101 Bugs may be submitted through L<https://github.com/maxmind/webservice-paypal-paymentsadvanced/issues>.
102  
103 =head1 AUTHOR
104  
105 Olaf Alders <olaf@wundercounter.com>
106  
107 =head1 COPYRIGHT AND LICENSE
108  
109 This software is copyright (c) 2022 by MaxMind, Inc.
110  
111 This is free software; you can redistribute it and/or modify it under
112 the same terms as the Perl 5 programming language system itself.
113  
114 =cut
115  
116 __END__
« PaymentsAdvanced/Mocker/SilentPOST.pm ↑ Summary PaymentsAdvanced/Mocker.pm »