lib/Google/Ads/AdWords/RequestStats.pm

filter: Statementstmt 100% 28 / 28 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 100% 34 / 34 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« lib/Google/Ads/AdWords/Reports/ReportingConfiguration.pm ↑ Summary lib/Google/Ads/AdWords/Serializer.pm »
1 # Copyright 2012, Google Inc. All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14  
15 package Google::Ads::AdWords::RequestStats;
16  
17 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use Encode qw( encode_utf8 decode_utf8 );
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 2 ▶use Class::Std::Fast;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 my %client_id_of : ATTR(:name<client_id> :default<>);
25 1 my %service_name_of : ATTR(:name<service_name> :default<>);
26 1 my %method_name_of : ATTR(:name<method_name> :default<>);
27 1 my %response_time_of : ATTR(:name<response_time> :default<0>);
28 1 my %request_id_of : ATTR(:name<request_id> :default<>);
29 1 my %operations_of : ATTR(:name<operations> :default<0>);
30 1 my %is_fault_of : ATTR(:name<is_fault> :default<0>);
31 1 my %server_of : ATTR(:name<server> :default<>);
32 1 my %fault_message_of : ATTR(:name<fault_message> :default<>);
33  
34 sub as_str : STRINGIFY {
35 my $self = shift;
36 my $client_id = $self->get_client_id() || "";
37 my $server = $self->get_server() || "";
38 my $service = $self->get_service_name() || "";
39 my $method = $self->get_method_name() || "";
40 my $response_time = $self->get_response_time() || "";
41 my $request_id = $self->get_request_id() || "";
42 my $operations = $self->get_operations() || "";
43 my $is_fault = $self->get_is_fault() ? "yes" : "no";
44 my $fault_message = $self->get_fault_message() || "";
45  
46 # Convert the fault message to one less than 16K characters.
47 $fault_message =~ s/\r?\n/ /g;
48 my $utf8 = encode_utf8($fault_message);
49 my @utf8_chunks = $utf8 =~ /\G(.{1,16000})(?![\x80-\xBF])/sg;
50 $fault_message = decode_utf8($_) for @utf8_chunks;
51  
52 return " clientCustomerId=${client_id}" . " server=${server}" .
53 " service=${service}" . " method=${method}" .
54 " responseTime=${response_time}" . " requestId=${request_id}" .
55 " operations=${operations}" . " isFault=${is_fault}" .
56 " faultMessage=${fault_message}";
57 2 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
58  
59 1 return 1;
60  
61 =pod
62  
63 =head1 NAME
64  
65 Google::Ads::AdWords::RequestStats
66  
67 =head1 SYNOPSIS
68  
69 Class that wraps API request statistics such as number of operations,
70 request id and others.
71  
72 =head1 DESCRIPTION
73  
74 This class holds the data coming from API response headers and others related
75 to a given request.
76  
77 =head1 ATTRIBUTES
78  
79 =head2 client_id
80  
81 The client id against which the call was made if available.
82  
83 =head2 server
84  
85 The server endpoint.
86  
87 =head2 service_name
88  
89 The name of the service that was called.
90  
91 =head2 method_name
92  
93 The method name of the service that was called.
94  
95 =head2 response_time
96  
97 Server side time of the duration of the call.
98  
99 =head2 request_id
100  
101 Request id of the call.
102  
103 =head2 operations
104  
105 Number of operations in the request.
106  
107 =head2 is_fault
108  
109 Whether the request returned as a fault or not.
110  
111 =head2 fault_message
112  
113 The stack trace of up to 16K characters if a fault occurs.
114  
115 =head1 LICENSE AND COPYRIGHT
116  
117 Copyright 2012 Google Inc.
118  
119 Licensed under the Apache License, Version 2.0 (the "License");
120 you may not use this file except in compliance with the License.
121 You may obtain a copy of the License at
122  
123 http://www.apache.org/licenses/LICENSE-2.0
124  
125 Unless required by applicable law or agreed to in writing, software
126 distributed under the License is distributed on an "AS IS" BASIS,
127 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
128 See the License for the specific language governing permissions and
129 limitations under the License.
130  
131 =head1 REPOSITORY INFORMATION
132  
133 $Rev: $
134 $LastChangedBy: $
135 $Id: $
136  
137 =cut
« lib/Google/Ads/AdWords/Reports/ReportingConfiguration.pm ↑ Summary lib/Google/Ads/AdWords/Serializer.pm »