File Coverage

blib/lib/WebService/ScormCloud/Service/Debug.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             package WebService::ScormCloud::Service::Debug;
2              
3 1     1   2022 use Moose::Role;
  0            
  0            
4              
5             with 'WebService::ScormCloud::Service';
6              
7             =head1 NAME
8              
9             WebService::ScormCloud::Service::Debug - ScormCloud API "debug" namespace
10              
11             =head1 VERSION
12              
13             Version 0.03
14              
15             =cut
16              
17             our $VERSION = '0.03';
18              
19             =head1 SYNOPSIS
20              
21             use WebService::ScormCloud;
22              
23             my $ScormCloud = WebService::ScormCloud->new(
24             app_id => '12345678',
25             secret_key => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
26             );
27              
28             print "Service is alive\n" if $ScormCloud->ping;
29              
30             print "Auth is valid\n" if $ScormCloud->authPing;
31              
32             print "Service says the UTC time is ", $ScormCloud->getTime, "\n";
33              
34             =head1 DESCRIPTION
35              
36             This module defines L<WebService::ScormCloud> API methods in the "debug"
37             namespace. See L<WebService::ScormCloud> for more info.
38              
39             =cut
40              
41             requires 'process_request';
42              
43             =head1 METHODS
44              
45             =head2 ping
46              
47             Returns true if the API service is reachable.
48              
49             =cut
50              
51             sub ping
52             {
53             my ($self) = @_;
54              
55             return $self->process_request(
56             {method => 'debug.ping'},
57             sub {
58             my ($response) = @_;
59              
60             exists $response->{pong} ? 1 : 0;
61             }
62             );
63             }
64              
65             =head2 authPing
66              
67             Returns true if the API service is reachable, and both the
68             application ID and secret key are valid.
69              
70             =cut
71              
72             sub authPing ## no critic (NamingConventions::Capitalization)
73             {
74             my ($self) = @_;
75              
76             return $self->process_request(
77             {method => 'debug.authPing'},
78             sub {
79             my ($response) = @_;
80              
81             exists $response->{pong} ? 1 : 0;
82             }
83             );
84             }
85              
86             =head2 getTime
87              
88             Returns the current time at the API service host. The time is in
89             UTC and is formatted as "YYYYMMDDhhmmss".
90              
91             =cut
92              
93             sub getTime ## no critic (NamingConventions::Capitalization)
94             {
95             my ($self) = @_;
96              
97             return $self->process_request(
98             {method => 'debug.getTime'},
99             sub {
100             my ($response) = @_;
101              
102             return $response->{currenttime}->{content};
103             }
104             );
105             }
106              
107             1;
108              
109             __END__
110              
111             =head1 SEE ALSO
112              
113             L<WebService::ScormCloud>
114              
115             =head1 AUTHOR
116              
117             Larry Leszczynski, C<< <larryl at cpan.org> >>
118              
119             =head1 BUGS
120              
121             Please report any bugs or feature requests to C<bug-scormcloud at rt.cpan.org>, or through
122             the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WebService-ScormCloud>. I will be notified, and then you'll
123             automatically be notified of progress on your bug as I make changes.
124              
125             Patches more than welcome, especially via GitHub:
126             L<https://github.com/larryl/ScormCloud>
127              
128             =head1 SUPPORT
129              
130             You can find documentation for this module with the perldoc command.
131              
132             perldoc WebService::ScormCloud::Service::Debug
133              
134             You can also look for information at:
135              
136             =over 4
137              
138             =item * GitHub
139              
140             L<https://github.com/larryl/ScormCloud>
141              
142             =item * RT: CPAN's request tracker
143              
144             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=WebService-ScormCloud>
145              
146             =item * AnnoCPAN: Annotated CPAN documentation
147              
148             L<http://annocpan.org/dist/WebService-ScormCloud>
149              
150             =item * CPAN Ratings
151              
152             L<http://cpanratings.perl.org/d/WebService-ScormCloud>
153              
154             =item * Search CPAN
155              
156             L<http://search.cpan.org/dist/WebService-ScormCloud/>
157              
158             =back
159              
160             =head1 ACKNOWLEDGEMENTS
161              
162              
163             =head1 COPYRIGHT & LICENSE
164              
165             Copyright 2010 Larry Leszczynski.
166              
167             This program is free software; you can redistribute it and/or modify it
168             under the terms of either: the GNU General Public License as published
169             by the Free Software Foundation; or the Artistic License.
170              
171             See http://dev.perl.org/licenses/ for more information.
172              
173             =cut
174