lib/Google/Ads/Common/AuthHandlerInterface.pm

filter: Statementstmt 14.2% 1 / 7 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 3 Podpod 100% 3 / 3 totaltotal 30.7% 4 / 13 CC 1 SCAR 6.9
CC
1
Cov
14%
initialize
2.0
prepare_request
2.0
is_auth_enabled
2.0
CRAP 2.0
« blib/lib/Google/Ads/Common/ReportDownloadError.pm ↑ Summary lib/Google/Ads/Common/AuthError.pm »
1 # Copyright 2011, 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::Common::AuthHandlerInterface;
16  
17 # Initializes the handler with a given set of properties and the API client
18 # object.
19 0 ▶sub initialize {
Subroutine initialize: not called CC=1 SCAR=6.9
Pod documented
20 0 my ($self, $api_client, $properties) = @_;
21 0 die "Needs to be implemented by subclass";
22 }
23  
24 # Method that given an HTTP:Request prepares it with the relevant
25 # authorization data (i.e. headers, protected resource url, etc).
26 0 ▶sub prepare_request {
Subroutine prepare_request: not called CC=1 SCAR=6.9
Pod documented
27 0 my ($self, $endpoint, $http_headers, $envelope) = @_;
28 0 die "Needs to be implemented by subclass";
29 }
30  
31 # Returns true if the handler can prepare request with the appropiate
32 # authorization info.
33 0 ▶sub is_auth_enabled {
Subroutine is_auth_enabled: not called CC=1 SCAR=6.9
Pod documented
34 0 my ($self) = @_;
35 0 die "Needs to be implemented by subclass";
36 }
37  
38 9 1;
39  
40 =pod
41  
42 =head1 NAME
43  
44 Google::Ads::Common::AuthHandlerInterface
45  
46 =head1 DESCRIPTION
47  
48 Interface to be implemented by concrete authorization handlers. Defines the
49 necessary subroutines to build authorized request against a Google API.
50  
51 =head1 METHODS
52  
53 =head2 initialize
54  
55 Initializes the handler with a given set of properties. Used to pass parameters
56 such as: client ids, access tokens, etc.
57  
58 =head3 Parameters
59  
60 =over
61  
62 =item *
63  
64 A required I<api_client> with a reference to the API client object handling the
65 requests against the API.
66  
67 =item *
68  
69 A required I<properties> with a reference to a hash of properties.
70  
71 =back
72  
73 =head2 prepare_request
74  
75 Constructs a L<HTTP::Request> valid to send an authorized request to the API.
76 Implementors will attach authorization headers to the request at this phase.
77  
78 =head3 Parameters
79  
80 =over
81  
82 =item *
83  
84 I<endpoint>: URL to the resource to access.
85  
86 =item *
87  
88 I<http_headers>: a map of HTTP headers to be included in the request.
89  
90 =item *
91  
92 I<envelope>: a string with the payload to be send in the request.
93  
94 =back
95  
96 =head2 is_auth_enabled
97  
98 Method called to check if the authorization has already been setup, so the
99 I<prepare_request> method can be called.
100  
101 =head3 Returns
102  
103 True, if the authorization is in place and the class can prepare requests.
104 False, otherwise.
105  
106 =head1 LICENSE AND COPYRIGHT
107  
108 Copyright 2012 Google Inc.
109  
110 Licensed under the Apache License, Version 2.0 (the "License");
111 you may not use this file except in compliance with the License.
112 You may obtain a copy of the License at
113  
114 http://www.apache.org/licenses/LICENSE-2.0
115  
116 Unless required by applicable law or agreed to in writing, software
117 distributed under the License is distributed on an "AS IS" BASIS,
118 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
119 See the License for the specific language governing permissions and
120 limitations under the License.
121  
122 =head1 AUTHOR
123  
124 David Torres E<lt>david.t at google.comE<gt>
125  
126 =head1 REPOSITORY INFORMATION
127  
128 $Rev: $
129 $LastChangedBy: $
130 $Id: $
131  
132 =cut
« blib/lib/Google/Ads/Common/ReportDownloadError.pm ↑ Summary lib/Google/Ads/Common/AuthError.pm »