File Coverage

blib/lib/Google/Ads/GoogleAds/BaseEntity.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 20 20 100.0


line stmt bran cond sub pod time code
1             # Copyright 2019, Google LLC
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             # The base class for all Google Ads API entities, e.g. common, resource,
16             # request, response, etc.
17              
18              
19             use strict;
20 7     7   879 use warnings;
  7         16  
  7         193  
21 7     7   33 use version;
  7         9  
  7         149  
22 7     7   359  
  7         1616  
  7         30  
23             # The following needs to be on one line because CPAN uses a particularly hacky
24             # eval() to determine module versions.
25             use Google::Ads::GoogleAds::Constants; our $VERSION = ${Google::Ads::GoogleAds::Constants::VERSION};
26 7     7   765  
  7         18  
  7         478  
27             # Called by JSON::XS to convert a blessed object to JSON.
28             return {%{shift()}};
29             }
30 1     1 1 2  
  1         10  
31             1;
32              
33             =pod
34              
35             =head1 NAME
36              
37             Google::Ads::GoogleAds::BaseEntity
38              
39             =head1 DESCRIPTION
40              
41             The abstract base class for all Google Ads API entities, e.g. common, resource,
42             request, response, etc.
43              
44             =head1 METHODS
45              
46             =head2 TO_JSON
47              
48             The C<TO_JSON> method is invoked by L<JSON::XS> in scalar context, to convert a
49             blessed object into JSON. As JSON cannot directly represent Perl objects, we have
50             to enable the C<convert_blessed> attribute in L<JSON::XS> and define the C<TO_JSON>
51             method for each entity class to convert.
52              
53             =head3 Returns
54              
55             A scalar as the reference to the hash to convert based on the current object.
56              
57             =head1 LICENSE AND COPYRIGHT
58              
59             Copyright 2019 Google LLC
60              
61             Licensed under the Apache License, Version 2.0 (the "License");
62             you may not use this file except in compliance with the License.
63             You may obtain a copy of the License at
64              
65             http://www.apache.org/licenses/LICENSE-2.0
66              
67             Unless required by applicable law or agreed to in writing, software
68             distributed under the License is distributed on an "AS IS" BASIS,
69             WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
70             See the License for the specific language governing permissions and
71             limitations under the License.
72              
73             =head1 REPOSITORY INFORMATION
74              
75             $Rev: $
76             $LastChangedBy: $
77             $Id: $
78              
79             =cut