File Coverage

lib/API/BigBlueButton/Requests.pm
Criterion Covered Total %
statement 64 76 84.2
branch 9 10 90.0
condition 2 3 66.6
subroutine 18 22 81.8
pod 14 14 100.0
total 107 125 85.6


line stmt bran cond sub pod time code
1             package API::BigBlueButton::Requests;
2              
3             =head1 NAME
4              
5             API::BigBlueButton::Requests - processing of API requests
6              
7             =cut
8              
9 3     3   67 use 5.008008;
  3         11  
10 3     3   16 use strict;
  3         6  
  3         123  
11 3     3   21 use warnings;
  3         6  
  3         111  
12              
13 3     3   1294 use Digest::SHA1 qw/ sha1_hex /;
  3         2011  
  3         198  
14 3     3   24 use Carp qw/ confess /;
  3         6  
  3         286  
15              
16             use constant {
17 3         3299 REQUIRE_CREATE_PARAMS => [ qw/ meetingID / ],
18             REQUIRE_JOIN_PARAMS => [ qw/ fullName meetingID password / ],
19             REQUIRE_ISMEETINGRUNNING_PARAMS => [ qw/ meetingID / ],
20             REQUIRE_END_PARAMS => [ qw/ meetingID password / ],
21             REQUIRE_GETMEETINGINFO_PARAMS => [ qw/ meetingID password / ],
22             REQUIRE_PUBLISHRECORDINGS_PARAMS => [ qw/ recordID publish / ],
23             REQUIRE_DELETERECORDINGS_PARAMS => [ qw/ recordID / ],
24             REQUIRE_SETCONFIGXML_PARAMS => [ qw/ meetingID configXML / ],
25 3     3   22 };
  3         6  
26              
27             our $VERSION = "0.015";
28              
29             =head1 VERSION
30            
31             version 0.015
32              
33             =cut
34              
35             =head1 METHODS
36              
37             =over
38              
39             =item B
40              
41             Getting the current version of the BigBlueButton
42              
43             =cut
44              
45             sub get_version {
46 1     1 1 20 my ( $self ) = @_;
47              
48 1 50       6 my $url = $self->{use_https} ? 'https://' : 'http://';
49 1         4 $url .= $self->{server} . '/bigbluebutton/api';
50              
51 1         3 return $self->request( $url );
52             }
53              
54             =item B
55              
56             Create a meeting
57              
58             %params:
59              
60             name
61            
62             This parameter is optional.
63             A name for the meeting.
64              
65             meetingID
66            
67             This parameter is mandatory.
68             A meeting ID that can be used to identify this meeting by the third party application.
69              
70             attendeePW
71              
72             This parameter is optional.
73              
74             moderatorPW
75              
76             This parameter is optional.
77              
78             welcome
79            
80             This parameter is optional.
81              
82             dialNumber
83              
84             This parameter is optional.
85              
86             voiceBridge
87              
88             This parameter is optional.
89              
90             webVoice
91              
92             This parameter is optional.
93              
94             logoutURL
95              
96             This parameter is optional.
97              
98             record
99            
100             This parameter is optional.
101              
102             duration
103              
104             This parameter is optional.
105              
106             meta
107              
108             This parameter is optional.
109              
110             redirectClient
111              
112             This parameter is optional.
113              
114             clientURL
115              
116             This parameter is optional.
117              
118             SEE MORE L
119              
120             =cut
121              
122             sub create {
123 2     2 1 2692 my ( $self, %params ) = @_;
124              
125 2         10 my $data = $self->_generate_data( 'create', \%params );
126 1         4 return $self->abstract_request( $data );
127             }
128              
129             =item B
130              
131             Joins a user to the meeting specified in the meetingID parameter.
132              
133             %params:
134              
135             fullName
136              
137             This parameter is mandatory.
138             The full name that is to be used to identify this user to other conference attendees.
139              
140             meetingID
141              
142             This parameter is mandatory.
143             The meeting ID that identifies the meeting you are attempting to join.
144              
145             password
146              
147             This parameter is mandatory.
148             The password that this attendee is using. If the moderator password is supplied,
149             he will be given moderator status (and the same for attendee password, etc)
150              
151             createTime
152              
153             This parameter is optional.
154              
155             userID
156              
157             This parameter is optional.
158              
159             webVoiceConf
160              
161             This parameter is optional.
162              
163             configToken
164              
165             This parameter is optional.
166              
167             avatarURL
168              
169             This parameter is optional.
170              
171             redirectClient
172              
173             This parameter is optional.
174              
175             clientURL
176              
177             This parameter is optional.
178              
179             SEE MORE L
180              
181             =cut
182              
183             sub join {
184 1     1 1 3041 my ( $self, %params ) = @_;
185              
186 1         4 my $data = $self->_generate_data( 'join', \%params );
187 1         4 return $self->abstract_request( $data );
188             }
189              
190             =item B
191              
192             This call enables you to simply check on whether or not a meeting is running by
193             looking it up with your meeting ID.
194              
195             %params:
196              
197             meetingID
198              
199             This parameter is mandatory.
200             The meeting ID that identifies the meeting you are attempting to check on.
201              
202             =cut
203              
204             sub ismeetingrunning {
205 1     1 1 2223 my ( $self, %params ) = @_;
206              
207 1         4 my $data = $self->_generate_data( 'isMeetingRunning', \%params );
208 1         4 return $self->abstract_request( $data );
209             }
210              
211             =item B
212              
213             Use this to forcibly end a meeting and kick all participants out of the meeting.
214              
215             %params:
216              
217             meetingID
218              
219             This parameter is mandatory.
220             The meeting ID that identifies the meeting you are attempting to end.
221              
222             password
223              
224             This parameter is mandatory.
225             The moderator password for this meeting. You can not end a meeting using the attendee password.
226              
227             =cut
228              
229             sub end {
230 1     1 1 2417 my ( $self, %params ) = @_;
231              
232 1         4 my $data = $self->_generate_data( 'end', \%params );
233 1         5 return $self->abstract_request( $data );
234             }
235              
236             =item B
237              
238             This call will return all of a meeting's information,
239             including the list of attendees as well as start and end times.
240              
241             %params:
242              
243             meetingID
244              
245             This parameter is mandatory.
246             The meeting ID that identifies the meeting you are attempting to check on.
247              
248             password
249              
250             This parameter is mandatory.
251             The moderator password for this meeting.
252             You can not get the meeting information using the attendee password.
253              
254             =cut
255              
256             sub getmeetinginfo {
257 1     1 1 2524 my ( $self, %params ) = @_;
258              
259 1         4 my $data = $self->_generate_data( 'getMeetingInfo', \%params );
260 1         4 return $self->abstract_request( $data );
261             }
262              
263             =item B
264              
265             This call will return a list of all the meetings found on this server.
266              
267             =cut
268              
269             sub getmeetings {
270 1     1 1 2630 my ( $self ) = @_;
271              
272 1         3 my $data = $self->_generate_data( 'getMeetings' );
273 1         4 return $self->abstract_request( $data );
274             }
275              
276             =item B
277              
278             Retrieves the recordings that are available for playback for a given meetingID (or set of meeting IDs).
279              
280             %params:
281              
282             meetingID
283              
284             This parameter is optional.
285              
286             =cut
287              
288             sub getrecordings {
289 1     1 1 2801 my ( $self, %params ) = @_;
290              
291 1         3 my $data = $self->_generate_data( 'getRecordings', \%params );
292 1         4 return $self->abstract_request( $data );
293             }
294              
295             =item B
296              
297             Publish and unpublish recordings for a given recordID (or set of record IDs).
298              
299             %params:
300              
301             recordID
302              
303             This parameter is mandatory.
304             A record ID for specify the recordings to apply the publish action.
305             It can be a set of record IDs separated by commas.
306              
307             publish
308              
309             This parameter is mandatory.
310             The value for publish or unpublish the recording(s). Available values: true or false.
311              
312             =cut
313              
314             sub publishrecordings {
315 0     0 1 0 my ( $self, %params ) = @_;
316              
317 0         0 my $data = $self->_generate_data( 'publishRecordings', \%params );
318 0         0 return $self->abstract_request( $data );
319             }
320              
321             =item B
322              
323             Delete one or more recordings for a given recordID (or set of record IDs).
324              
325             %params:
326              
327             recordID
328              
329             This parameter is mandatory.
330             A record ID for specify the recordings to delete.
331             It can be a set of record IDs separated by commas.
332              
333             =cut
334              
335             sub deleterecordings {
336 0     0 1 0 my ( $self, %params ) = @_;
337              
338 0         0 my $data = $self->_generate_data( 'deleteRecordings', \%params );
339 0         0 return $self->abstract_request( $data );
340             }
341              
342             =item B
343              
344             Retrieve the default config.xml.
345              
346             SEE MORE L
347              
348             =cut
349              
350             sub getdefaultconfigxml {
351 0     0 1 0 my ( $self ) = @_;
352              
353 0         0 my $data = $self->_generate_data( 'getDefaultConfigXML' );
354 0         0 return $self->abstract_request( $data );
355             }
356              
357             =item B
358              
359             Associate an custom config.xml file with the current session.
360              
361             %params:
362              
363             meetingID
364              
365             This parameter is mandatory.
366             A meetingID to an active meeting.
367              
368             configXML
369              
370             This parameter is mandatory.
371             A valid config.xml file
372              
373             SEE MORE L
374              
375             =cut
376              
377             sub setconfigxml {
378 0     0 1 0 my ( $self, %params ) = @_;
379              
380 0         0 my $data = $self->_generate_data( 'setConfigXML', \%params );
381 0         0 return $self->abstract_request( $data );
382             }
383              
384             =item B
385              
386             Create a checksum for the query
387              
388             $request
389              
390             Name of query, e.g. 'create' or 'join'
391              
392             $params:
393              
394             Query parameters
395              
396             my $chksum = $self->generate_checksum( 'create', \%params );
397              
398             =cut
399              
400             sub generate_checksum {
401 7     7 1 14 my ( $self, $request, $params ) = @_;
402              
403 7         11 my $string = $request;
404 7 100 66     36 $string .= $self->generate_url_query( $params ) if ( $params && ref $params );
405 7         36 $string .= $self->{secret};
406              
407 7         45 return sha1_hex( $string );
408             }
409              
410             =item B
411              
412             Creating a query string
413              
414             $params:
415              
416             Query parameters
417              
418             $params{checksum} = $self->generate_checksum( 'create', \%params );
419             $params{request} = 'create';
420             my $url = $self->generate_url_query( \%params );
421              
422             =cut
423              
424             sub generate_url_query {
425 12     12 1 21 my ( $self, $params ) = @_;
426              
427 12         15 my $string = CORE::join( '&', map { "$_=$params->{$_}" } sort keys %{ $params } );
  22         66  
  12         42  
428              
429 12         42 return $string;
430             }
431              
432             sub _generate_data {
433 8     8   18 my ( $self, $request, $params ) = @_;
434              
435 8 100       37 $self->_check_params( $request, $params ) if $params;
436 7         19 $params->{checksum} = $self->generate_checksum( $request, $params );
437 7         14 $params->{request} = $request;
438              
439 7         12 return $params;
440             }
441              
442             sub _check_params {
443 7     7   12 my ( $self, $request, $params ) = @_;
444              
445 7         21 my $const = 'REQUIRE_' . uc $request . '_PARAMS';
446 7 100       66 return unless $self->can( $const );
447              
448 6         13 for my $req_param ( @{ $self->$const } ) {
  6         18  
449 10 100       224 confess "Parameter $req_param required!" unless $params->{ $req_param };
450             }
451              
452 5         9 return 1;
453             }
454              
455             =back
456              
457             =head1 SEE ALSO
458              
459             L
460              
461             L
462              
463             L
464              
465             =head1 AUTHOR
466              
467             Alexander Ruzhnikov Ea.ruzhnikov@reg.ruE
468              
469             =cut
470              
471             1;